зеркало из https://github.com/github/ruby.git
Extract platform dependent part as `fdopen_internal`
This commit is contained in:
Родитель
82e480ff40
Коммит
f0edcd8283
33
io.c
33
io.c
|
@ -6966,8 +6966,8 @@ rb_sysopen(VALUE fname, int oflags, mode_t perm)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
static inline FILE *
|
||||||
rb_fdopen(int fd, const char *modestr)
|
fdopen_internal(int fd, const char *modestr)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
|
@ -6976,24 +6976,25 @@ rb_fdopen(int fd, const char *modestr)
|
||||||
#endif
|
#endif
|
||||||
file = fdopen(fd, modestr);
|
file = fdopen(fd, modestr);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
int e = errno;
|
#ifdef _WIN32
|
||||||
#if defined(__sun)
|
if (errno == 0) errno = EINVAL;
|
||||||
if (e == 0) {
|
#elif defined(__sun)
|
||||||
rb_gc();
|
if (errno == 0) errno = EMFILE;
|
||||||
errno = 0;
|
|
||||||
file = fdopen(fd, modestr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *
|
||||||
|
rb_fdopen(int fd, const char *modestr)
|
||||||
|
{
|
||||||
|
FILE *file = fdopen_internal(fd, modestr);
|
||||||
|
if (!file) {
|
||||||
|
int e = errno;
|
||||||
if (rb_gc_for_fd(e)) {
|
if (rb_gc_for_fd(e)) {
|
||||||
file = fdopen(fd, modestr);
|
file = fdopen_internal(fd, modestr);
|
||||||
}
|
}
|
||||||
if (!file) {
|
if (!file) {
|
||||||
#ifdef _WIN32
|
|
||||||
if (e == 0) e = EINVAL;
|
|
||||||
#elif defined(__sun)
|
|
||||||
if (e == 0) e = EMFILE;
|
|
||||||
#endif
|
|
||||||
rb_syserr_fail(e, 0);
|
rb_syserr_fail(e, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче