1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-08 06:30:28 +00:00

Remove special casing for MinGW

This commit is contained in:
Michael Camilleri 2024-12-16 08:12:14 +09:00
parent 1a24d4fc86
commit e94e8dc484
No known key found for this signature in database
GPG Key ID: 7EB218A48DF8B572

View File

@ -3308,16 +3308,15 @@ static JanetFile *get_file_for_stream(JanetStream *stream) {
if (fd_dup < 0) return NULL; if (fd_dup < 0) return NULL;
FILE *f = _fdopen(fd_dup, fmt); FILE *f = _fdopen(fd_dup, fmt);
if (NULL == f) { if (NULL == f) {
/* the stream isn't duplicated so this would close the stream _close(fd_dup);
* _close(fd); */
return NULL; return NULL;
} }
#else #else
int newHandle = dup(stream->handle); int fd_dup = dup(stream->handle);
if (newHandle < 0) return NULL; if (fd_dup < 0) return NULL;
FILE *f = fdopen(newHandle, fmt); FILE *f = fdopen(fd_dup, fmt);
if (NULL == f) { if (NULL == f) {
close(newHandle); close(fd_dup);
return NULL; return NULL;
} }
#endif #endif
@ -3329,17 +3328,10 @@ JANET_CORE_FN(janet_cfun_to_file,
"Create core/file copy of the stream. This value can be used " "Create core/file copy of the stream. This value can be used "
"when blocking IO behavior is needed.") { "when blocking IO behavior is needed.") {
janet_fixarity(argc, 1); janet_fixarity(argc, 1);
#ifdef JANET_MINGW
(void) argc;
(void) argv;
janet_panic("ev/to-file not supported on MinGW");
return janet_wrap_nil();
#else
JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type); JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type);
JanetFile *iof = get_file_for_stream(stream); JanetFile *iof = get_file_for_stream(stream);
if (iof == NULL) janet_panic("cannot make file from stream"); if (iof == NULL) janet_panic("cannot make file from stream");
return janet_wrap_abstract(iof); return janet_wrap_abstract(iof);
#endif
} }
JANET_CORE_FN(janet_cfun_ev_all_tasks, JANET_CORE_FN(janet_cfun_ev_all_tasks,