From 5c2f190c29d4f950f045506e14b6157217158672 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 17 Jul 2022 12:58:48 +0200 Subject: [PATCH] Lots of binary mode flags. --- lang/a68s/util/xref.c | 10 +++++----- lang/basic/lib/file.c | 6 +++--- mach/arm/cv/cv.c | 4 ++-- mach/i86/cv/cv.c | 2 +- mach/m68020/cv/cv.c | 4 ++-- mach/m68k2/cv/cv.c | 4 ++-- mach/m68k2/cv/cv.prev.c | 4 ++-- mach/m68k2/dl/cv.c | 4 ++-- mach/mantra/cv/Xcv.c | 2 +- mach/mantra/cv/cv.c | 2 +- mach/mips/as/mktables.lua | 6 +++--- mach/pdp/cv/cv.c | 2 +- mach/pmds/cv/cv.c | 2 +- mach/proto/as/comm4.c | 2 +- mach/proto/cg/fillem.c | 2 +- mach/proto/cg/gencode.c | 2 +- mach/proto/mcg/main.c | 6 +++--- mach/proto/ncg/fillem.c | 2 +- mach/proto/ncg/gencode.c | 2 +- mach/sparc/ce/back.src/do_open.c | 2 +- mach/sun3/cv/Xcv.c | 2 +- mach/z80/int/dl.c | 4 ++-- modules/src/em_opt/outputdfa.c | 6 +++--- modules/src/malloc/check.c | 2 +- 24 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lang/a68s/util/xref.c b/lang/a68s/util/xref.c index 4f7beb16e..cc93b5abd 100644 --- a/lang/a68s/util/xref.c +++ b/lang/a68s/util/xref.c @@ -93,13 +93,13 @@ int narg; postin[0] = dup(0); if (pass1) { if (useroif) { - if ((hashin = fopen(oifile, "r")) == NULL) + if ((hashin = fopen(oifile, "rb")) == NULL) fatal("bad ignore/only file: %s",oifile); buildhash(); fclose(hashin); } input = stdin; - output = fdopen(scanout[1], "w"); + output = fdopen(scanout[1], "wb"); nfiles = argc; setjmp(env); while (argc--) @@ -203,9 +203,9 @@ scan(s) char *s; oifsuf++; if (lastc != oifile[oifsuf] ) { oifile[oifsuf] = lastc; - if ((hashin = fopen(oifile, "r")) == NULL) { + if ((hashin = fopen(oifile, "rb")) == NULL) { oifile[oifsuf] = 'x'; - if ((hashin = fopen(oifile, "r")) == NULL) + if ((hashin = fopen(oifile, "rb")) == NULL) fatal("cannot open %s",oifile); } buildhash(); @@ -215,7 +215,7 @@ scan(s) char *s; if (s[0]=='-' && s[1]=='\0') input = stdin; else - if ((input = fopen(s, "r")) == NULL) + if ((input = fopen(s, "rb")) == NULL) fatal("cannot open %s",s); switch (type) { case 'x': diff --git a/lang/basic/lib/file.c b/lang/basic/lib/file.c index cba32c439..55a8f4215 100644 --- a/lang/basic/lib/file.c +++ b/lang/basic/lib/file.c @@ -76,19 +76,19 @@ void _opnchn(int reclen, String* fname, String* mode) { case 'O': case 'o': - if ((f = fopen(fname->strval, "w")) == NULL) + if ((f = fopen(fname->strval, "wb")) == NULL) error(28); m = OMODE; break; case 'I': case 'i': - if ((f = fopen(fname->strval, "r")) == NULL) + if ((f = fopen(fname->strval, "rb")) == NULL) error(28); m = IMODE; break; case 'r': case 'R': - if ((f = fopen(fname->strval, "a")) == NULL) + if ((f = fopen(fname->strval, "ab")) == NULL) error(28); m = RMODE; break; diff --git a/mach/arm/cv/cv.c b/mach/arm/cv/cv.c index 1d0276845..2f4d89389 100644 --- a/mach/arm/cv/cv.c +++ b/mach/arm/cv/cv.c @@ -93,12 +93,12 @@ main(argc, argv) } switch (argc) { case 1: break; - case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0) + case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0) fatal("Can't write %s.\n", argv[2]); ofile = argv[2]; ofile_created = 1; /* FALLTHROUGH */ - case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0) + case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0) fatal("Can't read %s.\n", argv[1]); break; default:fatal("Usage: %s .\n", argv[0]); diff --git a/mach/i86/cv/cv.c b/mach/i86/cv/cv.c index 028d77bac..7f329ad6e 100644 --- a/mach/i86/cv/cv.c +++ b/mach/i86/cv/cv.c @@ -102,7 +102,7 @@ main(argc, argv) switch (argc) { case 1: rd_fdopen(0); break; - case 3: if ((output = fopen(argv[2], "w")) == 0) { + case 3: if ((output = fopen(argv[2], "wb")) == 0) { fatal("Can't write %s.\n", argv[2]); } output_file = argv[2]; diff --git a/mach/m68020/cv/cv.c b/mach/m68020/cv/cv.c index 0ef5cc55d..e28908690 100644 --- a/mach/m68020/cv/cv.c +++ b/mach/m68020/cv/cv.c @@ -141,12 +141,12 @@ main(argc, argv) } switch (argc) { case 1: break; - case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0) + case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0) fatal("Can't write %s.\n", argv[2]); output_file = argv[2]; outputfile_created = 1; /* FALLTHROUGH */ - case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0) + case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0) fatal("Can't read %s.\n", argv[1]); break; default:fatal("Usage: %s
.\n", argv[0]); diff --git a/mach/m68k2/cv/cv.c b/mach/m68k2/cv/cv.c index 290c6b1de..4989b6102 100644 --- a/mach/m68k2/cv/cv.c +++ b/mach/m68k2/cv/cv.c @@ -102,12 +102,12 @@ main(argc, argv) } switch (argc) { case 1: break; - case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0) + case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0) fatal("Can't write %s.\n", argv[2]); ofile = argv[2]; ofile_created = 1; /* FALLTHROUGH */ - case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0) + case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0) fatal("Can't read %s.\n", argv[1]); break; default:fatal("Usage: %s
.\n", argv[0]); diff --git a/mach/m68k2/cv/cv.prev.c b/mach/m68k2/cv/cv.prev.c index 8494ce3fc..8fb222fff 100644 --- a/mach/m68k2/cv/cv.prev.c +++ b/mach/m68k2/cv/cv.prev.c @@ -38,12 +38,12 @@ main(argc, argv) program= argv[0] ; switch (argc) { case 1: break; - case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0) + case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0) fatal("Can't write %s.\n", argv[2]); output_file = argv[2]; output_file_created = 1; /* FALLTHROUGH */ - case 2: if ((input = fopen(argv[1], "r")) == (FILE *)0) + case 2: if ((input = fopen(argv[1], "rb")) == (FILE *)0) fatal("Can't read %s.\n", argv[1]); break; default:fatal("Usage: %s
.\n", argv[0]); diff --git a/mach/m68k2/dl/cv.c b/mach/m68k2/dl/cv.c index cf2a7f98f..3546b253d 100644 --- a/mach/m68k2/dl/cv.c +++ b/mach/m68k2/dl/cv.c @@ -36,11 +36,11 @@ main(argc,argv) char **argv; { fprintf(stderr,"Usage: %s VU-a.out Bleasdale-a.out\n",argv[0]); exit(-1); } - if (freopen(argv[1],"r",stdin)==NULL) { + if (freopen(argv[1],"rb",stdin)==NULL) { perror(argv[1]); exit(-1); } - if (freopen(argv[2],"w",stdout)==NULL) { + if (freopen(argv[2],"wb",stdout)==NULL) { perror(argv[2]); exit(-1); } diff --git a/mach/mantra/cv/Xcv.c b/mach/mantra/cv/Xcv.c index da3033ead..d8a9f4988 100644 --- a/mach/mantra/cv/Xcv.c +++ b/mach/mantra/cv/Xcv.c @@ -108,7 +108,7 @@ main(argc, argv) case 3: if (! wr_open(argv[2])) fatal("Can't write %s.\n", argv[2]); output_file = argv[2]; - if ((input = fopen(argv[1], "r")) == (FILE *)0) + if ((input = fopen(argv[1], "rb")) == (FILE *)0) fatal("Can't read %s.\n", argv[1]); break; default:fatal("Usage: %s .\n", argv[0]); diff --git a/mach/mantra/cv/cv.c b/mach/mantra/cv/cv.c index f9a2536ba..2dfeb1b89 100644 --- a/mach/mantra/cv/cv.c +++ b/mach/mantra/cv/cv.c @@ -107,7 +107,7 @@ main(argc, argv) argc-- ; argv++ ; } switch (argc) { - case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0) + case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0) fatal("Can't write %s.\n", argv[2]); output_file = argv[2]; outputfile_created = 1; diff --git a/mach/mips/as/mktables.lua b/mach/mips/as/mktables.lua index f1214e248..b6bbf1883 100755 --- a/mach/mips/as/mktables.lua +++ b/mach/mips/as/mktables.lua @@ -139,19 +139,19 @@ while true do end end -local definitionsfp = io.open(args[1], "w") +local definitionsfp = io.open(args[1], "wb") for word, value in pairs(words) do definitionsfp:write("%token OP_", tostring(value), " /* ", word, " */\n") end definitionsfp:close() -local tokensfp = io.open(args[2], "w") +local tokensfp = io.open(args[2], "wb") for word, value in pairs(words) do tokensfp:write("0, OP_", value, ", 0, \"", word, "\",\n") end tokensfp:close() -local rulesfp = io.open(args[3], "w") +local rulesfp = io.open(args[3], "wb") rulesfp:write("operation\n") for index, insn in ipairs(insns) do if index == 1 then diff --git a/mach/pdp/cv/cv.c b/mach/pdp/cv/cv.c index e5c5ffd9f..455469a6b 100644 --- a/mach/pdp/cv/cv.c +++ b/mach/pdp/cv/cv.c @@ -86,7 +86,7 @@ main(argc, argv) switch (argc) { case 1: rd_fdopen(0); break; - case 3: if ((output = fopen(argv[2], "w")) == NULL) { + case 3: if ((output = fopen(argv[2], "wb")) == NULL) { fatal("Can't write %s.\n", argv[2]); } output_file = argv[2]; diff --git a/mach/pmds/cv/cv.c b/mach/pmds/cv/cv.c index bc1fecb2f..4d6c9cec6 100644 --- a/mach/pmds/cv/cv.c +++ b/mach/pmds/cv/cv.c @@ -88,7 +88,7 @@ main(argc, argv) argc-- ; argv++ ; } switch (argc) { - case 3: if ((output = fopen(argv[2], "w")) == (FILE *)0) + case 3: if ((output = fopen(argv[2], "wb")) == (FILE *)0) fatal("Can't write %s.\n", argv[2]); output_file = argv[2]; outputfile_created = 1; diff --git a/mach/proto/as/comm4.c b/mach/proto/as/comm4.c index f2479f710..756f2d4c0 100644 --- a/mach/proto/as/comm4.c +++ b/mach/proto/as/comm4.c @@ -165,7 +165,7 @@ pass_1(int argc, char **argv) continue; } #endif - if ((input = fopen(p, "r")) == NULL) + if ((input = fopen(p, "rb")) == NULL) fatal("can't open %s", p); #ifdef ASLD if ( diff --git a/mach/proto/cg/fillem.c b/mach/proto/cg/fillem.c index f33520e8b..4547b212d 100644 --- a/mach/proto/cg/fillem.c +++ b/mach/proto/cg/fillem.c @@ -141,7 +141,7 @@ static long our_atol(register char *s) void in_init(char *filename) { - if ((emfile=freopen(filename,"r",stdin))==NULL) + if ((emfile=freopen(filename,"rb",stdin))==NULL) error("Can't open %s",filename); if (get16()!=sp_magic) error("Bad format %s",filename); diff --git a/mach/proto/cg/gencode.c b/mach/proto/cg/gencode.c index 7582808ab..47ba70293 100644 --- a/mach/proto/cg/gencode.c +++ b/mach/proto/cg/gencode.c @@ -34,7 +34,7 @@ void out_init(char *filename) #endif if (filename == (char *) 0) codefile = stdout; - else if ((codefile = freopen(filename, "w", stdout)) == NULL) + else if ((codefile = freopen(filename, "wb", stdout)) == NULL) error("Can't create %s", filename); #ifndef NDEBUG } diff --git a/mach/proto/mcg/main.c b/mach/proto/mcg/main.c index 9f4982d66..4fbd78173 100644 --- a/mach/proto/mcg/main.c +++ b/mach/proto/mcg/main.c @@ -56,7 +56,7 @@ int main(int argc, char* const argv[]) switch (c) { case 'C': - cfg_dot_file = fopen(optarg, "w"); + cfg_dot_file = fopen(optarg, "wb"); if (!cfg_dot_file) fatal("couldn't open output file '%s': %s", optarg, strerror(errno)); @@ -64,7 +64,7 @@ int main(int argc, char* const argv[]) break; case 'D': - dominance_dot_file = fopen(optarg, "w"); + dominance_dot_file = fopen(optarg, "wb"); if (!dominance_dot_file) fatal("couldn't open output file '%s': %s", optarg, strerror(errno)); @@ -98,7 +98,7 @@ int main(int argc, char* const argv[]) if (outputfilename) { - outputfile = fopen(outputfilename, "w"); + outputfile = fopen(outputfilename, "wb"); if (!outputfile) fatal("couldn't open output '%s': %s", outputfilename, strerror(errno)); diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index c83144b1a..2aa6798d2 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -140,7 +140,7 @@ static long our_atol(char *s) { void in_init(char *filename) { emfile = stdin; - if (filename && (emfile=freopen(filename,"r",stdin))==NULL) + if (filename && (emfile=freopen(filename,"rb",stdin))==NULL) error("Can't open %s",filename); if (get16()!=sp_magic) error("Bad format %s",filename ? filename : "standard-input"); diff --git a/mach/proto/ncg/gencode.c b/mach/proto/ncg/gencode.c index 8b097f9ec..a0550fde1 100644 --- a/mach/proto/ncg/gencode.c +++ b/mach/proto/ncg/gencode.c @@ -39,7 +39,7 @@ void out_init(char *filename) { if (filename == (char *) 0) codefile = stdout; else - if ((codefile=freopen(filename,"w",stdout))==NULL) + if ((codefile=freopen(filename,"wb",stdout))==NULL) error("Can't create %s",filename); #ifndef NDEBUG } diff --git a/mach/sparc/ce/back.src/do_open.c b/mach/sparc/ce/back.src/do_open.c index 3887e0d9e..f50e4a4ab 100644 --- a/mach/sparc/ce/back.src/do_open.c +++ b/mach/sparc/ce/back.src/do_open.c @@ -13,7 +13,7 @@ char *filename; #ifndef sys_close if ( sys_open( filename, OP_WRITE, &codefile)) { #else - if ((codefile = fopen(filename, "w")) != NULL) { + if ((codefile = fopen(filename, "wb")) != NULL) { #endif #ifdef __solaris__ fprint(codefile, ".section \".text\"\n"); diff --git a/mach/sun3/cv/Xcv.c b/mach/sun3/cv/Xcv.c index 68c287086..696155959 100644 --- a/mach/sun3/cv/Xcv.c +++ b/mach/sun3/cv/Xcv.c @@ -60,7 +60,7 @@ main(argc, argv) case 3: if (! wr_open(argv[2])) fatal("Can't write %s.\n", argv[2]); output_file = argv[2]; - if ((input = fopen(argv[1], "r")) == (FILE *)0) + if ((input = fopen(argv[1], "rb")) == (FILE *)0) fatal("Can't read %s.\n", argv[1]); break; default:fatal("Usage: %s .\n", argv[0]); diff --git a/mach/z80/int/dl.c b/mach/z80/int/dl.c index f37714ff6..8d79832b3 100644 --- a/mach/z80/int/dl.c +++ b/mach/z80/int/dl.c @@ -39,7 +39,7 @@ main(argc,argv) char **argv; { s = "a.out"; if (argc >= 2) s = argv[1]; - if (freopen(s,"r",stdin) == NULL) + if (freopen(s,"rb",stdin) == NULL) fatal("can't open %s",s); s = "/dev/tty05"; if (argc >= 3) @@ -54,7 +54,7 @@ main(argc,argv) char **argv; { tty.sg_flags = RAW; stty(ttyfd,&tty); } else { - freopen(s,"w",stdout); + freopen(s,"wb",stdout); } first = 1; osg = 0; /* uid = getuid(); */ diff --git a/modules/src/em_opt/outputdfa.c b/modules/src/em_opt/outputdfa.c index 110bdea2f..2a885e3ef 100644 --- a/modules/src/em_opt/outputdfa.c +++ b/modules/src/em_opt/outputdfa.c @@ -48,7 +48,7 @@ PRIVATE void openofile(char *filename) strcpy(ofilename, filename); strcpy(ofiletemp, filename); strcat(ofiletemp, ".new"); - if ((ofile = fopen(ofiletemp, "w")) == NULL) + if ((ofile = fopen(ofiletemp, "wb")) == NULL) { fprintf(stderr, "Fatal Error: cannot open output file %s\n", ofiletemp); sys_stop(S_EXIT); @@ -65,12 +65,12 @@ PRIVATE void installofile(void) register FILE *f1, *f2; register int c1, c2; fclose(ofile); - if ((f1 = fopen(ofiletemp, "r")) == NULL) + if ((f1 = fopen(ofiletemp, "rb")) == NULL) { fprintf(stderr, "Fatal Error: cannont reopen file %s\n", ofiletemp); sys_stop(S_EXIT); } - if ((f2 = fopen(ofilename, "r")) == NULL) + if ((f2 = fopen(ofilename, "rb")) == NULL) { fclose(f1); RENAME(ofiletemp, ofilename); diff --git a/modules/src/malloc/check.c b/modules/src/malloc/check.c index b73e7b797..ea09ed78b 100644 --- a/modules/src/malloc/check.c +++ b/modules/src/malloc/check.c @@ -65,7 +65,7 @@ acquire_malout() { static char buf[BUFSIZ]; if (!malout) { - malout = freopen("mal.out", "w", stderr); + malout = freopen("mal.out", "wb", stderr); setbuf(malout, buf); } }