freopen() appears to be problematic on OSX; as it's only ever used to rewind

files, replace with rewind().
This commit is contained in:
David Given 2019-02-10 14:32:17 +01:00
parent 1dfafe070c
commit 63fa647bc9
3 changed files with 3 additions and 10 deletions

View file

@ -155,7 +155,6 @@ void emit4(long);
void emitx(valu_t, int); void emitx(valu_t, int);
void emitf(int size, int negative); void emitf(int size, int negative);
void emitstr(int); void emitstr(int);
void ffreopen(char *, FILE *);
FILE *ffcreat(char *); FILE *ffcreat(char *);
FILE *fftemp(char *, char *); FILE *fftemp(char *, char *);
void yyerror(const char *); void yyerror(const char *);

View file

@ -399,7 +399,7 @@ pass_23(int n)
#ifdef LISTING #ifdef LISTING
listmode >>= 3; listmode >>= 3;
if (listmode & 4) if (listmode & 4)
ffreopen(listpath, listfile); rewind(listfile);
listeoln = 1; listeoln = 1;
#endif #endif
#ifdef THREE_PASS #ifdef THREE_PASS
@ -438,7 +438,7 @@ pass_23(int n)
#ifndef ASLD #ifndef ASLD
newmodule(modulename); newmodule(modulename);
#endif /* ASLD */ #endif /* ASLD */
ffreopen(temppath, tempfile); rewind(tempfile);
yyparse(); yyparse();
commfinish(); commfinish();
machfinish(n); machfinish(n);

View file

@ -389,17 +389,11 @@ void emitf(int size, int negative)
/* ---------- Error checked file I/O ---------- */ /* ---------- 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* ffcreat(char* s)
{ {
FILE* f; FILE* f;
if ((f = fopen(s, "w")) == NULL) if ((f = fopen(s, "w+")) == NULL)
fatal("can't create %s", s); fatal("can't create %s", s);
return (f); return (f);
} }