Add more binary mode flags.

This commit is contained in:
David Given 2022-07-18 19:36:44 +02:00
parent 279de30935
commit 205a50d8ee
7 changed files with 9 additions and 9 deletions

View file

@ -151,7 +151,7 @@ int main(int argc, char* const argv[])
switch (opt) switch (opt)
{ {
case 'o': case 'o':
outputfp = fopen(optarg, "w"); outputfp = fopen(optarg, "wb");
if (!outputfp) if (!outputfp)
fatal("cannot open output file: %s", strerror(errno)); fatal("cannot open output file: %s", strerror(errno));
break; break;

View file

@ -221,7 +221,7 @@ int main(int argc, char* argv[])
break; break;
case 3: /* Both input and output files specified. */ case 3: /* Both input and output files specified. */
output = fopen(argv[2], "w"); output = fopen(argv[2], "wb");
if (!output) if (!output)
fatal("unable to open output file."); fatal("unable to open output file.");
outputfile = argv[2]; outputfile = argv[2];

View file

@ -435,7 +435,7 @@ do_file(p)
} }
return; return;
} }
if ((f = fopen(p->t_args[0]->t_str, "r")) == NULL) { if ((f = fopen(p->t_args[0]->t_str, "rb")) == NULL) {
error("could not open %s", p->t_args[0]->t_str); error("could not open %s", p->t_args[0]->t_str);
return; return;
} }
@ -810,7 +810,7 @@ do_source(p)
FILE *old_db_in = db_in; FILE *old_db_in = db_in;
p = p->t_args[0]; p = p->t_args[0];
if ((db_in = fopen(p->t_str, "r")) == NULL) { if ((db_in = fopen(p->t_str, "rb")) == NULL) {
db_in = old_db_in; db_in = old_db_in;
error("could not open %s", p->t_str); error("could not open %s", p->t_str);
return; return;

View file

@ -108,7 +108,7 @@ int
rd_open(f) rd_open(f)
char *f; char *f;
{ {
if ((inf = fopen(f, "r")) == NULL) return 0; if ((inf = fopen(f, "rb")) == NULL) return 0;
return 1; return 1;
} }
@ -346,7 +346,7 @@ int
rd_open(f) rd_open(f)
char *f; char *f;
{ {
if ((inf = fopen(f, "r")) == NULL) return 0; if ((inf = fopen(f, "rb")) == NULL) return 0;
return 1; return 1;
} }

View file

@ -14,7 +14,7 @@ void core_dump(void)
{ {
FILE *core_file; FILE *core_file;
core_file = fopen("int.core", "w"); core_file = fopen("int.core", "wb");
if (!core_file) { if (!core_file) {
/* no point in giving a fatal error again! */ /* no point in giving a fatal error again! */
return; return;

View file

@ -61,7 +61,7 @@ PRIVATE long rd_int(size);
void rd_open(char *fname) void rd_open(char *fname)
{ /* Open loadfile */ { /* Open loadfile */
if ((load_fp = fopen(fname, "r")) == NULL) if ((load_fp = fopen(fname, "rb")) == NULL)
{ {
fatal("Cannot open loadfile '%s'", fname); fatal("Cannot open loadfile '%s'", fname);
} }

View file

@ -115,7 +115,7 @@ void out_tally(void)
if (!*hook) if (!*hook)
return; return;
tally_fp = fopen("int.tally", "w"); tally_fp = fopen("int.tally", "wb");
if (!tally_fp) if (!tally_fp)
return; return;