Skip to content

Commit

Permalink
Merge pull request #321 from davidgiven/dtrg-simplify
Browse files Browse the repository at this point in the history
Replace some old and extremely obsolete system call wrappers with direct system calls.
  • Loading branch information
davidgiven authored Dec 9, 2024
2 parents 9152154 + cea6b9a commit 26511fe
Show file tree
Hide file tree
Showing 302 changed files with 2,825 additions and 4,368 deletions.
6 changes: 3 additions & 3 deletions doc/ceg/ceg.tr
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ struct t_operand *op;
case BX : R233( 0x0, reg, 0x7);
break;

default : fprint( STDERR, "Wrong index register %d\en",
default : fprintf( stderr, "Wrong index register %d\en",
op->reg);
}
else {
Expand All @@ -1208,7 +1208,7 @@ struct t_operand *op;
case BX : R233( 0x1, reg, 0x7);
break;

default : fprint( STDERR, "Wrong index register %d\en",
default : fprintf( stderr, "Wrong index register %d\en",
op->reg);
}
@text1( %$(op->expr));
Expand All @@ -1226,7 +1226,7 @@ struct t_operand *op;
case BX : R233( 0x2, reg, 0x7);
break;

default : fprint( STDERR, "Wrong index register %d\en",
default : fprintf( stderr, "Wrong index register %d\en",
op->reg);
}
@text2( %$(op->expr));
Expand Down
2 changes: 1 addition & 1 deletion fast/f_c.ansi/Parameters
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion fast/f_c/Parameters
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion fast/f_m2/Parameters
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion fast/f_pc/Parameters
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down
2 changes: 1 addition & 1 deletion fcc/cemcom/Parameters.sun3
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion fcc/cemcom/Parameters.vax4
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
16 changes: 8 additions & 8 deletions lang/basic/src/basic.g
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ filelist { int intv; }
]* ;

datastmt: DATASYM { datastmt(); in_data = 1;}
datalist { fprint(datfile,"\n"); in_data = 0; }
datalist { fprintf(datfile,"\n"); in_data = 0; }
;

dataelm : INTVALUE { fprint(datfile,"%d",ival); }
| '-' [ INTVALUE { fprint(datfile,"%d",-ival); }
| FLTVALUE { fprint(datfile,"-%s",dval); }
dataelm : INTVALUE { fprintf(datfile,"%d",ival); }
| '-' [ INTVALUE { fprintf(datfile,"%d",-ival); }
| FLTVALUE { fprintf(datfile,"-%s",dval); }
]
| FLTVALUE { fprint(datfile,dval); }
| STRVALUE { fprint(datfile,"\"%s\"",sval); }
| IDENTIFIER { fprint(datfile,"\"%s\"",sval); }
| FLTVALUE { fprintf(datfile,dval); }
| STRVALUE { fprintf(datfile,"\"%s\"",sval); }
| IDENTIFIER { fprintf(datfile,"\"%s\"",sval); }
;

datalist: dataelm
[ ',' { fprint(datfile,","); }
[ ',' { fprintf(datfile,","); }
dataelm ]*
;

Expand Down
24 changes: 12 additions & 12 deletions lang/basic/src/basic.lex
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void fillkex(void)
if (debug)
{
for(i=0;i<27;i++)
print("%c:%d\n",'a'+i,kex[i]);
printf("%c:%d\n",'a'+i,kex[i]);
}
}

Expand All @@ -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;
Expand All @@ -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 */
Expand All @@ -244,7 +244,7 @@ int getinputline(void)
error("source line too long");
inputline[MAXLINELENGTH-1]=0;
if ( listing)
fprint(STDERR, inputline);
fprintf(stderr, inputline);
cptr= inputline;
return(TRUE);
}
Expand Down Expand Up @@ -296,7 +296,7 @@ int lookup(void)
/* keywords door delimiters gescheiden */
cptr += k->length;
yylval.integer= k->classvalue;
if (debug) print("lookup:%d %d\n",
if (debug) printf("lookup:%d %d\n",
k->classvalue,k->token);
if ( k->token == FUNCTION)
{
Expand Down Expand Up @@ -329,7 +329,7 @@ int lookup(void)
}
if ( typech)
Sym->symtype=typech;
if (debug) print("lookup:%d Identifier\n",Sym);
if (debug) printf("lookup:%d Identifier\n",Sym);
if ( (name[0]=='f' || name[0]=='F') &&
(name[1]=='n' || name[1]=='N') )
return(FUNCTID);
Expand Down Expand Up @@ -422,7 +422,7 @@ int number(void)
}
/*NOSTRICT*/ ival= i1;
#ifdef YYDEBUG
if (yydebug) print("number:INTVALUE %d",i1);
if (yydebug) printf("number:INTVALUE %d",i1);
#endif
return(INTVALUE);
}
Expand Down Expand Up @@ -452,7 +452,7 @@ int number(void)
*d = 0;
cptr=c;
#ifdef YYDEBUG
if (yydebug) print("number:FLTVALUE %s",dval);
if (yydebug) printf("number:FLTVALUE %s",dval);
#endif
return(FLTVALUE);
}
Expand Down Expand Up @@ -481,7 +481,7 @@ int scanstring(void)
case 0:
case '\n':
#ifdef YYDEBUG
if (yydebug) print("STRVALUE\n");
if (yydebug) printf("STRVALUE\n");
#endif
if ( firstchar == '"')
error("non-terminated string");
Expand Down Expand Up @@ -521,7 +521,7 @@ int scanstring(void)
C_rom_icon(myitoa(length),(arith)BEMINTSIZE);
}
#ifdef YYDEBUG
if (yydebug) print("STRVALUE found\n");
if (yydebug) printf("STRVALUE found\n");
#endif
return(STRVALUE);
}
Expand Down Expand Up @@ -561,7 +561,7 @@ int yylex(void)
return(EOLN);
case 0:
#ifdef YYDEBUG
if ( yydebug) print("end of buffer");
if ( yydebug) printf("end of buffer");
#endif
return(0);
case '"':
Expand Down
4 changes: 2 additions & 2 deletions lang/basic/src/bem.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc,char **argv)
compileprogram();
linewarnings();
C_close();
if( errorcnt) sys_stop(S_EXIT);
if( errorcnt) exit(1);
/* process em object files */
sys_stop(S_END); /* This was not done in the old compiler */
exit(0); /* This was not done in the old compiler */
}
7 changes: 3 additions & 4 deletions lang/basic/src/bem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string.h>
#include <signal.h>
#include "system.h"
#include "print.h"
#include "em.h"
#include "em_mes.h"

