Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace some old and extremely obsolete system call wrappers with direct system calls. #321

Merged
merged 29 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5686b30
Eliminate Malloc, Realloc and Free in favour of malloc, realloc and f…
davidgiven Nov 20, 2024
f9b150b
Eliminate No_Mem(), which is largely useless on modern systems with o…
davidgiven Nov 20, 2024
f7c583c
Reformat.
davidgiven Nov 20, 2024
b81f8a8
Remove botch, as it's no longer used.
davidgiven Nov 27, 2024
b78dee5
Replace clear with memset, and remove clear.
davidgiven Nov 27, 2024
6b6ffb1
Remove strindex and strrindex, which weren't used (and are just strch…
davidgiven Nov 27, 2024
61193a0
Remove strzero, which wasn't used.
davidgiven Nov 27, 2024
7d1a108
Remove parts of the bts library which aren't used.
davidgiven Nov 27, 2024
b50b6dd
Replace str2long with strtol.
davidgiven Nov 27, 2024
1531b7d
Reformat.
davidgiven Nov 27, 2024
3938f8a
Replace sprint with sprintf.
davidgiven Dec 5, 2024
04bec50
Replace print() with printf().
davidgiven Dec 5, 2024
c926f0b
The system module now uses FILE* throughout.
davidgiven Dec 8, 2024
2999ca8
Remove the unused sys_chmode.
davidgiven Dec 8, 2024
b74bd7b
Remove sys_remove() in favour of real remove().
davidgiven Dec 8, 2024
9e3ce86
Remove the unused sys_rename.
davidgiven Dec 8, 2024
6545c4f
Cleanup.
davidgiven Dec 8, 2024
d01d716
Remove the unused sys_access.
davidgiven Dec 8, 2024
96e3657
Remove the unused sys_modtime.
davidgiven Dec 8, 2024
514140f
Rip out all the system library file stuff in favour of standard stdio.
davidgiven Dec 8, 2024
6a4b65d
Eliminate sys_stop() in favour of exit() and abort().
davidgiven Dec 8, 2024
1eca3e3
Replace fprint() with fprintf().
davidgiven Dec 8, 2024
dbe0ae0
Eliminate dprnt() in favour of vfprintf().
davidgiven Dec 8, 2024
280f50f
Remove the unused _format().
davidgiven Dec 8, 2024
424dabd
Remove the print module completely, as it's now no longer used.
davidgiven Dec 8, 2024
a5c1726
Rip out Salloc() and replace it with strdup().
davidgiven Dec 8, 2024
c1c1d14
Replace btscpy with memcpy.
davidgiven Dec 8, 2024
c25cd39
Fix oddity with OSX and Windows.
davidgiven Dec 8, 2024
cea6b9a
Remember to open files in binary mode to avoid stupid translation iss…
davidgiven Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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