From 514140fbdfa1bd496387aa48f87d1788621e0568 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 22:32:05 +0100 Subject: [PATCH] Rip out all the system library file stuff in favour of standard stdio. --- doc/ceg/ceg.tr | 6 +- fast/f_c.ansi/Parameters | 2 +- fast/f_c/Parameters | 2 +- fast/f_m2/Parameters | 2 +- fast/f_pc/Parameters | 2 +- fcc/cemcom/Parameters.sun3 | 2 +- fcc/cemcom/Parameters.vax4 | 2 +- lang/basic/src/basic.lex | 8 +- lang/basic/src/bem.h | 6 +- lang/basic/src/compile.c | 4 +- lang/basic/src/gencode.c | 4 +- lang/basic/src/graph.c | 2 +- lang/basic/src/initialize.c | 10 +- lang/basic/src/llmess.h | 8 +- lang/basic/src/parsepar.c | 4 +- lang/basic/src/util.c | 4 +- lang/cem/cemcom.ansi/BigPars | 2 +- lang/cem/cemcom.ansi/SmallPars | 2 +- lang/cem/cemcom.ansi/stack.c | 2 +- lang/cem/cemcom/BigPars | 2 +- lang/cem/cemcom/SmallPars | 2 +- lang/cem/cemcom/main.c | 2 +- lang/cem/cemcom/stack.c | 6 +- lang/cem/cpp.ansi/main.c | 10 +- lang/cem/cpp.ansi/parameters.h | 2 +- lang/cem/cpp.ansi/preprocess.c | 4 +- lang/cem/lint/lpass1.ansi/Parameters | 2 +- lang/cem/lint/lpass1/Parameters | 2 +- lang/cem/lint/lpass2/l_print3ack.c | 4 +- lang/cem/lint/lpass2/report.c | 4 +- lang/m2/comp/BigPars | 2 +- lang/m2/comp/SmallPars | 2 +- lang/m2/comp/main.c | 4 +- lang/m2/m2mm/error.c | 8 +- lang/occam/comp/occam.g | 2 +- lang/occam/comp/report.c | 18 +-- lang/pc/comp/Parameters | 2 +- lang/pc/comp/main.c | 4 +- mach/i386/ce/as.c | 10 +- mach/i386/ce/mach.c | 2 +- mach/i86/ce/as.c | 6 +- mach/i86/ce/mach.c | 2 +- mach/m68020/ce/mach.c | 2 +- mach/sparc/ce/back.src/back.h | 8 +- mach/sparc/ce/back.src/do_open.c | 2 +- mach/sparc/ce/back.src/gen_str.c | 2 +- mach/sparc/ce/cache.c.x | 6 +- mach/sparc/ce/mach.c | 2 +- mach/sparc/ce_cg/convert.c | 6 +- mach/sun3/ce/do_close.c | 2 +- mach/sun3/ce/do_open.c | 2 +- mach/sun3/ce/mach.c | 2 +- mach/sun3/ce/misc.c | 4 +- mach/sun3/ce/output.c | 6 +- mach/sun3/ce/relocation.c | 4 +- mach/vax4/ce/as.c | 4 +- mach/vax4/ce/do_close.c | 2 +- mach/vax4/ce/do_open.c | 2 +- mach/vax4/ce/mach.c | 2 +- mach/vax4/ce/output.c | 6 +- mach/vax4/ce/relocation.c | 4 +- modules/src/em_code/convert.c | 6 +- modules/src/em_code/em.c | 15 +- modules/src/em_code/failed.c | 5 +- modules/src/em_code/insert.c | 4 +- modules/src/em_code/insert.h | 4 +- modules/src/em_code/internerr.c | 2 +- modules/src/em_opt/nopt.c | 6 +- modules/src/input/inp_pkg.body | 32 ++-- modules/src/object/wr_bytes.c | 4 +- modules/src/print/doprnt.c | 4 +- modules/src/print/fprint.c | 4 +- modules/src/print/print.3 | 6 +- modules/src/print/print.h | 4 +- modules/src/system/build.lua | 7 - modules/src/system/close.c | 17 --- modules/src/system/create.c | 22 --- modules/src/system/open.c | 51 ------- modules/src/system/read.c | 22 --- modules/src/system/seek.c | 18 --- modules/src/system/system.3 | 169 +--------------------- modules/src/system/system.c | 35 ----- modules/src/system/system.h | 48 +----- modules/src/system/write.c | 18 --- util/ack/util.c | 30 ++-- util/ceg/EM_parser/as_EM_pars/error.c | 12 +- util/ceg/EM_parser/common/C_instr2.c | 2 +- util/ceg/EM_parser/common/default.c | 2 +- util/ceg/EM_parser/common/help.c | 4 +- util/ceg/EM_parser/common/pars.g | 32 ++-- util/ceg/EM_parser/obj_EM_pars/dist.c | 6 +- util/ceg/as_parser/as_parser.h | 2 +- util/ceg/as_parser/help.c | 16 +- util/ceg/as_parser/pars.g | 30 ++-- util/ceg/assemble/obj_assemble/assemble.c | 12 +- util/ceg/ce_back/as_back/back.h | 2 +- util/ceg/ce_back/as_back/bottom.c | 2 +- util/ceg/ce_back/as_back/gen1.c | 2 +- util/ceg/ce_back/as_back/gen2.c | 2 +- util/ceg/ce_back/as_back/gen4.c | 2 +- util/ceg/ce_back/obj_back/gen1.c | 2 +- util/ceg/ce_back/obj_back/gen2.c | 2 +- util/ceg/ce_back/obj_back/gen4.c | 2 +- util/ceg/ce_back/obj_back/misc.c | 4 +- util/ceg/ce_back/obj_back/output.c | 2 +- util/ceg/ce_back/obj_back/relocation.c | 4 +- util/ceg/defaults/not_impl/not_impl.c | 2 +- util/ceg/defaults/pseudo/C_init.c | 4 +- util/ceg/defaults/pseudo/C_open.c | 2 +- util/ego/em_ego/em_ego.c | 10 +- util/misc/convert.c | 6 +- 111 files changed, 274 insertions(+), 671 deletions(-) delete mode 100644 modules/src/system/close.c delete mode 100644 modules/src/system/create.c delete mode 100644 modules/src/system/open.c delete mode 100644 modules/src/system/read.c delete mode 100644 modules/src/system/seek.c delete mode 100644 modules/src/system/system.c delete mode 100644 modules/src/system/write.c diff --git a/doc/ceg/ceg.tr b/doc/ceg/ceg.tr index f26d400007..b5eb464832 100644 --- a/doc/ceg/ceg.tr +++ b/doc/ceg/ceg.tr @@ -1190,7 +1190,7 @@ struct t_operand *op; case BX : R233( 0x0, reg, 0x7); break; - default : fprint( STDERR, "Wrong index register %d\en", + default : fprint( stderr, "Wrong index register %d\en", op->reg); } else { @@ -1208,7 +1208,7 @@ struct t_operand *op; case BX : R233( 0x1, reg, 0x7); break; - default : fprint( STDERR, "Wrong index register %d\en", + default : fprint( stderr, "Wrong index register %d\en", op->reg); } @text1( %$(op->expr)); @@ -1226,7 +1226,7 @@ struct t_operand *op; case BX : R233( 0x2, reg, 0x7); break; - default : fprint( STDERR, "Wrong index register %d\en", + default : fprint( stderr, "Wrong index register %d\en", op->reg); } @text2( %$(op->expr)); diff --git a/fast/f_c.ansi/Parameters b/fast/f_c.ansi/Parameters index 2700280cfd..89275e6f26 100644 --- a/fast/f_c.ansi/Parameters +++ b/fast/f_c.ansi/Parameters @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/fast/f_c/Parameters b/fast/f_c/Parameters index 34a4f45642..05ee887680 100644 --- a/fast/f_c/Parameters +++ b/fast/f_c/Parameters @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/fast/f_m2/Parameters b/fast/f_m2/Parameters index a2d5ea1977..6a2f743b45 100644 --- a/fast/f_m2/Parameters +++ b/fast/f_m2/Parameters @@ -1,5 +1,5 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/fast/f_pc/Parameters b/fast/f_pc/Parameters index e26506bb5c..b00e1538fe 100644 --- a/fast/f_pc/Parameters +++ b/fast/f_pc/Parameters @@ -9,7 +9,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define MAXERR_LINE 5 /* maximum number of error messages given on the same input line. */ diff --git a/fcc/cemcom/Parameters.sun3 b/fcc/cemcom/Parameters.sun3 index 9b4540d7e9..f2d198d050 100644 --- a/fcc/cemcom/Parameters.sun3 +++ b/fcc/cemcom/Parameters.sun3 @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/fcc/cemcom/Parameters.vax4 b/fcc/cemcom/Parameters.vax4 index 34a4f45642..05ee887680 100644 --- a/fcc/cemcom/Parameters.vax4 +++ b/fcc/cemcom/Parameters.vax4 @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index a327fbd3b2..fcbb50c5c8 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -191,7 +191,7 @@ char fgets_buf[GETSBUFSIZE]; -char *our_fgets(char* buffer, int n_char, File* stream) +char *our_fgets(char* buffer, int n_char, FILE* stream) { /* Read one line or n_char */ static int characters_left = 0; @@ -217,10 +217,10 @@ char *our_fgets(char* buffer, int n_char, File* stream) return(buffer); } } else { /* Read new block */ - sys_read(stream,fgets_buf,GETSBUFSIZE,&characters_left); + characters_left = fread(fgets_buf, 1, GETSBUFSIZE, stream); internal_bufp = fgets_buf; /* Move pointer back to the beginning */ - if ( characters_left == 0 ) { /* Nothing read */ + if ( characters_left <= 0 ) { /* Nothing read */ if ( external_bufp == buffer ) { *external_bufp = '\0'; return(0); /* EOF */ @@ -244,7 +244,7 @@ int getinputline(void) error("source line too long"); inputline[MAXLINELENGTH-1]=0; if ( listing) - fprint(STDERR, inputline); + fprint(stderr, inputline); cptr= inputline; return(TRUE); } diff --git a/lang/basic/src/bem.h b/lang/basic/src/bem.h index 6a34332c30..e216a5f65b 100644 --- a/lang/basic/src/bem.h +++ b/lang/basic/src/bem.h @@ -51,9 +51,9 @@ extern char *outfile; /* output from compiler */ extern char datfname[MAXFILENAME]; /* data statements file */ -extern File *emfile; /* EM output file */ -extern File *datfile; /* data file */ -extern File *yyin; /* Compiler input */ +extern FILE *emfile; /* EM output file */ +extern FILE *datfile; /* data file */ +extern FILE *yyin; /* Compiler input */ extern int endofinput; extern int wflag; diff --git a/lang/basic/src/compile.c b/lang/basic/src/compile.c index 850e03c185..94ac3ef43d 100644 --- a/lang/basic/src/compile.c +++ b/lang/basic/src/compile.c @@ -19,7 +19,7 @@ extern void LLparse(void); /* compile the next program in the list */ /* Here we should open the input file. (for the future) */ -File *yyin; +FILE* yyin; void compileprogram(void) { @@ -34,5 +34,5 @@ void compileprogram(void) LLparse(); } epilogcode(); - sys_close(yyin); + fclose(yyin); } diff --git a/lang/basic/src/gencode.c b/lang/basic/src/gencode.c index 3f920c4833..2f49dadbc9 100644 --- a/lang/basic/src/gencode.c +++ b/lang/basic/src/gencode.c @@ -632,8 +632,8 @@ void prolog2(void) C_csa((arith)BEMINTSIZE); C_df_ilb((label)0); C_asp((arith)BEMINTSIZE); - result= sys_open(datfname, OP_WRITE, &datfile); - if ( result==0 ) fatal("improper file creation permission"); + datfile = fopen(datfname, "w+b"); + if (!datfile) fatal("improper file creation permission"); gendata(); } diff --git a/lang/basic/src/graph.c b/lang/basic/src/graph.c index c714e1de5e..f9dba49733 100644 --- a/lang/basic/src/graph.c +++ b/lang/basic/src/graph.c @@ -64,7 +64,7 @@ void linewarnings(void) { if ( !srchline(l->linenr)) { - fprint(STDERR, "ERROR: line %d not defined\n",l->linenr); + fprint(stderr, "ERROR: line %d not defined\n",l->linenr); errorcnt++; } l=l->nextlist; diff --git a/lang/basic/src/initialize.c b/lang/basic/src/initialize.c index 48f5363056..9ee04757e2 100644 --- a/lang/basic/src/initialize.c +++ b/lang/basic/src/initialize.c @@ -13,14 +13,14 @@ static char rcs_id[] = "$Id$"; /* generate temporary files etc */ -File *datfile; +FILE *datfile; extern void fillkex(void); void initialize(void) { char *cindex, *cptr; - int result1, result2; + int result; /* Find the basename */ /* Strip leading directories */ @@ -40,9 +40,9 @@ void initialize(void) if ( cptr>datfname+3 && cptr[-3]=='.' ) cptr[-3]=0; strcat(datfname,".d"); C_init((arith)BEMINTSIZE, (arith)BEMPTRSIZE); - result1 = sys_open(inpfile, OP_READ, &yyin); - result2 = C_open(outfile); - if ( result1==0 || result2== 0 ) + yyin = fopen(inpfile, "r"); + result = C_open(outfile); + if ( !yyin || result== 0 ) fatal("Improper file permissions"); C_magic(); fillkex(); /* initialize symbol table */ diff --git a/lang/basic/src/llmess.h b/lang/basic/src/llmess.h index 39c3722d10..d0a8198898 100644 --- a/lang/basic/src/llmess.h +++ b/lang/basic/src/llmess.h @@ -18,8 +18,8 @@ void error_char(char *format,char ch) extern int listing,errorcnt; extern int basicline; - if ( !listing ) fprint(STDERR, "LINE %d:",basicline); - fprint(STDERR, format,ch); + if ( !listing ) fprint(stderr, "LINE %d:",basicline); + fprint(stderr, format,ch); errorcnt++; } @@ -30,8 +30,8 @@ void error_string(char* format,char* str) extern int listing,errorcnt; extern int basicline; - if ( !listing ) fprint(STDERR, "LINE %d:",basicline); - fprint(STDERR, format,str); + if ( !listing ) fprint(stderr, "LINE %d:",basicline); + fprint(stderr, format,str); errorcnt++; } diff --git a/lang/basic/src/parsepar.c b/lang/basic/src/parsepar.c index acfeb512fa..92e9849103 100644 --- a/lang/basic/src/parsepar.c +++ b/lang/basic/src/parsepar.c @@ -32,7 +32,7 @@ void parseparams(int argc,char **argv) if(argc< 4) { - fprint(STDERR,"usage %s \n", + fprint(stderr,"usage %s \n", argv[0]); sys_stop(S_EXIT); } @@ -46,7 +46,7 @@ void parseparams(int argc,char **argv) case 't': traceflag++; break; /* line tracing */ case 'h': /* split EM file */ - fprint(STDERR, + fprint(stderr, "h option not implemented\n"); break; case 'd': debug++; diff --git a/lang/basic/src/util.c b/lang/basic/src/util.c index 6c8a6342dc..64e1c5ed6d 100644 --- a/lang/basic/src/util.c +++ b/lang/basic/src/util.c @@ -25,8 +25,8 @@ static void Xerror(char *type, char *str) extern int listing; extern int basicline; - if( !listing) fprint(STDERR, "LINE %d:",basicline); - fprint(STDERR, "%s:%s\n",type, str); + if( !listing) fprint(stderr, "LINE %d:",basicline); + fprint(stderr, "%s:%s\n",type, str); } diff --git a/lang/cem/cemcom.ansi/BigPars b/lang/cem/cemcom.ansi/BigPars index 8226992a22..53c86a6c12 100644 --- a/lang/cem/cemcom.ansi/BigPars +++ b/lang/cem/cemcom.ansi/BigPars @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/cem/cemcom.ansi/SmallPars b/lang/cem/cemcom.ansi/SmallPars index fa3147ea95..9681fdb2d4 100644 --- a/lang/cem/cemcom.ansi/SmallPars +++ b/lang/cem/cemcom.ansi/SmallPars @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/cem/cemcom.ansi/stack.c b/lang/cem/cemcom.ansi/stack.c index 0c6a4d910a..670494f286 100644 --- a/lang/cem/cemcom.ansi/stack.c +++ b/lang/cem/cemcom.ansi/stack.c @@ -262,7 +262,7 @@ void unstack_world(void) list is generated. */ extern char *nmlist; /* BAH! -- main.c */ -static File *nfp = 0; +static FILE* nfp = 0; void open_name_list(void) { diff --git a/lang/cem/cemcom/BigPars b/lang/cem/cemcom/BigPars index f01c3716ac..cb637be7a8 100644 --- a/lang/cem/cemcom/BigPars +++ b/lang/cem/cemcom/BigPars @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/cem/cemcom/SmallPars b/lang/cem/cemcom/SmallPars index 84639871a7..303fd265a1 100644 --- a/lang/cem/cemcom/SmallPars +++ b/lang/cem/cemcom/SmallPars @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/cem/cemcom/main.c b/lang/cem/cemcom/main.c index f033706099..6a541e85af 100644 --- a/lang/cem/cemcom/main.c +++ b/lang/cem/cemcom/main.c @@ -44,7 +44,7 @@ char **inctable; extern int do_dependencies; extern char *dep_file; -static File *dep_fd = STDOUT; +static FILE* dep_fd = stdout; extern char *getwdir(); #endif /* NOPP */ diff --git a/lang/cem/cemcom/stack.c b/lang/cem/cemcom/stack.c index fd480c6150..88a411bf8e 100644 --- a/lang/cem/cemcom/stack.c +++ b/lang/cem/cemcom/stack.c @@ -266,7 +266,7 @@ unstack_world() list is generated. */ extern char *nmlist; /* BAH! -- main.c */ -static File *nfp = 0; +static FILE* nfp = 0; open_name_list() { @@ -278,7 +278,7 @@ namelist(nm) char *nm; { if (nmlist) { - sys_write(nfp, nm, strlen(nm)); - sys_write(nfp, "\n", 1); + fwrite(nm, 1, strlen(nm), nfp); + fputc('\n', nfp); } } diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index d0c599612e..2b459a1333 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -30,7 +30,7 @@ extern int do_dependencies; extern char *dep_file; int idfsize = IDFSIZE; extern char options[]; -static File *dep_fd; +static FILE* dep_fd; arith ifval; @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) { /* parse and interpret the command line options */ prog_name = argv[0]; - dep_fd = STDOUT; + dep_fd = stdout; init_idf(); @@ -130,8 +130,10 @@ static void list_dependencies(char *source) } else source = 0; } - if (dep_file && !sys_open(dep_file, OP_WRITE, &dep_fd)) { - fatal("could not open %s", dep_file); + if (dep_file) { + dep_fd = fopen(dep_file, "w+"); + if (!dep_fd) + fatal("could not open %s", dep_file); } while (p) { assert(p->id_resmac == K_FILE); diff --git a/lang/cem/cpp.ansi/parameters.h b/lang/cem/cpp.ansi/parameters.h index 37bdebe129..7d589d9d9b 100644 --- a/lang/cem/cpp.ansi/parameters.h +++ b/lang/cem/cpp.ansi/parameters.h @@ -4,7 +4,7 @@ #define PATHLENGTH 1024 /* max. length of path to file */ -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define MAXERR_LINE 5 /* maximum number of error messages given on the same input line. */ diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index afc72526be..141ef2fcec 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -32,7 +32,7 @@ extern int InputLevel; void Xflush(void) { - sys_write(STDOUT, _obuf, OBUFSIZE); + fwrite(_obuf, 1, OBUFSIZE, stdout); } static char* SkipComment(char *op, int *lineno); @@ -135,7 +135,7 @@ void preprocess(char *fn) int lineno = 0; int startline; -#define flush(X) (sys_write(STDOUT, _obuf, X)) +#define flush(X) (fwrite(_obuf, 1, X, stdout)) #define echo(ch) \ if (op == ob) \ { \ diff --git a/lang/cem/lint/lpass1.ansi/Parameters b/lang/cem/lint/lpass1.ansi/Parameters index bf6c51871a..fec95f29b9 100644 --- a/lang/cem/lint/lpass1.ansi/Parameters +++ b/lang/cem/lint/lpass1.ansi/Parameters @@ -8,7 +8,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 0 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/cem/lint/lpass1/Parameters b/lang/cem/lint/lpass1/Parameters index 539950ed1d..96c69d9d18 100644 --- a/lang/cem/lint/lpass1/Parameters +++ b/lang/cem/lint/lpass1/Parameters @@ -7,7 +7,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 0 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/cem/lint/lpass2/l_print3ack.c b/lang/cem/lint/lpass2/l_print3ack.c index b76e43bf80..eb5d86b40c 100644 --- a/lang/cem/lint/lpass2/l_print3ack.c +++ b/lang/cem/lint/lpass2/l_print3ack.c @@ -20,11 +20,11 @@ printf(format) char *format; { ; } /* FORMAT1 */ -fprint(filep, format) File *filep; char *format; { ; } +fprint(filep, format) FILE* filep; char *format; { ; } /* FORMAT1 */ sprintf(s, format) char *s; char *format; { ; } /* FORMAT1 */ -doprnt(filep, format) File *filep; char *format; { ; } +doprnt(filep, format) FILE* filep; char *format; { ; } #endif /* lint */ diff --git a/lang/cem/lint/lpass2/report.c b/lang/cem/lint/lpass2/report.c index 3188ffe91c..57197f6aa6 100644 --- a/lang/cem/lint/lpass2/report.c +++ b/lang/cem/lint/lpass2/report.c @@ -17,8 +17,8 @@ extern panic(char *, ...); #include "class.h" #include "inpdef.h" -#define MSGOUT STDERR /* file descr. on which to write the messages */ -#define ERROUT STDERR /* file descr. on which to write the panics */ +#define MSGOUT stderr /* file descr. on which to write the messages */ +#define ERROUT stderr /* file descr. on which to write the panics */ extern int LineNr; diff --git a/lang/m2/comp/BigPars b/lang/m2/comp/BigPars index b75eed601a..2acfd7f42e 100644 --- a/lang/m2/comp/BigPars +++ b/lang/m2/comp/BigPars @@ -1,5 +1,5 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/m2/comp/SmallPars b/lang/m2/comp/SmallPars index 2625fa260b..003a76857e 100644 --- a/lang/m2/comp/SmallPars +++ b/lang/m2/comp/SmallPars @@ -1,5 +1,5 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define ERR_SHADOW 5 /* a syntax error overshadows error messages until ERR_SHADOW symbols have been accepted without syntax error */ diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 243d773705..1aeee4ed65 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -84,7 +84,7 @@ int main(int argc, char **argv) } Nargv[Nargc] = 0; /* terminate the arg vector */ if (Nargc < 2) { - fprint(STDERR, "%s: Use a file argument\n", ProgName); + fprint(stderr, "%s: Use a file argument\n", ProgName); sys_stop(S_EXIT); } sys_stop(Compile(Nargv[1], Nargv[2]) ? S_END : S_EXIT); @@ -96,7 +96,7 @@ int Compile(char *src, char *dst) extern struct tokenname tkidf[]; if (! InsertFile(src, (char **) 0, &src)) { - fprint(STDERR,"%s: cannot open %s\n", ProgName, src); + fprint(stderr,"%s: cannot open %s\n", ProgName, src); return 0; } LineNumber = 1; diff --git a/lang/m2/m2mm/error.c b/lang/m2/m2mm/error.c index ec10224dee..967d144c5f 100644 --- a/lang/m2/m2mm/error.c +++ b/lang/m2/m2mm/error.c @@ -228,10 +228,10 @@ _error(class, fmt, argv) break; } - if (FileName) fprint(STDERR, "\"%s\", line %u: ", FileName, ln); + if (FileName) fprint(stderr, "\"%s\", line %u: ", FileName, ln); - if (remark) fprint(STDERR, "%s ", remark); + if (remark) fprint(stderr, "%s ", remark); - doprnt(STDERR, fmt, argv); /* contents of error */ - fprint(STDERR, "\n"); + doprnt(stderr, fmt, argv); /* contents of error */ + fprint(stderr, "\n"); } diff --git a/lang/occam/comp/occam.g b/lang/occam/comp/occam.g index 79290932cb..b495602208 100644 --- a/lang/occam/comp/occam.g +++ b/lang/occam/comp/occam.g @@ -711,7 +711,7 @@ LLmessage(tk) register tk; warning("syntax error: garbage at end of program"); } if (++errors==MAXERRORS) { - fprint(STDERR, "Too many insert/delete errors. Compiler ends.\n"); + fprint(stderr, "Too many insert/delete errors. Compiler ends.\n"); err=1; trailer(); exit(1); } } diff --git a/lang/occam/comp/report.c b/lang/occam/comp/report.c index 62f2b5fe36..96856b0640 100644 --- a/lang/occam/comp/report.c +++ b/lang/occam/comp/report.c @@ -13,25 +13,25 @@ extern char *curr_file; /*VARARGS1*/ report(fmt, arg1, arg2, arg3) char *fmt; { - fprint(STDERR, "%s (%d) F: ", curr_file, lineno); - fprint(STDERR, fmt, arg1, arg2, arg3); - fprint(STDERR,"\n"); + fprint(stderr, "%s (%d) F: ", curr_file, lineno); + fprint(stderr, fmt, arg1, arg2, arg3); + fprint(stderr,"\n"); err=1; } /*VARARGS1*/ warning(fmt, arg1, arg2, arg3) char *fmt, *arg1; { - fprint(STDERR, "%s (%d) E: ", curr_file, lineno); - fprint(STDERR, fmt, arg1, arg2, arg3); - fprint(STDERR,"\n"); + fprint(stderr, "%s (%d) E: ", curr_file, lineno); + fprint(stderr, fmt, arg1, arg2, arg3); + fprint(stderr,"\n"); } /*VARARGS1*/ fatal(fmt, arg1, arg2, arg3) char *fmt, *arg1; { - fprint(STDERR, "%s (%d) X: ", curr_file, lineno); - fprint(STDERR, fmt, arg1, arg2, arg3); - fprint(STDERR,"\n"); + fprint(stderr, "%s (%d) X: ", curr_file, lineno); + fprint(stderr, fmt, arg1, arg2, arg3); + fprint(stderr,"\n"); exit(1); } diff --git a/lang/pc/comp/Parameters b/lang/pc/comp/Parameters index 46d4ed6836..4a1238c6a0 100644 --- a/lang/pc/comp/Parameters +++ b/lang/pc/comp/Parameters @@ -9,7 +9,7 @@ !File: errout.h -#define ERROUT STDERR /* file pointer for writing messages */ +#define ERROUT stderr /* file pointer for writing messages */ #define MAXERR_LINE 5 /* maximum number of error messages given on the same input line. */ diff --git a/lang/pc/comp/main.c b/lang/pc/comp/main.c index 4b48f34318..d5a98f9e62 100644 --- a/lang/pc/comp/main.c +++ b/lang/pc/comp/main.c @@ -66,7 +66,7 @@ int main(int argc, char **argv) } Nargv[Nargc] = 0; /* terminate the arg vector */ if( Nargc < 2 ) { - fprint(STDERR, "%s: Use a file argument\n", ProgName); + fprint(stderr, "%s: Use a file argument\n", ProgName); return EXIT_FAILURE; } if(!Compile(Nargv[1], Nargv[2])) @@ -81,7 +81,7 @@ int Compile(char *src, char *dst) int tk; if( !InsertFile(src, (char **) 0, &src) ) { - fprint(STDERR, "%s: cannot open %s\n", ProgName, src); + fprint(stderr, "%s: cannot open %s\n", ProgName, src); return 0; } LineNumber = 1; diff --git a/mach/i386/ce/as.c b/mach/i386/ce/as.c index ec3c09b262..2cde0cf56c 100644 --- a/mach/i386/ce/as.c +++ b/mach/i386/ce/as.c @@ -203,7 +203,7 @@ struct t_operand *op; @text1( 0); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } else { @@ -222,7 +222,7 @@ struct t_operand *op; case SI : R233( 0x1, reg, op->reg); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } @text1( %$(op->expr)); @@ -237,7 +237,7 @@ struct t_operand *op; case SI : R233( 0x2, reg, op->reg); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } @text4( %$(op->expr)); @@ -254,7 +254,7 @@ struct t_operand *op; case SI : R233( 0x1, reg, op->reg); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } @text1( %$(op->expr)); @@ -269,7 +269,7 @@ struct t_operand *op; case SI : R233( 0x2, reg, op->reg); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } @text4( %$(op->expr)); diff --git a/mach/i386/ce/mach.c b/mach/i386/ce/mach.c index 3232764623..c91e98bd08 100644 --- a/mach/i386/ce/mach.c +++ b/mach/i386/ce/mach.c @@ -8,7 +8,7 @@ arg_error( s, arg) char *s; int arg; { - fprint( STDERR, "arg_error %s %d\n", s, arg); + fprint( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/i86/ce/as.c b/mach/i86/ce/as.c index de2bd38084..2d43415829 100644 --- a/mach/i86/ce/as.c +++ b/mach/i86/ce/as.c @@ -242,7 +242,7 @@ struct t_operand *op; case BX : R233( 0x0, reg, 0x7); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } else { @@ -260,7 +260,7 @@ struct t_operand *op; case BX : R233( 0x1, reg, 0x7); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } @text1( %$(op->expr)); @@ -278,7 +278,7 @@ struct t_operand *op; case BX : R233( 0x2, reg, 0x7); break; - default : fprint( STDERR, "Wrong index register %d\n", + default : fprint( stderr, "Wrong index register %d\n", op->reg); } @text2( %$(op->expr)); diff --git a/mach/i86/ce/mach.c b/mach/i86/ce/mach.c index 9ed03698c6..d52895537c 100644 --- a/mach/i86/ce/mach.c +++ b/mach/i86/ce/mach.c @@ -8,7 +8,7 @@ arg_error( s, arg) char *s; int arg; { - fprint( STDERR, "arg_error %s %d\n", s, arg); + fprint( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/m68020/ce/mach.c b/mach/m68020/ce/mach.c index 290a1a2aa4..da488aac03 100644 --- a/mach/m68020/ce/mach.c +++ b/mach/m68020/ce/mach.c @@ -9,7 +9,7 @@ arg_error( s, arg) char *s; int arg; { - fprint( STDERR, "arg_error %s %d\n", s, arg); + fprint( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/sparc/ce/back.src/back.h b/mach/sparc/ce/back.src/back.h index cb53d12891..c7fdfbbb5a 100644 --- a/mach/sparc/ce/back.src/back.h +++ b/mach/sparc/ce/back.src/back.h @@ -70,15 +70,9 @@ extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(), #define fprint fprintf #define sprint sprintf #define print printf -#undef STDOUT -#define STDOUT stdout -#undef STDERR -#define STDERR stderr -#undef STDIN -#define STDIN stdin #undef File #define File FILE #define sys_close fclose #include -extern File *codefile; +extern FILE* codefile; diff --git a/mach/sparc/ce/back.src/do_open.c b/mach/sparc/ce/back.src/do_open.c index f50e4a4ab0..53f7cf05ae 100644 --- a/mach/sparc/ce/back.src/do_open.c +++ b/mach/sparc/ce/back.src/do_open.c @@ -4,7 +4,7 @@ open_back( filename) char *filename; { if ( filename == (char *) 0) { - codefile= STDOUT; + codefile= stdout; #ifdef __solaris__ fprint(codefile, ".section \".text\"\n"); #endif diff --git a/mach/sparc/ce/back.src/gen_str.c b/mach/sparc/ce/back.src/gen_str.c index 34e4e5f1ee..e1046225a4 100644 --- a/mach/sparc/ce/back.src/gen_str.c +++ b/mach/sparc/ce/back.src/gen_str.c @@ -22,6 +22,6 @@ int n; break; case SEGBSS : bss( (arith) 1); break; - default : fprint( STDERR, "gen1 unkown seg %d\n", cur_seg); + default : fprint( stderr, "gen1 unkown seg %d\n", cur_seg); } } diff --git a/mach/sparc/ce/cache.c.x b/mach/sparc/ce/cache.c.x index 6b1514a825..65fac31f7a 100644 --- a/mach/sparc/ce/cache.c.x +++ b/mach/sparc/ce/cache.c.x @@ -36,7 +36,7 @@ static int indent_count = 0; push_ext(char *) flush_cache() after branches and labels cache_read(int) read-ahead. optimization only - dump_cache(File *) debug info: show current stack + dump_cache(FILE* ) debug info: show current stack pop_nop() remove element from cache reg_t alloc_reg() @@ -108,7 +108,7 @@ static int c_count = 0; static const_str_t s; _PROTOTYPE(static void panic, (char*)); -_PROTOTYPE(static void dump_cache, (File *stream)); +_PROTOTYPE(static void dump_cache, (FILE* stream)); _PROTOTYPE(static int cache_read, (int n, int i)); _PROTOTYPE(static void flush_part_cache, (int c, int r, int f, int d)); _PROTOTYPE(static void subst_reg, (reg_t, reg_t)); @@ -1238,7 +1238,7 @@ leave("cache_read"); } static void dump_cache(stream) /* to codefile! */ -File *stream; +FILE* stream; { int i; diff --git a/mach/sparc/ce/mach.c b/mach/sparc/ce/mach.c index 6a6547e651..7d53f9db79 100644 --- a/mach/sparc/ce/mach.c +++ b/mach/sparc/ce/mach.c @@ -9,7 +9,7 @@ arg_error( s, arg) char *s; int arg; { - fprint( STDERR, "arg_error %s %d\n", s, arg); + fprint( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/sparc/ce_cg/convert.c b/mach/sparc/ce_cg/convert.c index 8d266bba43..06fa3794f8 100644 --- a/mach/sparc/ce_cg/convert.c +++ b/mach/sparc/ce_cg/convert.c @@ -97,12 +97,12 @@ main(argc,argv) error(s,a1,a2,a3,a4) char *s; { - fprint(STDERR, + fprint(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - fprint(STDERR,s,a1,a2,a3,a4); - fprint(STDERR, "\n"); + fprint(stderr,s,a1,a2,a3,a4); + fprint(stderr, "\n"); errors++; } diff --git a/mach/sun3/ce/do_close.c b/mach/sun3/ce/do_close.c index 1e442dc7f8..b0ea7083e0 100644 --- a/mach/sun3/ce/do_close.c +++ b/mach/sun3/ce/do_close.c @@ -1,7 +1,7 @@ #include #include -extern File *B_out_file; +extern FILE* B_out_file; close_back() { diff --git a/mach/sun3/ce/do_open.c b/mach/sun3/ce/do_open.c index 41d5d56506..4bc7f4c747 100644 --- a/mach/sun3/ce/do_open.c +++ b/mach/sun3/ce/do_open.c @@ -1,7 +1,7 @@ #include #include -File *B_out_file; +FILE* B_out_file; open_back( filename) char *filename; diff --git a/mach/sun3/ce/mach.c b/mach/sun3/ce/mach.c index 9a0dd08adb..c7289cea13 100644 --- a/mach/sun3/ce/mach.c +++ b/mach/sun3/ce/mach.c @@ -9,7 +9,7 @@ arg_error( s, arg) char *s; int arg; { - fprint( STDERR, "arg_error %s %d\n", s, arg); + fprint( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/sun3/ce/misc.c b/mach/sun3/ce/misc.c index 10eced7e62..370c88924e 100644 --- a/mach/sun3/ce/misc.c +++ b/mach/sun3/ce/misc.c @@ -22,7 +22,7 @@ align_word() case SEGBSS : if ( nbss % 2 != 0) nbss++; return; - default : fprint( STDERR, "align_word() : unknown seg\n"); + default : fprint( stderr, "align_word() : unknown seg\n"); return; } } @@ -38,7 +38,7 @@ long cur_value() case SEGCON: return data - data_area; case SEGROM: return data - data_area; case SEGBSS: return nbss; - default : fprint( STDERR, "cur_value() : unknown seg\n"); + default : fprint( stderr, "cur_value() : unknown seg\n"); return -1L; } } diff --git a/mach/sun3/ce/output.c b/mach/sun3/ce/output.c index 690d3b8c85..e89ee67801 100644 --- a/mach/sun3/ce/output.c +++ b/mach/sun3/ce/output.c @@ -10,7 +10,7 @@ Read above comment ... #endif -extern File *B_out_file; +extern FILE* B_out_file; #include #include @@ -224,7 +224,7 @@ struct relocation_info *u_relo; case SEGBSS : u_relo->r_symbolnum = N_BSS; break; /* Shut up; this could actually happen on erroneous input - default : fprint( STDERR, + default : fprint( stderr, "convert_relo(): bad segment %d\n", (symbol_table[ a_relo->or_nami].on_type & S_TYP) - S_MIN); */ @@ -263,7 +263,7 @@ struct nlist *u_name; break; /* Shut up; this could actually happen on erroneous input default: - fprint(STDERR, "convert_name(): bad section %d\n", + fprint(stderr, "convert_name(): bad section %d\n", (a_name->on_type & S_TYP) - S_MIN); break; */ diff --git a/mach/sun3/ce/relocation.c b/mach/sun3/ce/relocation.c index 30886d60e4..7e85a2be67 100644 --- a/mach/sun3/ce/relocation.c +++ b/mach/sun3/ce/relocation.c @@ -29,7 +29,7 @@ do_local_relocation() sect = data_area; break; default: - fprint( STDERR, + fprint( stderr, "do_local_relo(): bad section %d\n", rp->or_sect - S_MIN); break; @@ -39,7 +39,7 @@ do_local_relocation() np->on_valu + B_base_address[(np->on_type&S_TYP)-S_MIN]; else - fprint( STDERR, + fprint( stderr, "do_relo() : bad relocation size\n"); } } diff --git a/mach/vax4/ce/as.c b/mach/vax4/ce/as.c index c063f9adec..29a0d87d1d 100644 --- a/mach/vax4/ce/as.c +++ b/mach/vax4/ce/as.c @@ -99,7 +99,7 @@ struct t_operand *op; if ( is_reg( arg+1, &(op->num))) op->indx = ind_buf[ n_index]; else - fprint( STDERR, "unknown argtype %s\n", arg); + fprint( stderr, "unknown argtype %s\n", arg); } else { op->type = LABEL; @@ -270,6 +270,6 @@ struct t_operand *op; break; case L_ILB : @text1( %dist( op->lab)); break; - default : fprint( STDERR, "error"); + default : fprint( stderr, "error"); } } diff --git a/mach/vax4/ce/do_close.c b/mach/vax4/ce/do_close.c index 1e442dc7f8..b0ea7083e0 100644 --- a/mach/vax4/ce/do_close.c +++ b/mach/vax4/ce/do_close.c @@ -1,7 +1,7 @@ #include #include -extern File *B_out_file; +extern FILE* B_out_file; close_back() { diff --git a/mach/vax4/ce/do_open.c b/mach/vax4/ce/do_open.c index 41d5d56506..4bc7f4c747 100644 --- a/mach/vax4/ce/do_open.c +++ b/mach/vax4/ce/do_open.c @@ -1,7 +1,7 @@ #include #include -File *B_out_file; +FILE* B_out_file; open_back( filename) char *filename; diff --git a/mach/vax4/ce/mach.c b/mach/vax4/ce/mach.c index 1953dd9694..4dff97337a 100644 --- a/mach/vax4/ce/mach.c +++ b/mach/vax4/ce/mach.c @@ -9,7 +9,7 @@ arg_error( s, arg) char *s; int arg; { - fprint( STDERR, "arg_error %s %d\n", s, arg); + fprint( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/vax4/ce/output.c b/mach/vax4/ce/output.c index 04c869913f..c95872bf07 100644 --- a/mach/vax4/ce/output.c +++ b/mach/vax4/ce/output.c @@ -10,7 +10,7 @@ Read above comment ... #endif -extern File *B_out_file; +extern FILE* B_out_file; #include #include @@ -224,7 +224,7 @@ struct relocation_info *u_relo; case SEGBSS : u_relo->r_symbolnum = N_BSS; break; /* Shut up; this can actually happen on erroneous input - default : fprint( STDERR, + default : fprint( stderr, "convert_relo(): bad segment %d\n", (symbol_table[ a_relo->or_nami].on_type & S_TYP) - S_MIN); */ @@ -263,7 +263,7 @@ struct nlist *u_name; break; /* Shut up; this can actually happen on erroneous input default: - fprint(STDERR, "convert_name(): bad section %d\n", + fprint(stderr, "convert_name(): bad section %d\n", (a_name->on_type & S_TYP) - S_MIN); break; */ diff --git a/mach/vax4/ce/relocation.c b/mach/vax4/ce/relocation.c index 1a6190c337..b6865631ea 100644 --- a/mach/vax4/ce/relocation.c +++ b/mach/vax4/ce/relocation.c @@ -29,7 +29,7 @@ do_local_relocation() sect = data_area; break; default: - fprint( STDERR, + fprint( stderr, "do_local_relo(): bad section %d\n", rp->or_sect - S_MIN); break; @@ -39,7 +39,7 @@ do_local_relocation() np->on_valu + B_base_address[(np->on_type&S_TYP)-S_MIN]; else - fprint( STDERR, + fprint( stderr, "do_relo() : bad relocation size\n"); } } diff --git a/modules/src/em_code/convert.c b/modules/src/em_code/convert.c index 81a3b52964..1da029ab81 100644 --- a/modules/src/em_code/convert.c +++ b/modules/src/em_code/convert.c @@ -71,12 +71,12 @@ main(argc,argv) error(s,a1,a2,a3,a4) char *s; { - fprint(STDERR, + fprint(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - fprint(STDERR,s,a1,a2,a3,a4); - fprint(STDERR, "\n"); + fprint(stderr,s,a1,a2,a3,a4); + fprint(stderr, "\n"); errors++; } diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index 38016aa3e6..610f66fdf4 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -28,10 +28,10 @@ Part *C_curr_part; char *C_BASE; #endif -File *C_ofp; +FILE *C_ofp; #ifndef INCORE -File *C_tfr; +FILE *C_tfr; char *C_tmpfile; char *C_ibuf = 0; long C_current_out; @@ -75,7 +75,7 @@ void C_flush(void) return; } #endif - if (C_opp != obuf && sys_write(C_ofp, obuf, (int)(C_opp - obuf)) == 0) { + if (C_opp != obuf && fwrite(obuf, (int)(C_opp - obuf), 1, C_ofp) != 1) { C_ofp = 0; C_failed(); } @@ -109,13 +109,14 @@ int C_open(char* nm) if (nm == 0) { - C_ofp = STDOUT; /* standard output */ + C_ofp = stdout; /* standard output */ sys_setbinarymode(stdout); } else { - if (sys_open(nm, OP_WRITE, &C_ofp) == 0) + C_ofp = fopen(nm, "w+b"); + if (!C_ofp) return 0; } return 1; @@ -150,8 +151,8 @@ void C_close(void) #endif } C_flush(); - if (C_ofp != STDOUT) - sys_close(C_ofp); + if (C_ofp != stdout) + fclose(C_ofp); C_ofp = 0; } diff --git a/modules/src/em_code/failed.c b/modules/src/em_code/failed.c index 1c8a7ffa7e..9565305293 100644 --- a/modules/src/em_code/failed.c +++ b/modules/src/em_code/failed.c @@ -5,9 +5,8 @@ */ #include -void -C_failed(void) +void C_failed(void) { - sys_write(STDERR,"read, write, or open failed\n",28); + fputs("read, write, or open failed\n", stderr); sys_stop(S_EXIT); } diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index fc211b2a36..78118fad59 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -164,7 +164,7 @@ static int swttmp(void) } } if (! C_ontmpfile) { - File *p = C_ofp; + FILE* p = C_ofp; C_flush(); C_ofp = C_old_ofp; @@ -192,7 +192,7 @@ static int swtout(void) { #ifndef INCORE if (C_ontmpfile) { - File *p = C_ofp; + FILE* p = C_ofp; C_flush(); C_ofp = C_old_ofp; diff --git a/modules/src/em_code/insert.h b/modules/src/em_code/insert.h index 8980dfeb5b..ec978b7e10 100644 --- a/modules/src/em_code/insert.h +++ b/modules/src/em_code/insert.h @@ -59,10 +59,10 @@ extern int (*C_outpart)(int); extern int (*C_swtout)(void); extern int (*C_swttmp)(void); -extern File *C_ofp; +extern FILE *C_ofp; #ifndef INCORE -extern File *C_tfr; +extern FILE *C_tfr; extern char *C_tmpfile; #endif diff --git a/modules/src/em_code/internerr.c b/modules/src/em_code/internerr.c index f77aadfc8c..3c67d1f017 100644 --- a/modules/src/em_code/internerr.c +++ b/modules/src/em_code/internerr.c @@ -9,6 +9,6 @@ void C_internal_error(void) { - sys_write(STDERR,"internal error\n",15); + fputs("internal error\n", stderr); sys_stop(S_EXIT); } diff --git a/modules/src/em_opt/nopt.c b/modules/src/em_opt/nopt.c index e0f9489859..16ebb809bf 100644 --- a/modules/src/em_opt/nopt.c +++ b/modules/src/em_opt/nopt.c @@ -110,9 +110,9 @@ void OO_dfa(int last) static void fatal(s, a) char *s;int a; { - fprint(STDERR, "%s: ", filename ? filename : "standard input"); - fprint(STDERR, s, a); - fprint(STDERR, "\n"); + fprint(stderr, "%s: ", filename ? filename : "standard input"); + fprint(stderr, s, a); + fprint(stderr, "\n"); sys_stop(S_EXIT); } diff --git a/modules/src/input/inp_pkg.body b/modules/src/input/inp_pkg.body index 2e9ea7416d..1d89b26b9b 100644 --- a/modules/src/input/inp_pkg.body +++ b/modules/src/input/inp_pkg.body @@ -77,7 +77,7 @@ struct INP_buffer_header { #ifdef INP_TYPE INP_TYPE bh_i; /* user defined */ #endif /* INP_TYPE */ - File *bh_fd; /* A file descriptor in case of a file */ + FILE* bh_fd; /* A file descriptor in case of a file */ char bh_eofreturned; /* set if we returned eof for this buffer */ }; @@ -104,7 +104,7 @@ INP_PRIVATE struct INP_buffer_header *INP_head, *INP_free; INP_PRIVATE int -INP_rdfile(File* fd, char* fn, long* size, char** pbuf) +INP_rdfile(FILE* fd, char* fn, long* size, char** pbuf) { int rsize; @@ -116,8 +116,9 @@ INP_rdfile(File* fd, char* fn, long* size, char** pbuf) !(*pbuf = malloc((unsigned) (*size + 1)))) { return 0; } + rsize = fread(*pbuf, 1, *size, fd); if ( - !sys_read(fd, *pbuf, (int) *size, &rsize) + rsize <= 0 || *size != rsize ) { @@ -205,11 +206,12 @@ INP_PRIVATE int INP_pop_bh(void) */ INP_PRIVATE int -INP_rdblock(File* fd, char* buf, int* n) +INP_rdblock(FILE* fd, char* buf, int* n) { - if (!sys_read(fd, buf, INP_BUFSIZE, n)) { + *n = fread(buf, 1, INP_BUFSIZE, fd); + if (*n <= 0) { return 0; } @@ -251,13 +253,14 @@ int InsertFile(char *filnam, char *table[], char **result) char *text; long size; #endif /* INP_READ_IN_ONE */ - File *fd = 0; + FILE* fd = 0; - if (!filnam) fd = STDIN; + if (!filnam) fd = stdin; else { if (table == 0 || filnam[0] == '/') { /* don't look in the table! */ - if (!sys_open(filnam, OP_READ, &fd)) return 0; + fd = fopen(filnam, "r"); + if (!fd) return 0; } else { while (*table) { @@ -265,7 +268,8 @@ int InsertFile(char *filnam, char *table[], char **result) if (!INP_mk_filename(*table++, filnam, &newfn)) { return 0; } - if (sys_open(newfn, OP_READ, &fd)) { + fd = fopen(newfn, "r"); + if (fd) { /* free filnam ??? NO we don't know where it comes from! */ @@ -282,13 +286,13 @@ int InsertFile(char *filnam, char *table[], char **result) register struct INP_buffer_header *bh = INP_push_bh(); if (!bh) { - if (fd != STDIN) sys_close(fd); + if (fd != stdin) fclose(fd); return 0; } #ifdef INP_READ_IN_ONE - if (fd == STDIN) return 0; /* illegal */ + if (fd == stdin) return 0; /* illegal */ if (!INP_rdfile(fd, filnam, &size, &text)) { - sys_close(fd); + fclose(fd); return 0; } bh->bh_size = size; @@ -298,7 +302,7 @@ int InsertFile(char *filnam, char *table[], char **result) !(_ipp = bh->bh_text = INP_pbuf()) || !INP_rdblock(fd,_ipp,&(bh->bh_size))) { - if (fd != STDIN) sys_close(fd); + if (fd != stdin) fclose(fd); return 0; } #endif /* INP_READ_IN_ONE */ @@ -394,7 +398,7 @@ int loadbuf(void) } #endif /* not INP_READ_IN_ONE */ - if (FromFile && bh->bh_fd != STDIN) sys_close(bh->bh_fd); + if (FromFile && bh->bh_fd != stdin) fclose(bh->bh_fd); #if INP_NPUSHBACK > 1 { diff --git a/modules/src/object/wr_bytes.c b/modules/src/object/wr_bytes.c index 4619cfa1e0..23f73706f4 100644 --- a/modules/src/object/wr_bytes.c +++ b/modules/src/object/wr_bytes.c @@ -30,8 +30,8 @@ void wr_bytes(FILE* fd, const char *buf, long cnt) { int n = cnt >= maxchunk ? maxchunk : cnt; - written_bytes = fwrite(buf, 1, n, fd); - if (written_bytes != (size_t)n) + written_bytes = fwrite(buf, n, 1, fd); + if (written_bytes != 1) { wr_fatal(); } diff --git a/modules/src/print/doprnt.c b/modules/src/print/doprnt.c index 1d888e570b..e9b32e3f4d 100644 --- a/modules/src/print/doprnt.c +++ b/modules/src/print/doprnt.c @@ -16,9 +16,9 @@ %d = int $ */ void -doprnt(File *fp, const char *fmt, va_list argp) +doprnt(FILE* fp, const char *fmt, va_list argp) { char buf[SSIZE]; - sys_write(fp, buf, _format(buf, fmt, argp)); + fwrite(buf, 1, _format(buf, fmt, argp), fp); } diff --git a/modules/src/print/fprint.c b/modules/src/print/fprint.c index 6b5b8a3898..d29b0bb1ae 100644 --- a/modules/src/print/fprint.c +++ b/modules/src/print/fprint.c @@ -17,12 +17,12 @@ $ */ /*VARARGS*/ void -fprint(File *fp, const char *fmt, ...) +fprint(FILE* fp, const char *fmt, ...) { va_list args; char buf[SSIZE]; va_start(args, fmt); - sys_write(fp, buf, _format(buf, fmt, args)); + fwrite(buf, 1, _format(buf, fmt, args), fp); va_end(args); } diff --git a/modules/src/print/print.3 b/modules/src/print/print.3 index 89838bd635..fed19fff36 100644 --- a/modules/src/print/print.3 +++ b/modules/src/print/print.3 @@ -7,9 +7,9 @@ print, fprint, doprnt -- very simple formatted-output routines .B #include .B #include .PP -.B void fprint(File *filep, char *format [, arg] ... ) +.B void fprint(FILE* filep, char *format [, arg] ... ) .PP -.B void doprnt(File *filep, char *format, va_list args) +.B void doprnt(FILE* filep, char *format, va_list args) .PP .B int _format(char *buf, char *format, va_lsit args) .fi @@ -19,7 +19,7 @@ and .I doprnt place output on the open file known by .IR filep . -.I filep could for instance be STDOUT or STDERR. +.I filep could for instance be stdout or stderr. .PP Each of these functions converts, formats and prints its arguments, following the diff --git a/modules/src/print/print.h b/modules/src/print/print.h index c9d5de57f6..a8db7c9ab5 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -9,8 +9,8 @@ #include #include -void fprint(File *f, const char *fmt, ...); -void doprnt(File *f, const char *fmt, va_list ap); +void fprint(FILE *f, const char *fmt, ...); +void doprnt(FILE *f, const char *fmt, va_list ap); int _format(char *buf, const char *fmt, va_list ap); #endif /* __PRINT_INCLUDED__ */ diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index c7a9f27909..10338bdad2 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -2,20 +2,13 @@ clibrary { name = "lib", srcs = { "./basename.c", - "./close.c", - "./create.c", "./filesize.c", "./maketempfile.c", - "./open.c", - "./read.c", - "./seek.c", "./setbinarymode.c", "./stop.c", "./strndup.c", "./syssystem.c", - "./system.c", "./tmpdir.c", - "./write.c", }, hdrs = { "./system.h" }, deps = { diff --git a/modules/src/system/close.c b/modules/src/system/close.c deleted file mode 100644 index f3176cb9e4..0000000000 --- a/modules/src/system/close.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* $Id$ */ - -#include -#include "system.h" - -void sys_close(File* fp) -{ - if (fp) - { - fclose(fp->fd); - fp->fd = NULL; - } -} diff --git a/modules/src/system/create.c b/modules/src/system/create.c deleted file mode 100644 index db2f5fba9d..0000000000 --- a/modules/src/system/create.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* $Id$ */ - -#include -#include "system.h" - -int sys_create(File** filep, char* path, int mode) -{ - int fd; - File* fp; - - if ((fp = _get_entry()) == (File*)0) - return 0; - fp->fd = fopen(path, "wb"); - if (!fp->fd) - return 0; - *filep = fp; - return 1; -} diff --git a/modules/src/system/open.c b/modules/src/system/open.c deleted file mode 100644 index dd443b084b..0000000000 --- a/modules/src/system/open.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* $Id$ */ - -#include -#include -#include -#include "system.h" - -int sys_open(char* path, int flag, File** filep) -{ - File* fp; - FILE* fd; - - if ((fp = _get_entry()) == (File*)0) - return 0; - switch (flag) - { - case OP_READ: - if (!(fd = fopen(path, "rb"))) - return 0; - break; - case OP_APPEND: - if (!(fd = fopen(path, "a+b"))) - { - if (access(path, 0) == 0) - return 0; - } - else - { - if (fseek(fd, 0L, SEEK_SET) < 0L) - { - fclose(fd); - return 0; - } - break; - } - /* Fall through */ - case OP_WRITE: - if (!(fd = fopen(path, "w+b"))) - return 0; - break; - default: - return 0; - } - fp->fd = fd; - *filep = fp; - return 1; -} diff --git a/modules/src/system/read.c b/modules/src/system/read.c deleted file mode 100644 index c407c96f7d..0000000000 --- a/modules/src/system/read.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* $Id$ */ - -#include -#include "system.h" - -int sys_read(File* fp, char* bufptr, int bufsiz, int* pnbytes) -{ - if (!fp) - return 0; - - FILE* fd = getfd(fp); - *pnbytes = 0; - int len = fread(bufptr, 1, bufsiz, fd); - if (len < 0) - return 0; - *pnbytes = len; - return 1; -} diff --git a/modules/src/system/seek.c b/modules/src/system/seek.c deleted file mode 100644 index d385d7f355..0000000000 --- a/modules/src/system/seek.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* $Id$ */ - -#include -#include "system.h" - -int sys_seek(File* fp, long off, int whence, long* poff) -{ - if (!fp) - return 0; - - FILE* fd = getfd(fp); - *poff = ftell(fd); - return (fseek(fd, off, SEEK_SET) == 0); -} diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index d2cec18e64..5f0e69be7b 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -1,48 +1,14 @@ .TH SYSTEM 3 "$Revision$" .ad .SH NAME -sys_open, sys_close, sys_read, sys_write, sys_reset, -sys_filesize, -sys_lock, sys_unlock, sys_stop \- system call interface +sys_filesize, sys_lock, sys_unlock, sys_stop \- system call interface .SH SYNOPSIS .nf .B #include .PP -.B File *STDIN, *STDOUT, *STDERR; -.PP -.B int sys_open(path, flag, filep) -.B char *path; -.B int flag; -.B File **filep; -.PP -.B void sys_close(filep) -.B File *filep; -.PP -.B int sys_read(filep, bufptr, bufsiz, pnbytes) -.B File *filep; -.B char *bufptr; -.B int bufsiz, *pnbytes; -.PP -.B int sys_write(filep, bufptr, nbytes) -.B File *filep; -.B char *bufptr; -.B int nbytes; -.PP -.B int sys_seek(filep, offset, whence, poffset) -.B File *filep; -.B long offset; -.B int whence; -.B long *poffset; -.PP -.B int sys_reset(filep) -.B File *filep -.PP .B long sys_filesize(path) .B char *path; .PP -.B char *sys_break(incr) -.B int incr; -.PP .B void sys_stop(how) .B int how; .fi @@ -52,109 +18,6 @@ primarily intended for use in compilers. The include file contains a defined constant, .IR BUFSIZ , which gives the system-dependent block size. -Another constant, -.IR SYS_NOPEN , -gives the maximum number of open files in a process. -.PP -.I Sys_open -opens a file called -.I path -for sequential reading or writing, as specified by -.I flag -and returns in -.I filep -a decsriptor for the opened file. -The allowed values for -.I flag -are -.IP OP_READ 15 -open for reading -.IP OP_WRITE 15 -open for rewriting (create -.I path -if it did not exist) -.IP OP_APPEND 15 -open for writing at the end (create -.I path -if it did not exist) -.LP -Created files are given read and write permission for its creator and -read permission for other users. -.br -Specifying -.I path -as null pointer opens a so-called anonymous file, which has no name and -disappears when it is closed or when the program exits. -It is possible to read the contents of an anonymous file by using -.I reset . -.br -There are three normally open files with the following descriptors: -.IP STDIN 15 -standard input file; opened as OP_READ -.IP STDOUT 15 -standard output file; opened as OP_APPEND -.IP STDERR 15 -standard error file; opened as OP_APPEND -.LP -.I Sys_close -causes the open file known by -.I filep -to be closed. -.PP -.I Sys_read -causes up to -.I bufsiz -contiguous bytes to be read from the open file known by -.I filep -into a piece of memory pointed at by -.IR bufptr . -The number of bytes actually read is returned in -.IR *pnbytes . -If -.I *pnbytes -is set to 0 then the end-of-file is reached. -.PP -.I Sys_write -writes -.I nbytes -contiguous bytes from the memory pointed at by -.I bufptr -onto the open file known by -.IR filep . -A non-zero return value indicates that -.I nbytes -are actually written. -.PP -.I Sys_seek -sets the file pointer of -.I filep -as follows: -.IP " " -If -.I whence -is 0, the pointer is set to -.I offset -bytes. -.IP " " -If -.I whence -is 1, the pointer is set to its current location plus -.IR offset . -.IP " " -If -.I whence -is 2, the pointer is set to the size of the file plus -.IR offset . -.PP -Upon succesful completion, the resulting pointer location is returned in -.IR poffset , -and 1 is returned. Otherwise, 0 is returned. -.PP -.I Sys_reset -causes the open file known by -.I filep -to be re-opened for reading (cf. open flag OP_READ). -This may be useful in reading anonymous files. .PP The function .I sys_filesize @@ -164,16 +27,6 @@ file specified by if possible. The value \-1L is returned if the size cannot be retrieved for some reason. .PP -.I Sys_break -adds -.I incr -more bytes to the program's data space and returns a pointer to -the newly allocated area. -ILL_BREAK is returned in case of some error, due to a lack of space or -some interrupt. -It is equivalent to the UNIX version 7 -.IR sbrk (2). -.PP .I Sys_stop should be called when the process is terminated due to the end of the program or some error. @@ -199,27 +52,7 @@ since 00:00:00 GMT, Jan. 1, 1970, measured in seconds. ~em/modules/h/system.h ~em/modules/lib/libsystem.a .fi -.SH DIAGNOSTICS -.PP -The routines -.IR sys_open , -.IR sys_read , -.IR sys_write , -.IR sys_reset , -.IR sys_chmode , -and -.IR sys_rename -return a value of zero upon any failure and a non-zero -value if the call succeeds. .SH BUGS The current implementation does not allow the use of anonymous files. -.br -.I Sys_reset -is not implemented. -A -.I sys_close -followed by a -.I sys_open -with the proper mode has the same effect on non-anonymous files. .SH "SEE ALSO" UNIX version 7 manual volume 1, chapter 2 diff --git a/modules/src/system/system.c b/modules/src/system/system.c deleted file mode 100644 index 91eb9ddfed..0000000000 --- a/modules/src/system/system.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* RCS: $Id$ */ - -#include "system.h" - -File _sys_ftab[SYS_NOPEN]; -File sys_stdin; -File sys_stdout; -File sys_stderr; - -FILE* getfd(File* fp) -{ - if (fp == &sys_stdin) - return stdin; - if (fp == &sys_stdout) - return stdout; - if (fp == &sys_stderr) - return stderr; - return fp->fd; -} - -File * _get_entry(void) -{ - File *fp; - - for (fp = &_sys_ftab[0]; fp < &_sys_ftab[SYS_NOPEN]; fp++) - { - if (!fp->fd) - return fp; - } - return NULL; -} diff --git a/modules/src/system/system.h b/modules/src/system/system.h index 85cf7e2753..e2a11a96f3 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -10,53 +10,17 @@ #include #include -struct _sys_fildes { - FILE* fd; -}; - -typedef struct _sys_fildes File; - -extern File _sys_ftab[]; -extern File sys_stdin; -extern File sys_stdout; -extern File sys_stderr; - -/* flags for sys_open() */ -#define OP_READ 01 -#define OP_WRITE 02 -#define OP_APPEND 04 - /* flags for sys_stop() */ #define S_END 0 #define S_EXIT 1 #define S_ABORT 2 -extern FILE* getfd(File* fp); - -int sys_open(char *, int, File **); -void sys_close(File *); -int sys_read(File *, char *, int, int *); -int sys_write(File *, char *, int); -int sys_seek(File *, long, int, long *); -int sys_reset(File *); -off_t sys_filesize(char *); +extern off_t sys_filesize(char *); /* Return the temporary directory location */ -char* sys_gettmpdir(void); +extern char* sys_gettmpdir(void); /* Call another program. */ -int sys_system(const char* prog, const char* const* argv); -NORETURN void sys_stop(int); - -/* standard file decsriptors */ -#define STDIN &sys_stdin -#define STDOUT &sys_stdout -#define STDERR &sys_stderr - -/* maximum number of open files */ -#define SYS_NOPEN 20 - -/* return value for sys_break */ -#define ILL_BREAK ((char *)0) - +extern int sys_system(const char* prog, const char* const* argv); +extern NORETURN void sys_stop(int); /* Extract the base name from a full path specification * in "str" and returns it in "dst". @@ -85,8 +49,4 @@ extern void sys_setbinarymode(FILE* fp); * right size for the result. */ extern char* aprintf(const char* format, ...); -/* Implementation definitions. */ - -extern File *_get_entry(void); - #endif /* __SYSTEM_INCLUDED__ */ diff --git a/modules/src/system/write.c b/modules/src/system/write.c deleted file mode 100644 index df31d6472b..0000000000 --- a/modules/src/system/write.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* $Id$ */ - -#include -#include "system.h" - -int sys_write(File* fp, char* bufptr, int nbytes) -{ - if (!fp) - return 0; - - FILE* fd = getfd(fp); - int len = fwrite(bufptr, 1, nbytes, fd); - return (len == nbytes); -} diff --git a/util/ack/util.c b/util/ack/util.c index a281d341e0..bf23ff5c96 100644 --- a/util/ack/util.c +++ b/util/ack/util.c @@ -27,9 +27,9 @@ extern int w_flag; extern int n_error; #ifdef DEBUG -#define STDOUT stdout +#define stdout stdout #else -#define STDOUT stderr +#define stdout stderr #endif char* ack_basename(const char* string) @@ -91,9 +91,9 @@ void fatal(const char* fmt, ...) /* Fatal internal error */ va_list ap; va_start(ap, fmt); - fprintf(STDOUT, "%s: fatal internal error, ", progname); - vfprintf(STDOUT, fmt, ap); - fprintf(STDOUT, "\n"); + fprintf(stdout, "%s: fatal internal error, ", progname); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\n"); quit(-2); } @@ -103,7 +103,7 @@ void vprint(const char* fmt, ...) /* Diagnostic print, no auto NL */ va_list ap; va_start(ap, fmt); - vfprintf(STDOUT, fmt, ap); + vfprintf(stdout, fmt, ap); va_end(ap); } @@ -113,9 +113,9 @@ void fuerror(const char* fmt, ...) /* Fatal user error */ va_list ap; va_start(ap, fmt); - fprintf(STDOUT, "%s: ", progname); - vfprintf(STDOUT, fmt, ap); - fprintf(STDOUT, "\n"); + fprintf(stdout, "%s: ", progname); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\n"); quit(-1); } @@ -127,9 +127,9 @@ void werror(const char* fmt, ...) if (w_flag) return; va_start(ap, fmt); - fprintf(STDOUT, "%s: warning, ", progname); - vfprintf(STDOUT, fmt, ap); - fprintf(STDOUT, "\n"); + fprintf(stdout, "%s: warning, ", progname); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\n"); va_end(ap); } @@ -139,9 +139,9 @@ void error(const char* fmt, ...) /* User error, it is the callers responsibility to quit */ va_list ap; va_start(ap, fmt); - fprintf(STDOUT, "%s: ", progname); - vfprintf(STDOUT, fmt, ap); - fprintf(STDOUT, "\n"); + fprintf(stdout, "%s: ", progname); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\n"); n_error++; va_end(ap); } diff --git a/util/ceg/EM_parser/as_EM_pars/error.c b/util/ceg/EM_parser/as_EM_pars/error.c index e93c79f5bf..d6575b504e 100644 --- a/util/ceg/EM_parser/as_EM_pars/error.c +++ b/util/ceg/EM_parser/as_EM_pars/error.c @@ -14,9 +14,9 @@ error(char *fmt, ...) va_list pvar; va_start(pvar, fmt); - fprint( STDERR, "!! ERROR : "); - doprnt( STDERR, fmt, pvar); - fprint( STDERR, " !!\n"); + fprint( stderr, "!! ERROR : "); + doprnt( stderr, fmt, pvar); + fprint( stderr, " !!\n"); va_end(pvar); nerrors++; } @@ -30,9 +30,9 @@ va_dcl va_start(pvar); fmt = va_arg(pvar, char *); - fprint( STDERR, "!! ERROR : "); - doprnt( STDERR, fmt, pvar); - fprint( STDERR, " !!\n"); + fprint( stderr, "!! ERROR : "); + doprnt( stderr, fmt, pvar); + fprint( stderr, " !!\n"); va_end(pvar); nerrors++; } diff --git a/util/ceg/EM_parser/common/C_instr2.c b/util/ceg/EM_parser/common/C_instr2.c index f9d8b5b853..3eff9a595f 100644 --- a/util/ceg/EM_parser/common/C_instr2.c +++ b/util/ceg/EM_parser/common/C_instr2.c @@ -436,7 +436,7 @@ char *instr; if ( rel == 0 ) break; else if ( high == low) { - fprint(STDERR, "ERROR : can't find >>%s<< !!\n", instr); + fprint(stderr, "ERROR : can't find >>%s<< !!\n", instr); abort(); } else if ( rel < 0) diff --git a/util/ceg/EM_parser/common/default.c b/util/ceg/EM_parser/common/default.c index 1156a7f02d..a4386ddea0 100644 --- a/util/ceg/EM_parser/common/default.c +++ b/util/ceg/EM_parser/common/default.c @@ -89,7 +89,7 @@ int def_start, /* Index in def_info[], start of the expanded C_INSTR */ def_end, /* last expanded C_INSTR index. */ save_lineno; -extern File *outfile; +extern FILE* outfile; extern char yytext[]; extern int yylineno; diff --git a/util/ceg/EM_parser/common/help.c b/util/ceg/EM_parser/common/help.c index fb55820cc3..2f7c0956bc 100644 --- a/util/ceg/EM_parser/common/help.c +++ b/util/ceg/EM_parser/common/help.c @@ -13,7 +13,7 @@ extern out(char *, ...); #include "decl.h" extern int library; -extern File *outfile; +extern FILE* outfile; /* This file contains some routines called from the parser in 'pars.g' */ @@ -165,7 +165,7 @@ char *name; name = suffix( name, "c"); sys_close( outfile); if ( !sys_open( name, OP_WRITE, &outfile)) - fprint( STDERR, "!! can't create %s !!\n", name); + fprint( stderr, "!! can't create %s !!\n", name); file_header(); } } diff --git a/util/ceg/EM_parser/common/pars.g b/util/ceg/EM_parser/common/pars.g index 62bc9c0541..2928bf0b7f 100644 --- a/util/ceg/EM_parser/common/pars.g +++ b/util/ceg/EM_parser/common/pars.g @@ -39,7 +39,7 @@ extern int first_action, last_action, token; t_token tok, stok; int no_conversions = FALSE, library, segment = UNKNOWN; -File *outfile; +FILE* outfile; char *to_change; } @@ -211,20 +211,20 @@ int inserted_token; { nerrors++; if ( inserted_token == 0) { - fprint( STDERR, "EM_table : syntax error in line %d, >>", + fprint( stderr, "EM_table : syntax error in line %d, >>", yylineno); print_token( LLsymb); - fprint( STDERR, "<< will be deleted!!\n"); + fprint( stderr, "<< will be deleted!!\n"); } else if ( inserted_token < 0) { - fprint(STDERR,"EM_table : syntax error in line %d, garbage at end of table\n", + fprint(stderr,"EM_table : syntax error in line %d, garbage at end of table\n", yylineno); } else { - fprint( STDERR, "EM_table : syntax error in line %d, >>", + fprint( stderr, "EM_table : syntax error in line %d, >>", yylineno); print_token( inserted_token); - fprint( STDERR, "<< will be inserted!!\n"); + fprint( stderr, "<< will be inserted!!\n"); token = LLsymb; saved = 1; } @@ -234,21 +234,21 @@ print_token( token) int token; { switch ( token) { - case C_INSTR : fprint( STDERR, "C_INSTR %s", yytext); + case C_INSTR : fprint( stderr, "C_INSTR %s", yytext); break; - case ASSEM_INSTR : fprint( STDERR, "STRING %s", yytext); + case ASSEM_INSTR : fprint( stderr, "STRING %s", yytext); break; - case CALL : fprint( STDERR, "CALL %s", yytext); + case CALL : fprint( stderr, "CALL %s", yytext); break; - case ARROW : fprint( STDERR, "==> "); + case ARROW : fprint( stderr, "==> "); break; - case CONDITION: fprint( STDERR, "CONDITION %s", yytext); + case CONDITION: fprint( stderr, "CONDITION %s", yytext); break; - case DEFAULT : fprint( STDERR, "default "); + case DEFAULT : fprint( stderr, "default "); break; - case ERROR : fprint( STDERR, "unmatched %s", yytext); + case ERROR : fprint( stderr, "unmatched %s", yytext); break; - default : fprint( STDERR, " %c", token); + default : fprint( stderr, " %c", token); break; } } @@ -302,7 +302,7 @@ main( argc, argv) int argc; char **argv; { - outfile = STDOUT; + outfile = stdout; if ( argc > 1) { if ( strcmp( argv[1], "-l") == 0) library = TRUE; @@ -311,7 +311,7 @@ char **argv; to_change = argv[2]; c_table(); if (to_change) { - fprint( STDERR, "No rule for %s\n", to_change); + fprint( stderr, "No rule for %s\n", to_change); exit( 1); } exit(nerrors); diff --git a/util/ceg/EM_parser/obj_EM_pars/dist.c b/util/ceg/EM_parser/obj_EM_pars/dist.c index 5d9433e1e7..1decd3e411 100644 --- a/util/ceg/EM_parser/obj_EM_pars/dist.c +++ b/util/ceg/EM_parser/obj_EM_pars/dist.c @@ -64,8 +64,8 @@ FILE *f; #include -File *oldout; -extern File *outfile; +FILE* oldout; +extern FILE* outfile; back_patch() /* Echo the text on file '.tmp', but replace every occurence of label- @@ -109,7 +109,7 @@ save_output() oldout = outfile; if ( ! sys_open( ".tmp", OP_WRITE, &outfile)) - fprint( STDERR, "can't open .tmp\n"); + fprint( stderr, "can't open .tmp\n"); cur_pos = 0; n_labs = 0; } diff --git a/util/ceg/as_parser/as_parser.h b/util/ceg/as_parser/as_parser.h index 8de0d14dc9..1ed60bddfb 100644 --- a/util/ceg/as_parser/as_parser.h +++ b/util/ceg/as_parser/as_parser.h @@ -1,5 +1,5 @@ #include #include -extern File *outfile; +extern FILE* outfile; extern arith cur_pos; diff --git a/util/ceg/as_parser/help.c b/util/ceg/as_parser/help.c index e805bbdddd..5138256a2d 100644 --- a/util/ceg/as_parser/help.c +++ b/util/ceg/as_parser/help.c @@ -25,7 +25,7 @@ static char *assem_instr = 0; /* Name of the current assembly instr */ static Bool restriction = FALSE; /* Is there a restriction on the * current operand? */ -File *outfile; +FILE* outfile; save_instr( instr, len) char *instr; @@ -171,7 +171,7 @@ char *quest; init_table() { - outfile = STDOUT; + outfile = stdout; out( "#include \"as.h\"\n"); out( "#include \"as_parser.h\"\n"); } @@ -237,9 +237,9 @@ error(char *fmt, ...) nerrors++; va_start(pvar, fmt); - fprint( STDERR, "!! ERROR : "); - doprnt( STDERR, fmt, pvar); - fprint( STDERR, " !!\n"); + fprint( stderr, "!! ERROR : "); + doprnt( stderr, fmt, pvar); + fprint( stderr, " !!\n"); va_end(pvar); } #else @@ -268,9 +268,9 @@ va_dcl nerrors++; va_start(pvar); fmt = va_arg(pvar, char *); - fprint( STDERR, "!! ERROR : "); - doprnt( STDERR, fmt, pvar); - fprint( STDERR, " !!\n"); + fprint( stderr, "!! ERROR : "); + doprnt( stderr, fmt, pvar); + fprint( stderr, " !!\n"); va_end(pvar); } #endif diff --git a/util/ceg/as_parser/pars.g b/util/ceg/as_parser/pars.g index 23b28dbbc3..c0cc597370 100644 --- a/util/ceg/as_parser/pars.g +++ b/util/ceg/as_parser/pars.g @@ -149,18 +149,18 @@ int inserted_token; { nerrors++; if ( inserted_token == 0) { - fprint( STDERR, "Sytax error in line %d, ", lineno); + fprint( stderr, "Sytax error in line %d, ", lineno); print_token( LLsymb); - fprint( STDERR, " will be deleted!!\n"); + fprint( stderr, " will be deleted!!\n"); } else if ( inserted_token < 0) { - fprint( STDERR, "Garbage at end, line %d!!\n", + fprint( stderr, "Garbage at end, line %d!!\n", lineno); } else { - fprint( STDERR, "Sytax error in line %d, ", lineno); + fprint( stderr, "Sytax error in line %d, ", lineno); print_token( inserted_token); - fprint( STDERR, " will be inserted!!\n"); + fprint( stderr, " will be inserted!!\n"); token = LLsymb; saved = 1; } @@ -170,25 +170,25 @@ print_token( token) int token; { switch ( token) { - case IDENTIFIER : fprint( STDERR, "IDENTIFIER %s", yytext); + case IDENTIFIER : fprint( stderr, "IDENTIFIER %s", yytext); break; - case CALL : fprint( STDERR, "CALL %s", yytext); + case CALL : fprint( stderr, "CALL %s", yytext); break; - case CONDITION: fprint( STDERR, "CONDITION %s", yytext); + case CONDITION: fprint( stderr, "CONDITION %s", yytext); break; - case IF : fprint( STDERR, "@if "); + case IF : fprint( stderr, "@if "); break; - case ELSIF : fprint( STDERR, "@elsif "); + case ELSIF : fprint( stderr, "@elsif "); break; - case ELSE : fprint( STDERR, "@else "); + case ELSE : fprint( stderr, "@else "); break; - case FI : fprint( STDERR, "@fi "); + case FI : fprint( stderr, "@fi "); break; - case ARROW : fprint( STDERR, "==> "); + case ARROW : fprint( stderr, "==> "); break; - case MORE : fprint( STDERR, "... "); + case MORE : fprint( stderr, "... "); break; - default : fprint( STDERR, "%c ", token); + default : fprint( stderr, "%c ", token); break; } } diff --git a/util/ceg/assemble/obj_assemble/assemble.c b/util/ceg/assemble/obj_assemble/assemble.c index 70709d2dfa..ddb449946e 100644 --- a/util/ceg/assemble/obj_assemble/assemble.c +++ b/util/ceg/assemble/obj_assemble/assemble.c @@ -238,9 +238,9 @@ error(char *fmt, ...) extern int nerrors; va_start(args, fmt); - fprint( STDERR, "ERROR in line %d : ", yylineno); - doprnt( STDERR, fmt, args); - fprint( STDERR, "\n"); + fprint( stderr, "ERROR in line %d : ", yylineno); + doprnt( stderr, fmt, args); + fprint( stderr, "\n"); va_end(args); nerrors++; } @@ -256,9 +256,9 @@ error(va_alist) va_start(args); fmt = va_arg(args, char *); - fprint( STDERR, "ERROR in line %d : ", yylineno); - doprnt( STDERR, fmt, args); - fprint( STDERR, "\n"); + fprint( stderr, "ERROR in line %d : ", yylineno); + doprnt( stderr, fmt, args); + fprint( stderr, "\n"); va_end(args); nerrors++; } diff --git a/util/ceg/ce_back/as_back/back.h b/util/ceg/ce_back/as_back/back.h index 54f7f82daa..218ca4df84 100644 --- a/util/ceg/ce_back/as_back/back.h +++ b/util/ceg/ce_back/as_back/back.h @@ -49,7 +49,7 @@ #define switchseg B_switchseg #define not_implemented B_not_implemented -extern File *codefile; +extern FILE* codefile; extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(), *extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(), diff --git a/util/ceg/ce_back/as_back/bottom.c b/util/ceg/ce_back/as_back/bottom.c index 96838f3093..a4191e2dc3 100644 --- a/util/ceg/ce_back/as_back/bottom.c +++ b/util/ceg/ce_back/as_back/bottom.c @@ -5,7 +5,7 @@ int cur_seg = -1, saved = 0; char name[256], labeltje[256]; -File *codefile; +FILE* codefile; align_word() diff --git a/util/ceg/ce_back/as_back/gen1.c b/util/ceg/ce_back/as_back/gen1.c index 6655466e38..385c900e29 100644 --- a/util/ceg/ce_back/as_back/gen1.c +++ b/util/ceg/ce_back/as_back/gen1.c @@ -12,6 +12,6 @@ ONE_BYTE w; break; case SEGBSS : bss( (arith) 1); break; - default : fprint( STDERR, "gen1 unkown seg %d\n", cur_seg); + default : fprint( stderr, "gen1 unkown seg %d\n", cur_seg); } } diff --git a/util/ceg/ce_back/as_back/gen2.c b/util/ceg/ce_back/as_back/gen2.c index 43ecd0236d..320f3f5070 100644 --- a/util/ceg/ce_back/as_back/gen2.c +++ b/util/ceg/ce_back/as_back/gen2.c @@ -12,6 +12,6 @@ TWO_BYTES w; break; case SEGBSS : bss( (arith) 2); break; - default : fprint( STDERR, "gen2 unkown seg %d\n", cur_seg); + default : fprint( stderr, "gen2 unkown seg %d\n", cur_seg); } } diff --git a/util/ceg/ce_back/as_back/gen4.c b/util/ceg/ce_back/as_back/gen4.c index 80f231a59f..12de8bdad0 100644 --- a/util/ceg/ce_back/as_back/gen4.c +++ b/util/ceg/ce_back/as_back/gen4.c @@ -12,6 +12,6 @@ FOUR_BYTES w; break; case SEGBSS : bss( (arith) 4); break; - default : fprint( STDERR, "gen4 unkown seg %d\n", cur_seg); + default : fprint( stderr, "gen4 unkown seg %d\n", cur_seg); } } diff --git a/util/ceg/ce_back/obj_back/gen1.c b/util/ceg/ce_back/obj_back/gen1.c index 293addcb1e..ec46ec3ab2 100644 --- a/util/ceg/ce_back/obj_back/gen1.c +++ b/util/ceg/ce_back/obj_back/gen1.c @@ -14,7 +14,7 @@ ONE_BYTE c; return; case SEGBSS : bss( (arith) 1); return; - default : fprint( STDERR, "gen1() : bad seg number\n"); + default : fprint( stderr, "gen1() : bad seg number\n"); return; } } diff --git a/util/ceg/ce_back/obj_back/gen2.c b/util/ceg/ce_back/obj_back/gen2.c index d98ca8640d..33c5e0b03a 100644 --- a/util/ceg/ce_back/obj_back/gen2.c +++ b/util/ceg/ce_back/obj_back/gen2.c @@ -29,7 +29,7 @@ TWO_BYTES w; return; case SEGBSS : bss( (arith) 2); return; - default : fprint( STDERR, "gen2() : bad seg number\n"); + default : fprint( stderr, "gen2() : bad seg number\n"); return; } } diff --git a/util/ceg/ce_back/obj_back/gen4.c b/util/ceg/ce_back/obj_back/gen4.c index d9aadb7865..0a2eba6777 100644 --- a/util/ceg/ce_back/obj_back/gen4.c +++ b/util/ceg/ce_back/obj_back/gen4.c @@ -38,7 +38,7 @@ FOUR_BYTES l; return; case SEGBSS : bss( (arith) 4); return; - default : fprint( STDERR, "gen4() : bad seg number\n"); + default : fprint( stderr, "gen4() : bad seg number\n"); return; } } diff --git a/util/ceg/ce_back/obj_back/misc.c b/util/ceg/ce_back/obj_back/misc.c index 750cc74595..bf87825238 100644 --- a/util/ceg/ce_back/obj_back/misc.c +++ b/util/ceg/ce_back/obj_back/misc.c @@ -22,7 +22,7 @@ align_word() case SEGBSS : while ( nbss % EM_WSIZE != 0) nbss++; return; - default : fprint( STDERR, "align_word() : unknown seg\n"); + default : fprint( stderr, "align_word() : unknown seg\n"); return; } } @@ -38,7 +38,7 @@ long cur_value() case SEGCON: return data - data_area; case SEGROM: return data - data_area; case SEGBSS: return nbss; - default : fprint( STDERR, "cur_value() : unknown seg\n"); + default : fprint( stderr, "cur_value() : unknown seg\n"); return -1L; } } diff --git a/util/ceg/ce_back/obj_back/output.c b/util/ceg/ce_back/obj_back/output.c index 5f519de61a..94d9e6029c 100644 --- a/util/ceg/ce_back/obj_back/output.c +++ b/util/ceg/ce_back/obj_back/output.c @@ -166,7 +166,7 @@ reduce_name_table() wr_fatal() { - fprint( STDERR, "write failed\n"); + fprint( stderr, "write failed\n"); sys_stop(S_ABORT); } diff --git a/util/ceg/ce_back/obj_back/relocation.c b/util/ceg/ce_back/obj_back/relocation.c index 8c4cf00334..d40e9d5f1f 100644 --- a/util/ceg/ce_back/obj_back/relocation.c +++ b/util/ceg/ce_back/obj_back/relocation.c @@ -39,7 +39,7 @@ do_local_relocation() sect = data_area; break; default: - fprint( STDERR, + fprint( stderr, "do_local_relo(): bad section %d\n", rp->or_sect - S_MIN); break; @@ -61,7 +61,7 @@ do_local_relocation() put1( sect, rp->or_addr, (char) newval); } else - fprint( STDERR, "do_relo() : bad relocation size\n"); + fprint( stderr, "do_relo() : bad relocation size\n"); rp->or_nami = seg_index((np->on_type & S_TYP) - S_MIN); /* printf( "reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n", diff --git a/util/ceg/defaults/not_impl/not_impl.c b/util/ceg/defaults/not_impl/not_impl.c index 4a7eaf0215..cc36ad3ca1 100644 --- a/util/ceg/defaults/not_impl/not_impl.c +++ b/util/ceg/defaults/not_impl/not_impl.c @@ -5,5 +5,5 @@ void not_implemented( instr) char *instr; { - fprint( STDERR, "!! %s, NOT implemented !!\n", instr); + fprint( stderr, "!! %s, NOT implemented !!\n", instr); } diff --git a/util/ceg/defaults/pseudo/C_init.c b/util/ceg/defaults/pseudo/C_init.c index 220340e5ca..984a165bd0 100644 --- a/util/ceg/defaults/pseudo/C_init.c +++ b/util/ceg/defaults/pseudo/C_init.c @@ -8,11 +8,11 @@ C_init( wsize, psize) arith wsize, psize; { if ( wsize != EM_WSIZE) { - fprint( STDERR, "wrong word size\n"); + fprint( stderr, "wrong word size\n"); exit( -1); } if ( psize != EM_PSIZE) { - fprint( STDERR, "wrong pointer size\n"); + fprint( stderr, "wrong pointer size\n"); exit( -1); } diff --git a/util/ceg/defaults/pseudo/C_open.c b/util/ceg/defaults/pseudo/C_open.c index 8fc2d841a2..8a69a1df45 100644 --- a/util/ceg/defaults/pseudo/C_open.c +++ b/util/ceg/defaults/pseudo/C_open.c @@ -11,7 +11,7 @@ char *filename; assert( !B_busy); if ( !open_back( filename)) { - fprint( STDERR, "Couldn't open %s\n", filename); + fprint( stderr, "Couldn't open %s\n", filename); return( 0); } B_busy = 1; diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 2bdf90ccd0..95e66bdfb0 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -115,9 +115,9 @@ static void fatal(const char* s, ...) va_list ap; va_start(ap, s); - fprint(STDERR, "%s: ", prog_name); - doprnt(STDERR, s, ap); - fprint(STDERR, "\n"); + fprint(stderr, "%s: ", prog_name); + doprnt(stderr, s, ap); + fprint(stderr, "\n"); cleanup(); sys_stop(S_EXIT); UNREACHABLE_CODE; @@ -279,10 +279,10 @@ static void run_phase(int phase) while (phargs[i]) { - fprint(STDERR, "%s ", phargs[i]); + fprint(stderr, "%s ", phargs[i]); i++; } - fprint(STDERR, "\n"); + fprint(stderr, "\n"); } status = sys_system(phargs[0], (const char* const*)phargs); diff --git a/util/misc/convert.c b/util/misc/convert.c index c204410bb2..84e7d4a9b6 100644 --- a/util/misc/convert.c +++ b/util/misc/convert.c @@ -88,10 +88,10 @@ void error(const char *s, ...) { va_list ap; va_start(ap, s); - fprint(STDERR, "%s, line %d: ", filename ? filename : "standard input", + fprint(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - doprnt(STDERR, s, ap); - fprint(STDERR, "\n"); + doprnt(stderr, s, ap); + fprint(stderr, "\n"); errors++; va_end(ap); }