From 63fa647bc9cbc94373b2fb56a04fdeb0fd23ccbc Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 10 Feb 2019 14:32:17 +0100 Subject: [PATCH] freopen() appears to be problematic on OSX; as it's only ever used to rewind files, replace with rewind(). --- mach/proto/as/comm1.h | 1 - mach/proto/as/comm4.c | 4 ++-- mach/proto/as/comm7.c | 8 +------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index 206ae0b5d..660f41907 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -155,7 +155,6 @@ void emit4(long); void emitx(valu_t, int); void emitf(int size, int negative); void emitstr(int); -void ffreopen(char *, FILE *); FILE *ffcreat(char *); FILE *fftemp(char *, char *); void yyerror(const char *); diff --git a/mach/proto/as/comm4.c b/mach/proto/as/comm4.c index 3e88c41ed..9348b802a 100644 --- a/mach/proto/as/comm4.c +++ b/mach/proto/as/comm4.c @@ -399,7 +399,7 @@ pass_23(int n) #ifdef LISTING listmode >>= 3; if (listmode & 4) - ffreopen(listpath, listfile); + rewind(listfile); listeoln = 1; #endif #ifdef THREE_PASS @@ -438,7 +438,7 @@ pass_23(int n) #ifndef ASLD newmodule(modulename); #endif /* ASLD */ - ffreopen(temppath, tempfile); + rewind(tempfile); yyparse(); commfinish(); machfinish(n); diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index c48de4d92..debee0ca2 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -389,17 +389,11 @@ void emitf(int size, int negative) /* ---------- Error checked file I/O ---------- */ -void ffreopen(char* s, FILE* f) -{ - if (freopen(s, "r", f) == NULL) - fatal("can't reopen %s: %s", s, strerror(errno)); -} - FILE* ffcreat(char* s) { FILE* f; - if ((f = fopen(s, "w")) == NULL) + if ((f = fopen(s, "w+")) == NULL) fatal("can't create %s", s); return (f); }