Expand Down Expand Up @@ -51,9 +50,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;
Expand Down
1 change: 0 additions & 1 deletion lang/basic/src/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ cprogram {
"modules/src/em_code+lib_k",
"modules/src/em_data+lib",
"modules/src/em_mes+lib",
"modules/src/print+lib",
"modules/src/string+lib",
"modules/src/system+lib",
}
Expand Down
4 changes: 2 additions & 2 deletions lang/basic/src/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -34,5 +34,5 @@ void compileprogram(void)
LLparse();
}
epilogcode();
sys_close(yyin);
fclose(yyin);
}
14 changes: 7 additions & 7 deletions lang/basic/src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void conversion(int oldtype,int newtype)
C_cif ();
} else {
if (debug)
print("type n=%d o=%d\n",newtype,oldtype);
printf("type n=%d o=%d\n",newtype,oldtype);
error("conversion error");
}
break;
Expand All @@ -67,7 +67,7 @@ void conversion(int oldtype,int newtype)
break;
default:
if (debug)
print("type n=%d o=%d\n",newtype,oldtype);
printf("type n=%d o=%d\n",newtype,oldtype);
error("conversion error");
}
}
Expand All @@ -78,7 +78,7 @@ void extraconvert(int oldtype,int newtype,int topstack)
{
/* the value below the top of the stack should be converted */
if ( oldtype==newtype ) return;
if ( debug) print("extra convert %d %d %d\n",oldtype,newtype,topstack);
if ( debug) printf("extra convert %d %d %d\n",oldtype,newtype,topstack);
/* save top in dummy */

switch( topstack)
Expand Down Expand Up @@ -188,7 +188,7 @@ int relop(int ltype,int rtype,int operator)
{
int result;

if (debug) print("relop %d %d op=%d\n",ltype,rtype,operator);
if (debug) printf("relop %d %d op=%d\n",ltype,rtype,operator);
result= exprtype(ltype,rtype);
extraconvert(ltype,result,rtype);
conversion(rtype,result);
Expand Down Expand Up @@ -348,7 +348,7 @@ int typesize(int ltype)
return(BEMPTRSIZE);
default:
error("typesize:unexpected");
if (debug) print("type received %d\n",ltype);
if (debug) printf("type received %d\n",ltype);
}
return(BEMINTSIZE);
}
Expand Down Expand Up @@ -417,12 +417,12 @@ int loadaddr(Symbol *s)
int i,j;
arith sum;

if (debug) print("load %s %d\n",s->symname,s->symtype);
if (debug) printf("load %s %d\n",s->symname,s->symtype);
if ( s->symalias>0)
C_lae_dlb((label)s->symalias,(arith)0);
else {
j= -s->symalias;
if (debug) print("load parm %d\n",j);
if (debug) printf("load parm %d\n",j);
/* first count the sizes. */
sum = 0;
for(i=fcn->dimensions;i>j;i--)
Expand Down
2 changes: 1 addition & 1 deletion lang/basic/src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int callfcn(int fcnnr,int cnt,int *typetable)

type= typetable[0];
exprlimit=cnt;
if(debug) print("fcn=%d\n",fcnnr);
if(debug) printf("fcn=%d\n",fcnnr);

switch(fcnnr)
{
Expand Down
4 changes: 2 additions & 2 deletions lang/basic/src/gencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Loading

0 comments on commit 26511fe

Please sign in to comment.