Lots of binary mode flags.

This commit is contained in:
David Given 2022-07-17 12:58:48 +02:00
parent cb37502a23
commit 5c2f190c29
24 changed files with 42 additions and 42 deletions

View file

@ -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':

View file

@ -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;

View file

@ -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 <ack object> <riscos object>.\n", argv[0]);

View file

@ -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];

View file

@ -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 <as object> <dl object>.\n", argv[0]);

View file

@ -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 <as object> <dl object>.\n", argv[0]);

View file

@ -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 <as object> <dl object>.\n", argv[0]);

View file

@ -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);
}

View file

@ -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 <Mantra object> <ACK object>.\n", argv[0]);

View file

@ -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;

View file

@ -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 <y_word> 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

View file

@ -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];

View file

@ -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;

View file

@ -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 (

View file

@ -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);

View file

@ -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
}

View file

@ -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));

View file

@ -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");

View file

@ -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
}

View file

@ -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");

View file

@ -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 <Sun-3 object> <ACK object>.\n", argv[0]);

View file

@ -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(); */

View file

@ -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);

View file

@ -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);
}
}