From 5686b30df824892d7d09d88fa1e27d0f21c98987 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 20 Nov 2024 16:52:31 +0100 Subject: [PATCH 01/29] Eliminate Malloc, Realloc and Free in favour of malloc, realloc and free. --- lang/cem/cemcom.ansi/LLlex.c | 5 +-- lang/cem/cemcom.ansi/expression.g | 3 +- lang/cem/cemcom.ansi/idf.c | 4 +-- lang/cem/cemcom.ansi/ival.g | 2 +- lang/cem/cemcom.ansi/l_comment.c | 2 +- lang/cem/cemcom.ansi/stab.c | 4 +-- lang/cem/cemcom/LLlex.c | 4 +-- lang/cem/cemcom/domacro.c | 12 +++---- lang/cem/cemcom/idf.c | 2 +- lang/cem/cemcom/ival.g | 2 +- lang/cem/cemcom/l_comment.c | 2 +- lang/cem/cemcom/mcomm.c | 6 ++-- lang/cem/cemcom/options.c | 2 +- lang/cem/cemcom/replace.c | 6 ++-- lang/cem/cemcom/stab.c | 4 +-- lang/cem/cpp.ansi/LLlex.c | 9 ++--- lang/cem/cpp.ansi/domacro.c | 4 +-- lang/cem/cpp.ansi/main.c | 2 +- lang/cem/cpp.ansi/options.c | 2 +- lang/cem/cpp.ansi/preprocess.c | 8 ++--- lang/cem/cpp.ansi/replace.c | 12 +++---- lang/m2/comp/LLlex.c | 8 ++--- lang/m2/comp/LLmessage.c | 2 +- lang/m2/comp/chk_expr.c | 4 +-- lang/m2/comp/defmodule.c | 2 +- lang/m2/comp/main.c | 2 +- lang/m2/comp/misc.c | 4 +-- lang/m2/comp/options.c | 2 +- lang/m2/comp/stab.c | 4 +-- lang/m2/m2mm/lib.c | 2 +- lang/m2/m2mm/main.c | 4 +-- lang/m2/m2mm/options.c | 6 ++-- lang/m2/m2mm/program.g | 2 +- lang/occam/comp/em.c | 8 ++--- lang/occam/comp/expr.c | 22 ++++++------ lang/occam/comp/lex.l | 8 ++--- lang/occam/comp/symtab.c | 8 ++--- lang/pc/comp/LLlex.c | 10 +++--- lang/pc/comp/LLmessage.c | 7 ++-- lang/pc/comp/chk_expr.c | 2 +- lang/pc/comp/declar.g | 4 +-- lang/pc/comp/misc.c | 4 +-- lang/pc/comp/stab.c | 4 +-- mach/m68020/ce/as.c | 4 +-- mach/sparc/ce/cache.c.x | 4 +-- mach/sun3/ce/as.c | 4 +-- mach/sun3/ce/output.c | 8 ++--- mach/vax4/ce/output.c | 8 ++--- modules/src/alloc/Malloc.c | 26 --------------- modules/src/alloc/Realloc.c | 30 ----------------- modules/src/alloc/Srealloc.c | 18 ---------- modules/src/alloc/alloc.3 | 21 +----------- modules/src/alloc/alloc.h | 9 +---- modules/src/alloc/build.lua | 3 -- modules/src/em_code/em.c | 4 +-- modules/src/em_code/insert.c | 8 ++--- modules/src/em_opt/nopt.c | 8 ++--- modules/src/em_opt/outputdfa.c | 12 +++---- modules/src/em_opt/parser.g | 14 ++++---- modules/src/idf/idf_pkg.body | 5 +-- modules/src/read_em/reade.c | 8 ++--- modules/src/read_em/readk.c | 4 +-- util/LLgen/lib/nc_rec | 48 +++++++++++++-------------- util/ceg/EM_parser/common/action.c | 4 +-- util/ceg/as_parser/pars.g | 4 +-- util/ceg/ce_back/obj_back/init_back.c | 12 +++---- util/ceg/ce_back/obj_back/memory.c | 12 +++---- util/ceg/ce_back/obj_back/output.c | 4 +-- util/cmisc/cclash.c | 12 +++---- util/cmisc/cid.c | 8 ++--- util/cmisc/mkdep.c | 8 ++--- util/cmisc/prid.c | 8 ++--- util/grind/db_symtab.g | 14 ++++---- util/grind/expr.c | 2 +- util/grind/list.c | 8 ++--- util/grind/rd.c | 2 +- util/grind/type.c | 14 ++++---- 77 files changed, 238 insertions(+), 336 deletions(-) delete mode 100644 modules/src/alloc/Malloc.c delete mode 100644 modules/src/alloc/Realloc.c delete mode 100644 modules/src/alloc/Srealloc.c diff --git a/lang/cem/cemcom.ansi/LLlex.c b/lang/cem/cemcom.ansi/LLlex.c index 5a24464ac9..e85637f40a 100644 --- a/lang/cem/cemcom.ansi/LLlex.c +++ b/lang/cem/cemcom.ansi/LLlex.c @@ -7,6 +7,7 @@ #include #include +#include #include "parameters.h" #include "input.h" #include "arith.h" @@ -426,7 +427,7 @@ static char* string_token(char *nm, int stop_char, int *plen) { int ch; int str_size; - char* str = Malloc((unsigned)(str_size = ISTRSIZE)); + char* str = malloc((unsigned)(str_size = ISTRSIZE)); int pos = 0; ch = GetChar(); @@ -447,7 +448,7 @@ static char* string_token(char *nm, int stop_char, int *plen) ch = quoted(GetChar()); str[pos++] = ch; if (pos == str_size) - str = Realloc(str, (unsigned)(str_size += RSTRSIZE)); + str = realloc(str, (unsigned)(str_size += RSTRSIZE)); ch = GetChar(); } str[pos++] = '\0'; /* for filenames etc. */ diff --git a/lang/cem/cemcom.ansi/expression.g b/lang/cem/cemcom.ansi/expression.g index 594c51a5e9..b2cba80b93 100644 --- a/lang/cem/cemcom.ansi/expression.g +++ b/lang/cem/cemcom.ansi/expression.g @@ -7,6 +7,7 @@ { #include +#include #include "parameters.h" #include #include "arith.h" @@ -71,7 +72,7 @@ string(struct expr **expp;) */ if (dot.tk_fund != fund) warning("illegal pasting of string literals"); - str = Realloc(str, (unsigned) (--len + dot.tk_len)); + str = realloc(str, (unsigned) (--len + dot.tk_len)); for (i = 0; i < dot.tk_len; i++) str[len++] = dot.tk_bts[i]; } diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 82b02c86e1..c9c05ae342 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -51,10 +51,10 @@ struct idf *gen_idf(void) anonymous name. */ static int name_cnt; - char *s = Malloc(strlen(dot.tk_file) + 50); + char *s = malloc(strlen(dot.tk_file) + 50); sprint(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line); - s = Realloc(s, strlen(s) + 1); + s = realloc(s, strlen(s) + 1); return str2idf(s, 0); } diff --git a/lang/cem/cemcom.ansi/ival.g b/lang/cem/cemcom.ansi/ival.g index 6b9447b69d..c94123c538 100644 --- a/lang/cem/cemcom.ansi/ival.g +++ b/lang/cem/cemcom.ansi/ival.g @@ -642,7 +642,7 @@ void ch_array(struct type **tpp, /* type tp = array of characters */ length = dim; } /* throw out the characters of the already prepared string */ - s = Malloc((unsigned) (length)); + s = malloc((unsigned) (length)); clear(s, (unsigned)length); i = length <= ex->SG_LEN ? length : ex->SG_LEN; to = s; from = ex->SG_VALUE; diff --git a/lang/cem/cemcom.ansi/l_comment.c b/lang/cem/cemcom.ansi/l_comment.c index 04efae2103..c944d8680e 100644 --- a/lang/cem/cemcom.ansi/l_comment.c +++ b/lang/cem/cemcom.ansi/l_comment.c @@ -168,7 +168,7 @@ make_format(argn, oldf) } /* there is a new format to be composed */ - newf = Malloc(strlen(oldf)); + newf = malloc(strlen(oldf)); /* certainly enough and probably not overly too much */ formatN = argn; format = newf; diff --git a/lang/cem/cemcom.ansi/stab.c b/lang/cem/cemcom.ansi/stab.c index 284235e783..7cfc8f924a 100644 --- a/lang/cem/cemcom.ansi/stab.c +++ b/lang/cem/cemcom.ansi/stab.c @@ -45,7 +45,7 @@ static void create_db_str(void) { if (!db_str.base) { - db_str.base = Malloc(INCR_SIZE); + db_str.base = malloc(INCR_SIZE); db_str.sz = INCR_SIZE; } db_str.currpos = db_str.base; @@ -57,7 +57,7 @@ static void addc_db_str(int c) if (df >= db_str.sz - 1) { db_str.sz += INCR_SIZE; - db_str.base = Realloc(db_str.base, db_str.sz); + db_str.base = realloc(db_str.base, db_str.sz); db_str.currpos = db_str.base + df; } *db_str.currpos++ = c; diff --git a/lang/cem/cemcom/LLlex.c b/lang/cem/cemcom/LLlex.c index 6fb9c1454e..8f0f5dccea 100644 --- a/lang/cem/cemcom/LLlex.c +++ b/lang/cem/cemcom/LLlex.c @@ -494,7 +494,7 @@ string_token(nm, stop_char, plen) { int ch; int str_size; - char *str = Malloc((unsigned) (str_size = ISTRSIZE)); + char *str = malloc((unsigned) (str_size = ISTRSIZE)); int pos = 0; LoadChar(ch); @@ -519,7 +519,7 @@ string_token(nm, stop_char, plen) } str[pos++] = ch; if (pos == str_size) - str = Srealloc(str, (unsigned) (str_size += RSTRSIZE)); + str = realloc(str, (unsigned) (str_size += RSTRSIZE)); LoadChar(ch); } str[pos++] = '\0'; /* for filenames etc. */ diff --git a/lang/cem/cemcom/domacro.c b/lang/cem/cemcom/domacro.c index 5ba3a89988..8c3e7cb957 100644 --- a/lang/cem/cemcom/domacro.c +++ b/lang/cem/cemcom/domacro.c @@ -593,7 +593,7 @@ get_text(formals, length) */ int c; int text_size; - char *text = Malloc(text_size = ITEXTSIZE); + char *text = malloc(text_size = ITEXTSIZE); int pos = 0; LoadChar(c); @@ -613,7 +613,7 @@ get_text(formals, length) else text[pos++] = '\\'; if (pos == text_size) - text = Srealloc(text, text_size += RTEXTSIZE); + text = realloc(text, text_size += RTEXTSIZE); } else if ( c == '/') { @@ -626,7 +626,7 @@ get_text(formals, length) else text[pos++] = '/'; if (pos == text_size) - text = Srealloc(text, text_size += RTEXTSIZE); + text = realloc(text, text_size += RTEXTSIZE); } else if (formals && class(c) == STIDF) { @@ -646,14 +646,14 @@ get_text(formals, length) /* construct the formal parameter mark */ text[pos++] = FORMALP | (char) n; if (pos == text_size) - text = Srealloc(text, + text = realloc(text, text_size += RTEXTSIZE); } else { char *ptr = &id_buf[0]; while (pos + id_size >= text_size) - text = Srealloc(text, + text = realloc(text, text_size += RTEXTSIZE); while (text[pos++] = *ptr++) ; pos--; @@ -662,7 +662,7 @@ get_text(formals, length) else { text[pos++] = c; if (pos == text_size) - text = Srealloc(text, text_size += RTEXTSIZE); + text = realloc(text, text_size += RTEXTSIZE); LoadChar(c); } } diff --git a/lang/cem/cemcom/idf.c b/lang/cem/cemcom/idf.c index b70d5d465b..789fbf0d4b 100644 --- a/lang/cem/cemcom/idf.c +++ b/lang/cem/cemcom/idf.c @@ -155,7 +155,7 @@ gen_idf() */ static int name_cnt; struct idf *id; - char *s = Malloc(strlen(dot.tk_file)+50); + char *s = malloc(strlen(dot.tk_file)+50); sprint(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line); diff --git a/lang/cem/cemcom/ival.g b/lang/cem/cemcom/ival.g index ad309fe1cf..e7ca7f6cef 100644 --- a/lang/cem/cemcom/ival.g +++ b/lang/cem/cemcom/ival.g @@ -586,7 +586,7 @@ ch_array(tpp, ex) length = dim; } /* throw out the characters of the already prepared string */ - s = Malloc((unsigned) (length)); + s = malloc((unsigned) (length)); clear(s, length); i = length <= ex->SG_LEN ? length : ex->SG_LEN; to = s; from = ex->SG_VALUE; diff --git a/lang/cem/cemcom/l_comment.c b/lang/cem/cemcom/l_comment.c index 15c41bff81..308a612df2 100644 --- a/lang/cem/cemcom/l_comment.c +++ b/lang/cem/cemcom/l_comment.c @@ -169,7 +169,7 @@ make_format(argn, oldf) } /* there is a new format to be composed */ - newf = Malloc(strlen(oldf)); + newf = malloc(strlen(oldf)); /* certainly enough and probably not overly too much */ formatN = argn; format = newf; diff --git a/lang/cem/cemcom/mcomm.c b/lang/cem/cemcom/mcomm.c index e299a05b4d..692a725c86 100644 --- a/lang/cem/cemcom/mcomm.c +++ b/lang/cem/cemcom/mcomm.c @@ -18,7 +18,7 @@ struct node { }; char * -Malloc(n) +malloc(n) unsigned n; { char *space; @@ -33,7 +33,7 @@ Malloc(n) struct node *make_tree(); -#define new_node() ((struct node *) Malloc(sizeof (struct node))) +#define new_node() ((struct node *) malloc(sizeof (struct node))) main(argc, argv) char *argv[]; @@ -86,7 +86,7 @@ readfile(filename, psiz) if (((fd = open(filename, 0)) < 0) || (fstat(fd, &stbuf) != 0)) return 0; - cbuf = Malloc(stbuf.st_size + 1); + cbuf = malloc(stbuf.st_size + 1); if (read(fd, cbuf, stbuf.st_size) != stbuf.st_size) return 0; cbuf[stbuf.st_size] = '\0'; diff --git a/lang/cem/cemcom/options.c b/lang/cem/cemcom/options.c index f150ed5dbb..c83aadc64d 100644 --- a/lang/cem/cemcom/options.c +++ b/lang/cem/cemcom/options.c @@ -189,7 +189,7 @@ deleted, is now a debug-flag if (++inc_total > inc_max) { inctable = (char **) - Realloc((char *) inctable,(inc_max+=10)*sizeof(char *)); + realloc((char *) inctable,(inc_max+=10)*sizeof(char *)); } for (i = inc_pos++; i < inc_total; i++) { diff --git a/lang/cem/cemcom/replace.c b/lang/cem/cemcom/replace.c index 9061073169..4d50d5d1ea 100644 --- a/lang/cem/cemcom/replace.c +++ b/lang/cem/cemcom/replace.c @@ -184,7 +184,7 @@ macro2buffer(idef, actpars, siztext) the same as strcpy(). */ int size = 8; - char *text = Malloc(size); + char *text = malloc(size); int pos = 0; char *ptr = idef->id_macro->mc_text; @@ -200,13 +200,13 @@ macro2buffer(idef, actpars, siztext) for (p = actpars[n - 1]; *p; p++) { text[pos++] = *p; if (pos == size) - text = Srealloc(text, size += RSTRSIZE); + text = realloc(text, size += RSTRSIZE); } } else { text[pos++] = *ptr++; if (pos == size) - text = Srealloc(text, size += RSTRSIZE); + text = realloc(text, size += RSTRSIZE); } } text[pos] = '\0'; diff --git a/lang/cem/cemcom/stab.c b/lang/cem/cemcom/stab.c index f95f12f4f2..a2b52ceb08 100644 --- a/lang/cem/cemcom/stab.c +++ b/lang/cem/cemcom/stab.c @@ -45,7 +45,7 @@ static create_db_str() { if (! db_str.base) { - db_str.base = Malloc(INCR_SIZE); + db_str.base = malloc(INCR_SIZE); db_str.sz = INCR_SIZE; } db_str.currpos = db_str.base; @@ -58,7 +58,7 @@ addc_db_str(c) int df = db_str.currpos - db_str.base; if (df >= db_str.sz-1) { db_str.sz += INCR_SIZE; - db_str.base = Realloc(db_str.base, db_str.sz); + db_str.base = realloc(db_str.base, db_str.sz); db_str.currpos = db_str.base + df; } *db_str.currpos++ = c; diff --git a/lang/cem/cpp.ansi/LLlex.c b/lang/cem/cpp.ansi/LLlex.c index 58218f7e5a..06551358a8 100644 --- a/lang/cem/cpp.ansi/LLlex.c +++ b/lang/cem/cpp.ansi/LLlex.c @@ -7,6 +7,7 @@ #include "parameters.h" +#include #include #include #include @@ -304,7 +305,7 @@ int GetToken(struct token* ptok) ptok->tk_val = (arith)0; return ptok->tk_symb = INTEGER; } - ptok->tk_str = Malloc((unsigned)(tg - buf)); + ptok->tk_str = malloc((unsigned)(tg - buf)); strcpy(ptok->tk_str, buf); return IDENTIFIER; } @@ -484,7 +485,7 @@ static char* string_token(char* nm, int stop_char) { int ch; int str_size; - char* str = Malloc((unsigned)(str_size = ISTRSIZE)); + char* str = malloc((unsigned)(str_size = ISTRSIZE)); int pos = 0; ch = GetChar(); @@ -505,11 +506,11 @@ static char* string_token(char* nm, int stop_char) ch = quoted(GetChar()); str[pos++] = ch; if (pos == str_size) - str = Realloc(str, (unsigned)(str_size <<= 1)); + str = realloc(str, (unsigned)(str_size <<= 1)); ch = GetChar(); } str[pos++] = '\0'; /* for filenames etc. */ - str = Realloc(str, (unsigned)pos); + str = realloc(str, (unsigned)pos); return str; } diff --git a/lang/cem/cpp.ansi/domacro.c b/lang/cem/cpp.ansi/domacro.c index 92a21d6ba3..e8b3bc53e7 100644 --- a/lang/cem/cpp.ansi/domacro.c +++ b/lang/cem/cpp.ansi/domacro.c @@ -741,7 +741,7 @@ static char* get_text(char* formals[], int* length) c = GetChar(); - repl->r_ptr = repl->r_text = Malloc((unsigned)(repl->r_size = ITEXTSIZE)); + repl->r_ptr = repl->r_text = malloc((unsigned)(repl->r_size = ITEXTSIZE)); *repl->r_ptr = '\0'; while ((c != EOI) && (class(c) != STNL)) { @@ -876,7 +876,7 @@ static char* get_text(char* formals[], int* length) } } *length = repl->r_ptr - repl->r_text; - return Realloc(repl->r_text, (unsigned)(repl->r_ptr - repl->r_text + 1)); + return realloc(repl->r_text, (unsigned)(repl->r_ptr - repl->r_text + 1)); } /* macroeq() decides whether two macro replacement texts are diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index 1db525daf0..b515a736ef 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) init_idf(); - inctable = (char **) Malloc(10 * sizeof(char *)); + inctable = (char **) malloc(10 * sizeof(char *)); inc_max = 10; inc_total = 3; inctable[0] = "."; diff --git a/lang/cem/cpp.ansi/options.c b/lang/cem/cpp.ansi/options.c index 2771911dd8..f89e6a12b9 100644 --- a/lang/cem/cpp.ansi/options.c +++ b/lang/cem/cpp.ansi/options.c @@ -94,7 +94,7 @@ void do_option(char *text) if (++inc_total > inc_max) { inctable = (char **) - Realloc((char *)inctable, + realloc((char *)inctable, (unsigned)((inc_max+=10)*sizeof(char *))); } diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index 828057f57f..72c85ac221 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -52,7 +52,7 @@ static int pragma_nr; void do_pragma(void) { int size = ITEXTSIZE; - char* cur_line = Malloc((unsigned)size); + char* cur_line = malloc((unsigned)size); char* c_ptr = cur_line; int c = GetChar(); int delim = 0; @@ -61,7 +61,7 @@ void do_pragma(void) { if (c_ptr + 1 - cur_line == size) { - cur_line = Realloc(cur_line, (unsigned)(size + ITEXTSIZE)); + cur_line = realloc(cur_line, (unsigned)(size + ITEXTSIZE)); c_ptr = cur_line + size - 1; size += ITEXTSIZE; } @@ -107,11 +107,11 @@ void do_pragma(void) *c_ptr = '\0'; if (!pragma_nr) { - pragma_tab = (struct prag_info*)Malloc(sizeof(struct prag_info)); + pragma_tab = (struct prag_info*)malloc(sizeof(struct prag_info)); } else { - pragma_tab = (struct prag_info*)Realloc( + pragma_tab = (struct prag_info*)realloc( (char*)pragma_tab, (unsigned)(sizeof(struct prag_info) * (pragma_nr + 1))); } if (delim) diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index 900eee202a..4049c3d8c6 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -48,7 +48,7 @@ int replace(struct idf *idf) if (idf->id_macro->mc_flag & NOREPLACE) return 0; repl = new_repl(); - repl->r_ptr = repl->r_text = Malloc((unsigned)(repl->r_size = LAPBUF)); + repl->r_ptr = repl->r_text = malloc((unsigned)(repl->r_size = LAPBUF)); repl->r_args = new_args(); repl->r_idf = idf; if (!expand_macro(repl, idf)) @@ -209,8 +209,8 @@ static void expand_defined(struct repl *repl) static void newarg(struct args *args) { - args->a_expptr = args->a_expbuf = Malloc((unsigned)(args->a_expsize = ARGBUF)); - args->a_rawptr = args->a_rawbuf = Malloc((unsigned)(args->a_rawsize = ARGBUF)); + args->a_expptr = args->a_expbuf = malloc((unsigned)(args->a_expsize = ARGBUF)); + args->a_rawptr = args->a_rawbuf = malloc((unsigned)(args->a_rawsize = ARGBUF)); } static void getactuals(struct repl *repl, struct idf *idf) @@ -748,7 +748,7 @@ void add2repl(struct repl *repl, int ch) assert(index < repl->r_size); if (index + 2 >= repl->r_size) { - repl->r_text = Realloc(repl->r_text, (unsigned)(repl->r_size <<= 1)); + repl->r_text = realloc(repl->r_text, (unsigned)(repl->r_size <<= 1)); repl->r_ptr = repl->r_text + index; } *repl->r_ptr++ = ch; @@ -769,7 +769,7 @@ static void stash(struct repl *repl, int ch, int stashraw) if (stashraw >= 0) { assert(index < args->a_expsize); if (index + 1 >= args->a_expsize) { - args->a_expbuf = Realloc(args->a_expbuf, + args->a_expbuf = realloc(args->a_expbuf, (unsigned)(args->a_expsize <<= 1)); args->a_expptr = args->a_expbuf + index; } @@ -780,7 +780,7 @@ static void stash(struct repl *repl, int ch, int stashraw) index = args->a_rawptr - args->a_rawbuf; assert(index < args->a_rawsize); if (index + 1 >= args->a_rawsize) { - args->a_rawbuf = Realloc(args->a_rawbuf, + args->a_rawbuf = realloc(args->a_rawbuf, (unsigned)(args->a_rawsize <<= 1)); args->a_rawptr = args->a_rawbuf + index; } diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index aa85ba04cc..7729d34c52 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -127,12 +127,12 @@ static struct string *GetString(int upto) */ int ch; struct string *str = (struct string *) - Malloc((unsigned) sizeof(struct string)); + malloc((unsigned) sizeof(struct string)); char *p; int len; len = ISTRSIZE; - str->s_str = p = Malloc((unsigned int) ISTRSIZE); + str->s_str = p = malloc((unsigned int) ISTRSIZE); while (LoadChar(ch), ch != upto) { if (!(ch & 0200) && class(ch) == STNL) { lexerror("newline in string"); @@ -148,7 +148,7 @@ static struct string *GetString(int upto) } *p++ = ch; if (p - str->s_str == len) { - str->s_str = Realloc(str->s_str, + str->s_str = realloc(str->s_str, (unsigned int) len + RSTRSIZE); p = str->s_str + len; len += RSTRSIZE; @@ -159,7 +159,7 @@ static struct string *GetString(int upto) while (p - str->s_str < len) { *p++ = '\0'; } - str->s_str = Realloc(str->s_str, (unsigned) len); + str->s_str = realloc(str->s_str, (unsigned) len); if (str->s_length == 0) str->s_length = 1; /* ??? string length at least 1 ??? */ return str; diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index d17c6b3941..56ec472bb6 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -49,7 +49,7 @@ void LLmessage(int tk) break; case STRING: dotp->tk_data.tk_str = (struct string *) - Malloc(sizeof (struct string)); + malloc(sizeof (struct string)); dotp->TOK_SLE = 1; dotp->TOK_STR = Salloc("", 1); break; diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index b79e29b7ad..14da1a2dd7 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -487,7 +487,7 @@ arith *MkSet(unsigned int size) { arith *s, *t; - s = t = (arith *) Malloc(size); + s = t = (arith *) malloc(size); s++; size /= sizeof(arith); while (size--) *t++ = 0; @@ -1472,7 +1472,7 @@ void TryToString(struct node *nd, struct type *tp) buf[0] = nd->nd_INT; nd->nd_type = standard_type(T_STRING, 1, (arith) 2); nd->nd_SSTR = - (struct string *) Malloc(sizeof(struct string)); + (struct string *) malloc(sizeof(struct string)); nd->nd_STR = Salloc(buf, (unsigned) word_size); nd->nd_SLE = 1; } diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index a8968a0c5a..3e88839e86 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -73,7 +73,7 @@ static int GetFile(char *name) char *buf; len = strlen(name); - buf = Malloc(len + 5); + buf = malloc(len + 5); memcpy(buf, name, len); memcpy(buf + len, ".def", 5); DEFPATH[0] = WorkingDir; diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 2995f90727..1b6757cd34 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -73,7 +73,7 @@ int main(int argc, char **argv) char **Nargv = &argv[0]; ProgName = *argv++; - DEFPATH = (char **) Malloc((unsigned)mDEF * sizeof(char *)); + DEFPATH = (char **) malloc((unsigned)mDEF * sizeof(char *)); DEFPATH[1] = 0; while (--argc > 0) { diff --git a/lang/m2/comp/misc.c b/lang/m2/comp/misc.c index 1f59e98e55..b85cb54cf0 100644 --- a/lang/m2/comp/misc.c +++ b/lang/m2/comp/misc.c @@ -45,11 +45,11 @@ struct idf *gen_anon_idf(void) anonymous name. */ static int name_cnt; - char *s = Malloc(strlen(FileName)+50); + char *s = malloc(strlen(FileName)+50); sprint(s, "#%d in %s, line %u", ++name_cnt, FileName, LineNumber); - s = Realloc(s, strlen(s)+1); + s = realloc(s, strlen(s)+1); return str2idf(s, 0); } diff --git a/lang/m2/comp/options.c b/lang/m2/comp/options.c index e86da7f929..b66cb277e6 100644 --- a/lang/m2/comp/options.c +++ b/lang/m2/comp/options.c @@ -160,7 +160,7 @@ void DoOption(char *text) if (nDEF > mDEF) { DEFPATH = (char **) - Realloc((char *)DEFPATH,(unsigned)(mDEF+=10)*sizeof(char *)); + realloc((char *)DEFPATH,(unsigned)(mDEF+=10)*sizeof(char *)); } for (i = ndirs++; i < nDEF; i++) { diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index 0c2c9f5b70..fac59cfd6b 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -45,7 +45,7 @@ static struct db_str { static void create_db_str(void) { if (! db_str.base) { - db_str.base = Malloc(INCR_SIZE); + db_str.base = malloc(INCR_SIZE); db_str.sz = INCR_SIZE; } db_str.currpos = db_str.base; @@ -56,7 +56,7 @@ static void addc_db_str(int c) int df = db_str.currpos - db_str.base; if (df >= db_str.sz-1) { db_str.sz += INCR_SIZE; - db_str.base = Realloc(db_str.base, db_str.sz); + db_str.base = realloc(db_str.base, db_str.sz); db_str.currpos = db_str.base + df; } *db_str.currpos++ = c; diff --git a/lang/m2/m2mm/lib.c b/lang/m2/m2mm/lib.c index 1f7a648042..c32654e094 100644 --- a/lang/m2/m2mm/lib.c +++ b/lang/m2/m2mm/lib.c @@ -57,7 +57,7 @@ init_lib() set_libdir(n) { struct liblist *p = - (struct liblist *) Malloc(sizeof(struct liblist)); + (struct liblist *) malloc(sizeof(struct liblist)); p->libnext = lblist; p->libno = n; diff --git a/lang/m2/m2mm/main.c b/lang/m2/m2mm/main.c index 28e9a3c6b5..47114e0259 100644 --- a/lang/m2/m2mm/main.c +++ b/lang/m2/m2mm/main.c @@ -89,7 +89,7 @@ main(argc, argv) int i; ProgName = *argv++; - DEFPATH = (char **) Malloc(10 * sizeof(char *)); + DEFPATH = (char **) malloc(10 * sizeof(char *)); DEFPATH[1] = 0; mDEF = 10; nDEF = 2; @@ -126,7 +126,7 @@ new_file_list() static int cnt; if (--cnt < 0) { - p = (struct file_list *)Malloc(50*sizeof(struct file_list)); + p = (struct file_list *)malloc(50*sizeof(struct file_list)); cnt = 49; } f = p++; diff --git a/lang/m2/m2mm/options.c b/lang/m2/m2mm/options.c index f88533f390..82133b812d 100644 --- a/lang/m2/m2mm/options.c +++ b/lang/m2/m2mm/options.c @@ -51,10 +51,10 @@ DoOption(text) unsigned int len = strlen(text) + 4; if (liblen) { - llibs = Realloc(llibs, liblen += len); + llibs = realloc(llibs, liblen += len); } else { - llibs = Malloc(liblen = len); + llibs = malloc(liblen = len); *llibs = '\0'; } strcat(llibs,"\\\n\t"); @@ -81,7 +81,7 @@ AddInclDir(text) if (++nDEF > mDEF) { mDEF += 10; - DEFPATH = (char **) Realloc((char *)DEFPATH, + DEFPATH = (char **) realloc((char *)DEFPATH, (unsigned)(mDEF * sizeof(char *))); } diff --git a/lang/m2/m2mm/program.g b/lang/m2/m2mm/program.g index bf2b5b9a80..492c4398e6 100644 --- a/lang/m2/m2mm/program.g +++ b/lang/m2/m2mm/program.g @@ -39,7 +39,7 @@ new_lnk() static int cnt; if (cnt-- <= 0) { - p = (struct lnk *)Malloc(50*sizeof(struct lnk)); + p = (struct lnk *)malloc(50*sizeof(struct lnk)); cnt = 49; } p->lnk_next = 0; diff --git a/lang/occam/comp/em.c b/lang/occam/comp/em.c index 426d0734ad..6038d073b8 100644 --- a/lang/occam/comp/em.c +++ b/lang/occam/comp/em.c @@ -21,7 +21,7 @@ int wz = 4, pz = 4, vz = 4; int Lflag; static Lab=0; -char *Malloc(); +char *malloc(); void init() { @@ -86,7 +86,7 @@ char *proc_label(L, name) register L; register char *name; if (lab!=nil) free(lab); - lab=Malloc(strlen(name)+(1+sizeof(int)*3+1)); + lab=malloc(strlen(name)+(1+sizeof(int)*3+1)); /* That is: P\0 */ sprint(lab, "P%d", L); @@ -416,8 +416,8 @@ int set_file(f) char *f; apf= cmp<0 ? &pf->left : &pf->right; if (pf==nil) { - *apf= pf= (struct ftree *) Malloc(sizeof *pf); - pf->file=strcpy(Malloc(strlen(f)+1), f); + *apf= pf= (struct ftree *) malloc(sizeof *pf); + pf->file=strcpy(malloc(strlen(f)+1), f); pf->lab=0; pf->left=pf->right=nil; } diff --git a/lang/occam/comp/expr.c b/lang/occam/comp/expr.c index e19edf28e8..ea7a705eac 100644 --- a/lang/occam/comp/expr.c +++ b/lang/occam/comp/expr.c @@ -11,7 +11,7 @@ static void rvalue(), assignable(), inputable(), outputable(), subscriptable(); static void assigned(); -char *Malloc(); +char *malloc(); /* The new_* functions make use of the used() and assinged() functions to * make known what is done to a variable. @@ -91,7 +91,7 @@ struct expr *new_node(op, left, right, byte) subscriptable(left, right, byte, &type, &arr_siz); break; } - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); pe->kind=E_NODE; pe->type=type; @@ -112,7 +112,7 @@ struct expr *new_var(var) { struct expr *pe; - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); pe->kind=E_VAR; @@ -135,7 +135,7 @@ struct expr *new_const(cst) { struct expr *pe; - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); pe->kind=E_CONST; pe->type=T_VALUE; @@ -154,7 +154,7 @@ struct expr *new_table(kind, tab) { struct expr *pe; - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); pe->kind=kind; pe->type=T_VALUE|T_ARR; @@ -182,7 +182,7 @@ struct expr *copy_const(e) struct expr *e; { struct expr *c; - c= (struct expr *) Malloc(sizeof *c); + c= (struct expr *) malloc(sizeof *c); *c= *e; return c; @@ -193,7 +193,7 @@ struct expr *new_now() { struct expr *pe; - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); pe->kind=E_NOW; pe->type=T_VALUE; @@ -215,7 +215,7 @@ struct expr *new_io(out, chan, args) report("channel variable expected"); used(chan); - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); pe->kind=E_IO; pe->type=T_VOID; @@ -236,7 +236,7 @@ struct expr *new_call(proc, args) { struct expr *pe; - pe= (struct expr *) Malloc(sizeof *pe); + pe= (struct expr *) malloc(sizeof *pe); used(proc); @@ -255,7 +255,7 @@ void table_add(aapt, val) register struct table ***aapt; long val; { struct table *pt; - pt= (struct table *) Malloc(sizeof *pt); + pt= (struct table *) malloc(sizeof *pt); pt->val=val; pt->next= **aapt; @@ -271,7 +271,7 @@ void expr_list_add(aaelp, arg) { struct expr_list *elp; - elp= (struct expr_list *) Malloc(sizeof *elp); + elp= (struct expr_list *) malloc(sizeof *elp); elp->arg=arg; elp->next= **aaelp; diff --git a/lang/occam/comp/lex.l b/lang/occam/comp/lex.l index f6a0d71055..0a7e9bbbbd 100644 --- a/lang/occam/comp/lex.l +++ b/lang/occam/comp/lex.l @@ -15,7 +15,7 @@ # define TABSTOP(ind) (((ind)+TAB)&(~(TAB-1))) # endif -char *Malloc(), *strcpy(); +char *malloc(), *strcpy(); struct token token; int ind=0; /* Indentation level of current line */ @@ -73,7 +73,7 @@ int lineno = 1; register key; if ((key=keyword(yytext))==IDENTIFIER) - token.t_sval=strcpy(Malloc(yyleng+1), yytext); + token.t_sval=strcpy(malloc(yyleng+1), yytext); return key; } @@ -293,7 +293,7 @@ char *tokenname(tk, inst) register tk, inst; case IDENTIFIER: if (inst) { sprint(fake_id, "_%d", ++fake_cnt); - token.t_sval=strcpy(Malloc(strlen(fake_id)+1), + token.t_sval=strcpy(malloc(strlen(fake_id)+1), fake_id); return "IDENTIFIER"; } else @@ -304,7 +304,7 @@ char *tokenname(tk, inst) register tk, inst; return "NUMBER"; case STRING: if (inst) { - token.t_sval=Malloc(1); + token.t_sval=malloc(1); token.t_sval[0]=0; } else free(token.t_sval); diff --git a/lang/occam/comp/symtab.c b/lang/occam/comp/symtab.c index f9d142e47e..06dab0677c 100644 --- a/lang/occam/comp/symtab.c +++ b/lang/occam/comp/symtab.c @@ -13,7 +13,7 @@ int min_offset=0; /* Minimum of all offsets within current level */ static struct symtab *sym_table=nil; -char *Malloc(); +char *malloc(); static struct symbol **search_sym(tree, name) struct symbol **tree; @@ -46,7 +46,7 @@ struct symbol *insert(name, type, arr_siz, info) return nil; } - ps= (struct symbol *) Malloc(sizeof *ps); + ps= (struct symbol *) malloc(sizeof *ps); ps->s_name=name; @@ -89,7 +89,7 @@ void sym_down() { struct symtab *ps; - ps= (struct symtab *) Malloc(sizeof *ps); + ps= (struct symtab *) malloc(sizeof *ps); ps->local=nil; ps->global=sym_table; @@ -172,7 +172,7 @@ void pars_add(aapars, type, var) { struct par_list *pl; - pl= (struct par_list *) Malloc(sizeof *pl); + pl= (struct par_list *) malloc(sizeof *pl); pl->pr_type=type; pl->pr_var=var; diff --git a/lang/pc/comp/LLlex.c b/lang/pc/comp/LLlex.c index 42545461bb..20e7ecb3fb 100644 --- a/lang/pc/comp/LLlex.c +++ b/lang/pc/comp/LLlex.c @@ -159,11 +159,11 @@ static struct string *GetString(int delim) */ int ch; struct string *str = (struct string *) - Malloc((unsigned) sizeof(struct string)); + malloc((unsigned) sizeof(struct string)); char *p; int len = ISTRSIZE; - str->s_str = p = Malloc((unsigned int) ISTRSIZE); + str->s_str = p = malloc((unsigned int) ISTRSIZE); for( ; ; ) { LoadChar(ch); if( class(ch) == STNL ) { @@ -185,7 +185,7 @@ static struct string *GetString(int delim) } *p++ = ch; if( p - str->s_str == len ) { - str->s_str = Srealloc(str->s_str, + str->s_str = realloc(str->s_str, (unsigned int) len + RSTRSIZE); p = str->s_str + len; len += RSTRSIZE; @@ -534,9 +534,9 @@ int LLlex(void) } /* REAL_MODE */ tk->tk_data.tk_real = (struct real *) - Malloc(sizeof(struct real)); + malloc(sizeof(struct real)); /* allocate struct for inverse */ - tk->TOK_RIV = (struct real *) Malloc(sizeof(struct real)); + tk->TOK_RIV = (struct real *) malloc(sizeof(struct real)); tk->TOK_RIV->r_inverse = tk->tk_data.tk_real; tk->TOK_RLA = 0; tk->TOK_RIV->r_lab = 0; diff --git a/lang/pc/comp/LLmessage.c b/lang/pc/comp/LLmessage.c index 10b90477e6..4a979d9c7a 100644 --- a/lang/pc/comp/LLmessage.c +++ b/lang/pc/comp/LLmessage.c @@ -7,6 +7,7 @@ */ #include +#include #include #include @@ -42,7 +43,7 @@ void LLmessage(int tk) break; case STRING: dotp->tk_data.tk_str = (struct string *) - Malloc(sizeof (struct string)); + malloc(sizeof (struct string)); dotp->TOK_SLE = 1; dotp->TOK_STR = Salloc("", 1); toktype = standard_type(T_STRINGCONST, 1, (arith) 1); @@ -56,10 +57,10 @@ void LLmessage(int tk) break; case REAL: dotp->tk_data.tk_real = (struct real *) - Malloc(sizeof(struct real)); + malloc(sizeof(struct real)); /* inverse struct */ dotp->TOK_RIV = (struct real *) - Malloc(sizeof(struct real)); + malloc(sizeof(struct real)); dotp->TOK_RIV->r_inverse = dotp->tk_data.tk_real; dotp->TOK_REL = Salloc("0.0", 4); diff --git a/lang/pc/comp/chk_expr.c b/lang/pc/comp/chk_expr.c index 09e1fe49ab..30018f8396 100644 --- a/lang/pc/comp/chk_expr.c +++ b/lang/pc/comp/chk_expr.c @@ -604,7 +604,7 @@ static int ChkElement(struct node *expp, struct type **tp, *tp = set_type(expp->nd_type, 0); size = (*tp)->tp_size * (sizeof(arith) / word_size); - *set = (arith *) Malloc(size); + *set = (arith *) malloc(size); clear((char *) *set, size); } else if (!TstCompat(ElementType(*tp), expp->nd_type)) diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index d7ca62447e..6b27710fac 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -659,7 +659,7 @@ VariantPart(struct scope *scope; arith *cnt; int *palign; * We're almost there !! */ - { *sel = (struct selector *) Malloc(sizeof(struct selector)); + { *sel = (struct selector *) malloc(sizeof(struct selector)); (*sel)->sel_ptrs = 0; } CASE @@ -687,7 +687,7 @@ VariantPart(struct scope *scope; arith *cnt; int *palign; else { /* initialize selector */ (*sel)->sel_ptrs = (struct selector **) - Malloc((unsigned)ncst * sizeof(struct selector *)); + malloc((unsigned)ncst * sizeof(struct selector *)); (*sel)->sel_ncst = ncst; (*sel)->sel_lb = lb; diff --git a/lang/pc/comp/misc.c b/lang/pc/comp/misc.c index 756a88b433..990c32d924 100644 --- a/lang/pc/comp/misc.c +++ b/lang/pc/comp/misc.c @@ -21,10 +21,10 @@ struct idf *gen_anon_idf(void) anonymous name. */ static int name_cnt; - char *s = Malloc(strlen(FileName) + 50); + char *s = malloc(strlen(FileName) + 50); sprint(s, "#%d in %s, line %u", ++name_cnt, FileName, LineNumber); - s = Realloc(s, strlen(s)+1); + s = realloc(s, strlen(s)+1); return str2idf(s, 0); } diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index ce4d8c9c0f..4247fb252e 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -42,7 +42,7 @@ static struct db_str { static void create_db_str(void) { if (! db_str.base) { - db_str.base = Malloc(INCR_SIZE); + db_str.base = malloc(INCR_SIZE); db_str.sz = INCR_SIZE; } db_str.currpos = db_str.base; @@ -53,7 +53,7 @@ static void addc_db_str(int c) int df = db_str.currpos - db_str.base; if (df >= db_str.sz-1) { db_str.sz += INCR_SIZE; - db_str.base = Realloc(db_str.base, db_str.sz); + db_str.base = realloc(db_str.base, db_str.sz); db_str.currpos = db_str.base + df; } *db_str.currpos++ = c; diff --git a/mach/m68020/ce/as.c b/mach/m68020/ce/as.c index bfeef2b7b3..6f294e2748 100644 --- a/mach/m68020/ce/as.c +++ b/mach/m68020/ce/as.c @@ -194,9 +194,9 @@ char *str; char *glob_lbl( lbl) char *lbl; { - char *gl, *Malloc(); + char *gl, *malloc(); - gl = Malloc( strlen( lbl) + 3); + gl = malloc( strlen( lbl) + 3); sprintf( gl, "\"%s\"", lbl); return( gl); } diff --git a/mach/sparc/ce/cache.c.x b/mach/sparc/ce/cache.c.x index 56792a940d..3e0cb86e04 100644 --- a/mach/sparc/ce/cache.c.x +++ b/mach/sparc/ce/cache.c.x @@ -829,7 +829,7 @@ char *s; char *p; enter("push_ext"); - p = Malloc(strlen(s)+1); + p = malloc(strlen(s)+1); INC_TOS; tos->reg = reg_g0; @@ -1286,7 +1286,7 @@ enter("dup_tos"); *tos = tos[-n]; if (tos->ext) { - ext= Malloc(strlen(tos->ext)+1); + ext= malloc(strlen(tos->ext)+1); strcpy(ext, tos->ext); tos->ext= ext; } diff --git a/mach/sun3/ce/as.c b/mach/sun3/ce/as.c index 824f27ce15..32c7185a3c 100644 --- a/mach/sun3/ce/as.c +++ b/mach/sun3/ce/as.c @@ -187,9 +187,9 @@ char *str; char *glob_lbl( lbl) char *lbl; { - char *gl, *Malloc(); + char *gl, *malloc(); - gl = Malloc( strlen( lbl) + 3); + gl = malloc( strlen( lbl) + 3); sprintf( gl, "\"%s\"", lbl); return( gl); } diff --git a/mach/sun3/ce/output.c b/mach/sun3/ce/output.c index 22dbdc7dcc..498c2fc1b9 100644 --- a/mach/sun3/ce/output.c +++ b/mach/sun3/ce/output.c @@ -43,7 +43,7 @@ output_back() nrelo = relo - reloc_info; u_reloc = (struct relocation_info *) - Malloc((unsigned)nrelo*sizeof(struct relocation_info)); + malloc((unsigned)nrelo*sizeof(struct relocation_info)); rp = reloc_info; for (i = nrelo; i > 0; i--, rp++) { @@ -76,7 +76,7 @@ output_back() free(u_reloc); u_name = (struct nlist *) - Malloc((unsigned)nname * sizeof(struct nlist)); + malloc((unsigned)nname * sizeof(struct nlist)); for (i = 0; i < nname ; i++) { /* The segment names can be omitted */ convert_name( &symbol_table[i], u_name++); @@ -107,7 +107,7 @@ reduce_name_table() #define removable(nm) (!(nm->on_type & (S_NEEDED|S_STB)) && *(nm->on_foff+string_area) == GENLAB) int *diff_index = - (int *) Malloc((unsigned)(nname + 1) * sizeof(int)); + (int *) malloc((unsigned)(nname + 1) * sizeof(int)); int i; struct outname *np; char *new_str; @@ -162,7 +162,7 @@ reduce_name_table() nname -= diff_index[nname - 1]; free((char *)(diff_index-1)); - new_str = q = Malloc((unsigned)(string - string_area)); + new_str = q = malloc((unsigned)(string - string_area)); np = symbol_table; for (i = nname; i > 0; i--, np++) { p = np->on_foff + string_area; diff --git a/mach/vax4/ce/output.c b/mach/vax4/ce/output.c index 4b5e2a1359..c2db2f6121 100644 --- a/mach/vax4/ce/output.c +++ b/mach/vax4/ce/output.c @@ -43,7 +43,7 @@ output_back() nrelo = relo - reloc_info; u_reloc = (struct relocation_info *) - Malloc((unsigned)nrelo*sizeof(struct relocation_info)); + malloc((unsigned)nrelo*sizeof(struct relocation_info)); rp = reloc_info; for (i = nrelo; i > 0; i--, rp++) { @@ -76,7 +76,7 @@ output_back() free(u_reloc); u_name = (struct nlist *) - Malloc((unsigned)nname * sizeof(struct nlist)); + malloc((unsigned)nname * sizeof(struct nlist)); for (i = 0; i < nname ; i++) { /* The segment names can be omitted */ convert_name( &symbol_table[i], u_name++); @@ -107,7 +107,7 @@ reduce_name_table() #define removable(nm) (!(nm->on_type & (S_NEEDED|S_STB)) && *(nm->on_foff+string_area) == GENLAB) int *diff_index = - (int *) Malloc((unsigned)(nname + 1) * sizeof(int)); + (int *) malloc((unsigned)(nname + 1) * sizeof(int)); int i; struct outname *np; char *new_str; @@ -162,7 +162,7 @@ reduce_name_table() nname -= diff_index[nname - 1]; free((char *)(diff_index-1)); - new_str = q = Malloc((unsigned)(string - string_area)); + new_str = q = malloc((unsigned)(string - string_area)); np = symbol_table; for (i = nname; i > 0; i--, np++) { p = np->on_foff + string_area; diff --git a/modules/src/alloc/Malloc.c b/modules/src/alloc/Malloc.c deleted file mode 100644 index 793334ea56..0000000000 --- a/modules/src/alloc/Malloc.c +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* M E M O R Y A L L O C A T I O N R O U T I N E S */ - -/* The memory allocation routines offered in this file are: - - char *Malloc(n) : allocate n bytes -*/ - -#if __STDC__ -#include -#else -extern char *malloc(); -#endif -#include "alloc.h" - -char *Malloc(unsigned int sz) -{ - char *res = malloc(sz); - - if (sz && res == 0) No_Mem(); - return res; -} diff --git a/modules/src/alloc/Realloc.c b/modules/src/alloc/Realloc.c deleted file mode 100644 index 29f946779d..0000000000 --- a/modules/src/alloc/Realloc.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* M E M O R Y A L L O C A T I O N R O U T I N E S */ - -/* The memory allocation routines offered in this file are: - - char *Realloc(ptr, n) : reallocate buffer to n bytes -*/ - -#if __STDC__ -#include -#else -extern char *malloc(); -extern char *realloc(); -#endif - -#include "alloc.h" - -char *Realloc(char ptr[], unsigned int sz) -{ - char *mptr; - - if (!ptr) mptr = malloc(sz); - else mptr = realloc(ptr, sz); - if (sz && mptr == 0) No_Mem(); - return mptr; -} diff --git a/modules/src/alloc/Srealloc.c b/modules/src/alloc/Srealloc.c deleted file mode 100644 index 32ddf9a928..0000000000 --- a/modules/src/alloc/Srealloc.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* M E M O R Y A L L O C A T I O N R O U T I N E S */ - -/* The memory allocation routines offered in this file are: - - char *Srealloc(ptr, n) : reallocate buffer to n bytes -*/ - -#include "alloc.h" - -char *Srealloc(char str[], unsigned int sz) -{ - return Realloc(str, sz); -} diff --git a/modules/src/alloc/alloc.3 b/modules/src/alloc/alloc.3 index 8cc7c32df0..f143bd48c8 100644 --- a/modules/src/alloc/alloc.3 +++ b/modules/src/alloc/alloc.3 @@ -5,14 +5,8 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc .SH SYNOPSIS .B #include .PP -.B char *Malloc(unsigned int size) -.PP .B char *Salloc(char *str, unsigned int size) .PP -.B char *Realloc(char *buf, unsigned int size) -.PP -.B char *Srealloc(char *str, unsigned int size) -.PP .B char *st_alloc(char **phead, unsigned int size, int count) .PP .B st_free(char *ptr, char **phead, unsigned int size) @@ -24,22 +18,9 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc .SH DESCRIPTION This set of routines provides a checking memory allocation mechanism. .PP -\fIMalloc\fR returns a pointer to a block of at least \fIsize\fR -bytes, beginning on a boundary suitable for any data type. -.PP \fISalloc\fR returns a pointer to a block of at least \fIsize\fR bytes, initialized with the null-terminated string \fIstr\fR. .PP -\fIRealloc\fR changes the size of -the block at \fIbuf\fR to \fIsize\fR bytes, and returns a pointer to the -(possibly moved) block. If \fIbuf\fP is a null pointer, \fIRealloc\fP -behaves as \fIMalloc\fP. -.PP -\fISrealloc\fR reallocates -the string at \fIstr\fR to \fIsize\fR bytes. -It actually does the same as \fIRealloc\fP, and exists only for -backwards compatibility. -.PP All these routines use \fImalloc\fR and \fIrealloc\fR. The routine \fIfree\fR can be used on pointers returned by these routines. .PP @@ -65,7 +46,7 @@ These last two routines are best used in a macro. .SH "SEE ALSO" malloc(3) .SH DIAGNOSTICS -\fIMalloc\fR, \fISalloc\fR, \fIRealloc\fP, \fISrealloc\fR, and \fIst_alloc\fR +\fISalloc\fR, \fISrealloc\fR, and \fIst_alloc\fR call a routine \fINo_Mem\fR if there is no memory available. This routine is not supposed to return. A default one, that gives an error message and stops execution, is provided. diff --git a/modules/src/alloc/alloc.h b/modules/src/alloc/alloc.h index 72d64736e4..a805d01e10 100644 --- a/modules/src/alloc/alloc.h +++ b/modules/src/alloc/alloc.h @@ -10,17 +10,12 @@ /* This file serves as the interface between the program and the memory allocating routines. There are 3 memory allocation routines: - char *Malloc(n) allocate n bytes + char *malloc(n) allocate n bytes char *Salloc(str, n) allocate n bytes and fill them with string str - char *Realloc(str, n) reallocate the block at str to n bytes. - char *Srealloc(str, n) same as Realloc. */ -char *Malloc(unsigned int); char *Salloc(char *, unsigned int); -char *Srealloc(char *, unsigned int); -char *Realloc(char *, unsigned int); char *st_alloc(char **, unsigned int, int); char *std_alloc(char **, unsigned int, int, int *); void No_Mem(void); @@ -45,6 +40,4 @@ typedef struct _ALLOC_ { _A_st_free(ptr, phead, size)) #endif /* BOTCH_FREE */ -#define Free(p) free(p) - #endif /* __ALLOC_INCLUDED__ */ diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua index 0012345797..371ea30d3b 100644 --- a/modules/src/alloc/build.lua +++ b/modules/src/alloc/build.lua @@ -3,11 +3,8 @@ clibrary { srcs = { "./botch.c", "./clear.c", - "./Malloc.c", "./No_Mem.c", - "./Realloc.c", "./Salloc.c", - "./Srealloc.c", "./st_alloc.c", "./std_alloc.c", }, diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index f0eeae41fa..6ad8ec89d6 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -62,12 +62,12 @@ void C_flush(void) if (C_ontmpfile) { if (C_BASE == 0) { - C_BASE = Malloc(BUFFERSIZ); + C_BASE = malloc(BUFFERSIZ); bufsiz = BUFFERSIZ; C_current_out = C_BASE; } else { - C_BASE = Srealloc(C_BASE, (bufsiz << 1)); + C_BASE = realloc(C_BASE, (bufsiz << 1)); C_current_out = C_BASE + bufsiz; bufsiz <<= 1; } diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index ae0aa80d1e..fc211b2a36 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -52,7 +52,7 @@ getbyte(b) } } if (! C_ibuf) { - C_ibuf = Malloc(BUFSIZ); + C_ibuf = malloc(BUFSIZ); } if (sys_read(C_tfr, C_ibuf, BUFSIZ, &n) == 0) { C_failed(); @@ -263,7 +263,7 @@ static Part *mkpart(int part) C_internal_error(); } - p = (Part *) Malloc(sizeof(Part)); + p = (Part *) malloc(sizeof(Part)); p->p_id = part; p->p_next = C_stable[index]; C_stable[index] = p; @@ -295,7 +295,7 @@ static void resume(Part *p) /* Resume part "p", by creating a new PartOfPart structure for it. */ - PartOfPart *pp = (PartOfPart *) Malloc(sizeof(PartOfPart)); + PartOfPart *pp = (PartOfPart *) malloc(sizeof(PartOfPart)); swttmp(); C_curr_part = p; @@ -334,7 +334,7 @@ void C_insertpart(int part) } /* Now, add the insertion of "part" to the current part. */ - pp = (PartOfPart *) Malloc(sizeof(PartOfPart)); + pp = (PartOfPart *) malloc(sizeof(PartOfPart)); pp->pp_next = p->p_parts; p->p_parts = pp; pp->pp_type = INSERT; diff --git a/modules/src/em_opt/nopt.c b/modules/src/em_opt/nopt.c index 939d3c21a0..e0f9489859 100644 --- a/modules/src/em_opt/nopt.c +++ b/modules/src/em_opt/nopt.c @@ -119,13 +119,13 @@ static void fatal(s, a) static void allocmem(void) { /* Allocate memory for queues on heap */ - OO_buffer = (p_instr) Malloc( + OO_buffer = (p_instr) malloc( (unsigned) (MAXBUFFER * sizeof(struct e_instr))); OO_patternqueue = OO_nxtpatt = OO_buffer; - OO_replqueue = (p_instr) Malloc( + OO_replqueue = (p_instr) malloc( (unsigned) OO_maxreplacement * sizeof(struct e_instr)); OO_nxtrepl = OO_replqueue; - nextstr = strqueue = (char *) Malloc(MAXSTRING * sizeof(char)); + nextstr = strqueue = (char *) malloc(MAXSTRING * sizeof(char)); laststr = strqueue + MAXSTRING - 1; } @@ -138,7 +138,7 @@ char * OO_freestr(char *str) again: if ((s - str) > (laststr - nextstr)) { unsigned newsize = (laststr - strqueue + 1) * 2; - res = Realloc(strqueue, newsize); + res = realloc(strqueue, newsize); laststr = res + newsize - 1; nextstr = res + (nextstr - strqueue); strqueue = res; diff --git a/modules/src/em_opt/outputdfa.c b/modules/src/em_opt/outputdfa.c index d6b3d69d2d..d38a392888 100644 --- a/modules/src/em_opt/outputdfa.c +++ b/modules/src/em_opt/outputdfa.c @@ -127,8 +127,8 @@ static void increase_next(unsigned int size) } while (newsize < size); printf("Note: Extending next/check arrays from %d to %d\n", currsize, newsize); - next = (int *) Realloc(next, newsize); - check = (int *) Realloc(check, newsize); + next = (int *) realloc(next, newsize); + check = (int *) realloc(check, newsize); /* clear ends of new arrays */ for (i = currsize; i < newsize; i++) next[i] = check[i] = EMPTY; @@ -189,9 +189,9 @@ static void outdfa(void) numentries++; /* start with next and check arrays twice this size */ currsize = 2 * numentries; - next = (int *) Malloc(currsize * sizeof(int)); - check = (int *) Malloc(currsize * sizeof(int)); - base = (int *) Malloc(((unsigned) (higheststate + 1)) * sizeof(int)); + next = (int *) malloc(currsize * sizeof(int)); + check = (int *) malloc(currsize * sizeof(int)); + base = (int *) malloc(((unsigned) (higheststate + 1)) * sizeof(int)); /* fill next array with EMPTY */ for (i = 0; i < currsize; i++) check[i] = next[i] = EMPTY; @@ -375,7 +375,7 @@ static void outdotrans(void) int *farray; fprintf(ofile, "#include \"nopt.h\"\n\n"); /* keep track of which procedure used for each state */ - farray = (int *) Malloc((unsigned) (higheststate + 1) * sizeof(int)); + farray = (int *) malloc((unsigned) (higheststate + 1) * sizeof(int)); for (s = 0; s <= higheststate; s++) farray[s] = EMPTY; /* output the functions avoiding duplicates */ diff --git a/modules/src/em_opt/parser.g b/modules/src/em_opt/parser.g index 719fec156b..1ab6f7b20f 100644 --- a/modules/src/em_opt/parser.g +++ b/modules/src/em_opt/parser.g @@ -345,7 +345,7 @@ void addaction(int startline, int state, struct exp_node *restrictions, struct exp_node *finaltest, struct mnem_list *repllist) { struct action *p, *q; - p=(struct action *)Malloc(sizeof(struct action)); + p=(struct action *)malloc(sizeof(struct action)); p->next = (struct action *)NULL; p->linenum = startline; p->test = combinetests(restrictions,finaltest); @@ -365,7 +365,7 @@ struct mnem_elem **constructlist(struct mnem_list *list, int len) { struct mnem_elem **p; p = (struct mnem_elem **) - Malloc((unsigned)(len*sizeof(struct mnem_elem *))); + malloc((unsigned)(len*sizeof(struct mnem_elem *))); while(len--) { p[len] = list->elem; list = list->next; @@ -379,10 +379,10 @@ struct mnem_list *addelem(struct mnem_list *oldlist, { struct mnem_list *reslist; struct mnem_elem *element; - element = (struct mnem_elem *)Malloc(sizeof(struct mnem_elem)); + element = (struct mnem_elem *)malloc(sizeof(struct mnem_elem)); element->op_code = mnem; element->arg = test; - reslist = (struct mnem_list *)Malloc(sizeof(struct mnem_list)); + reslist = (struct mnem_list *)malloc(sizeof(struct mnem_list)); reslist->elem = element; reslist->next = oldlist; return(reslist); @@ -402,7 +402,7 @@ int dotransition( ); if(p==(struct state *)NULL) { /* none found so add a new state to dfa */ - p=(struct state *)Malloc(sizeof(struct state)); + p=(struct state *)malloc(sizeof(struct state)); p->op=mnem; if(++higheststate>MAXSTATES) { fprintf(stderr,"Parser: More than %d states\n",MAXSTATES); @@ -466,7 +466,7 @@ struct exp_node *mknode(int op, struct exp_node *left, struct exp_node *right) { struct exp_node *p; - p = (struct exp_node *)Malloc(sizeof(struct exp_node)); + p = (struct exp_node *)malloc(sizeof(struct exp_node)); p->node_type = op; p->exp_left = left; p->exp_right = right; @@ -476,7 +476,7 @@ struct exp_node *mknode(int op, struct exp_node *left, struct exp_node *mkleaf(int op, int val) { struct exp_node *p; - p = (struct exp_node *)Malloc(sizeof(struct exp_node)); + p = (struct exp_node *)malloc(sizeof(struct exp_node)); p->node_type = op; p->leaf_val = val; return(p); diff --git a/modules/src/idf/idf_pkg.body b/modules/src/idf/idf_pkg.body index 8523289f5a..d14fe8b173 100644 --- a/modules/src/idf/idf_pkg.body +++ b/modules/src/idf/idf_pkg.body @@ -1,6 +1,7 @@ /* SYMBOL TABLE HANDLING */ #include +#include #define IDF_HASHSIZE 307 /* size of hashtable, must be odd */ @@ -38,7 +39,7 @@ static struct idf* IDF_new(char* tg, int size, int cpy) if (!nidf--) { nidf += NIDS; - pidf = (struct idf*)Malloc(NIDS * sizeof(struct idf)); + pidf = (struct idf*)malloc(NIDS * sizeof(struct idf)); } id = pidf; @@ -50,7 +51,7 @@ static struct idf* IDF_new(char* tg, int size, int cpy) if (size > icnt) { icnt = size > IBUFSIZ ? size : IBUFSIZ; - p = Malloc(icnt); + p = malloc(icnt); } else p = ip; diff --git a/modules/src/read_em/reade.c b/modules/src/read_em/reade.c index 28c49595d0..4907ced00c 100644 --- a/modules/src/read_em/reade.c +++ b/modules/src/read_em/reade.c @@ -172,7 +172,7 @@ static struct string *getname(void) p = s->str; if (!p) { s->maxlen = 256; - s->str = p = Malloc(256); + s->str = p = malloc(256); } c = getbyte(); @@ -185,7 +185,7 @@ static struct string *getname(void) while (isalnum(c) || c == '_') { if (p >= &(s->str[s->maxlen])) { int df = p - s->str; - s->str = Realloc(s->str, (s->maxlen += 256)); + s->str = realloc(s->str, (s->maxlen += 256)); p = s->str + df; } *p++ = c; @@ -211,7 +211,7 @@ static struct string *getstring(int isident) p = s->str; if (!p) { s->maxlen = 256; - s->str = p = Malloc(256); + s->str = p = malloc(256); } termc = getbyte(); @@ -237,7 +237,7 @@ static struct string *getstring(int isident) if (p >= &(s->str[s->maxlen])) { int df = p - s->str; - s->str = Realloc(s->str, (s->maxlen += 256)); + s->str = realloc(s->str, (s->maxlen += 256)); p = s->str + df; } diff --git a/modules/src/read_em/readk.c b/modules/src/read_em/readk.c index 1d36b3e4ca..a16d98a8b5 100644 --- a/modules/src/read_em/readk.c +++ b/modules/src/read_em/readk.c @@ -228,9 +228,9 @@ static struct string *getstring(int isident) if (n > s->maxlen) { if (! s->maxlen) { - s->str = Malloc(s->maxlen = 256); + s->str = malloc(s->maxlen = 256); } - else s->str = Realloc(s->str, (s->maxlen = (n+255)&~255)); + else s->str = realloc(s->str, (s->maxlen = (n+255)&~255)); } s->length = n; diff --git a/util/LLgen/lib/nc_rec b/util/LLgen/lib/nc_rec index 2b4523777b..2baf20faee 100644 --- a/util/LLgen/lib/nc_rec +++ b/util/LLgen/lib/nc_rec @@ -20,7 +20,7 @@ struct stacks { /* Acces to the stacks is through a 'dynamic array' of pointers * to the heads. We implemented it this way to save on the number - * of Malloc() calls. nr_heads is the number of heads; heads_buf_size + * of malloc() calls. nr_heads is the number of heads; heads_buf_size * is the current size of heads_buf. */ @@ -118,8 +118,8 @@ static struct nonterminal *nonterminals; /* These functions must be called instead of the original functions in * 'malloc.h'. They offer a checking allocation mechanism. */ -static void *Malloc(size_t); -static void *Realloc(void *, size_t); +static void *malloc(size_t); +static void *realloc(void *, size_t); @@ -164,7 +164,7 @@ void LLnc_recover(void); -static void *Malloc(size_t size) +static void *malloc(size_t size) { void *p; @@ -176,7 +176,7 @@ static void *Malloc(size_t size) } -static void *Realloc(void *ptr, size_t size) +static void *realloc(void *ptr, size_t size) { void *p; @@ -195,13 +195,13 @@ static void init_grammar(void) int i; terminals = (struct terminal *) - Malloc(LLFIRST_NT * sizeof(struct terminal)); + malloc(LLFIRST_NT * sizeof(struct terminal)); for (i = 0; i < LLFIRST_NT; i++) { (terminals + i)->link = (struct symbol *)0; } nonterminals = (struct nonterminal *) - Malloc(LLNNONTERMINALS * sizeof(struct nonterminal)); + malloc(LLNNONTERMINALS * sizeof(struct nonterminal)); for (i = 0; i < LLNNONTERMINALS; i++) { (nonterminals + i)->rule = (struct lhs *)0; (nonterminals + i)->link = (struct symbol *)0; @@ -232,7 +232,7 @@ static struct lhs *build_rule(void) struct lhs *l; int j; - l = (struct lhs *)Malloc(sizeof(struct lhs)); + l = (struct lhs *)malloc(sizeof(struct lhs)); l->nr = LLgrammar[grammar_index++]; /* Build first set */ @@ -262,7 +262,7 @@ static struct symbol *build_rhs(struct lhs *l) struct symbol *r; - r = (struct symbol *)Malloc(sizeof(struct symbol)); + r = (struct symbol *)malloc(sizeof(struct symbol)); if (LLgrammar[grammar_index] == LLALT) { grammar_index++; r->x = LLALT; @@ -422,7 +422,7 @@ static void start_stack(struct stacks *stack, int base, int l_ahead) } #endif bottom = (struct stack_elt *) - Malloc(sizeof(struct stack_elt)); + malloc(sizeof(struct stack_elt)); bottom->edges = (struct edge *)0; bottom->nr = LLEOSTACK; bottom->flags = 0; @@ -529,7 +529,7 @@ of the stack.*/ } #endif bottom = (struct stack_elt *) - Malloc(sizeof(struct stack_elt)); + malloc(sizeof(struct stack_elt)); bottom->edges = (struct edge *)0; bottom->nr = LLEOSTACK; bottom->flags = 0; @@ -597,7 +597,7 @@ static struct stack_elt *push_rule(struct stack_elt *element, } #endif - se = (struct stack_elt *)Malloc(sizeof(struct stack_elt)); + se = (struct stack_elt *)malloc(sizeof(struct stack_elt)); se->flags = 0; se->nr = symb_ptr->nr; se->ref_count = 0; @@ -612,7 +612,7 @@ static struct stack_elt *push_rule(struct stack_elt *element, } #endif - se->edges = (struct edge *)Malloc(sizeof(struct edge)); + se->edges = (struct edge *)malloc(sizeof(struct edge)); se->edges->ptr = top; se->edges->flags = 0; @@ -631,13 +631,13 @@ static void new_head(struct stacks *stack, struct stack_elt *ptr) if (stack->heads_buf_size == 0) { stack->heads_buf_size = LLHEADS_BUF_INCR; stack->heads_buf = (struct stack_elt **) - Malloc(LLHEADS_BUF_INCR * sizeof(struct stack_elt *)); + malloc(LLHEADS_BUF_INCR * sizeof(struct stack_elt *)); } else if (stack->nr_heads == stack->heads_buf_size) { /* buffer full? */ stack->heads_buf_size += LLHEADS_BUF_INCR; stack->heads_buf = (struct stack_elt **) - Realloc(stack->heads_buf, + realloc(stack->heads_buf, stack->heads_buf_size * sizeof(struct stack_elt *) ); @@ -671,12 +671,12 @@ static void to_delete(struct stacks *stack, struct stack_elt *ptr) if (stack->cleanup_buf_size == 0) { stack->cleanup_buf_size = LLCLEANUP_BUF_INCR; stack->cleanup_buf = (struct stack_elt **) - Malloc(LLCLEANUP_BUF_INCR * sizeof(struct stack_elt *)); + malloc(LLCLEANUP_BUF_INCR * sizeof(struct stack_elt *)); } else if (stack->nr_cleanups == stack->cleanup_buf_size) { stack->cleanup_buf_size += LLCLEANUP_BUF_INCR; stack->cleanup_buf = (struct stack_elt **) - Realloc(stack->cleanup_buf, + realloc(stack->cleanup_buf, stack->cleanup_buf_size * sizeof(struct stack_elt *)); } @@ -789,7 +789,7 @@ static int join(struct stacks *stack, struct stack_elt *top, int l_ahead) /* Allocate one more pointer to descendants */ size = se->nr_nexts * sizeof(struct edge); - se->edges = (struct edge *)Realloc(se->edges, size); + se->edges = (struct edge *)realloc(se->edges, size); /* Link it */ (se->edges + se->nr_nexts - 1)->ptr = top->edges->ptr; @@ -897,12 +897,12 @@ static void generate_heads(struct stacks *stack, struct stack_elt *se, if (stack->visited_buf_size == 0) { stack->visited_buf_size = LL_VIS_INCR; stack->visited_buf = (struct stack_elt **) - Malloc(LL_VIS_INCR * sizeof(struct stack_elt *)); + malloc(LL_VIS_INCR * sizeof(struct stack_elt *)); } else if (stack->nr_visited == stack->visited_buf_size) { stack->visited_buf_size += LL_VIS_INCR; stack->visited_buf = (struct stack_elt **) - Realloc(stack->visited_buf, + realloc(stack->visited_buf, stack->visited_buf_size * sizeof(struct stack_elt *)); } @@ -1071,7 +1071,7 @@ static struct stack_elt *split(struct stack_elt *se) } #endif - new_stack = (struct stack_elt *)Malloc(sizeof(struct stack_elt)); + new_stack = (struct stack_elt *)malloc(sizeof(struct stack_elt)); new_stack->flags = 0; /* Used by 'clear_gen_flags()' */ new_stack->nr = se->nr; new_stack->ref_count = 0; /* Copy is new top */ @@ -1087,7 +1087,7 @@ static struct stack_elt *split(struct stack_elt *se) #endif new_stack->edges = (struct edge *) - Malloc(se->nr_nexts * sizeof(struct edge)); + malloc(se->nr_nexts * sizeof(struct edge)); /* Copy gets the same successors as the original */ memcpy((char *) new_stack->edges, (char *) se->edges, @@ -1240,13 +1240,13 @@ static void match_heads(struct stacks *stack, int symb) if (stack->heads_buf_size == 0) { stack->heads_buf_size = LLHEADS_BUF_INCR; stack->heads_buf = (struct stack_elt **) - Malloc(stack->heads_buf_size * + malloc(stack->heads_buf_size * sizeof(struct stack_elt *)); } else if (stack->nr_heads == stack->heads_buf_size) { stack->heads_buf_size += LLHEADS_BUF_INCR; stack->heads_buf = (struct stack_elt **) - Realloc(stack->heads_buf, + realloc(stack->heads_buf, stack->heads_buf_size * sizeof(struct stack_elt *)); } diff --git a/util/ceg/EM_parser/common/action.c b/util/ceg/EM_parser/common/action.c index f13af78cc2..4776295059 100644 --- a/util/ceg/EM_parser/common/action.c +++ b/util/ceg/EM_parser/common/action.c @@ -23,7 +23,7 @@ init_as_block() if ( quantum == 0) { quantum = 16; - as_instructions = (char **)Malloc( quantum*sizeof( char *)); + as_instructions = (char **)malloc( quantum*sizeof( char *)); } } @@ -36,7 +36,7 @@ char *instr; { if ( nr_instr == quantum) { quantum *= 2; - as_instructions = (char **) Realloc( (char *) as_instructions, + as_instructions = (char **) realloc( (char *) as_instructions, quantum*sizeof( char *)); } diff --git a/util/ceg/as_parser/pars.g b/util/ceg/as_parser/pars.g index ee0b494519..23b28dbbc3 100644 --- a/util/ceg/as_parser/pars.g +++ b/util/ceg/as_parser/pars.g @@ -108,7 +108,7 @@ action : if_statement subroutine { char *s; } : IDENTIFIER { s = Salloc(yytext, yyleng+1); } - CONDITION { s = Realloc(s, strlen(s)+yyleng+1); + CONDITION { s = realloc(s, strlen(s)+yyleng+1); strcat(s, yytext); pr_subroutine( s); free(s); @@ -118,7 +118,7 @@ subroutine call { char *s; } : '@' IDENTIFIER { s = Salloc(yytext, yyleng+1); } - CONDITION { s = Realloc(s, strlen(s)+yyleng+1); + CONDITION { s = realloc(s, strlen(s)+yyleng+1); strcat(s, yytext); pr_call( s); free(s); diff --git a/util/ceg/ce_back/obj_back/init_back.c b/util/ceg/ce_back/obj_back/init_back.c index b97d8d5b64..a38a77bfcc 100644 --- a/util/ceg/ce_back/obj_back/init_back.c +++ b/util/ceg/ce_back/obj_back/init_back.c @@ -10,13 +10,13 @@ init_back() /* Allocate space for the tables and set the default values. */ { - text_area = Malloc( MAXTEXT); - data_area = Malloc( MAXDATA); - reloc_info = (struct outrelo *)Malloc( MAXRELO* sizeof(struct outrelo)); - symbol_table = (struct outname *)Malloc( MAXNAME* sizeof(struct outname)); - Hashitems = (struct Hashitem *)Malloc( (MAXNAME + 1)* + text_area = malloc( MAXTEXT); + data_area = malloc( MAXDATA); + reloc_info = (struct outrelo *)malloc( MAXRELO* sizeof(struct outrelo)); + symbol_table = (struct outname *)malloc( MAXNAME* sizeof(struct outname)); + Hashitems = (struct Hashitem *)malloc( (MAXNAME + 1)* sizeof( struct Hashitem)); - string_area = Malloc( MAXSTRING); + string_area = malloc( MAXSTRING); text = text_area; data = data_area; diff --git a/util/ceg/ce_back/obj_back/memory.c b/util/ceg/ce_back/obj_back/memory.c index 17fb68dd8b..c860c28a2b 100644 --- a/util/ceg/ce_back/obj_back/memory.c +++ b/util/ceg/ce_back/obj_back/memory.c @@ -14,7 +14,7 @@ mem_text() /* print( "text_area too small %d %d \n", text_area, text); */ int diff = text - text_area; - text_area = Realloc( text_area, sizeof( char) * 2 * size_text); + text_area = realloc( text_area, sizeof( char) * 2 * size_text); text = text_area + diff; text_cnt += size_text; size_text = 2 * size_text; @@ -26,7 +26,7 @@ mem_data() /* print( "data_area too small\n"); */ int diff = data - data_area; - data_area = Realloc( data_area, sizeof( char) * 2 * size_data); + data_area = realloc( data_area, sizeof( char) * 2 * size_data); data = data_area + diff; data_cnt += size_data; size_data = 2 * size_data; @@ -38,12 +38,12 @@ mem_symbol_hash() /* print( "symbol_table out of memory\n"); */ size_symbol = 2 * size_symbol; - symbol_table = (struct outname *) Realloc( (char *) symbol_table, + symbol_table = (struct outname *) realloc( (char *) symbol_table, sizeof( struct outname) * size_symbol); /* print( "hash out of memory\n"); */ - Hashitems = (struct Hashitem *) Realloc( (char *) Hashitems, + Hashitems = (struct Hashitem *) realloc( (char *) Hashitems, sizeof( struct Hashitem)*(size_symbol+1)); } @@ -53,7 +53,7 @@ mem_relo() /* print( "reloc_table out of memory\n"); */ int diff = relo - reloc_info; - reloc_info = (struct outrelo *) Realloc( (char *) reloc_info, + reloc_info = (struct outrelo *) realloc( (char *) reloc_info, sizeof( struct outrelo) * 2 * size_reloc); relo = reloc_info + diff; size_reloc = 2 * size_reloc; @@ -67,6 +67,6 @@ mem_string() /* print( "string_area out of memory %d %d \n", string_area, string);*/ size_string = 2 * size_string; - string_area = Realloc( string_area, sizeof( char) * size_string); + string_area = realloc( string_area, sizeof( char) * size_string); string = string_area + diff; } diff --git a/util/ceg/ce_back/obj_back/output.c b/util/ceg/ce_back/obj_back/output.c index 9c3cf2ad70..5f519de61a 100644 --- a/util/ceg/ce_back/obj_back/output.c +++ b/util/ceg/ce_back/obj_back/output.c @@ -98,7 +98,7 @@ reduce_name_table() #define removable(nm) (!(nm->on_type & (S_NEEDED|S_STB)) && *(nm->on_foff+string_area) == GENLAB) int *diff_index = - (int *) Malloc((unsigned)(nname + 1) * sizeof(int)); + (int *) malloc((unsigned)(nname + 1) * sizeof(int)); struct outrelo *rp = reloc_info; struct outname *np; int i; @@ -147,7 +147,7 @@ reduce_name_table() free((char *)(diff_index-1)); - new_str = q = Malloc((unsigned)(string - string_area)); + new_str = q = malloc((unsigned)(string - string_area)); for (i = 0, np = symbol_table; i < nname; i++, np++) { p = np->on_foff + string_area; np->on_foff = q - new_str; diff --git a/util/cmisc/cclash.c b/util/cmisc/cclash.c index 804a647eab..d4df485a4a 100644 --- a/util/cmisc/cclash.c +++ b/util/cmisc/cclash.c @@ -59,7 +59,7 @@ char* keywords[] "struct", "switch", "typedef", "union", "unsigned", "while", 0 }; void InsertId(char*, int); -char* Malloc(unsigned int); +char* malloc(unsigned int); char* Salloc(char*); int EnHash(char*); void EndOfProgram(void); @@ -111,7 +111,7 @@ void DoOption(char* str) struct idf* hash_tab[HASHSIZE]; -char *Malloc(), *Salloc(); +char *malloc(), *Salloc(); void InsertId(char* id, int key) { @@ -127,7 +127,7 @@ void InsertId(char* id, int key) if (idp == 0) { - idp = (struct idf*)Malloc(sizeof(struct idf)); + idp = (struct idf*)malloc(sizeof(struct idf)); idp->id_next = 0; if (!p) hash_tab[hash_val] = idp; @@ -147,7 +147,7 @@ void InsertId(char* id, int key) if (p == 0) { - p = (struct idf*)Malloc(sizeof(struct idf)); + p = (struct idf*)malloc(sizeof(struct idf)); p->id_next = 0; p->id_same = 0; p->id_name = Salloc(id); @@ -157,7 +157,7 @@ void InsertId(char* id, int key) p->id_key = key; } -char* Malloc(unsigned n) +char* malloc(unsigned n) { char* mem; @@ -174,7 +174,7 @@ char* Salloc(char* str) if (str == 0) str = ""; - return strcpy(Malloc((unsigned)strlen(str) + 1), str); + return strcpy(malloc((unsigned)strlen(str) + 1), str); } int EnHash(char* id) diff --git a/util/cmisc/cid.c b/util/cmisc/cid.c index 57a365ea7a..1245e5e238 100644 --- a/util/cmisc/cid.c +++ b/util/cmisc/cid.c @@ -34,7 +34,7 @@ struct idf struct idf* hash_tab[HASHSIZE]; -char* Malloc(unsigned int); +char* malloc(unsigned int); char* Salloc(char*); int EnHash(char*); void EndOfProgram(void); @@ -151,7 +151,7 @@ void InsertMacro(char* id, char* text) if (idp == 0) { - idp = (struct idf*)Malloc(sizeof(struct idf)); + idp = (struct idf*)malloc(sizeof(struct idf)); } idp->id_next = hash_tab[hash_val]; @@ -160,7 +160,7 @@ void InsertMacro(char* id, char* text) hash_tab[hash_val] = idp; } -char* Malloc(unsigned int n) +char* malloc(unsigned int n) { char* mem; @@ -178,7 +178,7 @@ char* Salloc(char* str) { str = ""; } - return strcpy(Malloc((unsigned)strlen(str) + 1), str); + return strcpy(malloc((unsigned)strlen(str) + 1), str); } struct idf* FindId(char* id) diff --git a/util/cmisc/mkdep.c b/util/cmisc/mkdep.c index 4e193e6ac6..ef148fa179 100644 --- a/util/cmisc/mkdep.c +++ b/util/cmisc/mkdep.c @@ -28,12 +28,12 @@ struct namelist* freelist; struct namelist* new_namelist(); struct namelist* nl = 0; -char* Malloc(unsigned int); +char* malloc(unsigned int); char* include_line(char*); int dofile(char*); -char* Malloc(u) +char* malloc(u) unsigned u; { char* sp; @@ -56,7 +56,7 @@ struct namelist* new_namelist() return nlp; } - return (struct namelist*)Malloc(sizeof(struct namelist)); + return (struct namelist*)malloc(sizeof(struct namelist)); } void free_namelist(struct namelist* nlp) @@ -84,7 +84,7 @@ void add_name(char* nm) nlp = nlp->next; } - (nnlp = new_namelist())->name = strcpy(Malloc((unsigned)strlen(nm) + 1), nm); + (nnlp = new_namelist())->name = strcpy(malloc((unsigned)strlen(nm) + 1), nm); if (lnlp) { diff --git a/util/cmisc/prid.c b/util/cmisc/prid.c index 0045d63d21..fca8b632bc 100644 --- a/util/cmisc/prid.c +++ b/util/cmisc/prid.c @@ -26,7 +26,7 @@ extern char* ProgName; int maxlen = DEF_LENGTH; void InsertId(char*); -char* Malloc(unsigned int); +char* malloc(unsigned int); char* Salloc(char*); int EnHash(char*); void EndOfProgram(void); @@ -88,7 +88,7 @@ void InsertId(char* id) if (idp == 0) { - idp = (struct idf*)Malloc(sizeof(struct idf)); + idp = (struct idf*)malloc(sizeof(struct idf)); idp->id_next = 0; if (!p) hash_tab[hash_val] = idp; @@ -98,7 +98,7 @@ void InsertId(char* id) } } -char* Malloc(unsigned int n) +char* malloc(unsigned int n) { char* mem; @@ -116,7 +116,7 @@ char* Salloc(char* str) if (str == 0) str = ""; - return strcpy(Malloc((unsigned)strlen(str) + 1), str); + return strcpy(malloc((unsigned)strlen(str) + 1), str); } int EnHash(char* id) diff --git a/util/grind/db_symtab.g b/util/grind/db_symtab.g index 00fcc050a2..e996721ea0 100644 --- a/util/grind/db_symtab.g +++ b/util/grind/db_symtab.g @@ -217,7 +217,7 @@ const_name(p_symbol cst;) 'S' type_index(type_index) { cst->sy_type = *tp_lookup(type_index); cst->sy_const.co_setval = p = - Malloc((unsigned) cst->sy_type->ty_size); + malloc((unsigned) cst->sy_type->ty_size); } [ ',' integer_const(&iconst) { *p++ = iconst; } @@ -530,7 +530,7 @@ param_list(p_type t;) integer_const(&iconst) ';' /* number of parameters */ { t->ty_nparams = iconst; t->ty_params = p = (struct param *) - Malloc((unsigned)(t->ty_nparams * sizeof(struct param))); + malloc((unsigned)(t->ty_nparams * sizeof(struct param))); } [ [ 'p' { p->par_kind = 'p'; } @@ -682,7 +682,7 @@ get_field_space(tp, s) if (! (tp->ty_nfields & 07)) { tp->ty_fields = (struct fields *) - Realloc((char *) tp->ty_fields, + realloc((char *) tp->ty_fields, (tp->ty_nfields+8)*sizeof(struct fields)); } p = &tp->ty_fields[tp->ty_nfields++]; @@ -698,7 +698,7 @@ end_field(tp) p_type tp; { tp->ty_fields = (struct fields *) - Realloc((char *) tp->ty_fields, + realloc((char *) tp->ty_fields, tp->ty_nfields * sizeof(struct fields)); } @@ -708,7 +708,7 @@ get_literal_space(tp) { if (! (tp->ty_nenums & 07)) { tp->ty_literals = (struct literal *) - Realloc((char *) tp->ty_literals, + realloc((char *) tp->ty_literals, (tp->ty_nenums+8)*sizeof(struct literal)); } return &tp->ty_literals[tp->ty_nenums++]; @@ -765,8 +765,8 @@ DbRead(f) /* Allocate space for name table and read it */ AckNames = (struct outname *) - Malloc((unsigned)(sizeof(struct outname) * h.oh_nname)); - AckStrings = Malloc((unsigned) h.oh_nchar); + malloc((unsigned)(sizeof(struct outname) * h.oh_nname)); + AckStrings = malloc((unsigned) h.oh_nchar); rd_name(AckNames, h.oh_nname); rd_string(AckStrings, h.oh_nchar); diff --git a/util/grind/expr.c b/util/grind/expr.c index b549dc6f84..065be46d20 100644 --- a/util/grind/expr.c +++ b/util/grind/expr.c @@ -763,7 +763,7 @@ arith_op(p, pbuf, psize, ptp) } l2 = get_int(buf, size, T_UNSIGNED); free(buf); - *pbuf = Realloc(*pbuf, (unsigned) long_size); + *pbuf = realloc(*pbuf, (unsigned) long_size); put_int(*pbuf, long_size, (l1 - l2)/(*ptp)->ty_ptrto->ty_size); *ptp = long_type; return 1; diff --git a/util/grind/list.c b/util/grind/list.c index 677f5547a5..072dbb77dd 100644 --- a/util/grind/list.c +++ b/util/grind/list.c @@ -22,7 +22,7 @@ mk_filnm(dir, file, newname) char *file; char **newname; { - char *dst = Malloc((unsigned) (strlen(dir) + strlen(file) + 2)); + char *dst = malloc((unsigned) (strlen(dir) + strlen(file) + 2)); *newname = dst; if (*dir) { @@ -111,7 +111,7 @@ line_positions(file, f) long cnt = 0; int c; - file->f_linepos = (long *) Malloc(n_alloc * sizeof(long)); + file->f_linepos = (long *) malloc(n_alloc * sizeof(long)); file->f_linepos[0] = 0; nl = 1; while ((c = getc(f)) != EOF) { @@ -120,14 +120,14 @@ line_positions(file, f) if (nl == n_alloc) { n_alloc <<= 1; file->f_linepos = - (long *) Realloc((char *)(file->f_linepos), + (long *) realloc((char *)(file->f_linepos), n_alloc * sizeof(long)); } file->f_linepos[nl++] = cnt; } } if (cnt == file->f_linepos[nl-1]) nl--; - file->f_linepos = (long *) Realloc((char *)(file->f_linepos), + file->f_linepos = (long *) realloc((char *)(file->f_linepos), (unsigned)nl * sizeof(long)); file->f_nlines = nl; clearerr(f); diff --git a/util/grind/rd.c b/util/grind/rd.c index 3d6c243fb9..437992ee15 100644 --- a/util/grind/rd.c +++ b/util/grind/rd.c @@ -477,7 +477,7 @@ rd_ohead(h) if (dt->d_size == 0) { fatal("(part of) symbol table is missing"); } - dbtab = (struct nlist *) Malloc(dt->d_size); + dbtab = (struct nlist *) malloc(dt->d_size); memcpy((char *) dbtab, (char *) dt->d_buf, dt->d_size); maxdn = (struct nlist *)((char *)dbtab+dt->d_size); break; diff --git a/util/grind/type.c b/util/grind/type.c index 6364de708c..c91eee77b8 100644 --- a/util/grind/type.c +++ b/util/grind/type.c @@ -290,11 +290,11 @@ tp_lookup(type_index) while (type_index[0] >= list_len) { if (list_len) { - list_row = (struct tp_index *) Realloc((char *) list_row, + list_row = (struct tp_index *) realloc((char *) list_row, (list_len += NINCR) * sizeof(struct tp_index)); } else list_row = (struct tp_index *) - Malloc((list_len = NINCR) * sizeof(struct tp_index)); + malloc((list_len = NINCR) * sizeof(struct tp_index)); for (i = NINCR; i > 0; i--) { list_row[list_len - i].len = 0; } @@ -303,12 +303,12 @@ tp_lookup(type_index) while (type_index[1] >= p->len) { int indx = p->len/NINCR; if (p->len) { - p->row = (p_type **) Realloc((char *) p->row, + p->row = (p_type **) realloc((char *) p->row, (unsigned) (indx + 1) * sizeof(p_type *)); } - else p->row = (p_type **) Malloc(sizeof(p_type *)); + else p->row = (p_type **) malloc(sizeof(p_type *)); p->len += NINCR; - p->row[indx] = (p_type *) Malloc(NINCR * sizeof(p_type)); + p->row[indx] = (p_type *) malloc(NINCR * sizeof(p_type)); for (i = NINCR-1; i >= 0; i--) { p->row[indx][i] = 0; } @@ -352,7 +352,7 @@ end_literal(tp, maxval) long maxval; { tp->ty_literals = (struct literal *) - Realloc((char *) tp->ty_literals, + realloc((char *) tp->ty_literals, tp->ty_nenums * sizeof(struct literal)); if (ufit(maxval, 1)) tp->ty_size = 1; else if (ufit(maxval, (int)short_size)) tp->ty_size = short_size; @@ -396,7 +396,7 @@ add_param_type(v, s) return; } prc_type->ty_nparams++; - prc_type->ty_params = (struct param *) Realloc((char *) prc_type->ty_params, + prc_type->ty_params = (struct param *) realloc((char *) prc_type->ty_params, (unsigned)prc_type->ty_nparams * sizeof(struct param)); prc_type->ty_params[prc_type->ty_nparams - 1].par_type = s->sy_type; prc_type->ty_params[prc_type->ty_nparams - 1].par_kind = v; From f9b150b15b42374f4650be63f56a012fa7b7f075 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 20 Nov 2024 16:57:16 +0100 Subject: [PATCH 02/29] Eliminate No_Mem(), which is largely useless on modern systems with overcommit. --- lang/cem/cemcom.ansi/main.c | 5 ----- lang/cem/cpp.ansi/main.c | 5 ----- lang/m2/comp/main.c | 5 ----- lang/m2/m2mm/main.c | 6 ------ lang/occam/comp/occam.g | 5 ----- modules/src/alloc/No_Mem.c | 15 --------------- modules/src/alloc/Salloc.c | 1 - modules/src/alloc/alloc.3 | 7 ------- modules/src/alloc/alloc.h | 1 - modules/src/alloc/build.lua | 1 - modules/src/alloc/st_alloc.c | 3 --- modules/src/alloc/std_alloc.c | 3 --- util/grind/main.c | 6 ------ util/grind/rd.c | 1 - 14 files changed, 64 deletions(-) delete mode 100644 modules/src/alloc/No_Mem.c diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 06e91ad082..a101eb0814 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -318,11 +318,6 @@ void Info(void) } #endif /* DEBUG */ -void No_Mem(void) /* called by alloc package */ -{ - fatal("out of memory"); -} - void C_failed(void) /* called by EM_code module */ { fatal("write failed"); diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index b515a736ef..d0c599612e 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -161,8 +161,3 @@ static void dependency(char *s, char *source) } else fprint(dep_fd, "%s\n", s); } - -void No_Mem(void) /* called by alloc package */ -{ - fatal("out of memory"); -} diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 1b6757cd34..2dc10e4756 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -288,11 +288,6 @@ print("\nNumber of lines read: %d\n", cntlines); } #endif -void No_Mem(void) -{ - fatal("out of memory"); -} - void C_failed(void) { fatal("write failed"); diff --git a/lang/m2/m2mm/main.c b/lang/m2/m2mm/main.c index 47114e0259..abb81ca9c1 100644 --- a/lang/m2/m2mm/main.c +++ b/lang/m2/m2mm/main.c @@ -208,12 +208,6 @@ ProcessArgs() } } -void -No_Mem() -{ - fatal("out of memory"); -} - AddToList(name, ext) char *name, *ext; { diff --git a/lang/occam/comp/occam.g b/lang/occam/comp/occam.g index 222ea95924..79290932cb 100644 --- a/lang/occam/comp/occam.g +++ b/lang/occam/comp/occam.g @@ -750,9 +750,4 @@ static void check_assoc(prev_op, op) register prev_op, op; } } -void -No_Mem() -{ - fatal("out of memory"); -} } diff --git a/modules/src/alloc/No_Mem.c b/modules/src/alloc/No_Mem.c deleted file mode 100644 index 2cd3fd0669..0000000000 --- a/modules/src/alloc/No_Mem.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include -#include -#include "alloc.h" - -void No_Mem(void) -{ - fprintf(stderr,"Out of memory\n"); - exit(1); -} diff --git a/modules/src/alloc/Salloc.c b/modules/src/alloc/Salloc.c index fbd3a9429e..aeb70ea996 100644 --- a/modules/src/alloc/Salloc.c +++ b/modules/src/alloc/Salloc.c @@ -27,7 +27,6 @@ char *Salloc(char *str, unsigned int sz) char *res = malloc(sz); char *m = res; - if (sz && m == 0) No_Mem(); while (sz--) *m++ = *str++; return res; diff --git a/modules/src/alloc/alloc.3 b/modules/src/alloc/alloc.3 index f143bd48c8..ea2004d7bc 100644 --- a/modules/src/alloc/alloc.3 +++ b/modules/src/alloc/alloc.3 @@ -13,8 +13,6 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc .PP .B void clear(char *ptr, unsigned int size) .PP -.void No_Mem() -.PP .SH DESCRIPTION This set of routines provides a checking memory allocation mechanism. .PP @@ -45,11 +43,6 @@ These last two routines are best used in a macro. .fi .SH "SEE ALSO" malloc(3) -.SH DIAGNOSTICS -\fISalloc\fR, \fISrealloc\fR, and \fIst_alloc\fR -call a routine \fINo_Mem\fR if there is no memory available. This routine -is not supposed to return. A default one, that -gives an error message and stops execution, is provided. .SH BUGS The .I st_alloc diff --git a/modules/src/alloc/alloc.h b/modules/src/alloc/alloc.h index a805d01e10..6dc9889dd0 100644 --- a/modules/src/alloc/alloc.h +++ b/modules/src/alloc/alloc.h @@ -18,7 +18,6 @@ char *Salloc(char *, unsigned int); char *st_alloc(char **, unsigned int, int); char *std_alloc(char **, unsigned int, int, int *); -void No_Mem(void); void clear(char *, unsigned int); void botch(char *, unsigned int); diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua index 371ea30d3b..c1a1675a25 100644 --- a/modules/src/alloc/build.lua +++ b/modules/src/alloc/build.lua @@ -3,7 +3,6 @@ clibrary { srcs = { "./botch.c", "./clear.c", - "./No_Mem.c", "./Salloc.c", "./st_alloc.c", "./std_alloc.c", diff --git a/modules/src/alloc/st_alloc.c b/modules/src/alloc/st_alloc.c index b0828e21fe..8ab55d3893 100644 --- a/modules/src/alloc/st_alloc.c +++ b/modules/src/alloc/st_alloc.c @@ -29,9 +29,6 @@ char *st_alloc(char **phead, unsigned int size, int count) while (count >= 1 && (p = malloc(size * count)) == 0) { count >>= 1; } - if (p == NULL) { - No_Mem(); - } ((_PALLOC_) p)->_A_next = 0; while (--count) { p += size; diff --git a/modules/src/alloc/std_alloc.c b/modules/src/alloc/std_alloc.c index 0b8f460024..c87ff13736 100644 --- a/modules/src/alloc/std_alloc.c +++ b/modules/src/alloc/std_alloc.c @@ -27,9 +27,6 @@ char *std_alloc(char **phead, unsigned int size, int count, int *pcnt) while (count >= 1 && (p = malloc(size * count)) == 0) { count >>= 1; } - if (p == 0) { - No_Mem(); - } *pcnt += count; ((_PALLOC_) p)->_A_next = 0; while (--count) { diff --git a/util/grind/main.c b/util/grind/main.c index de0388351a..a9cee5c368 100644 --- a/util/grind/main.c +++ b/util/grind/main.c @@ -233,9 +233,3 @@ rd_fatal() { fatal("read error in %s", AckObj); } - -void -No_Mem() -{ - fatal("out of memory"); -} diff --git a/util/grind/rd.c b/util/grind/rd.c index 437992ee15..ed2cf23bf3 100644 --- a/util/grind/rd.c +++ b/util/grind/rd.c @@ -286,7 +286,6 @@ get_names(h, sz) long s_value; } xnm; - if (xnms == 0 || onm == 0) No_Mem(); if (!readf(xnms, (unsigned) sz, 1)) rd_fatal(); names = onm; From f7c583cd25bc2eaaf395985c20536de42da57647 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 20 Nov 2024 16:58:02 +0100 Subject: [PATCH 03/29] Reformat. --- modules/src/alloc/Salloc.c | 16 +++++------ modules/src/alloc/alloc.h | 45 +++++++++++++++---------------- modules/src/alloc/botch.c | 16 ++++++----- modules/src/alloc/clear.c | 25 +++++++++-------- modules/src/alloc/st_alloc.c | 49 ++++++++++++++++++--------------- modules/src/alloc/std_alloc.c | 51 ++++++++++++++++++++--------------- 6 files changed, 109 insertions(+), 93 deletions(-) diff --git a/modules/src/alloc/Salloc.c b/modules/src/alloc/Salloc.c index aeb70ea996..9921ab9636 100644 --- a/modules/src/alloc/Salloc.c +++ b/modules/src/alloc/Salloc.c @@ -7,25 +7,25 @@ /* The memory allocation routines offered in this file are: - char *Salloc(str, n) : allocate n bytes, initialized with the string - str + char *Salloc(str, n) : allocate n bytes, initialized with the string + str */ #if __STDC__ #include #else -extern char *malloc(); +extern char* malloc(); #endif -#include "alloc.h" +#include "alloc.h" -char *Salloc(char *str, unsigned int sz) +char* Salloc(char* str, unsigned int sz) { /* Salloc() is not a primitive function: it just allocates a - piece of storage and copies a given string into it. + piece of storage and copies a given string into it. */ - char *res = malloc(sz); - char *m = res; + char* res = malloc(sz); + char* m = res; while (sz--) *m++ = *str++; diff --git a/modules/src/alloc/alloc.h b/modules/src/alloc/alloc.h index 6dc9889dd0..ac020f5104 100644 --- a/modules/src/alloc/alloc.h +++ b/modules/src/alloc/alloc.h @@ -8,35 +8,32 @@ /* PROGRAM'S INTERFACE TO MEMORY ALLOCATION ROUTINES */ /* This file serves as the interface between the program and the - memory allocating routines. - There are 3 memory allocation routines: - char *malloc(n) allocate n bytes - char *Salloc(str, n) allocate n bytes and fill them with - string str + memory allocating routines. + There are 3 memory allocation routines: + char *malloc(n) allocate n bytes + char *Salloc(str, n) allocate n bytes and fill them with + string str */ -char *Salloc(char *, unsigned int); -char *st_alloc(char **, unsigned int, int); -char *std_alloc(char **, unsigned int, int, int *); -void clear(char *, unsigned int); -void botch(char *, unsigned int); +char* Salloc(char*, unsigned int); +char* st_alloc(char**, unsigned int, int); +char* std_alloc(char**, unsigned int, int, int*); +void clear(char*, unsigned int); +void botch(char*, unsigned int); /* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */ -typedef struct _ALLOC_ { - struct _ALLOC_ *_A_next; -} *_PALLOC_; +typedef struct _ALLOC_ +{ + struct _ALLOC_* _A_next; +}* _PALLOC_; - -#define _A_st_free(ptr, phead, size) (((_PALLOC_)ptr)->_A_next = \ - (_PALLOC_)(*phead), \ - *((_PALLOC_ *)phead) = \ - (_PALLOC_) ptr) -#ifndef BOTCH_FREE -#define st_free(ptr, phead, size) _A_st_free(ptr, phead, size) -#else /* def BOTCH_FREE */ -#define st_free(ptr, phead, size) (botch((char *)(ptr), size), \ - _A_st_free(ptr, phead, size)) -#endif /* BOTCH_FREE */ +#define _A_st_free(ptr, phead, size) \ + (((_PALLOC_)ptr)->_A_next = (_PALLOC_)(*phead), *((_PALLOC_*)phead) = (_PALLOC_)ptr) +#ifndef BOTCH_FREE +#define st_free(ptr, phead, size) _A_st_free(ptr, phead, size) +#else /* def BOTCH_FREE */ +#define st_free(ptr, phead, size) (botch((char*)(ptr), size), _A_st_free(ptr, phead, size)) +#endif /* BOTCH_FREE */ #endif /* __ALLOC_INCLUDED__ */ diff --git a/modules/src/alloc/botch.c b/modules/src/alloc/botch.c index e27c0adceb..d4ed75f70f 100644 --- a/modules/src/alloc/botch.c +++ b/modules/src/alloc/botch.c @@ -4,17 +4,19 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* botch - write garbage over a chunk of memory, useful if you want - to check if freed memory is used inappopriately. + to check if freed memory is used inappopriately. */ #include "alloc.h" -void botch(char *ptr, unsigned int n) +void botch(char* ptr, unsigned int n) { - while (n >= sizeof (long)) { - /* high-speed botch loop */ - *(long *)ptr = 025252525252L; - ptr += sizeof (long), n -= sizeof (long); + while (n >= sizeof(long)) + { + /* high-speed botch loop */ + *(long*)ptr = 025252525252L; + ptr += sizeof(long), n -= sizeof(long); } - while (n--) *ptr++ = '\252'; + while (n--) + *ptr++ = '\252'; } diff --git a/modules/src/alloc/clear.c b/modules/src/alloc/clear.c index 927fd0bd0d..e4c2136d55 100644 --- a/modules/src/alloc/clear.c +++ b/modules/src/alloc/clear.c @@ -4,18 +4,19 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* clear - clear a block of memory, and try to do it fast. -*/ + */ #include "alloc.h" /* instead of Calloc: */ -void clear(char *ptr, unsigned int n) +void clear(char* ptr, unsigned int n) { - long *q = (long *) ptr; + long* q = (long*)ptr; - while (n >= 8*sizeof (long)) { - /* high-speed clear loop */ + while (n >= 8 * sizeof(long)) + { + /* high-speed clear loop */ *q++ = 0; *q++ = 0; *q++ = 0; @@ -24,13 +25,15 @@ void clear(char *ptr, unsigned int n) *q++ = 0; *q++ = 0; *q++ = 0; - n -= 8*sizeof (long); + n -= 8 * sizeof(long); } - while (n >= sizeof (long)) { - /* high-speed clear loop */ + while (n >= sizeof(long)) + { + /* high-speed clear loop */ *q++ = 0; - n -= sizeof (long); + n -= sizeof(long); } - ptr = (char *) q; - while (n--) *ptr++ = '\0'; + ptr = (char*)q; + while (n--) + *ptr++ = '\0'; } diff --git a/modules/src/alloc/st_alloc.c b/modules/src/alloc/st_alloc.c index 8ab55d3893..b86a6aa7bc 100644 --- a/modules/src/alloc/st_alloc.c +++ b/modules/src/alloc/st_alloc.c @@ -4,43 +4,48 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* st_alloc - get a structure from a free list. If no structures left, - create new ones. - The counterpart, st_free, is a macro, defined in alloc.h + create new ones. + The counterpart, st_free, is a macro, defined in alloc.h */ #if __STDC__ #include #else -extern char *malloc(); +extern char* malloc(); #ifndef NULL #define NULL 0 #endif #endif -#include "alloc.h" +#include "alloc.h" -char *st_alloc(char **phead, unsigned int size, int count) +char* st_alloc(char** phead, unsigned int size, int count) { - char *p = NULL; - long *q; - char *retval; + char* p = NULL; + long* q; + char* retval; - if (*phead == 0) { - while (count >= 1 && (p = malloc(size * count)) == 0) { + if (*phead == 0) + { + while (count >= 1 && (p = malloc(size * count)) == 0) + { count >>= 1; } - ((_PALLOC_) p)->_A_next = 0; - while (--count) { + ((_PALLOC_)p)->_A_next = 0; + while (--count) + { p += size; - ((_PALLOC_) p)->_A_next = (_PALLOC_) (p - size); + ((_PALLOC_)p)->_A_next = (_PALLOC_)(p - size); } *phead = p; } - else p = *phead; - *phead = (char *) (((_PALLOC_)p)->_A_next); + else + p = *phead; + *phead = (char*)(((_PALLOC_)p)->_A_next); retval = p; - q = (long *) p; - while (size >= 8*sizeof(long)) { + q = (long*)p; + while (size >= 8 * sizeof(long)) + { *q++ = 0; *q++ = 0; *q++ = 0; @@ -49,14 +54,16 @@ char *st_alloc(char **phead, unsigned int size, int count) *q++ = 0; *q++ = 0; *q++ = 0; - size -= 8*sizeof(long); + size -= 8 * sizeof(long); } - while (size >= sizeof(long)) { + while (size >= sizeof(long)) + { *q++ = 0; size -= sizeof(long); } - p = (char *) q; + p = (char*)q; - while (size--) *p++ = 0; + while (size--) + *p++ = 0; return retval; } diff --git a/modules/src/alloc/std_alloc.c b/modules/src/alloc/std_alloc.c index c87ff13736..5ff32acedb 100644 --- a/modules/src/alloc/std_alloc.c +++ b/modules/src/alloc/std_alloc.c @@ -4,42 +4,47 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* std_alloc - get a structure from a free list. If no structures left, - create new ones. - The counterpart, st_free, is a macro, defined in alloc.h - This is a counting version of st_alloc. + create new ones. + The counterpart, st_free, is a macro, defined in alloc.h + This is a counting version of st_alloc. */ #if __STDC__ #include #else -extern char *malloc(); +extern char* malloc(); #endif -#include "alloc.h" +#include "alloc.h" -char *std_alloc(char **phead, unsigned int size, int count, int *pcnt) +char* std_alloc(char** phead, unsigned int size, int count, int* pcnt) { - char *p; - long *q; - char *retval; + char* p; + long* q; + char* retval; - if (*phead == 0) { - while (count >= 1 && (p = malloc(size * count)) == 0) { + if (*phead == 0) + { + while (count >= 1 && (p = malloc(size * count)) == 0) + { count >>= 1; } *pcnt += count; - ((_PALLOC_) p)->_A_next = 0; - while (--count) { + ((_PALLOC_)p)->_A_next = 0; + while (--count) + { p += size; - ((_PALLOC_) p)->_A_next = (_PALLOC_) (p - size); + ((_PALLOC_)p)->_A_next = (_PALLOC_)(p - size); } *phead = p; } - else p = *phead; - *phead = (char *) (((_PALLOC_) p)->_A_next); + else + p = *phead; + *phead = (char*)(((_PALLOC_)p)->_A_next); retval = p; - q = (long *) p; - while (size >= 8*sizeof(long)) { + q = (long*)p; + while (size >= 8 * sizeof(long)) + { *q++ = 0; *q++ = 0; *q++ = 0; @@ -48,14 +53,16 @@ char *std_alloc(char **phead, unsigned int size, int count, int *pcnt) *q++ = 0; *q++ = 0; *q++ = 0; - size -= 8*sizeof(long); + size -= 8 * sizeof(long); } - while (size >= sizeof(long)) { + while (size >= sizeof(long)) + { *q++ = 0; size -= sizeof(long); } - p = (char *) q; + p = (char*)q; - while (size--) *p++ = 0; + while (size--) + *p++ = 0; return retval; } From b81f8a8d46ad7d5b945aeb8177b476a1250c25f6 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 14:09:46 +0100 Subject: [PATCH 04/29] Remove botch, as it's no longer used. --- modules/src/alloc/Amake.srclist | 13 ------------- modules/src/alloc/alloc.h | 5 ----- modules/src/alloc/botch.c | 22 ---------------------- modules/src/alloc/build.lua | 1 - 4 files changed, 41 deletions(-) delete mode 100644 modules/src/alloc/Amake.srclist delete mode 100644 modules/src/alloc/botch.c diff --git a/modules/src/alloc/Amake.srclist b/modules/src/alloc/Amake.srclist deleted file mode 100644 index 377a0a5ba4..0000000000 --- a/modules/src/alloc/Amake.srclist +++ /dev/null @@ -1,13 +0,0 @@ -L_ACK_MODULES_ALLOC = { - $PWD/Malloc.c, - $PWD/Salloc.c, - $PWD/Srealloc.c, - $PWD/Realloc.c, - $PWD/botch.c, - $PWD/clear.c, - $PWD/st_alloc.c, - $PWD/std_alloc.c, - $PWD/No_Mem.c, - $PWD/alloc.h -}; - diff --git a/modules/src/alloc/alloc.h b/modules/src/alloc/alloc.h index ac020f5104..e3ed90b760 100644 --- a/modules/src/alloc/alloc.h +++ b/modules/src/alloc/alloc.h @@ -19,7 +19,6 @@ char* Salloc(char*, unsigned int); char* st_alloc(char**, unsigned int, int); char* std_alloc(char**, unsigned int, int, int*); void clear(char*, unsigned int); -void botch(char*, unsigned int); /* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */ @@ -30,10 +29,6 @@ typedef struct _ALLOC_ #define _A_st_free(ptr, phead, size) \ (((_PALLOC_)ptr)->_A_next = (_PALLOC_)(*phead), *((_PALLOC_*)phead) = (_PALLOC_)ptr) -#ifndef BOTCH_FREE #define st_free(ptr, phead, size) _A_st_free(ptr, phead, size) -#else /* def BOTCH_FREE */ -#define st_free(ptr, phead, size) (botch((char*)(ptr), size), _A_st_free(ptr, phead, size)) -#endif /* BOTCH_FREE */ #endif /* __ALLOC_INCLUDED__ */ diff --git a/modules/src/alloc/botch.c b/modules/src/alloc/botch.c deleted file mode 100644 index d4ed75f70f..0000000000 --- a/modules/src/alloc/botch.c +++ /dev/null @@ -1,22 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* botch - write garbage over a chunk of memory, useful if you want - to check if freed memory is used inappopriately. -*/ - -#include "alloc.h" - -void botch(char* ptr, unsigned int n) -{ - while (n >= sizeof(long)) - { - /* high-speed botch loop */ - *(long*)ptr = 025252525252L; - ptr += sizeof(long), n -= sizeof(long); - } - while (n--) - *ptr++ = '\252'; -} diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua index c1a1675a25..53ae66f137 100644 --- a/modules/src/alloc/build.lua +++ b/modules/src/alloc/build.lua @@ -1,7 +1,6 @@ clibrary { name = "lib", srcs = { - "./botch.c", "./clear.c", "./Salloc.c", "./st_alloc.c", From b78dee5f37624aba68723dd424f660ce344d470d Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 14:16:46 +0100 Subject: [PATCH 05/29] Replace clear with memset, and remove clear. --- lang/cem/cemcom.ansi/ival.g | 3 +-- lang/pc/comp/chk_expr.c | 3 +-- modules/src/alloc/alloc.3 | 4 ---- modules/src/alloc/alloc.h | 1 - modules/src/alloc/build.lua | 1 - modules/src/alloc/clear.c | 39 ------------------------------------- 6 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 modules/src/alloc/clear.c diff --git a/lang/cem/cemcom.ansi/ival.g b/lang/cem/cemcom.ansi/ival.g index c94123c538..c6bb260428 100644 --- a/lang/cem/cemcom.ansi/ival.g +++ b/lang/cem/cemcom.ansi/ival.g @@ -642,8 +642,7 @@ void ch_array(struct type **tpp, /* type tp = array of characters */ length = dim; } /* throw out the characters of the already prepared string */ - s = malloc((unsigned) (length)); - clear(s, (unsigned)length); + s = calloc((unsigned) (length), 1); i = length <= ex->SG_LEN ? length : ex->SG_LEN; to = s; from = ex->SG_VALUE; while(--i >= 0) { diff --git a/lang/pc/comp/chk_expr.c b/lang/pc/comp/chk_expr.c index 30018f8396..c22b77c038 100644 --- a/lang/pc/comp/chk_expr.c +++ b/lang/pc/comp/chk_expr.c @@ -604,8 +604,7 @@ static int ChkElement(struct node *expp, struct type **tp, *tp = set_type(expp->nd_type, 0); size = (*tp)->tp_size * (sizeof(arith) / word_size); - *set = (arith *) malloc(size); - clear((char *) *set, size); + *set = (arith *) calloc(size, 1); } else if (!TstCompat(ElementType(*tp), expp->nd_type)) { diff --git a/modules/src/alloc/alloc.3 b/modules/src/alloc/alloc.3 index ea2004d7bc..512816276b 100644 --- a/modules/src/alloc/alloc.3 +++ b/modules/src/alloc/alloc.3 @@ -11,8 +11,6 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc .PP .B st_free(char *ptr, char **phead, unsigned int size) .PP -.B void clear(char *ptr, unsigned int size) -.PP .SH DESCRIPTION This set of routines provides a checking memory allocation mechanism. .PP @@ -34,8 +32,6 @@ the structure to be freed, \fIphead\fR is again a pointer to a field containing the head of the free list, and \fIsize\fR again contains the size of the structures. These last two routines are best used in a macro. -.PP -\fIclear\fR clears \fIsize\fR bytes, starting at \fIptr\fR. .SH FILES .nf ~em/modules/h/alloc.h diff --git a/modules/src/alloc/alloc.h b/modules/src/alloc/alloc.h index e3ed90b760..91ce8883a3 100644 --- a/modules/src/alloc/alloc.h +++ b/modules/src/alloc/alloc.h @@ -18,7 +18,6 @@ char* Salloc(char*, unsigned int); char* st_alloc(char**, unsigned int, int); char* std_alloc(char**, unsigned int, int, int*); -void clear(char*, unsigned int); /* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */ diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua index 53ae66f137..461062ca0a 100644 --- a/modules/src/alloc/build.lua +++ b/modules/src/alloc/build.lua @@ -1,7 +1,6 @@ clibrary { name = "lib", srcs = { - "./clear.c", "./Salloc.c", "./st_alloc.c", "./std_alloc.c", diff --git a/modules/src/alloc/clear.c b/modules/src/alloc/clear.c deleted file mode 100644 index e4c2136d55..0000000000 --- a/modules/src/alloc/clear.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* clear - clear a block of memory, and try to do it fast. - */ - -#include "alloc.h" - -/* instead of Calloc: */ - -void clear(char* ptr, unsigned int n) -{ - long* q = (long*)ptr; - - while (n >= 8 * sizeof(long)) - { - /* high-speed clear loop */ - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - *q++ = 0; - n -= 8 * sizeof(long); - } - while (n >= sizeof(long)) - { - /* high-speed clear loop */ - *q++ = 0; - n -= sizeof(long); - } - ptr = (char*)q; - while (n--) - *ptr++ = '\0'; -} From 6b6ffb1ad8be591f54eef0c23be39cfb29e92764 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 14:25:20 +0100 Subject: [PATCH 06/29] Remove strindex and strrindex, which weren't used (and are just strchr and strrchr anyway). --- modules/src/string/ack_string.h | 2 -- modules/src/string/build.lua | 4 ++-- modules/src/string/strindex.c | 17 ----------------- modules/src/string/string.3 | 14 -------------- modules/src/string/strrindex.c | 17 ----------------- 5 files changed, 2 insertions(+), 52 deletions(-) delete mode 100644 modules/src/string/strindex.c delete mode 100644 modules/src/string/strrindex.c diff --git a/modules/src/string/ack_string.h b/modules/src/string/ack_string.h index a74e89f18b..02c2b2c09e 100644 --- a/modules/src/string/ack_string.h +++ b/modules/src/string/ack_string.h @@ -7,8 +7,6 @@ #ifndef __ACK_STRING_INCLUDED__ #define __ACK_STRING_INCLUDED__ -char *strindex(char *s, int c); -char *strrindex(char *s, int c); char *strzero(char *s); char *str2bts(char *s, char *b, int *n); char *long2str(long l, int b); diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua index da63ed613e..f9dce39f86 100644 --- a/modules/src/string/build.lua +++ b/modules/src/string/build.lua @@ -3,8 +3,8 @@ clibrary { srcs = { "./bts2str.c", "./btscat.c", "./btscmp.c", "./btscpy.c", "./btszero.c", "./long2str.c", - "./str2bts.c", "./str2long.c", "./strindex.c", - "./strrindex.c", "./strzero.c", + "./str2bts.c", "./str2long.c", + "./strzero.c", }, hdrs = { "./ack_string.h", }, } diff --git a/modules/src/string/strindex.c b/modules/src/string/strindex.c deleted file mode 100644 index 072ed57112..0000000000 --- a/modules/src/string/strindex.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* strindex() -- (86/03/18 EHB) -*/ - -#include "ack_string.h" - -char *strindex(char *s, int c) -{ - while (*s) - if (*s++ == c) - return --s; - return (char *)0; -} diff --git a/modules/src/string/string.3 b/modules/src/string/string.3 index bb12a31f9a..e7a1b81785 100644 --- a/modules/src/string/string.3 +++ b/modules/src/string/string.3 @@ -9,8 +9,6 @@ conversions between strings and row of bytes .nf .B #include .PP -.B char *strindex(char *s, int c) -.PP .B char *strrindex(char *s, int c) .PP .B char *strzero(char *s) @@ -41,18 +39,6 @@ functions operate on variable-length rows of bytes, regardless of null bytes. Neither of these functions check for overflow of any receiving area. .PP -.I strindex -.RI ( strrindex ) -returns a pointer to the first (last) -occurrence of character -.I c -in string -.I s, -or zero if -.I c -does not occur in -.IR s . -.PP .I strzero turns .I s diff --git a/modules/src/string/strrindex.c b/modules/src/string/strrindex.c deleted file mode 100644 index 3738c4c98e..0000000000 --- a/modules/src/string/strrindex.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ - -#include "ack_string.h" - -char *strrindex(char *str, int chr) -{ - char *retptr = 0; - - while (*str) - if (*str++ == chr) - retptr = &str[-1]; - return retptr; -} From 61193a0d9647bbae1e090c4f70b4276d43be40f5 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 14:30:20 +0100 Subject: [PATCH 07/29] Remove strzero, which wasn't used. --- modules/src/string/ack_string.h | 2 +- modules/src/string/build.lua | 1 - modules/src/string/string.3 | 9 --------- modules/src/string/strzero.c | 15 --------------- 4 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 modules/src/string/strzero.c diff --git a/modules/src/string/ack_string.h b/modules/src/string/ack_string.h index 02c2b2c09e..9d21c99b7b 100644 --- a/modules/src/string/ack_string.h +++ b/modules/src/string/ack_string.h @@ -7,7 +7,7 @@ #ifndef __ACK_STRING_INCLUDED__ #define __ACK_STRING_INCLUDED__ -char *strzero(char *s); +//char *strzero(char *s); char *str2bts(char *s, char *b, int *n); char *long2str(long l, int b); long str2long(char *s, int b); diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua index f9dce39f86..3f630cc9a1 100644 --- a/modules/src/string/build.lua +++ b/modules/src/string/build.lua @@ -4,7 +4,6 @@ clibrary { "./bts2str.c", "./btscat.c", "./btscmp.c", "./btscpy.c", "./btszero.c", "./long2str.c", "./str2bts.c", "./str2long.c", - "./strzero.c", }, hdrs = { "./ack_string.h", }, } diff --git a/modules/src/string/string.3 b/modules/src/string/string.3 index e7a1b81785..74c62288eb 100644 --- a/modules/src/string/string.3 +++ b/modules/src/string/string.3 @@ -9,10 +9,6 @@ conversions between strings and row of bytes .nf .B #include .PP -.B char *strrindex(char *s, int c) -.PP -.B char *strzero(char *s) -.PP .B char *str2bts(char *s, char *b, int *n) .PP .B char *long2str(long l, int b) @@ -39,11 +35,6 @@ functions operate on variable-length rows of bytes, regardless of null bytes. Neither of these functions check for overflow of any receiving area. .PP -.I strzero -turns -.I s -into a null string. -.PP .I bts2str turns a row of .I n diff --git a/modules/src/string/strzero.c b/modules/src/string/strzero.c deleted file mode 100644 index 94e9b90c60..0000000000 --- a/modules/src/string/strzero.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* strzero() -*/ - -#include "ack_string.h" - -char *strzero(char *s) -{ - *s = '\0'; - return s; -} From 7d1a108a9d2b55cec4b2a4e8c70758569ab7ce3d Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 14:38:42 +0100 Subject: [PATCH 08/29] Remove parts of the bts library which aren't used. --- modules/src/string/ack_string.h | 5 --- modules/src/string/btscat.c | 18 --------- modules/src/string/btscmp.c | 20 ---------- modules/src/string/btszero.c | 19 --------- modules/src/string/build.lua | 6 +-- modules/src/string/str2bts.c | 68 --------------------------------- modules/src/string/string.3 | 60 ----------------------------- 7 files changed, 3 insertions(+), 193 deletions(-) delete mode 100644 modules/src/string/btscat.c delete mode 100644 modules/src/string/btscmp.c delete mode 100644 modules/src/string/btszero.c delete mode 100644 modules/src/string/str2bts.c diff --git a/modules/src/string/ack_string.h b/modules/src/string/ack_string.h index 9d21c99b7b..f04e04a952 100644 --- a/modules/src/string/ack_string.h +++ b/modules/src/string/ack_string.h @@ -7,14 +7,9 @@ #ifndef __ACK_STRING_INCLUDED__ #define __ACK_STRING_INCLUDED__ -//char *strzero(char *s); -char *str2bts(char *s, char *b, int *n); char *long2str(long l, int b); long str2long(char *s, int b); char *btscpy(char *b1, char *b2, int n); -char *btscat(char *b1, int n1, char *b2, int n2); -int btscmp(char *b1, int n1, char *b2, int n2); -char *btszero(char *b, int n); char *bts2str(char *b, int n, char *s); #endif /* __ACK_STRING_INCLUDED__ */ diff --git a/modules/src/string/btscat.c b/modules/src/string/btscat.c deleted file mode 100644 index f3dd3d8afd..0000000000 --- a/modules/src/string/btscat.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* btscat() -*/ - -#include "ack_string.h" - -char *btscat(char* b1, int n1, char *b2, int n2) -{ - char *b = b1 + n1; - - while (n2-- > 0) - *b++ = *b2++; - return b1; -} diff --git a/modules/src/string/btscmp.c b/modules/src/string/btscmp.c deleted file mode 100644 index 601a51cc5e..0000000000 --- a/modules/src/string/btscmp.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* btscmp() -*/ - -#include "ack_string.h" - -int btscmp(char *b1, int n1, char *b2, int n2) -{ - int n = (n1 <= n2) ? n1 : n2; - - while (n-- > 0) { - if (*b1++ != *b2++) - return *--b1 - *--b2; - } - return n2 - n1; -} diff --git a/modules/src/string/btszero.c b/modules/src/string/btszero.c deleted file mode 100644 index 9f6c297753..0000000000 --- a/modules/src/string/btszero.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* btszero() -*/ - -#include "ack_string.h" - -char *btszero(char *b, int n) -{ - char *s = b; - - while (n-- > 0) - *s++ = '\0'; - - return b; -} diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua index 3f630cc9a1..e051e6aa2b 100644 --- a/modules/src/string/build.lua +++ b/modules/src/string/build.lua @@ -1,9 +1,9 @@ clibrary { name = "lib", srcs = { - "./bts2str.c", "./btscat.c", "./btscmp.c", - "./btscpy.c", "./btszero.c", "./long2str.c", - "./str2bts.c", "./str2long.c", + "./bts2str.c", + "./btscpy.c","./long2str.c", + "./str2long.c", }, hdrs = { "./ack_string.h", }, } diff --git a/modules/src/string/str2bts.c b/modules/src/string/str2bts.c deleted file mode 100644 index aa289d968c..0000000000 --- a/modules/src/string/str2bts.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* str2bts -- (1985, EHB) -*/ - -#include "ack_string.h" - -static int is_oct(char c) -{ - return ((unsigned int)(c-'0') <= ('7'-'0')); -} - -/* str2bts() strips the escaped characters of a - string and replaces them by the ascii characters they stand for. - The ascii length of the resulting string is returned, including the - terminating null-character. -*/ -char *str2bts(char *str, char *bts, int *pn) -{ - char *t = bts; - - while (*str) { - if (*str == '\\') { - switch (*++str) { - case 'b': - *t++ = '\b'; - str++; - break; - case 'f': - *t++ = '\f'; - str++; - break; - case 'n': - *t++ = '\n'; - str++; - break; - case 'r': - *t++ = '\r'; - str++; - break; - case 't': - *t++ = '\t'; - str++; - break; - default: - if (is_oct(*str)) { - int cnt = 0, oct = 0; - - do - oct = oct * 8 + *str - '0'; - while (is_oct(*++str) && ++cnt < 3); - *t++ = (char) oct; - break; - } - *t++ = *str++; - break; - } - } - else - *t++ = *str++; - } - *t = '\0'; /* don't forget this one !!! */ - *pn = t - bts + 1; - return bts; -} diff --git a/modules/src/string/string.3 b/modules/src/string/string.3 index 74c62288eb..b0eb772975 100644 --- a/modules/src/string/string.3 +++ b/modules/src/string/string.3 @@ -9,20 +9,12 @@ conversions between strings and row of bytes .nf .B #include .PP -.B char *str2bts(char *s, char *b, int *n) -.PP .B char *long2str(long l, int b) .PP .B long str2long(char *s, int b) .PP .B char *btscpy(char *b1, char *b2, int n) .PP -.B char *btscat(char *b1, int n1, char *b2, int n2) -.PP -.B int btscmp(char *b1, int n1, char *b2, int n2) -.PP -.B char *btszero(char *b, int n) -.PP .B char *bts2str(char *b, int n, char *s) .fi .SH DESCRIPTION @@ -58,22 +50,6 @@ is turned into the string consisting of the following characters .RE The latter string could be represented in C as "\e\e000\e\en". .PP -.I str2bts -turns string -.I s -into a sequence of bytes pointed by -.IR b . -It has the inverse effect to -.IR bts2str . -The length of the resulting byte sequence is returned in -.RI *n . -.br -Both the functions -.I bts2str -and -.I str2bts -return a pointer to the result. -.PP .I long2str converts a long value .I l @@ -99,42 +75,6 @@ to .I b1 and returns .IR b1 . -.PP -.I btscat -appends a copy of -.I n2 -bytes from -.I b2 -to the end of -.IR b1 , -consisting of -.I n1 -bytes. -.I b1 -is returned. -.PP -.I btscmp -compares row of bytes -.I b1 -with length -.I n1 -and -.I b2 -with length -.I n2 -and returns an integer greater than, equal to, or less than 0, if -.I b1 -is lexicographically greater then, equal to, or less than -.IR b2 , -respectively. -.PP -.I btszero -places -.I n -null bytes in the string -.IR b . -.I b -is returned. .SH FILES ~em/modules/lib/libstring.a .SH "SEE ALSO" From b50b6dd3d5c3889d84157f3f0770ebb162f44e05 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 14:43:44 +0100 Subject: [PATCH 09/29] Replace str2long with strtol. --- lang/pc/comp/LLlex.c | 2 +- modules/src/read_em/reade.c | 2 +- modules/src/string/ack_string.h | 1 - modules/src/string/build.lua | 1 - modules/src/string/str2long.c | 36 --------------------------------- modules/src/string/string.3 | 7 ------- 6 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 modules/src/string/str2long.c diff --git a/lang/pc/comp/LLlex.c b/lang/pc/comp/LLlex.c index 20e7ecb3fb..518ee07274 100644 --- a/lang/pc/comp/LLlex.c +++ b/lang/pc/comp/LLlex.c @@ -522,7 +522,7 @@ int LLlex(void) np = &buf[1]; while (*np == '0') /* skip leading zeros */ np++; - tk->TOK_INT = str2long(np, 10); + tk->TOK_INT = strtol(np, NULL, 10); if( (tk->TOK_INT < 0) || (strlen(np) > strlen(maxint_str)) || (strlen(np) == strlen(maxint_str) && diff --git a/modules/src/read_em/reade.c b/modules/src/read_em/reade.c index 4907ced00c..18c5814a2c 100644 --- a/modules/src/read_em/reade.c +++ b/modules/src/read_em/reade.c @@ -353,7 +353,7 @@ static int getnumber(int c, struct e_arg *ap) } ungetbyte(c); - ap->ema_cst = (arith) str2long(str, 10); + ap->ema_cst = (arith) strtol(str, NULL, 10); return sp_cst4; } diff --git a/modules/src/string/ack_string.h b/modules/src/string/ack_string.h index f04e04a952..22aa0b226b 100644 --- a/modules/src/string/ack_string.h +++ b/modules/src/string/ack_string.h @@ -8,7 +8,6 @@ #define __ACK_STRING_INCLUDED__ char *long2str(long l, int b); -long str2long(char *s, int b); char *btscpy(char *b1, char *b2, int n); char *bts2str(char *b, int n, char *s); diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua index e051e6aa2b..a3cf03a414 100644 --- a/modules/src/string/build.lua +++ b/modules/src/string/build.lua @@ -3,7 +3,6 @@ clibrary { srcs = { "./bts2str.c", "./btscpy.c","./long2str.c", - "./str2long.c", }, hdrs = { "./ack_string.h", }, } diff --git a/modules/src/string/str2long.c b/modules/src/string/str2long.c deleted file mode 100644 index c97e56df9b..0000000000 --- a/modules/src/string/str2long.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* str2long() -*/ - -#include "ack_string.h" - -static int value(char c, int b) -{ - int ch; - - ch = c - '0'; - if ((unsigned) ch <= 9) return ch; - ch = c - 'A'; - if ((unsigned) ch <= 5) return ch + 10; - ch = c - 'a'; - if ((unsigned) ch <= 5) return ch + 10; - return b; -} - -long str2long(char *str, int base) -{ - int minus = 0, d; - long l = 0; - - if (*str == '-') { - minus++; - str++; - } - while ((d = value(*str++, base)) < base) - l = base * l + d; - return minus ? -l : l; -} diff --git a/modules/src/string/string.3 b/modules/src/string/string.3 index b0eb772975..bdabb97548 100644 --- a/modules/src/string/string.3 +++ b/modules/src/string/string.3 @@ -11,8 +11,6 @@ conversions between strings and row of bytes .PP .B char *long2str(long l, int b) .PP -.B long str2long(char *s, int b) -.PP .B char *btscpy(char *b1, char *b2, int n) .PP .B char *bts2str(char *b, int n, char *s) @@ -60,11 +58,6 @@ This base may be any of 2..16. A negative base (in the range -16..-2) indicates that the long must be seen as unsigned. A pointer to the string is returned. -.I str2long -returns the value that is represented in -.IR s , -according to -.IR base . .PP .I btscpy copies From 1531b7dbf7a714612823ab85ac91e26f5b0afbbf Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Nov 2024 16:40:23 +0100 Subject: [PATCH 10/29] Reformat. --- lang/cem/cemcom.ansi/stab.c | 391 ++++++++++---------- lang/m2/comp/stab.c | 688 +++++++++++++++++++----------------- lang/pc/comp/stab.c | 572 +++++++++++++++--------------- 3 files changed, 853 insertions(+), 798 deletions(-) diff --git a/lang/cem/cemcom.ansi/stab.c b/lang/cem/cemcom.ansi/stab.c index 7cfc8f924a..c0732f1c83 100644 --- a/lang/cem/cemcom.ansi/stab.c +++ b/lang/cem/cemcom.ansi/stab.c @@ -9,36 +9,36 @@ /* $Id$ */ -#include "parameters.h" +#include "parameters.h" -#ifdef DBSYMTAB +#ifdef DBSYMTAB -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include "stab.h" -#include "idf.h" -#include "LLlex.h" -#include "stack.h" -#include "def.h" -#include "type.h" -#include "struct.h" -#include "field.h" -#include "Lpars.h" -#include "level.h" -#include "print.h" +#include "stab.h" +#include "idf.h" +#include "LLlex.h" +#include "stack.h" +#include "def.h" +#include "type.h" +#include "struct.h" +#include "field.h" +#include "Lpars.h" +#include "level.h" +#include "print.h" -#define INCR_SIZE 64 +#define INCR_SIZE 64 static struct db_str { unsigned sz; - char *base; - char *currpos; + char* base; + char* currpos; } db_str; static void create_db_str(void) @@ -64,13 +64,13 @@ static void addc_db_str(int c) *db_str.currpos = '\0'; } -static void adds_db_str(char *s) +static void adds_db_str(char* s) { while (*s) addc_db_str(*s++); } -static void stb_type(struct type *tp) +static void stb_type(struct type* tp) { char buf[128], *range; static int stb_count; @@ -79,236 +79,245 @@ static void stb_type(struct type *tp) if (tp->tp_dbindex > 0) { - adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); + sprintf(buf, "%d", tp->tp_dbindex); + adds_db_str(buf); return; } if (tp->tp_dbindex < 0 && tp->tp_size < 0) { - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + sprintf(buf, "%d", -tp->tp_dbindex); + adds_db_str(buf); return; } if (tp->tp_dbindex <= 0) { tp->tp_dbindex = ++stb_count; } - adds_db_str(sprint(buf, "%d=", tp->tp_dbindex)); + sprintf(buf, "%d=", tp->tp_dbindex); + adds_db_str(buf); switch (tp->tp_fund) { - /* simple types ... */ - case VOID: - adds_db_str(sprint(buf, "%d", void_type->tp_dbindex)); - break; - case INT: - case LONG: - case LNGLNG: - case CHAR: - case SHORT: - switch ((tp->tp_size << 3) + !tp->tp_unsigned) - { -#define R(s) range = #s; break - case 0010: R(0;255); - case 0011: R(-128;127); - case 0020: R(0;65535); - case 0021: R(-32768;32767); - default: R(0;-1); /* acts as 0;4294967295 */ - case 0041: R(-2147483648;2147483647); - /* The stabs reader in gdb(1) needs an octal integer - when its value doesn't fit in type long. - */ - case 0100: R(0;01777777777777777777777); - case 0101: R(01000000000000000000000;0777777777777777777777); + /* simple types ... */ + case VOID: + sprintf(buf, "%d", void_type->tp_dbindex); + adds_db_str(buf); + break; + case INT: + case LONG: + case LNGLNG: + case CHAR: + case SHORT: + switch ((tp->tp_size << 3) + !tp->tp_unsigned) + { +#define R(s) \ + range = #s; \ + break + case 0010: + R(0; 255); + case 0011: + R(-128; 127); + case 0020: + R(0; 65535); + case 0021: + R(-32768; 32767); + default: + R(0; -1); /* acts as 0;4294967295 */ + case 0041: + R(-2147483648; 2147483647); + /* The stabs reader in gdb(1) needs an octal integer + when its value doesn't fit in type long. + */ + case 0100: + R(0; 01777777777777777777777); + case 0101: + R(01000000000000000000000; 0777777777777777777777); #undef R - } - adds_db_str(sprint(buf, "r%d;%s", tp->tp_dbindex, range)); - break; - case FLOAT: - case DOUBLE: - case LNGDBL: - adds_db_str( - sprint(buf, "r%d;%ld;0", tp->tp_dbindex, (long) tp->tp_size)); - break; + } + sprintf(buf, "r%d;%s", tp->tp_dbindex, range); + adds_db_str(buf); + break; + case FLOAT: + case DOUBLE: + case LNGDBL: + sprintf(buf, "r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size); + adds_db_str(buf); + break; - /* constructed types ... */ - case POINTER: - addc_db_str('*'); - stb_type(tp->tp_up); - break; - case ARRAY: - if (tp->tp_size > 0) - { - adds_db_str("ar"); - stb_type(int_type); - adds_db_str( - sprint(buf, ";0;%ld;", - tp->tp_size / tp->tp_up->tp_size - 1)); + /* constructed types ... */ + case POINTER: + addc_db_str('*'); stb_type(tp->tp_up); - } - break; - case ENUM: - if (tp->tp_size < 0) - { - adds_db_str(sprint(buf, "xe%s:", tp->tp_idf->id_text)); - tp->tp_dbindex = -tp->tp_dbindex; break; - } - addc_db_str('e'); - { - struct stack_entry *se = local_level->sl_entry; - - while (se) + case ARRAY: + if (tp->tp_size > 0) { - struct def *edef = se->se_idf->id_def; - while (edef) + adds_db_str("ar"); + stb_type(int_type); + sprintf(buf, ";0;%ld;", tp->tp_size / tp->tp_up->tp_size - 1); + adds_db_str(buf); + stb_type(tp->tp_up); + } + break; + case ENUM: + if (tp->tp_size < 0) + { + sprintf(buf, "xe%s:", tp->tp_idf->id_text); + adds_db_str(buf); + tp->tp_dbindex = -tp->tp_dbindex; + break; + } + addc_db_str('e'); + { + struct stack_entry* se = local_level->sl_entry; + + while (se) { - if (edef->df_type == tp && edef->df_sc == ENUM) + struct def* edef = se->se_idf->id_def; + while (edef) { - adds_db_str( - sprint(buf, "%s:%ld,", se->se_idf->id_text, - edef->df_address)); + if (edef->df_type == tp && edef->df_sc == ENUM) + { + sprintf(buf, "%s:%ld,", se->se_idf->id_text, edef->df_address); + adds_db_str(buf); + } + edef = edef->next; } - edef = edef->next; + se = se->next; } - se = se->next; } - } - addc_db_str(';'); - break; - case STRUCT: - case UNION: - if (tp->tp_size < 0) - { - adds_db_str( - sprint(buf, "x%c%s:", tp->tp_fund == STRUCT ? 's' : 'u', - tp->tp_idf->id_text)); - tp->tp_dbindex = -tp->tp_dbindex; + addc_db_str(';'); break; - } - adds_db_str( - sprint(buf, "%c%ld", tp->tp_fund == STRUCT ? 's' : 'u', - tp->tp_size)); - { - struct sdef *sdef = tp->tp_sdef; - - while (sdef) + case STRUCT: + case UNION: + if (tp->tp_size < 0) { - adds_db_str(sdef->sd_idf->id_text); - addc_db_str(':'); - if (sdef->sd_type->tp_fund == FIELD) - { - stb_type(sdef->sd_type->tp_up); - adds_db_str( - sprint(buf, ",%ld,%ld;", - sdef->sd_offset * 8 - + sdef->sd_type->tp_field->fd_shift, - sdef->sd_type->tp_field->fd_width)); - } - else + sprintf(buf, "x%c%s:", tp->tp_fund == STRUCT ? 's' : 'u', tp->tp_idf->id_text); + adds_db_str(buf); + tp->tp_dbindex = -tp->tp_dbindex; + break; + } + sprintf(buf, "%c%ld", tp->tp_fund == STRUCT ? 's' : 'u', tp->tp_size); + adds_db_str(buf); + { + struct sdef* sdef = tp->tp_sdef; + + while (sdef) { - stb_type(sdef->sd_type); - adds_db_str( - sprint(buf, ",%ld,%ld;", sdef->sd_offset * 8, - sdef->sd_type->tp_size * 8)); + adds_db_str(sdef->sd_idf->id_text); + addc_db_str(':'); + if (sdef->sd_type->tp_fund == FIELD) + { + stb_type(sdef->sd_type->tp_up); + sprintf( + buf, ",%ld,%ld;", + sdef->sd_offset * 8 + sdef->sd_type->tp_field->fd_shift, + sdef->sd_type->tp_field->fd_width); + adds_db_str(buf); + } + else + { + stb_type(sdef->sd_type); + sprintf(buf, ",%ld,%ld;", sdef->sd_offset * 8, sdef->sd_type->tp_size * 8); + adds_db_str(buf); + } + sdef = sdef->sd_sdef; } - sdef = sdef->sd_sdef; } - } - addc_db_str(';'); - break; - case FUNCTION: - addc_db_str('f'); - stb_type(tp->tp_up); + addc_db_str(';'); + break; + case FUNCTION: + addc_db_str('f'); + stb_type(tp->tp_up); } } -void stb_tag(struct tag *tg, char *str) +void stb_tag(struct tag* tg, char* str) { create_db_str(); adds_db_str(str); adds_db_str(":T"); stb_type(tg->tg_type); addc_db_str(';'); - C_ms_stb_cst(db_str.base, - N_LSYM, - tg->tg_type == void_type || tg->tg_type->tp_size >= 32767 ? - 0 : (int) tg->tg_type->tp_size, (arith) 0); + C_ms_stb_cst( + db_str.base, N_LSYM, + tg->tg_type == void_type || tg->tg_type->tp_size >= 32767 ? 0 : (int)tg->tg_type->tp_size, + (arith)0); } -void stb_typedef(struct type *tp, char *str) +void stb_typedef(struct type* tp, char* str) { create_db_str(); adds_db_str(str); adds_db_str(":t"); stb_type(tp); addc_db_str(';'); - C_ms_stb_cst(db_str.base, - N_LSYM, tp == void_type || tp->tp_size >= 32767 ? 0 : (int) tp->tp_size, - (arith) 0); + C_ms_stb_cst( + db_str.base, N_LSYM, tp == void_type || tp->tp_size >= 32767 ? 0 : (int)tp->tp_size, + (arith)0); } -void stb_string(struct def *df, int kind, char* str) +void stb_string(struct def* df, int kind, char* str) { - struct type *tp = df->df_type; + struct type* tp = df->df_type; create_db_str(); adds_db_str(str); addc_db_str(':'); switch (kind) { - case FUNCTION: - addc_db_str(df->df_sc == STATIC ? 'f' : 'F'); - stb_type(tp->tp_up); - addc_db_str(';'); - C_ms_stb_pnam(db_str.base, N_FUN, 1 /* proclevel */, str); - break; - default: - if (df->df_sc == FORMAL - || (df->df_sc == REGISTER && df->df_address >= 0)) - { - /* value parameter */ - addc_db_str('p'); - stb_type(tp); + case FUNCTION: + addc_db_str(df->df_sc == STATIC ? 'f' : 'F'); + stb_type(tp->tp_up); addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_PSYM, 0, df->df_address); - } - else if (df->df_sc != AUTO && df->df_sc != REGISTER) - { - /* global */ - int stabtp = df->df_initialized ? N_STSYM : N_LCSYM; - if (df->df_sc == STATIC) + C_ms_stb_pnam(db_str.base, N_FUN, 1 /* proclevel */, str); + break; + default: + if (df->df_sc == FORMAL || (df->df_sc == REGISTER && df->df_address >= 0)) + { + /* value parameter */ + addc_db_str('p'); + stb_type(tp); + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_PSYM, 0, df->df_address); + } + else if (df->df_sc != AUTO && df->df_sc != REGISTER) { - if (df->df_level >= L_LOCAL) + /* global */ + int stabtp = df->df_initialized ? N_STSYM : N_LCSYM; + if (df->df_sc == STATIC) { - addc_db_str('V'); + if (df->df_level >= L_LOCAL) + { + addc_db_str('V'); + } + else + { + addc_db_str('S'); + } } else { - addc_db_str('S'); + addc_db_str('G'); + } + stb_type(tp); + addc_db_str(';'); + if (df->df_sc == STATIC && df->df_level >= L_LOCAL) + { + C_ms_stb_dlb(db_str.base, stabtp, 0, (label)df->df_address, (arith)0); + } + else + { + C_ms_stb_dnam(db_str.base, stabtp, 0, str, (arith)0); } } else - { - addc_db_str('G'); - } - stb_type(tp); - addc_db_str(';'); - if (df->df_sc == STATIC && df->df_level >= L_LOCAL) - { - C_ms_stb_dlb(db_str.base, stabtp, 0, (label) df->df_address, - (arith) 0); - } - else - { - C_ms_stb_dnam(db_str.base, stabtp, 0, str, (arith) 0); + { /* local variable */ + stb_type(tp); /* assign type num to avoid + difficult to parse string */ + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_LSYM, 0, df->df_address); } - } - else - { /* local variable */ - stb_type(tp); /* assign type num to avoid - difficult to parse string */ - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_LSYM, 0, df->df_address); - } - break; + break; } } diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index fac59cfd6b..aba30930ca 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -13,38 +13,40 @@ #ifdef DBSYMTAB -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include "LLlex.h" -#include "def.h" -#include "type.h" -#include "idf.h" -#include "scope.h" -#include "error.h" -#include "stab.h" -#include "main.h" -#include "print.h" +#include "LLlex.h" +#include "def.h" +#include "type.h" +#include "idf.h" +#include "scope.h" +#include "error.h" +#include "stab.h" +#include "main.h" +#include "print.h" -extern int gdb_flag; +extern int gdb_flag; -#define INCR_SIZE 64 +#define INCR_SIZE 64 -extern int proclevel; +extern int proclevel; -static struct db_str { - unsigned sz; - char *base; - char *currpos; +static struct db_str +{ + unsigned sz; + char* base; + char* currpos; } db_str; static void create_db_str(void) { - if (! db_str.base) { + if (!db_str.base) + { db_str.base = malloc(INCR_SIZE); db_str.sz = INCR_SIZE; } @@ -54,7 +56,8 @@ static void create_db_str(void) static void addc_db_str(int c) { int df = db_str.currpos - db_str.base; - if (df >= db_str.sz-1) { + if (df >= db_str.sz - 1) + { db_str.sz += INCR_SIZE; db_str.base = realloc(db_str.base, db_str.sz); db_str.currpos = db_str.base + df; @@ -63,193 +66,195 @@ static void addc_db_str(int c) *db_str.currpos = '\0'; } -static void adds_db_str(char *s) +static void adds_db_str(char* s) { - while (*s) addc_db_str(*s++); + while (*s) + addc_db_str(*s++); } -static void stb_type(struct type *tp, int assign_num) +static void stb_type(struct type* tp, int assign_num) { char buf[128]; - static int stb_count; + static int stb_count; - if (tp->tp_dbindex > 0) { + if (tp->tp_dbindex > 0) + { adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); return; } - if (tp->tp_dbindex < 0) { - if (tp->tp_next == 0) { + if (tp->tp_dbindex < 0) + { + if (tp->tp_next == 0) + { adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); return; } tp->tp_dbindex = -tp->tp_dbindex; } - if (tp->tp_dbindex == 0 && assign_num) { + if (tp->tp_dbindex == 0 && assign_num) + { tp->tp_dbindex = ++stb_count; } - if (tp->tp_dbindex > 0) { + if (tp->tp_dbindex > 0) + { adds_db_str(sprint(buf, "%d=", tp->tp_dbindex)); } - if (tp == void_type) { + if (tp == void_type) + { adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); return; } - switch(tp->tp_fund) { - /* simple types ... */ - case T_INTEGER: - adds_db_str(sprint(buf, - "r%d;%ld;%ld", - tp->tp_dbindex, - (long) min_int[(int)tp->tp_size], - (long) max_int[(int)tp->tp_size])); - break; - case T_CARDINAL: - adds_db_str(sprint(buf, - "r%d;0;-1", - tp->tp_dbindex)); - break; - case T_REAL: - adds_db_str(sprint(buf, - "r%d;%ld;0", - tp->tp_dbindex, - (long)tp->tp_size)); - break; - case T_CHAR: - adds_db_str(sprint(buf, - "r%d;0;255", - tp->tp_dbindex)); - break; - case T_WORD: - if (tp->tp_size == word_size) { - adds_db_str(sprint(buf, - "r%d;0;-1", - tp->tp_dbindex)); - } - else { - adds_db_str(sprint(buf, - "r%d;0;255", - tp->tp_dbindex)); - } - break; + switch (tp->tp_fund) + { + /* simple types ... */ + case T_INTEGER: + adds_db_str(sprint( + buf, "r%d;%ld;%ld", tp->tp_dbindex, (long)min_int[(int)tp->tp_size], + (long)max_int[(int)tp->tp_size])); + break; + case T_CARDINAL: + adds_db_str(sprint(buf, "r%d;0;-1", tp->tp_dbindex)); + break; + case T_REAL: + adds_db_str(sprint(buf, "r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size)); + break; + case T_CHAR: + adds_db_str(sprint(buf, "r%d;0;255", tp->tp_dbindex)); + break; + case T_WORD: + if (tp->tp_size == word_size) + { + adds_db_str(sprint(buf, "r%d;0;-1", tp->tp_dbindex)); + } + else + { + adds_db_str(sprint(buf, "r%d;0;255", tp->tp_dbindex)); + } + break; - /* constructed types ... */ - case T_SUBRANGE: - adds_db_str(sprint(buf, - "r%d;%ld;%ld", - tp->tp_next->tp_dbindex, - (long) tp->sub_lb, - (long) tp->sub_ub)); - break; - case T_EQUAL: - stb_type(tp->tp_next, 0); - if (tp->tp_dbindex < 0) tp->tp_dbindex = -tp->tp_dbindex; - break; - case T_HIDDEN: - if (DefinitionModule && CurrVis == Defined->mod_vis) { - tp->tp_dbindex = - ++stb_count; - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); - } - else { - /* ??? what to do here??? */ - addc_db_str('*'); - stb_type(void_type, 0); - /* ??? this certainly is not correct */ - } - break; - case T_POINTER: - if (tp->tp_next) { - addc_db_str('*'); - stb_type(tp->tp_next, 0); - if (tp->tp_dbindex < 0) tp->tp_dbindex = -tp->tp_dbindex; - } - else { - tp->tp_dbindex = - ++stb_count; - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); - } - break; - case T_SET: - addc_db_str('S'); - stb_type(tp->tp_next, 0); - adds_db_str(sprint(buf, ";%ld;%ld;", tp->tp_size, tp->set_low)); - break; - case T_ARRAY: - addc_db_str('a'); - if (IsConformantArray(tp)) { - addc_db_str('r'); + /* constructed types ... */ + case T_SUBRANGE: + adds_db_str(sprint( + buf, "r%d;%ld;%ld", tp->tp_next->tp_dbindex, (long)tp->sub_lb, (long)tp->sub_ub)); + break; + case T_EQUAL: stb_type(tp->tp_next, 0); - adds_db_str(sprint(buf, ";0;A%ld", tp->arr_high)); - } - else { + if (tp->tp_dbindex < 0) + tp->tp_dbindex = -tp->tp_dbindex; + break; + case T_HIDDEN: + if (DefinitionModule && CurrVis == Defined->mod_vis) + { + tp->tp_dbindex = -++stb_count; + adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + } + else + { + /* ??? what to do here??? */ + addc_db_str('*'); + stb_type(void_type, 0); + /* ??? this certainly is not correct */ + } + break; + case T_POINTER: + if (tp->tp_next) + { + addc_db_str('*'); + stb_type(tp->tp_next, 0); + if (tp->tp_dbindex < 0) + tp->tp_dbindex = -tp->tp_dbindex; + } + else + { + tp->tp_dbindex = -++stb_count; + adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + } + break; + case T_SET: + addc_db_str('S'); stb_type(tp->tp_next, 0); - } - addc_db_str(';'); - stb_type(tp->arr_elem, 0); - break; - case T_ENUMERATION: - addc_db_str('e'); - { - struct def *edef = tp->enm_enums; - - while (edef) { - adds_db_str(sprint(buf, "%s:%ld,", - edef->df_idf->id_text, - edef->enm_val)); - edef = edef->enm_next; + adds_db_str(sprint(buf, ";%ld;%ld;", tp->tp_size, tp->set_low)); + break; + case T_ARRAY: + addc_db_str('a'); + if (IsConformantArray(tp)) + { + addc_db_str('r'); + stb_type(tp->tp_next, 0); + adds_db_str(sprint(buf, ";0;A%ld", tp->arr_high)); } - } - addc_db_str(';'); - break; - case T_RECORD: - adds_db_str(sprint(buf, "s%ld", tp->tp_size)); - { - struct def *sdef = tp->rec_scope->sc_def; + else + { + stb_type(tp->tp_next, 0); + } + addc_db_str(';'); + stb_type(tp->arr_elem, 0); + break; + case T_ENUMERATION: + addc_db_str('e'); + { + struct def* edef = tp->enm_enums; - while (sdef) { - adds_db_str(sdef->df_idf->id_text); - addc_db_str(':'); - stb_type(sdef->df_type, 0); - adds_db_str(sprint(buf, - ",%ld,%ld;", - sdef->fld_off*8, - sdef->df_type->tp_size*8)); - sdef = sdef->df_nextinscope; + while (edef) + { + adds_db_str(sprint(buf, "%s:%ld,", edef->df_idf->id_text, edef->enm_val)); + edef = edef->enm_next; + } } - } - addc_db_str(';'); - break; - case T_PROCEDURE: - if (gdb_flag) { - addc_db_str('f'); - stb_type(tp->tp_next ? tp->tp_next : void_type, 0); + addc_db_str(';'); break; - } - addc_db_str('Q'); - stb_type(tp->tp_next ? tp->tp_next : void_type, 0); - { - struct paramlist *p = tp->prc_params; - int paramcount = 0; + case T_RECORD: + adds_db_str(sprint(buf, "s%ld", tp->tp_size)); + { + struct def* sdef = tp->rec_scope->sc_def; - while (p) { - paramcount++; - p = p->par_next; + while (sdef) + { + adds_db_str(sdef->df_idf->id_text); + addc_db_str(':'); + stb_type(sdef->df_type, 0); + adds_db_str( + sprint(buf, ",%ld,%ld;", sdef->fld_off * 8, sdef->df_type->tp_size * 8)); + sdef = sdef->df_nextinscope; + } } - adds_db_str(sprint(buf, ",%d;", paramcount)); - p = tp->prc_params; - while (p) { - addc_db_str(IsVarParam(p) - ? 'v' - : IsConformantArray(TypeOfParam(p)) - ? 'i' - : 'p'); - stb_type(TypeOfParam(p), 0); - addc_db_str(';'); - p = p->par_next; + addc_db_str(';'); + break; + case T_PROCEDURE: + if (gdb_flag) + { + addc_db_str('f'); + stb_type(tp->tp_next ? tp->tp_next : void_type, 0); + break; + } + addc_db_str('Q'); + stb_type(tp->tp_next ? tp->tp_next : void_type, 0); + { + struct paramlist* p = tp->prc_params; + int paramcount = 0; + + while (p) + { + paramcount++; + p = p->par_next; + } + adds_db_str(sprint(buf, ",%d;", paramcount)); + p = tp->prc_params; + while (p) + { + addc_db_str( + IsVarParam(p) ? 'v' + : IsConformantArray(TypeOfParam(p)) ? 'i' + : 'p'); + stb_type(TypeOfParam(p), 0); + addc_db_str(';'); + p = p->par_next; + } } - } } } -void stb_addtp(char *s, struct type *tp) +void stb_addtp(char* s, struct type* tp) { create_db_str(); adds_db_str(s); @@ -257,182 +262,205 @@ void stb_addtp(char *s, struct type *tp) addc_db_str('t'); stb_type(tp, 1); addc_db_str(';'); - C_ms_stb_cst(db_str.base, - N_LSYM, - tp == void_type || tp->tp_size >= max_int[2] - ? 0 - : (int)tp->tp_size, - (arith) 0); + C_ms_stb_cst( + db_str.base, N_LSYM, tp == void_type || tp->tp_size >= max_int[2] ? 0 : (int)tp->tp_size, + (arith)0); } -void stb_string(struct def *df, int kind) +void stb_string(struct def* df, int kind) { - struct type *tp = df->df_type; + struct type* tp = df->df_type; char buf[64]; create_db_str(); adds_db_str(df->df_idf->id_text); addc_db_str(':'); - switch(kind) { - case D_MODULE: - if (gdb_flag) { - addc_db_str('F'); - stb_type(void_type, 0); - } - else { - adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count)); - } - C_ms_stb_pnam(db_str.base, N_FUN, gdb_flag ? 0 : proclevel, df->mod_vis->sc_scope->sc_name); - break; - case D_PROCEDURE: - if (gdb_flag) { - addc_db_str('f'); - } - else adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); - stb_type(tp->tp_next ? tp->tp_next : void_type, 0); - if (gdb_flag) { - struct scopelist *sc = df->prc_vis; - sc = enclosing(sc); - while (sc) { - struct def *d = sc->sc_scope->sc_definedby; - - if (d && d->df_kind == D_PROCEDURE) { - adds_db_str(sprint(buf, ",%s", d->df_idf->id_text)); - break; - } - sc = enclosing(sc); - } - } - else addc_db_str(';'); - C_ms_stb_pnam(db_str.base, N_FUN, gdb_flag ? 0 : proclevel, df->prc_vis->sc_scope->sc_name); - break; - case D_END: - if (gdb_flag) break; - adds_db_str(sprint(buf, "E%d;", df->mod_vis->sc_count)); - C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0); - break; - case D_PEND: - if (gdb_flag) break; - adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); - C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0); - break; - case D_VARIABLE: - if (DefinitionModule && CurrVis != Defined->mod_vis) break; - if (df->df_flags & D_VARPAR) { /* VAR parameter */ - addc_db_str('v'); - stb_type(tp, 0); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); - } - else if (df->df_flags & D_VALPAR) { /* value parameter */ - addc_db_str(IsConformantArray(tp) - ? 'i' - : 'p'); - stb_type(tp, 0); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); - } - else if (!proclevel || - (df->df_flags & D_ADDRGIVEN)) { /* global */ - int knd = N_LCSYM; - if (df->df_flags & D_EXPORTED) { - knd = N_GSYM; - addc_db_str('G'); + switch (kind) + { + case D_MODULE: + if (gdb_flag) + { + addc_db_str('F'); + stb_type(void_type, 0); } - else { - addc_db_str('S'); + else + { + adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count)); } - stb_type(tp, 0); - addc_db_str(';'); - if (df->df_flags & D_ADDRGIVEN) { - C_ms_stb_cst(db_str.base, knd, 0, df->var_off); + C_ms_stb_pnam( + db_str.base, N_FUN, gdb_flag ? 0 : proclevel, df->mod_vis->sc_scope->sc_name); + break; + case D_PROCEDURE: + if (gdb_flag) + { + addc_db_str('f'); } - else { - C_ms_stb_dnam(db_str.base, knd, 0, df->var_name, (arith) 0); + else + adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); + stb_type(tp->tp_next ? tp->tp_next : void_type, 0); + if (gdb_flag) + { + struct scopelist* sc = df->prc_vis; + sc = enclosing(sc); + while (sc) + { + struct def* d = sc->sc_scope->sc_definedby; + + if (d && d->df_kind == D_PROCEDURE) + { + adds_db_str(sprint(buf, ",%s", d->df_idf->id_text)); + break; + } + sc = enclosing(sc); + } } - } - else { /* local variable */ - stb_type(tp, 1); /* assign type num to avoid - difficult to parse string */ - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_LSYM, 0, df->var_off); - } - break; - case D_TYPE: - addc_db_str('t'); - stb_type(tp, 1); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, - N_LSYM, - tp == void_type || tp->tp_size >= max_int[2] - ? 0 - : (int)tp->tp_size, - (arith) 0); - break; - case D_CONST: - if (DefinitionModule && CurrVis != Defined->mod_vis) break; - addc_db_str('c'); - addc_db_str('='); - tp = BaseType(tp); - switch(tp->tp_fund) { - case T_INTEGER: - case T_INTORCARD: - case T_CARDINAL: - case T_WORD: - case T_POINTER: - case T_PROCEDURE: - adds_db_str(sprint(buf, "i%ld;", df->con_const.TOK_INT)); + else + addc_db_str(';'); + C_ms_stb_pnam( + db_str.base, N_FUN, gdb_flag ? 0 : proclevel, df->prc_vis->sc_scope->sc_name); break; - case T_CHAR: - adds_db_str(sprint(buf, "c%ld;", df->con_const.TOK_INT)); + case D_END: + if (gdb_flag) + break; + adds_db_str(sprint(buf, "E%d;", df->mod_vis->sc_count)); + C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); break; - case T_REAL: - addc_db_str('r'); - if (! df->con_const.TOK_RSTR) { - char buf2[FLT_STRLEN]; - - flt_flt2str(&df->con_const.TOK_RVAL, buf2, FLT_STRLEN); - adds_db_str(buf2); - } - else adds_db_str(df->con_const.TOK_RSTR); - addc_db_str(';'); + case D_PEND: + if (gdb_flag) + break; + adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); + C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); break; - case T_STRING: { - char *p = df->con_const.TOK_STR; - - adds_db_str("s'"); - while (*p) { - if (*p == '\'' || *p == '\\') { - addc_db_str('\\'); + case D_VARIABLE: + if (DefinitionModule && CurrVis != Defined->mod_vis) + break; + if (df->df_flags & D_VARPAR) + { /* VAR parameter */ + addc_db_str('v'); + stb_type(tp, 0); + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); + } + else if (df->df_flags & D_VALPAR) + { /* value parameter */ + addc_db_str(IsConformantArray(tp) ? 'i' : 'p'); + stb_type(tp, 0); + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); + } + else if (!proclevel || (df->df_flags & D_ADDRGIVEN)) + { /* global */ + int knd = N_LCSYM; + if (df->df_flags & D_EXPORTED) + { + knd = N_GSYM; + addc_db_str('G'); + } + else + { + addc_db_str('S'); + } + stb_type(tp, 0); + addc_db_str(';'); + if (df->df_flags & D_ADDRGIVEN) + { + C_ms_stb_cst(db_str.base, knd, 0, df->var_off); + } + else + { + C_ms_stb_dnam(db_str.base, knd, 0, df->var_name, (arith)0); } - addc_db_str(*p++); } - adds_db_str("';"); + else + { /* local variable */ + stb_type(tp, 1); /* assign type num to avoid + difficult to parse string */ + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_LSYM, 0, df->var_off); } break; - case T_ENUMERATION: - addc_db_str('e'); - stb_type(tp, 0); - adds_db_str(sprint(buf, ",%ld;", df->con_const.TOK_INT)); + case D_TYPE: + addc_db_str('t'); + stb_type(tp, 1); + addc_db_str(';'); + C_ms_stb_cst( + db_str.base, N_LSYM, + tp == void_type || tp->tp_size >= max_int[2] ? 0 : (int)tp->tp_size, (arith)0); break; - case T_SET: { - int i; + case D_CONST: + if (DefinitionModule && CurrVis != Defined->mod_vis) + break; + addc_db_str('c'); + addc_db_str('='); + tp = BaseType(tp); + switch (tp->tp_fund) + { + case T_INTEGER: + case T_INTORCARD: + case T_CARDINAL: + case T_WORD: + case T_POINTER: + case T_PROCEDURE: + adds_db_str(sprint(buf, "i%ld;", df->con_const.TOK_INT)); + break; + case T_CHAR: + adds_db_str(sprint(buf, "c%ld;", df->con_const.TOK_INT)); + break; + case T_REAL: + addc_db_str('r'); + if (!df->con_const.TOK_RSTR) + { + char buf2[FLT_STRLEN]; - addc_db_str('S'); - stb_type(tp, 0); - for (i = 0; i < tp->tp_size; i++) { - adds_db_str(sprint(buf, ",%ld", - (df->con_const.tk_data.tk_set[i/(int) word_size] >> (8*(i%(int)word_size)))&0377)); - } - addc_db_str(';'); + flt_flt2str(&df->con_const.TOK_RVAL, buf2, FLT_STRLEN); + adds_db_str(buf2); + } + else + adds_db_str(df->con_const.TOK_RSTR); + addc_db_str(';'); + break; + case T_STRING: + { + char* p = df->con_const.TOK_STR; + + adds_db_str("s'"); + while (*p) + { + if (*p == '\'' || *p == '\\') + { + addc_db_str('\\'); + } + addc_db_str(*p++); + } + adds_db_str("';"); + } + break; + case T_ENUMERATION: + addc_db_str('e'); + stb_type(tp, 0); + adds_db_str(sprint(buf, ",%ld;", df->con_const.TOK_INT)); + break; + case T_SET: + { + int i; + + addc_db_str('S'); + stb_type(tp, 0); + for (i = 0; i < tp->tp_size; i++) + { + adds_db_str(sprint( + buf, ",%ld", + (df->con_const.tk_data.tk_set[i / (int)word_size] + >> (8 * (i % (int)word_size))) + & 0377)); + } + addc_db_str(';'); + } + break; } + C_ms_stb_cst( + db_str.base, N_LSYM, tp->tp_size < max_int[2] ? (int)tp->tp_size : 0, (arith)0); break; - } - C_ms_stb_cst(db_str.base, - N_LSYM, - tp->tp_size < max_int[2] ? (int)tp->tp_size : 0, - (arith) 0); - break; } } diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index 4247fb252e..beda39c908 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -9,39 +9,41 @@ /* $Id$ */ -#include "parameters.h" +#include "parameters.h" -#ifdef DBSYMTAB +#ifdef DBSYMTAB -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include "LLlex.h" -#include "def.h" -#include "type.h" -#include "idf.h" -#include "const.h" -#include "scope.h" -#include "main.h" -#include "node.h" -#include "print.h" +#include "LLlex.h" +#include "def.h" +#include "type.h" +#include "idf.h" +#include "const.h" +#include "scope.h" +#include "main.h" +#include "node.h" +#include "print.h" -#define INCR_SIZE 64 +#define INCR_SIZE 64 -extern int proclevel; +extern int proclevel; -static struct db_str { - unsigned sz; - char *base; - char *currpos; +static struct db_str +{ + unsigned sz; + char* base; + char* currpos; } db_str; static void create_db_str(void) { - if (! db_str.base) { + if (!db_str.base) + { db_str.base = malloc(INCR_SIZE); db_str.sz = INCR_SIZE; } @@ -51,7 +53,8 @@ static void create_db_str(void) static void addc_db_str(int c) { int df = db_str.currpos - db_str.base; - if (df >= db_str.sz-1) { + if (df >= db_str.sz - 1) + { db_str.sz += INCR_SIZE; db_str.base = realloc(db_str.base, db_str.sz); db_str.currpos = db_str.base + df; @@ -60,168 +63,170 @@ static void addc_db_str(int c) *db_str.currpos = '\0'; } -static void adds_db_str(char *s) +static void adds_db_str(char* s) { - while (*s) addc_db_str(*s++); + while (*s) + addc_db_str(*s++); } -static void stb_type(struct type *tp, int assign_num) +static void stb_type(struct type* tp, int assign_num) { char buf[128]; - static int stb_count; + static int stb_count; - if (tp->tp_dbindex > 0) { + if (tp->tp_dbindex > 0) + { adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); return; } - if (tp->tp_dbindex < 0) { - if (tp->next == 0) { + if (tp->tp_dbindex < 0) + { + if (tp->next == 0) + { adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); return; } tp->tp_dbindex = -tp->tp_dbindex; } - if (tp->tp_dbindex == 0 && assign_num) { + if (tp->tp_dbindex == 0 && assign_num) + { tp->tp_dbindex = ++stb_count; } - if (tp->tp_dbindex > 0) { + if (tp->tp_dbindex > 0) + { adds_db_str(sprint(buf, "%d=", tp->tp_dbindex)); } - if (tp == void_type) { + if (tp == void_type) + { adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); return; } - switch(tp->tp_fund) { - /* simple types ... */ - case T_INTEGER: - case T_LONG: { - arith l = full_mask[(int)tp->tp_size] & ~(1L << (tp->tp_size*8-1)); - adds_db_str(sprint(buf, - "r%d;%ld;%ld", - tp->tp_dbindex, - (long) -l-1, - (long) l)); + switch (tp->tp_fund) + { + /* simple types ... */ + case T_INTEGER: + case T_LONG: + { + arith l = full_mask[(int)tp->tp_size] & ~(1L << (tp->tp_size * 8 - 1)); + adds_db_str(sprint(buf, "r%d;%ld;%ld", tp->tp_dbindex, (long)-l - 1, (long)l)); } break; - case T_REAL: - adds_db_str(sprint(buf, - "r%d;%ld;0", - tp->tp_dbindex, - (long)tp->tp_size)); - break; - case T_CHAR: - adds_db_str(sprint(buf, - "r%d;0;255", - tp->tp_dbindex)); - break; + case T_REAL: + adds_db_str(sprint(buf, "r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size)); + break; + case T_CHAR: + adds_db_str(sprint(buf, "r%d;0;255", tp->tp_dbindex)); + break; - /* constructed types ... */ - case T_SUBRANGE: - adds_db_str(sprint(buf, - "r%d;%ld;%ld", - tp->next->tp_dbindex, - (long) tp->sub_lb, - (long) tp->sub_ub)); - break; - case T_POINTER: - if (tp->next) { - addc_db_str('*'); - stb_type(tp->next, 0); - if (tp->tp_dbindex < 0) tp->tp_dbindex = -tp->tp_dbindex; - } - else { - tp->tp_dbindex = - ++stb_count; - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); - } - break; - case T_SET: - addc_db_str('S'); - stb_type(tp->next, 0); - adds_db_str(sprint(buf, ";%ld;%ld;", (long) tp->tp_size, 0L)); - break; - case T_ARRAY: - addc_db_str('a'); - if (IsConformantArray(tp)) { - addc_db_str('r'); - stb_type(tp->next, 0); - adds_db_str(sprint(buf, ";A%ld;Z%ld", (long) tp->arr_cfdescr, (long) tp->arr_cfdescr)); - } - else { + /* constructed types ... */ + case T_SUBRANGE: + adds_db_str(sprint( + buf, "r%d;%ld;%ld", tp->next->tp_dbindex, (long)tp->sub_lb, (long)tp->sub_ub)); + break; + case T_POINTER: + if (tp->next) + { + addc_db_str('*'); + stb_type(tp->next, 0); + if (tp->tp_dbindex < 0) + tp->tp_dbindex = -tp->tp_dbindex; + } + else + { + tp->tp_dbindex = -++stb_count; + adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + } + break; + case T_SET: + addc_db_str('S'); stb_type(tp->next, 0); - } - addc_db_str(';'); - stb_type(tp->arr_elem, 0); - break; - case T_ENUMERATION: - addc_db_str('e'); - { - struct def *edef = tp->enm_enums; - - while (edef) { - adds_db_str(sprint(buf, "%s:%ld,", - edef->df_idf->id_text, - (long) edef->enm_val)); - edef = edef->enm_next; + adds_db_str(sprint(buf, ";%ld;%ld;", (long)tp->tp_size, 0L)); + break; + case T_ARRAY: + addc_db_str('a'); + if (IsConformantArray(tp)) + { + addc_db_str('r'); + stb_type(tp->next, 0); + adds_db_str( + sprint(buf, ";A%ld;Z%ld", (long)tp->arr_cfdescr, (long)tp->arr_cfdescr)); } - } - addc_db_str(';'); - break; - case T_RECORD: - adds_db_str(sprint(buf, "s%ld", (long) tp->tp_size)); - { - struct def *sdef = tp->rec_scope->sc_def; + else + { + stb_type(tp->next, 0); + } + addc_db_str(';'); + stb_type(tp->arr_elem, 0); + break; + case T_ENUMERATION: + addc_db_str('e'); + { + struct def* edef = tp->enm_enums; - while (sdef) { - adds_db_str(sdef->df_idf->id_text); - addc_db_str(':'); - stb_type(sdef->df_type, 0); - adds_db_str(sprint(buf, - ",%ld,%ld;", - sdef->fld_off*8L, - sdef->df_type->tp_size*8L)); - sdef = sdef->df_nextinscope; + while (edef) + { + adds_db_str(sprint(buf, "%s:%ld,", edef->df_idf->id_text, (long)edef->enm_val)); + edef = edef->enm_next; + } } - } - addc_db_str(';'); - break; - case T_PROCEDURE: - case T_FUNCTION: - addc_db_str('Q'); - stb_type(tp->next ? tp->next : void_type, 0); - { - struct paramlist *p = tp->prc_params; - int paramcount = 0; + addc_db_str(';'); + break; + case T_RECORD: + adds_db_str(sprint(buf, "s%ld", (long)tp->tp_size)); + { + struct def* sdef = tp->rec_scope->sc_def; - while (p) { - paramcount++; - p = p->next; + while (sdef) + { + adds_db_str(sdef->df_idf->id_text); + addc_db_str(':'); + stb_type(sdef->df_type, 0); + adds_db_str( + sprint(buf, ",%ld,%ld;", sdef->fld_off * 8L, sdef->df_type->tp_size * 8L)); + sdef = sdef->df_nextinscope; + } } - adds_db_str(sprint(buf, ",%d;", paramcount)); - p = tp->prc_params; - while (p) { - addc_db_str(IsVarParam(p) - ? 'v' - : IsConformantArray(TypeOfParam(p)) - ? 'i' - : 'p'); - stb_type(TypeOfParam(p), 0); - addc_db_str(';'); - p = p->next; + addc_db_str(';'); + break; + case T_PROCEDURE: + case T_FUNCTION: + addc_db_str('Q'); + stb_type(tp->next ? tp->next : void_type, 0); + { + struct paramlist* p = tp->prc_params; + int paramcount = 0; + + while (p) + { + paramcount++; + p = p->next; + } + adds_db_str(sprint(buf, ",%d;", paramcount)); + p = tp->prc_params; + while (p) + { + addc_db_str( + IsVarParam(p) ? 'v' + : IsConformantArray(TypeOfParam(p)) ? 'i' + : 'p'); + stb_type(TypeOfParam(p), 0); + addc_db_str(';'); + p = p->next; + } } - } - break; - case T_FILE: - addc_db_str('L'); - stb_type(tp->next, 0); - break; - case T_STRING: - addc_db_str('*'); - stb_type(char_type, 0); - break; + break; + case T_FILE: + addc_db_str('L'); + stb_type(tp->next, 0); + break; + case T_STRING: + addc_db_str('*'); + stb_type(char_type, 0); + break; } } -void stb_addtp(char *s, struct type *tp) +void stb_addtp(char* s, struct type* tp) { create_db_str(); adds_db_str(s); @@ -229,155 +234,168 @@ void stb_addtp(char *s, struct type *tp) addc_db_str('t'); stb_type(tp, 1); addc_db_str(';'); - C_ms_stb_cst(db_str.base, - N_LSYM, - tp == void_type || tp->tp_size > 32767 - ? 0 - : (IsPacked(tp) ? (int) tp->tp_psize : (int)tp->tp_size), - (arith) 0); + C_ms_stb_cst( + db_str.base, N_LSYM, + tp == void_type || tp->tp_size > 32767 + ? 0 + : (IsPacked(tp) ? (int)tp->tp_psize : (int)tp->tp_size), + (arith)0); } -void stb_string(struct def *df, long kind) +void stb_string(struct def* df, long kind) { - struct type *tp = df->df_type; + struct type* tp = df->df_type; char buf[64]; create_db_str(); adds_db_str(df->df_idf->id_text); addc_db_str(':'); - if (kind == D_MODULE) { + if (kind == D_MODULE) + { adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count)); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "_m_a_i_n"); return; } - switch((int)kind) { - case D_PROCEDURE: - case D_FUNCTION: - adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); - stb_type(tp->next ? tp->next : void_type, 0); - addc_db_str(';'); - C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->df_idf->id_text); - { - struct paramlist *p = tp->prc_params; - while (p) { - stb_string(p->par_def, D_VARIABLE); - p = p->next; + switch ((int)kind) + { + case D_PROCEDURE: + case D_FUNCTION: + adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); + stb_type(tp->next ? tp->next : void_type, 0); + addc_db_str(';'); + C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->df_idf->id_text); + { + struct paramlist* p = tp->prc_params; + while (p) + { + stb_string(p->par_def, D_VARIABLE); + p = p->next; + } } - } - for (df = df->prc_vis->sc_scope->sc_def; df; df = df->df_nextinscope) { - if (df->df_kind == D_LBOUND || - df->df_kind == D_UBOUND) { - stb_string(df, df->df_kind); + for (df = df->prc_vis->sc_scope->sc_def; df; df = df->df_nextinscope) + { + if (df->df_kind == D_LBOUND || df->df_kind == D_UBOUND) + { + stb_string(df, df->df_kind); + } } - } - break; - case D_END: - case D_PEND: - adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); - C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); - break; - case D_VARIABLE: - if (df->df_flags & D_VARPAR) { /* VAR parameter */ - addc_db_str('v'); - stb_type(tp, 0); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); - } - else if (df->df_flags & D_VALPAR) { /* value parameter */ - addc_db_str(IsConformantArray(tp) - ? 'i' - : 'p'); - stb_type(tp, 0); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); - } - else if (!proclevel) { - addc_db_str('G'); - stb_type(tp, 0); - addc_db_str(';'); - C_ms_stb_dnam(db_str.base, N_LCSYM, 0, df->var_name, (arith) 0); - } - else { /* local variable */ - stb_type(tp, 1); /* assign type num to avoid - difficult to parse string */ - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_LSYM, 0, df->var_off); - } - break; - case D_LBOUND: - case D_UBOUND: - addc_db_str(kind == D_LBOUND ? 'A' : 'Z'); - addc_db_str('p'); - stb_type(tp, 0); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, N_PSYM, 0, df->bnd_type->arr_cfdescr); - break; - case D_TYPE: - addc_db_str('t'); - stb_type(tp, 1); - addc_db_str(';'); - C_ms_stb_cst(db_str.base, - N_LSYM, - tp == void_type || tp->tp_size > 32767 - ? 0 - : (IsPacked(tp) ? (int) tp->tp_psize : (int)tp->tp_size), - (arith) 0); - break; - case D_CONST: - addc_db_str('c'); - addc_db_str('='); - tp = BaseType(tp); - switch(tp->tp_fund) { - case T_INTEGER: - case T_LONG: - case T_POINTER: - case T_PROCEDURE: - adds_db_str(sprint(buf, "i%ld;", (long) df->con_const->nd_INT)); break; - case T_CHAR: - adds_db_str(sprint(buf, "c%ld;", (long) df->con_const->nd_INT)); + case D_END: + case D_PEND: + adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); + C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); break; - case T_REAL: - addc_db_str('r'); - adds_db_str(df->con_const->nd_REL); - addc_db_str(';'); - break; - case T_STRINGCONST: { - char *p = df->con_const->nd_STR; - - adds_db_str("s'"); - while (*p) { - if (*p == '\'' || *p == '\\') { - addc_db_str('\\'); - } - addc_db_str(*p++); + case D_VARIABLE: + if (df->df_flags & D_VARPAR) + { /* VAR parameter */ + addc_db_str('v'); + stb_type(tp, 0); + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); + } + else if (df->df_flags & D_VALPAR) + { /* value parameter */ + addc_db_str(IsConformantArray(tp) ? 'i' : 'p'); + stb_type(tp, 0); + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_PSYM, 0, df->var_off); } - adds_db_str("';"); + else if (!proclevel) + { + addc_db_str('G'); + stb_type(tp, 0); + addc_db_str(';'); + C_ms_stb_dnam(db_str.base, N_LCSYM, 0, df->var_name, (arith)0); + } + else + { /* local variable */ + stb_type(tp, 1); /* assign type num to avoid + difficult to parse string */ + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_LSYM, 0, df->var_off); } break; - case T_ENUMERATION: - addc_db_str('e'); + case D_LBOUND: + case D_UBOUND: + addc_db_str(kind == D_LBOUND ? 'A' : 'Z'); + addc_db_str('p'); stb_type(tp, 0); - adds_db_str(sprint(buf, ",%ld;", (long) df->con_const->nd_INT)); + addc_db_str(';'); + C_ms_stb_cst(db_str.base, N_PSYM, 0, df->bnd_type->arr_cfdescr); break; - case T_SET: { - int i; - - addc_db_str('S'); - stb_type(tp, 0); - for (i = 0; i < tp->tp_size; i++) { - adds_db_str(sprint(buf, ",%ld", - (long) (df->con_const->nd_set[i/(int) word_size] >> (8*(i%(int)word_size)))&0377)); - } + case D_TYPE: + addc_db_str('t'); + stb_type(tp, 1); addc_db_str(';'); + C_ms_stb_cst( + db_str.base, N_LSYM, + tp == void_type || tp->tp_size > 32767 + ? 0 + : (IsPacked(tp) ? (int)tp->tp_psize : (int)tp->tp_size), + (arith)0); + break; + case D_CONST: + addc_db_str('c'); + addc_db_str('='); + tp = BaseType(tp); + switch (tp->tp_fund) + { + case T_INTEGER: + case T_LONG: + case T_POINTER: + case T_PROCEDURE: + adds_db_str(sprint(buf, "i%ld;", (long)df->con_const->nd_INT)); + break; + case T_CHAR: + adds_db_str(sprint(buf, "c%ld;", (long)df->con_const->nd_INT)); + break; + case T_REAL: + addc_db_str('r'); + adds_db_str(df->con_const->nd_REL); + addc_db_str(';'); + break; + case T_STRINGCONST: + { + char* p = df->con_const->nd_STR; + + adds_db_str("s'"); + while (*p) + { + if (*p == '\'' || *p == '\\') + { + addc_db_str('\\'); + } + addc_db_str(*p++); + } + adds_db_str("';"); + } + break; + case T_ENUMERATION: + addc_db_str('e'); + stb_type(tp, 0); + adds_db_str(sprint(buf, ",%ld;", (long)df->con_const->nd_INT)); + break; + case T_SET: + { + int i; + + addc_db_str('S'); + stb_type(tp, 0); + for (i = 0; i < tp->tp_size; i++) + { + adds_db_str(sprint( + buf, ",%ld", + (long)(df->con_const->nd_set[i / (int)word_size] + >> (8 * (i % (int)word_size))) + & 0377)); + } + addc_db_str(';'); + } + break; } + C_ms_stb_cst( + db_str.base, N_LSYM, tp->tp_size <= 32767 ? (int)tp->tp_size : 0, (arith)0); break; - } - C_ms_stb_cst(db_str.base, - N_LSYM, - tp->tp_size <= 32767 ? (int)tp->tp_size : 0, - (arith) 0); - break; } } From 3938f8a3800050204bb76adc69d3efbdeaa3d1a3 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 5 Dec 2024 14:11:55 +0100 Subject: [PATCH 11/29] Replace sprint with sprintf. --- lang/basic/src/symbols.c | 4 +- lang/basic/src/util.c | 2 +- lang/cem/cemcom.ansi/dumpidf.c | 24 ++++----- lang/cem/cemcom.ansi/idf.c | 2 +- lang/cem/cemcom/arith.c | 2 +- lang/cem/cemcom/dumpidf.c | 16 +++--- lang/cem/cemcom/idf.c | 2 +- lang/cem/cpp.ansi/init.c | 4 +- lang/cem/cpp.ansi/preprocess.c | 4 +- lang/cem/lint/lpass2/l_print3ack.c | 2 +- lang/m2/comp/def.c | 6 +-- lang/m2/comp/enter.c | 2 +- lang/m2/comp/misc.c | 2 +- lang/m2/comp/program.g | 2 +- lang/m2/comp/stab.c | 82 +++++++++++++++++------------- lang/m2/comp/typequiv.c | 4 +- lang/m2/m2mm/misc.c | 2 +- lang/occam/comp/em.c | 4 +- lang/occam/comp/lex.l | 8 +-- lang/pc/comp/chk_expr.c | 4 +- lang/pc/comp/declar.g | 2 +- lang/pc/comp/misc.c | 4 +- lang/pc/comp/readwrite.c | 4 +- lang/pc/comp/stab.c | 64 +++++++++++++---------- mach/i386/ce/as.c | 4 +- mach/i86/ce/as.c | 4 +- mach/sparc/ce/EM_table.x | 32 ++++++------ mach/sparc/ce/cache.c.x | 30 +++++------ mach/vax4/ce/as.c | 2 +- modules/src/em_code/em.c | 12 ++--- modules/src/print/build.lua | 1 - modules/src/print/print.3 | 8 +-- modules/src/print/print.h | 1 - modules/src/print/sprint.c | 28 ---------- util/arch/archiver.c | 2 +- util/ceg/ce_back/as_back/bottom.c | 22 ++++---- 36 files changed, 191 insertions(+), 207 deletions(-) delete mode 100644 modules/src/print/sprint.c diff --git a/lang/basic/src/symbols.c b/lang/basic/src/symbols.c index 08017cc57e..7a61a2add5 100644 --- a/lang/basic/src/symbols.c +++ b/lang/basic/src/symbols.c @@ -256,7 +256,7 @@ void heading(void) { char procname[50]; - (void) sprint(procname,"_%s",fcn->symname); + (void) sprintf(procname,"_%s",fcn->symname); C_pro_narg(procname); if ( fcn->symtype== DEFAULTTYPE) fcn->symtype= DOUBLETYPE; @@ -348,7 +348,7 @@ int fcnend(int parmcount) error("not enough parameters"); if ( parmcount >fcn->dimensions) error("too many parameters"); - (void) sprint(concatbuf,"_%s",fcn->symname); + (void) sprintf(concatbuf,"_%s",fcn->symname); C_cal(concatbuf); C_asp((arith)fcnsize()); C_lfr((arith) typestring(fcn->symtype)); diff --git a/lang/basic/src/util.c b/lang/basic/src/util.c index d300431a14..6c8a6342dc 100644 --- a/lang/basic/src/util.c +++ b/lang/basic/src/util.c @@ -74,7 +74,7 @@ char *myitoa(int i) { static char buf[30]; - sprint(buf,"%d",i); + sprintf(buf,"%d",i); return(buf); } diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index e9d799fbcf..f262fdf5f4 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -324,37 +324,37 @@ static char *type2str(struct type *tp) buf[0] = '\0'; if (!tp) { - sprint(buf, ""); + sprintf(buf, ""); return buf; } - sprint(buf, "%s(@%lx, #%ld, &%d) ", + sprintf(buf, "%s(@%lx, #%ld, &%d) ", buf, tp, (long)tp->tp_size, tp->tp_align); while (ops) { - sprint(buf, "%s%s", buf, qual2str(tp->tp_typequal)); + sprintf(buf, "%s%s", buf, qual2str(tp->tp_typequal)); switch (tp->tp_fund) { case POINTER: - sprint(buf, "%spointer to ", buf); + sprintf(buf, "%spointer to ", buf); break; case ARRAY: - sprint(buf, "%sarray [%ld] of ", buf, tp->tp_size); + sprintf(buf, "%sarray [%ld] of ", buf, tp->tp_size); break; case FUNCTION: - sprint(buf, "%sfunction yielding ", buf); + sprintf(buf, "%sfunction yielding ", buf); break; default: - sprint(buf, "%s%s%s ", buf, + sprintf(buf, "%s%s%s ", buf, tp->tp_unsigned ? "unsigned " : "", symbol2str(tp->tp_fund) ); if (tp->tp_idf) - sprint(buf, "%s %s ", buf, + sprintf(buf, "%s %s ", buf, tp->tp_idf->id_text); #ifndef NOBITFIELD if (tp->tp_fund == FIELD && tp->tp_field) { struct field *fd = tp->tp_field; - sprint(buf, "%s [s=%ld,w=%ld] of ", buf, + sprintf(buf, "%s [s=%ld,w=%ld] of ", buf, fd->fd_shift, fd->fd_width); } else @@ -373,11 +373,11 @@ static char *qual2str(int qual) *buf = '\0'; if (qual == 0) - sprint(buf, "(none)"); + sprintf(buf, "(none)"); if (qual & TQ_CONST) - sprint(buf, "%sconst ", buf); + sprintf(buf, "%sconst ", buf); if (qual & TQ_VOLATILE) - sprint(buf, "%svolatile ", buf); + sprintf(buf, "%svolatile ", buf); return qual == 0 ? "" : buf; } diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index c9c05ae342..94d6ebb395 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -53,7 +53,7 @@ struct idf *gen_idf(void) static int name_cnt; char *s = malloc(strlen(dot.tk_file) + 50); - sprint(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line); + sprintf(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line); s = realloc(s, strlen(s) + 1); return str2idf(s, 0); } diff --git a/lang/cem/cemcom/arith.c b/lang/cem/cemcom/arith.c index f41a1a893d..26b192a605 100644 --- a/lang/cem/cemcom/arith.c +++ b/lang/cem/cemcom/arith.c @@ -281,7 +281,7 @@ int2float(expp, tp) if (is_cp_cst(exp)) { *expp = new_expr(); **expp = *exp; - sprint(buf+1, "%ld", (long)(exp->VL_VALUE)); + sprintf(buf+1, "%ld", (long)(exp->VL_VALUE)); buf[0] = '-'; exp = *expp; exp->ex_type = tp; diff --git a/lang/cem/cemcom/dumpidf.c b/lang/cem/cemcom/dumpidf.c index 39b3c74e9c..407fdddf4d 100644 --- a/lang/cem/cemcom/dumpidf.c +++ b/lang/cem/cemcom/dumpidf.c @@ -249,35 +249,35 @@ type2str(tp) buf[0] = '\0'; if (!tp) { - sprint(buf, ""); + sprintf(buf, ""); return buf; } - sprint(buf, "%s(#%ld, &%d) ", buf, (long)tp->tp_size, tp->tp_align); + sprintf(buf, "%s(#%ld, &%d) ", buf, (long)tp->tp_size, tp->tp_align); while (ops) { switch (tp->tp_fund) { case POINTER: - sprint(buf, "%spointer to ", buf); + sprintf(buf, "%spointer to ", buf); break; case ARRAY: - sprint(buf, "%sarray [%ld] of ", buf, tp->tp_size); + sprintf(buf, "%sarray [%ld] of ", buf, tp->tp_size); break; case FUNCTION: - sprint(buf, "%sfunction yielding ", buf); + sprintf(buf, "%sfunction yielding ", buf); break; default: - sprint(buf, "%s%s%s", buf, + sprintf(buf, "%s%s%s", buf, tp->tp_unsigned ? "unsigned " : "", symbol2str(tp->tp_fund) ); if (tp->tp_idf) - sprint(buf, "%s %s", buf, + sprintf(buf, "%s %s", buf, tp->tp_idf->id_text); #ifndef NOBITFIELD if (tp->tp_field) { struct field *fd = tp->tp_field; - sprint(buf, "%s [s=%ld,w=%ld] of ", buf, + sprintf(buf, "%s [s=%ld,w=%ld] of ", buf, fd->fd_shift, fd->fd_width); } else diff --git a/lang/cem/cemcom/idf.c b/lang/cem/cemcom/idf.c index 789fbf0d4b..9643bc1e10 100644 --- a/lang/cem/cemcom/idf.c +++ b/lang/cem/cemcom/idf.c @@ -157,7 +157,7 @@ gen_idf() struct idf *id; char *s = malloc(strlen(dot.tk_file)+50); - sprint(s, "#%d in %s, line %u", + sprintf(s, "#%d in %s, line %u", ++name_cnt, dot.tk_file, dot.tk_line); id = str2idf(s); free(s); diff --git a/lang/cem/cpp.ansi/init.c b/lang/cem/cpp.ansi/init.c index 68b760e0c2..0c52973e52 100644 --- a/lang/cem/cpp.ansi/init.c +++ b/lang/cem/cpp.ansi/init.c @@ -74,13 +74,13 @@ void init_pp(void) tp = localtime(&clock); /* __DATE__ */ - sprint(dbuf, "\"%s %2d %d\"", months[tp->tm_mon], + sprintf(dbuf, "\"%s %2d %d\"", months[tp->tm_mon], tp->tm_mday, tp->tm_year+1900); /* if (tp->tm_mday < 10) dbuf[5] = ' '; */ /* hack */ macro_def(str2idf("__DATE__", 0), dbuf, -1, strlen(dbuf), NOUNDEF); /* __TIME__ */ - sprint(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec); + sprintf(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec); macro_def(str2idf("__TIME__", 0), tbuf, -1, strlen(tbuf), NOUNDEF); /* __LINE__ */ diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index 72c85ac221..afc72526be 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -157,7 +157,7 @@ void preprocess(char *fn) */ char* p = Xbuf; - sprint(p, "%s 1 \"%s\"\n", LINE_PREFIX, FileName); + sprintf(p, "%s 1 \"%s\"\n", LINE_PREFIX, FileName); while (*p) { echo(*p++); @@ -172,7 +172,7 @@ void preprocess(char *fn) if (!options['P']) \ { \ char* p = Xbuf; \ - sprint(Xbuf, "%s %d \"%s\"\n", LINE_PREFIX, (int)LineNumber, FileName); \ + sprintf(Xbuf, "%s %d \"%s\"\n", LINE_PREFIX, (int)LineNumber, FileName); \ op--; \ while (op >= _obuf && (class(*op) == STSKIP || *op == '\n')) \ op--; \ diff --git a/lang/cem/lint/lpass2/l_print3ack.c b/lang/cem/lint/lpass2/l_print3ack.c index 1db021f54d..b0d8544edb 100644 --- a/lang/cem/lint/lpass2/l_print3ack.c +++ b/lang/cem/lint/lpass2/l_print3ack.c @@ -22,7 +22,7 @@ print(format) char *format; { ; } /* FORMAT1 */ fprint(filep, format) File *filep; char *format; { ; } /* FORMAT1 */ -sprint(s, format) char *s; char *format; { ; } +sprintf(s, format) char *s; char *format; { ; } /* FORMAT1 */ doprnt(filep, format) File *filep; char *format; { ; } diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 66f9553fab..682421f882 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -287,7 +287,7 @@ struct def * DeclProc(int type, struct idf *id) } else { - sprint(buf, "%s_%s", CurrentScope->sc_name, id->id_text); + sprintf(buf, "%s_%s", CurrentScope->sc_name, id->id_text); df->prc_name = Salloc(buf, (unsigned) (strlen(buf) + 1)); } if (CurrVis == Defined->mod_vis) @@ -311,7 +311,7 @@ struct def * DeclProc(int type, struct idf *id) else { df = define(id, CurrentScope, type); - sprint(buf, "_%d_%s", ++nmcount, id->id_text); + sprintf(buf, "_%d_%s", ++nmcount, id->id_text); df->prc_name = Salloc(buf, (unsigned) (strlen(buf) + 1)); internal(buf); df->df_flags |= D_DEFINED; @@ -355,7 +355,7 @@ struct def * DefineLocalModule(struct idf *id) char buf[256]; extern int proclevel; - sprint(buf, "_%d%s_", ++modulecount, id->id_text); + sprintf(buf, "_%d%s_", ++modulecount, id->id_text); if (!df->mod_vis) { diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 130ed2e6f2..89704d0976 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -159,7 +159,7 @@ void EnterVarList(struct node *Idlist, struct type *type, int local) df->var_name = df->df_idf->id_text; } else { - sprint(buf,"%s_%s", sc->sc_scope->sc_name, + sprintf(buf,"%s_%s", sc->sc_scope->sc_name, df->df_idf->id_text); df->var_name = Salloc(buf, (unsigned)(strlen(buf)+1)); diff --git a/lang/m2/comp/misc.c b/lang/m2/comp/misc.c index b85cb54cf0..dd172815ca 100644 --- a/lang/m2/comp/misc.c +++ b/lang/m2/comp/misc.c @@ -47,7 +47,7 @@ struct idf *gen_anon_idf(void) static int name_cnt; char *s = malloc(strlen(FileName)+50); - sprint(s, "#%d in %s, line %u", + sprintf(s, "#%d in %s, line %u", ++name_cnt, FileName, LineNumber); s = realloc(s, strlen(s)+1); return str2idf(s, 0); diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index c7882f136b..788a6187fb 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -156,7 +156,7 @@ DefinitionModule error("DEFINITION MODULE name is \"%s\", not \"%s\"", df->df_idf->id_text, DefId->id_text); } - sprint(buf, "_%s_", df->df_idf->id_text); + sprintf(buf, "_%s_", df->df_idf->id_text); currscope->sc_name = Salloc(buf, (unsigned) strlen(buf) + 1); df->mod_vis = CurrVis; df->df_type = standard_type(T_RECORD, 1, (arith) 1); diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index aba30930ca..e07a099faf 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -30,6 +30,8 @@ #include "main.h" #include "print.h" +#include + extern int gdb_flag; #define INCR_SIZE 64 @@ -72,21 +74,32 @@ static void adds_db_str(char* s) addc_db_str(*s++); } -static void stb_type(struct type* tp, int assign_num) +static void adds_db_strf(char* s, ...) { char buf[128]; + va_list ap; + + va_start(ap, s); + vsnprintf(buf, sizeof(buf), s, ap); + va_end(ap); + + adds_db_str(buf); +} + +static void stb_type(struct type* tp, int assign_num) +{ static int stb_count; if (tp->tp_dbindex > 0) { - adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); + adds_db_strf("%d", tp->tp_dbindex); return; } if (tp->tp_dbindex < 0) { if (tp->tp_next == 0) { - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + adds_db_strf("%d", -tp->tp_dbindex); return; } tp->tp_dbindex = -tp->tp_dbindex; @@ -97,45 +110,45 @@ static void stb_type(struct type* tp, int assign_num) } if (tp->tp_dbindex > 0) { - adds_db_str(sprint(buf, "%d=", tp->tp_dbindex)); + adds_db_strf("%d=", tp->tp_dbindex); } if (tp == void_type) { - adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); + adds_db_strf("%d", tp->tp_dbindex); return; } switch (tp->tp_fund) { /* simple types ... */ case T_INTEGER: - adds_db_str(sprint( - buf, "r%d;%ld;%ld", tp->tp_dbindex, (long)min_int[(int)tp->tp_size], - (long)max_int[(int)tp->tp_size])); + adds_db_strf( + "r%d;%ld;%ld", tp->tp_dbindex, (long)min_int[(int)tp->tp_size], + (long)max_int[(int)tp->tp_size]); break; case T_CARDINAL: - adds_db_str(sprint(buf, "r%d;0;-1", tp->tp_dbindex)); + adds_db_strf("r%d;0;-1", tp->tp_dbindex); break; case T_REAL: - adds_db_str(sprint(buf, "r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size)); + adds_db_strf("r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size); break; case T_CHAR: - adds_db_str(sprint(buf, "r%d;0;255", tp->tp_dbindex)); + adds_db_strf("r%d;0;255", tp->tp_dbindex); break; case T_WORD: if (tp->tp_size == word_size) { - adds_db_str(sprint(buf, "r%d;0;-1", tp->tp_dbindex)); + adds_db_strf("r%d;0;-1", tp->tp_dbindex); } else { - adds_db_str(sprint(buf, "r%d;0;255", tp->tp_dbindex)); + adds_db_strf("r%d;0;255", tp->tp_dbindex); } break; /* constructed types ... */ case T_SUBRANGE: - adds_db_str(sprint( - buf, "r%d;%ld;%ld", tp->tp_next->tp_dbindex, (long)tp->sub_lb, (long)tp->sub_ub)); + adds_db_strf( + "r%d;%ld;%ld", tp->tp_next->tp_dbindex, (long)tp->sub_lb, (long)tp->sub_ub); break; case T_EQUAL: stb_type(tp->tp_next, 0); @@ -146,7 +159,7 @@ static void stb_type(struct type* tp, int assign_num) if (DefinitionModule && CurrVis == Defined->mod_vis) { tp->tp_dbindex = -++stb_count; - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + adds_db_strf("%d", -tp->tp_dbindex); } else { @@ -167,13 +180,13 @@ static void stb_type(struct type* tp, int assign_num) else { tp->tp_dbindex = -++stb_count; - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + adds_db_strf("%d", -tp->tp_dbindex); } break; case T_SET: addc_db_str('S'); stb_type(tp->tp_next, 0); - adds_db_str(sprint(buf, ";%ld;%ld;", tp->tp_size, tp->set_low)); + adds_db_strf(";%ld;%ld;", tp->tp_size, tp->set_low); break; case T_ARRAY: addc_db_str('a'); @@ -181,7 +194,7 @@ static void stb_type(struct type* tp, int assign_num) { addc_db_str('r'); stb_type(tp->tp_next, 0); - adds_db_str(sprint(buf, ";0;A%ld", tp->arr_high)); + adds_db_strf(";0;A%ld", tp->arr_high); } else { @@ -197,14 +210,14 @@ static void stb_type(struct type* tp, int assign_num) while (edef) { - adds_db_str(sprint(buf, "%s:%ld,", edef->df_idf->id_text, edef->enm_val)); + adds_db_strf("%s:%ld,", edef->df_idf->id_text, edef->enm_val); edef = edef->enm_next; } } addc_db_str(';'); break; case T_RECORD: - adds_db_str(sprint(buf, "s%ld", tp->tp_size)); + adds_db_strf("s%ld", tp->tp_size); { struct def* sdef = tp->rec_scope->sc_def; @@ -213,8 +226,7 @@ static void stb_type(struct type* tp, int assign_num) adds_db_str(sdef->df_idf->id_text); addc_db_str(':'); stb_type(sdef->df_type, 0); - adds_db_str( - sprint(buf, ",%ld,%ld;", sdef->fld_off * 8, sdef->df_type->tp_size * 8)); + adds_db_strf(",%ld,%ld;", sdef->fld_off * 8, sdef->df_type->tp_size * 8); sdef = sdef->df_nextinscope; } } @@ -238,7 +250,7 @@ static void stb_type(struct type* tp, int assign_num) paramcount++; p = p->par_next; } - adds_db_str(sprint(buf, ",%d;", paramcount)); + adds_db_strf(",%d;", paramcount); p = tp->prc_params; while (p) { @@ -285,7 +297,7 @@ void stb_string(struct def* df, int kind) } else { - adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count)); + adds_db_strf("M%d;", df->mod_vis->sc_count); } C_ms_stb_pnam( db_str.base, N_FUN, gdb_flag ? 0 : proclevel, df->mod_vis->sc_scope->sc_name); @@ -296,7 +308,7 @@ void stb_string(struct def* df, int kind) addc_db_str('f'); } else - adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); + adds_db_strf("Q%d;", df->prc_vis->sc_count); stb_type(tp->tp_next ? tp->tp_next : void_type, 0); if (gdb_flag) { @@ -308,7 +320,7 @@ void stb_string(struct def* df, int kind) if (d && d->df_kind == D_PROCEDURE) { - adds_db_str(sprint(buf, ",%s", d->df_idf->id_text)); + adds_db_strf(",%s", d->df_idf->id_text); break; } sc = enclosing(sc); @@ -322,13 +334,13 @@ void stb_string(struct def* df, int kind) case D_END: if (gdb_flag) break; - adds_db_str(sprint(buf, "E%d;", df->mod_vis->sc_count)); + adds_db_strf("E%d;", df->mod_vis->sc_count); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); break; case D_PEND: if (gdb_flag) break; - adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); + adds_db_strf("E%d;", df->prc_vis->sc_count); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); break; case D_VARIABLE: @@ -401,10 +413,10 @@ void stb_string(struct def* df, int kind) case T_WORD: case T_POINTER: case T_PROCEDURE: - adds_db_str(sprint(buf, "i%ld;", df->con_const.TOK_INT)); + adds_db_strf("i%ld;", df->con_const.TOK_INT); break; case T_CHAR: - adds_db_str(sprint(buf, "c%ld;", df->con_const.TOK_INT)); + adds_db_strf("c%ld;", df->con_const.TOK_INT); break; case T_REAL: addc_db_str('r'); @@ -438,7 +450,7 @@ void stb_string(struct def* df, int kind) case T_ENUMERATION: addc_db_str('e'); stb_type(tp, 0); - adds_db_str(sprint(buf, ",%ld;", df->con_const.TOK_INT)); + adds_db_strf(",%ld;", df->con_const.TOK_INT); break; case T_SET: { @@ -448,11 +460,11 @@ void stb_string(struct def* df, int kind) stb_type(tp, 0); for (i = 0; i < tp->tp_size; i++) { - adds_db_str(sprint( - buf, ",%ld", + adds_db_strf( + ",%ld", (df->con_const.tk_data.tk_set[i / (int)word_size] >> (8 * (i % (int)word_size))) - & 0377)); + & 0377); } addc_db_str(';'); } diff --git a/lang/m2/comp/typequiv.c b/lang/m2/comp/typequiv.c index 53b6934c0a..6ad0a737b4 100644 --- a/lang/m2/comp/typequiv.c +++ b/lang/m2/comp/typequiv.c @@ -193,9 +193,9 @@ int TstParCompat(int parno, struct type *formaltype, int VARflag, struct node ** char ebuf[256]; if (edf) { - sprint(ebuf, "\"%s\", parameter %d: %%s", edf->df_idf->id_text, parno); + sprintf(ebuf, "\"%s\", parameter %d: %%s", edf->df_idf->id_text, parno); } - else sprint(ebuf, "parameter %d: %%s", parno); + else sprintf(ebuf, "parameter %d: %%s", parno); if ( TstTypeEquiv(formaltype, actualtype) diff --git a/lang/m2/m2mm/misc.c b/lang/m2/m2mm/misc.c index eabf2091c7..289e33ed26 100644 --- a/lang/m2/m2mm/misc.c +++ b/lang/m2/m2mm/misc.c @@ -24,7 +24,7 @@ gen_anon_idf() static int name_cnt; char buff[100]; - sprint(buff, "#%d in %s, line %u", + sprintf(buff, "#%d in %s, line %u", ++name_cnt, FileName, LineNumber); return str2idf(buff, 1); } diff --git a/lang/occam/comp/em.c b/lang/occam/comp/em.c index 6038d073b8..47c0d10f09 100644 --- a/lang/occam/comp/em.c +++ b/lang/occam/comp/em.c @@ -89,7 +89,7 @@ char *proc_label(L, name) register L; register char *name; lab=malloc(strlen(name)+(1+sizeof(int)*3+1)); /* That is: P\0 */ - sprint(lab, "P%d", L); + sprintf(lab, "P%d", L); n=lab+strlen(lab); @@ -358,7 +358,7 @@ void zne(lab) int lab; { C_zne((label) lab); } char *myitoa(i) long i; { static char a[sizeof(long)*3]; - sprint(a, "%ld", i); + sprintf(a, "%ld", i); return a; } diff --git a/lang/occam/comp/lex.l b/lang/occam/comp/lex.l index 0a7e9bbbbd..0b8c29de10 100644 --- a/lang/occam/comp/lex.l +++ b/lang/occam/comp/lex.l @@ -279,9 +279,9 @@ char *tokenname(tk, inst) register tk, inst; static char c[7]; if (' 'nd_type, (int) IsVarParam(param), left, new_par_section)) { - sprint(ebuf, "type incompatibility in parameter %d", cnt); + sprintf(ebuf, "type incompatibility in parameter %d", cnt); Xerror(name, ebuf); retval = 0; } diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index 6b27710fac..92bcdb5ecb 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -168,7 +168,7 @@ Label(struct node **pnd;) *pnd = NULLNODE; } else { - sprint(lab, "%d", (int) dot.TOK_INT); + sprintf(lab, "%d", (int) dot.TOK_INT); *pnd = MkLeaf(Name, &dot); (*pnd)->nd_IDF = str2idf(lab, 1); } diff --git a/lang/pc/comp/misc.c b/lang/pc/comp/misc.c index 990c32d924..44409013d4 100644 --- a/lang/pc/comp/misc.c +++ b/lang/pc/comp/misc.c @@ -23,7 +23,7 @@ struct idf *gen_anon_idf(void) static int name_cnt; char *s = malloc(strlen(FileName) + 50); - sprint(s, "#%d in %s, line %u", ++name_cnt, FileName, LineNumber); + sprintf(s, "#%d in %s, line %u", ++name_cnt, FileName, LineNumber); s = realloc(s, strlen(s)+1); return str2idf(s, 0); } @@ -48,7 +48,7 @@ char *gen_proc_name(struct idf *id, int inp) if( inp ) { - sprint(buf, "_%d%s", ++name_cnt, id->id_text); + sprintf(buf, "_%d%s", ++name_cnt, id->id_text); C_inp(buf); return Salloc(buf, (unsigned) (strlen(buf) + 1)); } diff --git a/lang/pc/comp/readwrite.c b/lang/pc/comp/readwrite.c index 706c08c5e6..5f16185341 100644 --- a/lang/pc/comp/readwrite.c +++ b/lang/pc/comp/readwrite.c @@ -91,7 +91,7 @@ void ChkRead(struct node *arg) } message = ChkAllowedVar(arg->nd_left, 1); if( message ) { - sprint(buff,"\"%%s\": %s can't be a variable parameter", + sprintf(buff,"\"%%s\": %s can't be a variable parameter", message); node_error(arg->nd_left, buff, name); return; @@ -146,7 +146,7 @@ void ChkReadln(struct node *arg) } message = ChkAllowedVar(arg->nd_left, 1); if( message ) { - sprint(buff,"\"%%s\": %s can't be a variable parameter", + sprintf(buff,"\"%%s\": %s can't be a variable parameter", message); node_error(arg->nd_left, buff, name); return; diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index beda39c908..1902d8a240 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -69,21 +69,32 @@ static void adds_db_str(char* s) addc_db_str(*s++); } -static void stb_type(struct type* tp, int assign_num) +static void adds_db_strf(char* s, ...) { char buf[128]; + va_list ap; + + va_start(ap, s); + vsnprintf(buf, sizeof(buf), s, ap); + va_end(ap); + + adds_db_str(buf); +} + +static void stb_type(struct type* tp, int assign_num) +{ static int stb_count; if (tp->tp_dbindex > 0) { - adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); + adds_db_strf("%d", tp->tp_dbindex); return; } if (tp->tp_dbindex < 0) { if (tp->next == 0) { - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + adds_db_strf("%d", -tp->tp_dbindex); return; } tp->tp_dbindex = -tp->tp_dbindex; @@ -94,11 +105,11 @@ static void stb_type(struct type* tp, int assign_num) } if (tp->tp_dbindex > 0) { - adds_db_str(sprint(buf, "%d=", tp->tp_dbindex)); + adds_db_strf("%d=", tp->tp_dbindex); } if (tp == void_type) { - adds_db_str(sprint(buf, "%d", tp->tp_dbindex)); + adds_db_strf("%d", tp->tp_dbindex); return; } switch (tp->tp_fund) @@ -108,20 +119,19 @@ static void stb_type(struct type* tp, int assign_num) case T_LONG: { arith l = full_mask[(int)tp->tp_size] & ~(1L << (tp->tp_size * 8 - 1)); - adds_db_str(sprint(buf, "r%d;%ld;%ld", tp->tp_dbindex, (long)-l - 1, (long)l)); + adds_db_strf("r%d;%ld;%ld", tp->tp_dbindex, (long)-l - 1, (long)l); } break; case T_REAL: - adds_db_str(sprint(buf, "r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size)); + adds_db_strf("r%d;%ld;0", tp->tp_dbindex, (long)tp->tp_size); break; case T_CHAR: - adds_db_str(sprint(buf, "r%d;0;255", tp->tp_dbindex)); + adds_db_strf("r%d;0;255", tp->tp_dbindex); break; /* constructed types ... */ case T_SUBRANGE: - adds_db_str(sprint( - buf, "r%d;%ld;%ld", tp->next->tp_dbindex, (long)tp->sub_lb, (long)tp->sub_ub)); + adds_db_strf("r%d;%ld;%ld", tp->next->tp_dbindex, (long)tp->sub_lb, (long)tp->sub_ub); break; case T_POINTER: if (tp->next) @@ -134,13 +144,13 @@ static void stb_type(struct type* tp, int assign_num) else { tp->tp_dbindex = -++stb_count; - adds_db_str(sprint(buf, "%d", -tp->tp_dbindex)); + adds_db_strf("%d", -tp->tp_dbindex); } break; case T_SET: addc_db_str('S'); stb_type(tp->next, 0); - adds_db_str(sprint(buf, ";%ld;%ld;", (long)tp->tp_size, 0L)); + adds_db_strf(";%ld;%ld;", (long)tp->tp_size, 0L); break; case T_ARRAY: addc_db_str('a'); @@ -148,8 +158,7 @@ static void stb_type(struct type* tp, int assign_num) { addc_db_str('r'); stb_type(tp->next, 0); - adds_db_str( - sprint(buf, ";A%ld;Z%ld", (long)tp->arr_cfdescr, (long)tp->arr_cfdescr)); + adds_db_strf(";A%ld;Z%ld", (long)tp->arr_cfdescr, (long)tp->arr_cfdescr); } else { @@ -165,14 +174,14 @@ static void stb_type(struct type* tp, int assign_num) while (edef) { - adds_db_str(sprint(buf, "%s:%ld,", edef->df_idf->id_text, (long)edef->enm_val)); + adds_db_strf("%s:%ld,", edef->df_idf->id_text, (long)edef->enm_val); edef = edef->enm_next; } } addc_db_str(';'); break; case T_RECORD: - adds_db_str(sprint(buf, "s%ld", (long)tp->tp_size)); + adds_db_strf("s%ld", (long)tp->tp_size); { struct def* sdef = tp->rec_scope->sc_def; @@ -181,8 +190,7 @@ static void stb_type(struct type* tp, int assign_num) adds_db_str(sdef->df_idf->id_text); addc_db_str(':'); stb_type(sdef->df_type, 0); - adds_db_str( - sprint(buf, ",%ld,%ld;", sdef->fld_off * 8L, sdef->df_type->tp_size * 8L)); + adds_db_strf(",%ld,%ld;", sdef->fld_off * 8L, sdef->df_type->tp_size * 8L); sdef = sdef->df_nextinscope; } } @@ -201,7 +209,7 @@ static void stb_type(struct type* tp, int assign_num) paramcount++; p = p->next; } - adds_db_str(sprint(buf, ",%d;", paramcount)); + adds_db_strf(",%d;", paramcount); p = tp->prc_params; while (p) { @@ -252,7 +260,7 @@ void stb_string(struct def* df, long kind) addc_db_str(':'); if (kind == D_MODULE) { - adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count)); + adds_db_strf("M%d;", df->prc_vis->sc_count); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "_m_a_i_n"); return; } @@ -260,7 +268,7 @@ void stb_string(struct def* df, long kind) { case D_PROCEDURE: case D_FUNCTION: - adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); + adds_db_strf("Q%d;", df->prc_vis->sc_count); stb_type(tp->next ? tp->next : void_type, 0); addc_db_str(';'); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->df_idf->id_text); @@ -282,7 +290,7 @@ void stb_string(struct def* df, long kind) break; case D_END: case D_PEND: - adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); + adds_db_strf("E%d;", df->prc_vis->sc_count); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith)0); break; case D_VARIABLE: @@ -344,10 +352,10 @@ void stb_string(struct def* df, long kind) case T_LONG: case T_POINTER: case T_PROCEDURE: - adds_db_str(sprint(buf, "i%ld;", (long)df->con_const->nd_INT)); + adds_db_strf("i%ld;", (long)df->con_const->nd_INT); break; case T_CHAR: - adds_db_str(sprint(buf, "c%ld;", (long)df->con_const->nd_INT)); + adds_db_strf("c%ld;", (long)df->con_const->nd_INT); break; case T_REAL: addc_db_str('r'); @@ -373,7 +381,7 @@ void stb_string(struct def* df, long kind) case T_ENUMERATION: addc_db_str('e'); stb_type(tp, 0); - adds_db_str(sprint(buf, ",%ld;", (long)df->con_const->nd_INT)); + adds_db_strf(",%ld;", (long)df->con_const->nd_INT); break; case T_SET: { @@ -383,11 +391,11 @@ void stb_string(struct def* df, long kind) stb_type(tp, 0); for (i = 0; i < tp->tp_size; i++) { - adds_db_str(sprint( - buf, ",%ld", + adds_db_strf( + ",%ld", (long)(df->con_const->nd_set[i / (int)word_size] >> (8 * (i % (int)word_size))) - & 0377)); + & 0377); } addc_db_str(';'); } diff --git a/mach/i386/ce/as.c b/mach/i386/ce/as.c index 42da48e800..ec3c09b262 100644 --- a/mach/i386/ce/as.c +++ b/mach/i386/ce/as.c @@ -147,7 +147,7 @@ set_label( str, op) char *str; struct t_operand *op; { - char *ptr, *strchr(), *sprint(); + char *ptr, *strchr(), *sprintf(); static char buf[256]; ptr = strchr( str, '+'); @@ -170,7 +170,7 @@ struct t_operand *op; if ( strchr( str, DOLLAR) != 0) op->lab = str; else - op->lab = sprint( buf, "\"%s\"", str); + op->lab = sprintf( buf, "\"%s\"", str); } } diff --git a/mach/i86/ce/as.c b/mach/i86/ce/as.c index 6f6d63adab..de2bd38084 100644 --- a/mach/i86/ce/as.c +++ b/mach/i86/ce/as.c @@ -184,7 +184,7 @@ set_label( str, op) char *str; struct t_operand *op; { - char *ptr, *strchr(), *sprint(); + char *ptr, *strchr(), *sprintf(); static char buf[256]; ptr = strchr( str, '+'); @@ -208,7 +208,7 @@ struct t_operand *op; op->lab = str; else /* nood oplossing */ - op->lab = sprint( buf, "\"%s\"", str); + op->lab = sprintf( buf, "\"%s\"", str); } } diff --git a/mach/sparc/ce/EM_table.x b/mach/sparc/ce/EM_table.x index 782cd246e3..1dbbbfbd60 100644 --- a/mach/sparc/ce/EM_table.x +++ b/mach/sparc/ce/EM_table.x @@ -186,7 +186,7 @@ C_lxl a = alloc_reg(); b = alloc_reg(); c = alloc_reg(); - sprint(n_str, "%d", $1); + sprintf(n_str, "%d", $1); "set $n_str, $a"; "mov $reg_lb, $b"; "1: ld [$b + EM_BSIZE], $c"; @@ -675,7 +675,7 @@ C_mli if (n0) { a = alloc_reg(); - sprint(n_str, "%d", n0); + sprintf(n_str, "%d", n0); "sll $orig, $n_str, $a"; free_reg(orig); orig = a; @@ -693,7 +693,7 @@ C_mli n <<= n1; } else { a = alloc_reg(); - sprint(n_str, "%d", n1); + sprintf(n_str, "%d", n1); "sll $orig, $n_str, $a"; b = alloc_reg(); "sub $a, $orig, $b"; @@ -1458,7 +1458,7 @@ C_ine.. ==> b= alloc_reg(); ename= $1; - sprint(evalue, "%d", $2); + sprintf(evalue, "%d", $2); "sethi %hi($ename+$evalue), $a"; "ld [$a+%lo($ename+$evalue)], $b"; "inc $b"; @@ -1505,7 +1505,7 @@ C_dee.. ==> b= alloc_reg(); ename= $1; - sprint(evalue, "%d", $2); + sprintf(evalue, "%d", $2); "sethi %hi($ename+$evalue), $a"; "ld [$a+%lo($ename+$evalue)], $b"; "dec $b"; @@ -1541,7 +1541,7 @@ C_zre.. ==> a= alloc_reg(); ename= $1; - sprint(evalue, "%d", $2); + sprintf(evalue, "%d", $2); "sethi %hi($ename+$evalue), $a"; "st %g0, [$a+%lo($ename+$evalue)]" free_reg(a); @@ -2835,7 +2835,7 @@ C_com_narg ==> b= alloc_reg(); for (i= 0; i< n; i += 4) { - sprint(i_str, "%d", i); + sprintf(i_str, "%d", i); "ld [$reg_sp+$i_str], $a"; "not $a, $b"; "st $b, [$reg_sp+$i_str]"; @@ -2890,9 +2890,9 @@ C_rol a= pop_reg(); b= alloc_reg(); c= alloc_reg(); - sprint(n_str, "%d", n); + sprintf(n_str, "%d", n); "sll $a, $n_str, $b"; - sprint(n_str, "%d", 32-n); + sprintf(n_str, "%d", 32-n); "srl $a, $n_str, $c"; "or $b, $c, $c"; free_reg(a); @@ -2949,9 +2949,9 @@ C_ror a= pop_reg(); b= alloc_reg(); c= alloc_reg(); - sprint(n_str, "%d", n); + sprintf(n_str, "%d", n); "srl $a, $n_str, $b"; - sprint(n_str, "%d", 32-n); + sprintf(n_str, "%d", 32-n); "sll $a, $n_str, $c"; "or $b, $c, $c"; free_reg(a); @@ -3147,7 +3147,7 @@ C_set_narg ==> c= alloc_reg(); d= alloc_reg(); flush_cache(); - sprint(n_str, "%d", n); + sprintf(n_str, "%d", n); "set $n_str, $a"; "sub $reg_sp, $a, $reg_sp"; "1:"; @@ -4269,7 +4269,7 @@ C_dus "sub $reg_sp, $n_str, $reg_sp"; for (i=0; i flush_cache(); for (i=0; i #ifdef FAST_LIN_LNI_FIL { const_str_t n_str; - sprint(n_str, "%d", $1); + sprintf(n_str, "%d", $1); "set $n_str, $reg_fil"; }. #else diff --git a/mach/sparc/ce/cache.c.x b/mach/sparc/ce/cache.c.x index 3e0cb86e04..6b1514a825 100644 --- a/mach/sparc/ce/cache.c.x +++ b/mach/sparc/ce/cache.c.x @@ -242,7 +242,7 @@ enter("flush_part_cache"); "dec $i_str, $reg_sp"; while (i--) { - sprint(i_str, "%d", 4*(j-1-i)); + sprintf(i_str, "%d", 4*(j-1-i)); if (cache[i].ext) { ext= cache[i].ext; @@ -263,7 +263,7 @@ enter("flush_part_cache"); } if (!const13(cache[i].cst)) { - sprint(n_str, "%d", + sprintf(n_str, "%d", cache[i].cst); "sethi %hi($n_str), $reg_tmp"; if (cache[i].reg != reg_g0) @@ -279,7 +279,7 @@ enter("flush_part_cache"); } if (cache[i].cst) { - sprint(n_str, "%d", cache[i].cst); + sprintf(n_str, "%d", cache[i].cst); "add $rh, $n_str, $reg_tmp"; rh= reg_tmp; } @@ -672,16 +672,16 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); } assert(tos->reg == reg_g0); S1 = alloc_reg(); V1 = tos->ext; - sprint(V2, "%d", tos->cst); + sprintf(V2, "%d", tos->cst); "sethi %hi($V1+$V2), $S1"; - sprint(n, "%%lo(%s+%d)", tos->ext, tos->cst); + sprintf(n, "%%lo(%s+%d)", tos->ext, tos->cst); free(V1); POP2; } else { S1 = tos->reg; if (!(const13(tos->cst))) { S3 = alloc_reg(); - sprint(V2, "%d", tos->cst); + sprintf(V2, "%d", tos->cst); "sethi %hi($V2), $S3"; if (tos->reg != reg_g0) { S2 = alloc_reg(); @@ -696,7 +696,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); } } tos->cst &= 0x3FF; } - sprint(n, "%d", tos->cst); + sprintf(n, "%d", tos->cst); POP2; } if (debug) { indent(); fprint(codefile, "\t\t! %s+%s cache:", S1, n); dump_cache(codefile);} @@ -850,7 +850,7 @@ enter("pop_const"); x = top_const(); POP2; if (n) - sprint(n, "%d", x); + sprintf(n, "%d", x); if (debug) { indent(); fprint(codefile, "\t\t! %d cache:", x); dump_cache(codefile); } leave("pop_const"); return x; @@ -907,7 +907,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); } } else if (tos->ext) { assert(tos->reg == reg_g0); V1 = tos->ext; - sprint(V2, "%d", tos->cst); + sprintf(V2, "%d", tos->cst); "set $V1+$V2, $r"; free(V1); POP2; @@ -928,7 +928,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); } soft_alloc_reg(r); tos_reg2= r; } - sprint(c_str, "%d", tos_cst); + sprintf(c_str, "%d", tos_cst); "sethi %hi($c_str), $tos_reg2"; tos_cst &= 0x3ff; if (tos_reg == reg_g0) @@ -955,7 +955,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); } } if (tos_cst) { - sprint(c_str, "%d", tos_cst); + sprintf(c_str, "%d", tos_cst); soft_alloc_reg(r); "add $tos_reg, $c_str, $r"; free_reg(tos_reg); @@ -1151,7 +1151,7 @@ enter("pop_nop"); POP2; } if (i) { - sprint(V1, "%d", 4*i); + sprintf(V1, "%d", 4*i); if (const13(4*i)) { "inc $V1, %l0"; } else { @@ -1212,7 +1212,7 @@ if (debug) { indent(); fprintf(stderr,"cache_read(%d, %d)\n", n,i); } S1= alloc_reg(); old_c_count = cache_read(n, i+1); - sprint(V1, "%d", (old_c_count-1-i) * 4); + sprintf(V1, "%d", (old_c_count-1-i) * 4); "ld [%l0+$V1], $S1"; cache[i].reg= S1; cache[i].reg2= reg_g0; @@ -1220,7 +1220,7 @@ if (debug) { indent(); fprintf(stderr,"cache_read(%d, %d)\n", n,i); } cache[i].cst= 0; if (!i) { - sprint(V1, "%d", (old_c_count)*4); + sprintf(V1, "%d", (old_c_count)*4); "add $reg_sp, $V1, $reg_sp"; } } @@ -1294,7 +1294,7 @@ enter("dup_tos"); soft_alloc_reg(tos->reg2); } else { a= alloc_reg(); - sprint(i_str, "%d", (n-c_count)*4); + sprintf(i_str, "%d", (n-c_count)*4); "ld [$reg_sp+$i_str], $a"; tos->reg = a; } diff --git a/mach/vax4/ce/as.c b/mach/vax4/ce/as.c index d10726ff9c..c063f9adec 100644 --- a/mach/vax4/ce/as.c +++ b/mach/vax4/ce/as.c @@ -264,7 +264,7 @@ struct t_operand *op; @reloc4( %$(op->lab), %$(op->offset), PC_REL); } else { - sprint( my_buf, "\"%s\"", op->lab); + sprintf( my_buf, "\"%s\"", op->lab); @reloc4( %$(my_buf), %$(op->offset) , PC_REL); } break; diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index 6ad8ec89d6..aaf7fb4267 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -193,7 +193,7 @@ void C_pt_ilb(label l) { char buf[16]; - sprint(buf, "*%ld", (long) l); + sprintf(buf, "*%ld", (long) l); wrs(buf); } @@ -211,7 +211,7 @@ void C_pt_cst(arith l) { char buf[16]; - sprint(buf, "%ld", (long) l); + sprintf(buf, "%ld", (long) l); wrs(buf); } @@ -242,7 +242,7 @@ void C_pt_dlb(label l) { char buf[16]; - sprint(buf, ".%ld", (long) l); + sprintf(buf, ".%ld", (long) l); wrs(buf); } @@ -252,7 +252,7 @@ void C_pt_doff(label l, arith v) C_pt_dlb(l); if (v != 0) { - sprint(buf,"+%ld", (long) v); + sprintf(buf,"+%ld", (long) v); wrs(buf); } } @@ -263,7 +263,7 @@ void C_pt_noff(char *s, arith v) wrs(s); if (v != 0) { - sprint(buf,"+%ld", (long) v); + sprintf(buf,"+%ld", (long) v); wrs(buf); } } @@ -278,7 +278,7 @@ void C_pt_dfilb(label l) { char buf[16]; - sprint(buf, "%ld", (long) l); + sprintf(buf, "%ld", (long) l); wrs(buf); } diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua index 745c622dce..5b09cab6b1 100644 --- a/modules/src/print/build.lua +++ b/modules/src/print/build.lua @@ -2,7 +2,6 @@ clibrary { name = "lib", srcs = { "./doprnt.c", "./format.c", "./fprint.c", "./print.c", - "./sprint.c", }, hdrs = { "./print.h" }, deps = { diff --git a/modules/src/print/print.3 b/modules/src/print/print.3 index 0061b8f9b4..e40473b974 100644 --- a/modules/src/print/print.3 +++ b/modules/src/print/print.3 @@ -1,7 +1,7 @@ .TH PRINT 3 "$Revision$" .ad .SH NAME -print, fprint, sprint, doprnt -- very simple formatted-output routines +print, fprint, doprnt -- very simple formatted-output routines .SH SYNOPSIS .nf .B #include @@ -11,8 +11,6 @@ print, fprint, sprint, doprnt -- very simple formatted-output routines .PP .B void fprint(File *filep, char *format [, arg] ... ) .PP -.B char *sprint(char *s, char *format [, arg] ... ) -.PP .B void doprnt(File *filep, char *format, va_list args) .PP .B int _format(char *buf, char *format, va_lsit args) @@ -26,10 +24,6 @@ and place output on the open file known by .IR filep . .I filep could for instance be STDOUT or STDERR. -.I sprint -places `output' in the string -.IR s , -followed by the character `\\0'. .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 1cc341b24c..1c7bd0e82c 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -13,6 +13,5 @@ void print(const char *fmt, ...); 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); -char *sprint(char *buf, const char *fmt, ...); #endif /* __PRINT_INCLUDED__ */ diff --git a/modules/src/print/sprint.c b/modules/src/print/sprint.c deleted file mode 100644 index 7c9dbf9b03..0000000000 --- a/modules/src/print/sprint.c +++ /dev/null @@ -1,28 +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 "print.h" -#include "param.h" - -/*FORMAT1v $ - %s = char * - %l = long - %c = int - %[uxbo] = unsigned int - %d = int -$ */ -/*VARARGS*/ -char * -sprint(char *buf, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - buf[_format(buf, fmt, args)] = '\0'; - va_end(args); - return buf; -} diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 44fd255c65..6da1bcf540 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -205,7 +205,7 @@ void error(BOOL quit, char* str1, char* str2) { char errbuf[256]; - sprint(errbuf, str1, str2); + sprintf(errbuf, str1, str2); fwrite(errbuf, 1, strlen(errbuf), stderr); if (quit) { diff --git a/util/ceg/ce_back/as_back/bottom.c b/util/ceg/ce_back/as_back/bottom.c index c4481125b9..96838f3093 100644 --- a/util/ceg/ce_back/as_back/bottom.c +++ b/util/ceg/ce_back/as_back/bottom.c @@ -24,7 +24,7 @@ align_word() save_label( l) char *l; { - sprint( labeltje, "%s", l); + sprintf( labeltje, "%s", l); saved = 1; } @@ -42,7 +42,7 @@ dump_label() char *extnd_pro( prcno) int prcno; { - sprint( name, "pro%d", prcno); + sprintf( name, "pro%d", prcno); return( name); } @@ -50,7 +50,7 @@ int prcno; char *extnd_start( prcno) int prcno; { - sprint( name, "start%d", prcno); + sprintf( name, "start%d", prcno); return( name); } @@ -58,7 +58,7 @@ int prcno; char *extnd_name( s) char *s; { - sprint( name, NAME_FMT, s); + sprintf( name, NAME_FMT, s); return( name); } @@ -66,7 +66,7 @@ char *s; char *extnd_dnam( s) char *s; { - sprint( name, DNAM_FMT, s); + sprintf( name, DNAM_FMT, s); return( name); } @@ -74,7 +74,7 @@ char *s; char *extnd_dlb( g) arith g; { - sprint( name, DLB_FMT, (long)g); + sprintf( name, DLB_FMT, (long)g); return( name); } @@ -82,7 +82,7 @@ arith g; char *extnd_ilb( l, prcno) arith l; { - sprint( name, ILB_FMT, prcno, (long) l); + sprintf( name, ILB_FMT, prcno, (long) l); return( name); } @@ -90,7 +90,7 @@ arith l; char *extnd_hol( hol) int hol; { - sprint( name, HOL_FMT, hol); + sprintf( name, HOL_FMT, hol); return( name); } @@ -98,7 +98,7 @@ int hol; char *extnd_part( d) int d; { - sprint( name, "part%x", d); + sprintf( name, "part%x", d); return( name); } @@ -106,7 +106,7 @@ int d; char *extnd_cont( d) int d; { - sprint( name, "cont%x", d); + sprintf( name, "cont%x", d); return( name); } @@ -114,6 +114,6 @@ int d; char *extnd_main( d) int d; { - sprint( name, "main%x", d); + sprintf( name, "main%x", d); return( name); } From 04bec5004203d9ac4ed2a2bdfe58e9196b2d0b72 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 5 Dec 2024 14:17:22 +0100 Subject: [PATCH 12/29] Replace print() with printf(). --- lang/basic/src/basic.lex | 16 ++-- lang/basic/src/eval.c | 14 ++-- lang/basic/src/func.c | 2 +- lang/basic/src/graph.c | 12 +-- lang/basic/src/symbols.c | 20 ++--- lang/cem/cemcom.ansi/dataflow.c | 4 +- lang/cem/cemcom.ansi/dumpidf.c | 106 ++++++++++++------------- lang/cem/cemcom.ansi/l_lint.c | 6 +- lang/cem/cemcom.ansi/l_states.c | 24 +++--- lang/cem/cemcom.ansi/main.c | 2 +- lang/cem/cemcom.ansi/proto.c | 4 +- lang/cem/cemcom.ansi/stack.c | 2 +- lang/cem/cemcom/dataflow.c | 4 +- lang/cem/cemcom/dumpidf.c | 82 +++++++++---------- lang/cem/cemcom/idf.c | 6 +- lang/cem/cemcom/l_lint.c | 6 +- lang/cem/cemcom/l_states.c | 24 +++--- lang/cem/cemcom/main.c | 18 ++--- lang/cem/cemcom/stack.c | 2 +- lang/cem/lint/lpass2/l_print3ack.c | 2 +- lang/cem/lint/lpass2/lpass2.c | 8 +- lang/m2/comp/def.c | 4 +- lang/m2/comp/expression.g | 4 +- lang/m2/comp/lookup.c | 2 +- lang/m2/comp/main.c | 16 ++-- lang/m2/comp/node.c | 10 +-- lang/m2/comp/scope.c | 2 +- lang/m2/comp/type.c | 52 ++++++------ lang/m2/m2mm/main.c | 46 +++++------ lang/m2/test/queens.mod | 2 +- lang/pc/comp/main.c | 16 ++-- lang/pc/comp/node.c | 10 +-- lang/pc/comp/type.c | 50 ++++++------ mach/sun3/ce/output.c | 6 +- mach/sun3/ce/relocation.c | 2 +- mach/vax4/ce/output.c | 6 +- mach/vax4/ce/relocation.c | 2 +- modules/src/em_code/em_code.3X | 2 +- modules/src/idf/idf_pkg.body | 12 +-- modules/src/print/build.lua | 2 +- modules/src/print/print.3 | 4 - modules/src/print/print.c | 28 ------- modules/src/print/print.h | 1 - util/arch/archiver.c | 12 +-- util/ceg/ce_back/obj_back/memory.c | 12 +-- util/ceg/ce_back/obj_back/reloc4.c | 2 +- util/ceg/ce_back/obj_back/relocation.c | 2 +- util/ego/sr/sr.c | 8 +- 48 files changed, 323 insertions(+), 356 deletions(-) delete mode 100644 modules/src/print/print.c diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index da73654373..a327fbd3b2 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -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]); } } @@ -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) { @@ -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); @@ -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); } @@ -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); } @@ -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"); @@ -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); } @@ -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 '"': diff --git a/lang/basic/src/eval.c b/lang/basic/src/eval.c index c7edc0d9f9..aa51720e04 100644 --- a/lang/basic/src/eval.c +++ b/lang/basic/src/eval.c @@ -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; @@ -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"); } } @@ -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) @@ -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); @@ -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); } @@ -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--) diff --git a/lang/basic/src/func.c b/lang/basic/src/func.c index d2e7456e62..25f7da4fb3 100644 --- a/lang/basic/src/func.c +++ b/lang/basic/src/func.c @@ -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) { diff --git a/lang/basic/src/graph.c b/lang/basic/src/graph.c index ed037ad824..c714e1de5e 100644 --- a/lang/basic/src/graph.c +++ b/lang/basic/src/graph.c @@ -78,15 +78,15 @@ void newblock(int nr) Linerecord *l; List *frwrd; - if ( debug) print("newblock at %d\n",nr); + if ( debug) printf("newblock at %d\n",nr); if ( nr>0 && currline && currline->linenr>= nr) { - if ( debug) print("old line:%d\n",currline->linenr); + if ( debug) printf("old line:%d\n",currline->linenr); error("Lines out of sequence"); } frwrd=srchforward(nr); - if ( frwrd && debug) print("forward found %d\n",frwrd->emlabel); + if ( frwrd && debug) printf("forward found %d\n",frwrd->emlabel); l= srchline(nr); if ( l) { @@ -117,7 +117,7 @@ int gotolabel(int nr) Linerecord *l1; List *ll; - if (debug) print("goto label %d\n",nr); + if (debug) printf("goto label %d\n",nr); /* update currline */ ll= newlist(); ll-> linenr=nr; @@ -132,7 +132,7 @@ int gotolabel(int nr) if ( l1==0) { /* declare forward label */ - if (debug) print("declare forward %d\n",nr); + if (debug) printf("declare forward %d\n",nr); ll= newlist(); ll->emlabel= genlabel(); ll-> linenr=nr; @@ -278,7 +278,7 @@ void ongotostmt(int type) l= l->nextlist; } jumphead= jumptail=0; jumpcnt=0; - if (debug) print("ongotst:%d labels\n", jumpcnt); + if (debug) printf("ongotst:%d labels\n", jumpcnt); conversion(type,INTTYPE); C_dup((arith) BEMINTSIZE); C_zlt(err_goto_label); diff --git a/lang/basic/src/symbols.c b/lang/basic/src/symbols.c index 7a61a2add5..56cd01cff4 100644 --- a/lang/basic/src/symbols.c +++ b/lang/basic/src/symbols.c @@ -44,7 +44,7 @@ Symbol *srchsymbol(char* str) Symbol *s; /* search symbol table entry or create it */ - if (debug) print("srchsymbol %s\n",str); + if (debug) printf("srchsymbol %s\n",str); s=firstsym; while (s) @@ -69,7 +69,7 @@ Symbol *srchsymbol(char* str) s->symname= (char *) salloc((unsigned) strlen(str)+1); strcpy(s->symname,str); firstsym= s; - if (debug) print("%s allocated\n",str); + if (debug) printf("%s allocated\n",str); return(s); } @@ -89,7 +89,7 @@ void dcltype(Symbol *s) if ( s->symalias==0) s->symalias= dclspace(type); s->symtype= type; - if (debug) print("symbol set to %d\n",type); + if (debug) printf("symbol set to %d\n",type); } @@ -99,8 +99,8 @@ void dclarray(Symbol *s) int i; int size; if ( s->symtype==DEFAULTTYPE) s->symtype= DOUBLETYPE; - if (debug) print("generate space and descriptors for %d\n",s->symtype); - if (debug) print("dim %d\n",s->dimensions); + if (debug) printf("generate space and descriptors for %d\n",s->symtype); + if (debug) printf("dim %d\n",s->dimensions); s->symalias= genlabel(); /* generate descriptors */ size=1; @@ -118,7 +118,7 @@ void dclarray(Symbol *s) size = size* (s->dimlimit[i]+1-indexbase); } - if (debug) print("size=%d\n",size); + if (debug) printf("size=%d\n",size); /* size of stuff */ C_df_dlb((label)s->symalias); get_space(s->symtype,size); /* Van ons. */ @@ -206,7 +206,7 @@ void setdefaulttype(int type) char first,last,i; /* handcrafted parser for letter ranges */ - if (debug) print("deftype:%s\n",cptr); + if (debug) printf("deftype:%s\n",cptr); while ( isspace(*cptr)) cptr++; if ( !isalpha(*cptr)) error("letter expected"); @@ -235,7 +235,7 @@ Symbol *fcn; void newscope(Symbol *s) { - if (debug) print("new scope for %s\n",s->symname); + if (debug) printf("new scope for %s\n",s->symname); alternate= firstsym; firstsym = NIL; fcn=s; @@ -281,7 +281,7 @@ void endscope(int type) { Symbol *s; - if ( debug) print("endscope"); + if ( debug) printf("endscope"); conversion(type,fcn->symtype); C_ret((arith) typestring(fcn->symtype)); /* generate portable EM code */ @@ -312,7 +312,7 @@ void dclparm(Symbol *s) fcn->dimlimit[fcn->dimensions]= s->symtype; fcn->dimensions++; s->symalias= -fcn->dimensions; - if ( debug) print("parameter %d offset %d\n",fcn->dimensions-1,-size); + if ( debug) printf("parameter %d offset %d\n",fcn->dimensions-1,-size); } diff --git a/lang/cem/cemcom.ansi/dataflow.c b/lang/cem/cemcom.ansi/dataflow.c index cdd7781cf0..a20e307584 100644 --- a/lang/cem/cemcom.ansi/dataflow.c +++ b/lang/cem/cemcom.ansi/dataflow.c @@ -26,12 +26,12 @@ void DfaStartFunction(char* nm) void DfaEndFunction(void) { if (NumberOfCalls == 0) - print("DFA: %s: --none--\n", CurrentFunction); + printf("DFA: %s: --none--\n", CurrentFunction); } void DfaCallFunction(char* s) { - print("DFA: %s: %s\n", CurrentFunction, s); + printf("DFA: %s: %s\n", CurrentFunction, s); ++NumberOfCalls; } #endif /* DATAFLOW */ diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index f262fdf5f4..d5fe62727b 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -63,13 +63,13 @@ void newline(void) { int dl = dumplevel; - print("\n"); + printf("\n"); while (dl >= 2) { - print("\t"); + printf("\t"); dl -= 2; } if (dl) - print(" "); + printf(" "); } @@ -83,11 +83,11 @@ void dumpidftab(char msg[], int opt) Unless opt & 4, universal identifiers are not dumped. */ - print(">>> DUMPIDF, %s (start)", msg); + printf(">>> DUMPIDF, %s (start)", msg); dumpstack(); idfappfun(dumpidf, opt); newline(); - print(">>> DUMPIDF, %s (end)\n", msg); + printf(">>> DUMPIDF, %s (end)\n", msg); } static void dumpstack(void) @@ -100,14 +100,14 @@ static void dumpstack(void) struct stack_entry *se = stl->sl_entry; newline(); - print("%3d: ", stl->sl_level); + printf("%3d: ", stl->sl_level); while (se) { - print("%s ", se->se_idf->id_text); + printf("%s ", se->se_idf->id_text); se = se->next; } stl = stl->sl_previous; } - print("\n"); + printf("\n"); } void dumpidf(struct idf *idf, int opt) @@ -122,28 +122,28 @@ void dumpidf(struct idf *idf, int opt) if ((opt&2) && idf->id_reserved) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } - print(" reserved: %d;", idf->id_reserved); + printf(" reserved: %d;", idf->id_reserved); } if (idf->id_def && ((opt&4) || idf->id_def->df_level)) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumpdefs(idf->id_def, opt); } if (idf->id_sdef) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumpsdefs(idf->id_sdef, selector); } if (idf->id_tag) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumptags(idf->id_tag); } @@ -154,7 +154,7 @@ void dumpdefs(struct def *def, int opt) dumplevel++; while (def && ((opt&4) || def->df_level)) { newline(); - print("L%d: %s %s%stype%s %lo; ", + printf("L%d: %s %s%stype%s %lo; ", def->df_level, symbol2str(def->df_sc), def->df_initialized ? "init'd " : "", @@ -162,7 +162,7 @@ void dumpdefs(struct def *def, int opt) def->df_sc == ENUM ? ", =" : " at", def->df_address ); - print("%s, line %u", + printf("%s, line %u", def->df_file ? def->df_file : "NO_FILE", def->df_line); dumptype(def->df_type); def = def->next; @@ -178,7 +178,7 @@ void dumptags(struct tag *tag) int fund = tp->tp_fund; newline(); - print("L%d: %s %s", + printf("L%d: %s %s", tag->tg_level, fund == STRUCT ? "struct" : fund == UNION ? "union" : @@ -186,12 +186,12 @@ void dumptags(struct tag *tag) tp->tp_idf->id_text ); if (is_struct_or_union(fund)) { - print(" {"); + printf(" {"); dumpsdefs(tp->tp_sdef, field); newline(); - print("}"); + printf("}"); } - print(";"); + printf(";"); tag = tag->next; } dumplevel--; @@ -209,16 +209,16 @@ void dumpsdefs(struct sdef *sdef, enum sdef_kind sdk) dumplevel++; while (sdef) { newline(); - print("L%d: ", sdef->sd_level); + printf("L%d: ", sdef->sd_level); #ifndef NOBITFIELD if (sdk == selector) #endif /* NOBITFIELD */ - print("selector %s at offset %lu in %s;", + printf("selector %s at offset %lu in %s;", type2str(sdef->sd_type), sdef->sd_offset, type2str(sdef->sd_stype) ); #ifndef NOBITFIELD - else print("field %s at offset %lu;", + else printf("field %s at offset %lu;", type2str(sdef->sd_type), sdef->sd_offset ); #endif /* NOBITFIELD */ @@ -233,10 +233,10 @@ void dumpproto(struct proto *pl) int argcnt = 0; newline(); - print("dump proto type list (start)"); + printf("dump proto type list (start)"); newline(); while (pl) { - print("%d: %s", argcnt++, + printf("%d: %s", argcnt++, pl->pl_flag & PL_FORMAL ? (pl->pl_flag & PL_VOID ? "void" : "formal") : (pl->pl_flag & PL_ELLIPSIS @@ -248,14 +248,14 @@ void dumpproto(struct proto *pl) } if (pl->pl_idf) { dumplevel++; - print("idf:"); + printf("idf:"); dumpidf(pl->pl_idf, 7); dumplevel--; } newline(); pl = pl->next; } - print("dump proto type list (end)\n"); + printf("dump proto type list (end)\n"); } void dumptype(struct type *tp) @@ -265,44 +265,44 @@ void dumptype(struct type *tp) dumplevel++; newline(); if (!tp) { - print(""); + printf(""); newline(); dumplevel--; return; } - print("(@%lx, #%ld, &%d) ", tp, (long)tp->tp_size, tp->tp_align); + printf("(@%lx, #%ld, &%d) ", tp, (long)tp->tp_size, tp->tp_align); while (ops) { - print("%s", qual2str(tp->tp_typequal)); + printf("%s", qual2str(tp->tp_typequal)); switch (tp->tp_fund) { case POINTER: - print("pointer to "); + printf("pointer to "); break; case ARRAY: - print("array [%ld] of ", tp->tp_size); + printf("array [%ld] of ", tp->tp_size); break; case FUNCTION: - print("function "); + printf("function "); if (tp->tp_proto) { - print("with prototype"); + printf("with prototype"); dumplevel++; dumpproto(tp->tp_proto); dumplevel--; newline(); } - print("yielding "); + printf("yielding "); break; default: - print("%s%s ", tp->tp_unsigned ? "unsigned " : "", + printf("%s%s ", tp->tp_unsigned ? "unsigned " : "", symbol2str(tp->tp_fund)); if (tp->tp_idf) - print("%s ", tp->tp_idf->id_text); + printf("%s ", tp->tp_idf->id_text); #ifndef NOBITFIELD if (tp->tp_fund == FIELD && tp->tp_field) { struct field *fd = tp->tp_field; - print("[s=%ld,w=%ld] of ", + printf("[s=%ld,w=%ld] of ", fd->fd_shift, fd->fd_width); } else @@ -400,8 +400,8 @@ void print_expr(char msg[], struct expr *expr) message msg. */ if (options['x']) { - print("\n%s: ", msg); - print("(L=line, T=type, r/lV=r/lvalue, F=flags, D=depth)\n"); + printf("\n%s: ", msg); + printf("(L=line, T=type, r/lV=r/lvalue, F=flags, D=depth)\n"); p1_expr(0, expr); } } @@ -410,10 +410,10 @@ static void p1_expr(int lvl, struct expr *expr) { p1_indent(lvl); if (!expr) { - print("NILEXPR\n"); + printf("NILEXPR\n"); return; } - print("expr: L=%u, T=%s, %cV, F=%03o, D=%d, %s: ", + printf("expr: L=%u, T=%s, %cV, F=%03o, D=%d, %s: ", expr->ex_line, type2str(expr->ex_type), expr->ex_lvalue ? 'l' : 'r', @@ -430,24 +430,24 @@ static void p1_expr(int lvl, struct expr *expr) case Value: switch (expr->VL_CLASS) { case Const: - print("(Const) "); + printf("(Const) "); break; case Name: - print("(Name) %s + ", expr->VL_IDF->id_text); + printf("(Name) %s + ", expr->VL_IDF->id_text); break; case Label: - print("(Label) .%lu + ", expr->VL_LBL); + printf("(Label) .%lu + ", expr->VL_LBL); break; default: - print("(Unknown) "); + printf("(Unknown) "); break; } - print("%s\n", writh2str(expr->VL_VALUE, + printf("%s\n", writh2str(expr->VL_VALUE, expr->ex_type->tp_unsigned)); break; case String: { - print( + printf( "\"%s\"\n", bts2str(expr->SG_VALUE, expr->SG_LEN-1, next_transient()) @@ -459,24 +459,24 @@ static void p1_expr(int lvl, struct expr *expr) char buf[FLT_STRLEN]; flt_flt2str(&(expr->FL_ARITH), buf, FLT_STRLEN); - print("%s\n", buf); + printf("%s\n", buf); break; } case Oper: o = &expr->ex_object.ex_oper; - print("\n"); + printf("\n"); p1_expr(lvl+1, o->op_left); p1_indent(lvl); - print("%s <%s>\n", symbol2str(o->op_oper), + printf("%s <%s>\n", symbol2str(o->op_oper), type2str(o->op_type) ); p1_expr(lvl+1, o->op_right); break; case Type: - print("\n"); + printf("\n"); break; default: - print("UNKNOWN CLASS\n"); + printf("UNKNOWN CLASS\n"); break; } } @@ -484,6 +484,6 @@ static void p1_expr(int lvl, struct expr *expr) static void p1_indent(int lvl) { while (lvl--) - print(" "); + printf(" "); } #endif /* DEBUG */ diff --git a/lang/cem/cemcom.ansi/l_lint.c b/lang/cem/cemcom.ansi/l_lint.c index e8bc957e21..7de31e0805 100644 --- a/lang/cem/cemcom.ansi/l_lint.c +++ b/lang/cem/cemcom.ansi/l_lint.c @@ -436,9 +436,9 @@ print_esp(msg, esp) char *msg; struct expr_state *esp; { - print("%s: <", msg); + printf("%s: <", msg); while (esp) { - print(" %s[%d]%c%c%c ", + printf(" %s[%d]%c%c%c ", esp->es_idf->id_text, esp->es_offset, (esp->es_used ? 'U' : ' '), (esp->es_referred ? 'R' : ' '), @@ -446,7 +446,7 @@ print_esp(msg, esp) ); esp = esp->next; } - print(">\n"); + printf(">\n"); } #endif /* DEBUG */ diff --git a/lang/cem/cemcom.ansi/l_states.c b/lang/cem/cemcom.ansi/l_states.c index 6c4bed9834..c4b2ff9d2d 100644 --- a/lang/cem/cemcom.ansi/l_states.c +++ b/lang/cem/cemcom.ansi/l_states.c @@ -1237,9 +1237,9 @@ print_autos(a) struct idf *idf = a->ad_idf; struct def *def = idf->id_def; - print("%s", idf->id_text); - print("(lvl=%d)", a->ad_def->df_level); - print("(u%ds%dm%d U%dS%d) ", + printf("%s", idf->id_text); + printf("(lvl=%d)", a->ad_def->df_level); + printf("(u%ds%dm%d U%dS%d) ", a->ad_used, a->ad_set, a->ad_maybe_set, def->df_used, def->df_set ); @@ -1252,15 +1252,15 @@ pr_lint_state(nm, st) char *nm; struct state *st; { - print("%s: ", nm); + printf("%s: ", nm); if (st) { - print("notreached == %d ", st->st_notreached); + printf("notreached == %d ", st->st_notreached); print_autos(st->st_auto_list); } else { - print("NULL"); + printf("NULL"); } - print("\n"); + printf("\n"); } print_lint_stack(msg) @@ -1268,13 +1268,13 @@ print_lint_stack(msg) { struct lint_stack_entry *lse = top_ls; - print("Lint stack: %s(level=%d)\n", msg, level); + printf("Lint stack: %s(level=%d)\n", msg, level); while (lse) { - print(" |-------------- level %d ------------\n", + printf(" |-------------- level %d ------------\n", lse->ls_level); pr_lint_state(" |current", lse->ls_current); - print(" |class == %s\n", + printf(" |class == %s\n", lse->ls_class ? symbol2str(lse->ls_class) : "{"); switch (lse->ls_class) { @@ -1286,7 +1286,7 @@ print_lint_stack(msg) case DO: case WHILE: case FOR: - print(" |LS_TEST == %s\n", + printf(" |LS_TEST == %s\n", lse->LS_TEST == TEST_VAR ? "TEST_VAR" : lse->LS_TEST == TEST_TRUE ? "TEST_TRUE" : lse->LS_TEST == TEST_FALSE ? "TEST_FALSE" : @@ -1305,7 +1305,7 @@ print_lint_stack(msg) } lse = lse->ls_previous; } - print(" |--------------\n\n"); + printf(" |--------------\n\n"); } #endif /* DEBUG */ diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index a101eb0814..6e78a4d438 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -296,7 +296,7 @@ void Info(void) cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace, cnt_lint_stack_entry, cnt_state, cnt_auto_def, cnt_expr_state, cnt_argument; - print("\ + printf("\ %6d string_cst\n%6d formal\n\ %6d decl_unary\n%6d def\n%6d expr\n%6d field\n\ %6d e_stack\n%6d localvar\n%6d proto\n\ diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index 33dd9d7a71..3453cd079f 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -382,7 +382,7 @@ static void remove_proto_tag(struct type *tp) #ifdef DEBUG if (options['t']) - print("Removing idf %s from list\n", + printf("Removing idf %s from list\n", ident->id_text); #endif @@ -403,7 +403,7 @@ void remove_proto_idfs(struct proto *pl) { #ifdef DEBUG if (options['t']) - print("Removing idf %s from list\n", + printf("Removing idf %s from list\n", pl->pl_idf->id_text); #endif def = pl->pl_idf->id_def; diff --git a/lang/cem/cemcom.ansi/stack.c b/lang/cem/cemcom.ansi/stack.c index e298fc08bc..0c6a4d910a 100644 --- a/lang/cem/cemcom.ansi/stack.c +++ b/lang/cem/cemcom.ansi/stack.c @@ -208,7 +208,7 @@ void unstack_world(void) if (options['a']) { char *symbol2str(); - print("\"%s\", %s, %s, %s, %s\n", + printf("\"%s\", %s, %s, %s, %s\n", idf->id_text, (def->df_alloc == 0) ? "no alloc" : (def->df_alloc == ALLOC_SEEN) ? "alloc seen" : diff --git a/lang/cem/cemcom/dataflow.c b/lang/cem/cemcom/dataflow.c index e6f00abacc..53077080ce 100644 --- a/lang/cem/cemcom/dataflow.c +++ b/lang/cem/cemcom/dataflow.c @@ -25,13 +25,13 @@ DfaStartFunction(nm) DfaEndFunction() { if (NumberOfCalls == 0) - print("DFA: %s: --none--\n", CurrentFunction); + printf("DFA: %s: --none--\n", CurrentFunction); } DfaCallFunction(s) char *s; { - print("DFA: %s: %s\n", CurrentFunction, s); + printf("DFA: %s: %s\n", CurrentFunction, s); ++NumberOfCalls; } #endif /* DATAFLOW */ diff --git a/lang/cem/cemcom/dumpidf.c b/lang/cem/cemcom/dumpidf.c index 407fdddf4d..425178b4c5 100644 --- a/lang/cem/cemcom/dumpidf.c +++ b/lang/cem/cemcom/dumpidf.c @@ -46,13 +46,13 @@ static newline() { int dl = dumplevel; - print("\n"); + printf("\n"); while (dl >= 2) { - print("\t"); + printf("\t"); dl -= 2; } if (dl) - print(" "); + printf(" "); } dumpidftab(msg, opt) @@ -66,7 +66,7 @@ dumpidftab(msg, opt) */ int i; - print(">>> DUMPIDF, %s (start)", msg); + printf(">>> DUMPIDF, %s (start)", msg); dumpstack(); for (i = 0; i < HASHSIZE; i++) { struct idf *notch = idf_hashtable[i]; @@ -77,7 +77,7 @@ dumpidftab(msg, opt) } } newline(); - print(">>> DUMPIDF, %s (end)\n", msg); + printf(">>> DUMPIDF, %s (end)\n", msg); } dumpstack() @@ -90,14 +90,14 @@ dumpstack() struct stack_entry *se = stl->sl_entry; newline(); - print("%3d: ", stl->sl_level); + printf("%3d: ", stl->sl_level); while (se) { - print("%s ", se->se_idf->id_text); + printf("%s ", se->se_idf->id_text); se = se->next; } stl = stl->sl_previous; } - print("\n"); + printf("\n"); } dumpidf(idf, opt) @@ -114,43 +114,43 @@ dumpidf(idf, opt) if ((opt&1) && idf->id_macro) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } - print(" macro"); + printf(" macro"); } #endif /* NOPP */ if ((opt&2) && idf->id_reserved) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } - print(" reserved: %d;", idf->id_reserved); + printf(" reserved: %d;", idf->id_reserved); } if (idf->id_def && ((opt&4) || idf->id_def->df_level)) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumpdefs(idf->id_def, opt); } if (idf->id_sdef) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumpsdefs(idf->id_sdef, selector); } if (idf->id_struct) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumptags(idf->id_struct); } if (idf->id_enum) { if (!started++) { newline(); - print("%s:", idf->id_text); + printf("%s:", idf->id_text); } dumptags(idf->id_enum); } @@ -162,7 +162,7 @@ dumpdefs(def, opt) dumplevel++; while (def && ((opt&4) || def->df_level)) { newline(); - print("L%d: %s %s%s%s%s %lo;", + printf("L%d: %s %s%s%s%s %lo;", def->df_level, symbol2str(def->df_sc), def->df_initialized ? "init'd " : "", @@ -171,7 +171,7 @@ dumpdefs(def, opt) def->df_sc == ENUM ? ", =" : " at", def->df_address ); - print("%s, line %u", + printf("%s, line %u", def->df_file ? def->df_file : "NO_FILE", def->df_line); def = def->next; } @@ -187,7 +187,7 @@ dumptags(tag) int fund = tp->tp_fund; newline(); - print("L%d: %s %s", + printf("L%d: %s %s", tag->tg_level, fund == STRUCT ? "struct" : fund == UNION ? "union" : @@ -195,12 +195,12 @@ dumptags(tag) tp->tp_idf->id_text ); if (is_struct_or_union(fund)) { - print(" {"); + printf(" {"); dumpsdefs(tp->tp_sdef, field); newline(); - print("}"); + printf("}"); } - print(";"); + printf(";"); tag = tag->next; } dumplevel--; @@ -220,16 +220,16 @@ dumpsdefs(sdef, sdk) dumplevel++; while (sdef) { newline(); - print("L%d: ", sdef->sd_level); + printf("L%d: ", sdef->sd_level); #ifndef NOBITFIELD if (sdk == selector) #endif /* NOBITFIELD */ - print("selector %s at offset %lu in %s;", + printf("selector %s at offset %lu in %s;", type2str(sdef->sd_type), sdef->sd_offset, type2str(sdef->sd_stype) ); #ifndef NOBITFIELD - else print("field %s at offset %lu;", + else printf("field %s at offset %lu;", type2str(sdef->sd_type), sdef->sd_offset ); #endif /* NOBITFIELD */ @@ -310,8 +310,8 @@ print_expr(msg, expr) message msg. */ if (options['x']) { - print("\n%s: ", msg); - print("(L=line, T=type, r/lV=r/lvalue, F=flags, D=depth)\n"); + printf("\n%s: ", msg); + printf("(L=line, T=type, r/lV=r/lvalue, F=flags, D=depth)\n"); p1_expr(0, expr); } } @@ -321,10 +321,10 @@ p1_expr(lvl, expr) { p1_indent(lvl); if (!expr) { - print("NILEXPR\n"); + printf("NILEXPR\n"); return; } - print("expr: L=%u, T=%s, %cV, F=%03o, D=%d, %s: ", + printf("expr: L=%u, T=%s, %cV, F=%03o, D=%d, %s: ", expr->ex_line, type2str(expr->ex_type), expr->ex_lvalue ? 'l' : 'r', @@ -343,26 +343,26 @@ p1_expr(lvl, expr) case Value: switch (expr->VL_CLASS) { case Const: - print("(Const) "); + printf("(Const) "); break; case Name: - print("(Name) %s + ", expr->VL_IDF->id_text); + printf("(Name) %s + ", expr->VL_IDF->id_text); break; case Label: - print("(Label) .%lu + ", expr->VL_LBL); + printf("(Label) .%lu + ", expr->VL_LBL); break; default: - print("(Unknown) "); + printf("(Unknown) "); break; } - print(expr->ex_type->tp_unsigned ? "%lu\n" : "%ld\n", + printf(expr->ex_type->tp_unsigned ? "%lu\n" : "%ld\n", expr->VL_VALUE); break; case String: { char *bts2str(); - print( + printf( "\"%s\"\n", bts2str(expr->SG_VALUE, expr->SG_LEN-1, next_transient()) @@ -371,24 +371,24 @@ p1_expr(lvl, expr) } #ifndef NOFLOAT case Float: - print("%s\n", expr->FL_VALUE); + printf("%s\n", expr->FL_VALUE); break; #endif /* NOFLOAT */ case Oper: o = &expr->ex_object.ex_oper; - print("\n"); + printf("\n"); p1_expr(lvl+1, o->op_left); p1_indent(lvl); - print("%s <%s>\n", symbol2str(o->op_oper), + printf("%s <%s>\n", symbol2str(o->op_oper), type2str(o->op_type) ); p1_expr(lvl+1, o->op_right); break; case Type: - print("\n"); + printf("\n"); break; default: - print("UNKNOWN CLASS\n"); + printf("UNKNOWN CLASS\n"); break; } } @@ -397,6 +397,6 @@ p1_indent(lvl) int lvl; { while (lvl--) - print(" "); + printf(" "); } #endif /* DEBUG */ diff --git a/lang/cem/cemcom/idf.c b/lang/cem/cemcom/idf.c index 9643bc1e10..8b089f94e3 100644 --- a/lang/cem/cemcom/idf.c +++ b/lang/cem/cemcom/idf.c @@ -104,7 +104,7 @@ hash_stat() if (options['h']) { int i; - print("Hash table tally:\n"); + printf("Hash table tally:\n"); for (i = 0; i < HASHSIZE; i++) { struct idf *notch = idf_hashtable[i]; int cnt = 0; @@ -113,9 +113,9 @@ hash_stat() cnt++; notch = notch->next; } - print("%d %d\n", i, cnt); + printf("%d %d\n", i, cnt); } - print("End hash table tally\n"); + printf("End hash table tally\n"); } } #endif /* DEBUG */ diff --git a/lang/cem/cemcom/l_lint.c b/lang/cem/cemcom/l_lint.c index e95c994d1c..c90624f186 100644 --- a/lang/cem/cemcom/l_lint.c +++ b/lang/cem/cemcom/l_lint.c @@ -438,9 +438,9 @@ print_esp(msg, esp) char *msg; struct expr_state *esp; { - print("%s: <", msg); + printf("%s: <", msg); while (esp) { - print(" %s[%d]%c%c%c ", + printf(" %s[%d]%c%c%c ", esp->es_idf->id_text, esp->es_offset, (esp->es_used ? 'U' : ' '), (esp->es_referred ? 'R' : ' '), @@ -448,7 +448,7 @@ print_esp(msg, esp) ); esp = esp->next; } - print(">\n"); + printf(">\n"); } #endif /* DEBUG */ diff --git a/lang/cem/cemcom/l_states.c b/lang/cem/cemcom/l_states.c index 593a443ef2..b04571a2b0 100644 --- a/lang/cem/cemcom/l_states.c +++ b/lang/cem/cemcom/l_states.c @@ -1232,9 +1232,9 @@ print_autos(a) struct idf *idf = a->ad_idf; struct def *def = idf->id_def; - print("%s", idf->id_text); - print("(lvl=%d)", a->ad_def->df_level); - print("(u%ds%dm%d U%dS%d) ", + printf("%s", idf->id_text); + printf("(lvl=%d)", a->ad_def->df_level); + printf("(u%ds%dm%d U%dS%d) ", a->ad_used, a->ad_set, a->ad_maybe_set, def->df_used, def->df_set ); @@ -1247,15 +1247,15 @@ pr_lint_state(nm, st) char *nm; struct state *st; { - print("%s: ", nm); + printf("%s: ", nm); if (st) { - print("notreached == %d ", st->st_notreached); + printf("notreached == %d ", st->st_notreached); print_autos(st->st_auto_list); } else { - print("NULL"); + printf("NULL"); } - print("\n"); + printf("\n"); } print_lint_stack(msg) @@ -1263,13 +1263,13 @@ print_lint_stack(msg) { struct lint_stack_entry *lse = top_ls; - print("Lint stack: %s(level=%d)\n", msg, level); + printf("Lint stack: %s(level=%d)\n", msg, level); while (lse) { - print(" |-------------- level %d ------------\n", + printf(" |-------------- level %d ------------\n", lse->ls_level); pr_lint_state(" |current", lse->ls_current); - print(" |class == %s\n", + printf(" |class == %s\n", lse->ls_class ? symbol2str(lse->ls_class) : "{"); switch (lse->ls_class) { @@ -1281,7 +1281,7 @@ print_lint_stack(msg) case DO: case WHILE: case FOR: - print(" |LS_TEST == %s\n", + printf(" |LS_TEST == %s\n", lse->LS_TEST == TEST_VAR ? "TEST_VAR" : lse->LS_TEST == TEST_TRUE ? "TEST_TRUE" : lse->LS_TEST == TEST_FALSE ? "TEST_FALSE" : @@ -1300,7 +1300,7 @@ print_lint_stack(msg) } lse = lse->ls_previous; } - print(" |--------------\n\n"); + printf(" |--------------\n\n"); } #endif /* DEBUG */ diff --git a/lang/cem/cemcom/main.c b/lang/cem/cemcom/main.c index a66ed19886..f033706099 100644 --- a/lang/cem/cemcom/main.c +++ b/lang/cem/cemcom/main.c @@ -410,12 +410,12 @@ preprocess() if (strcmp(lastfilenm, dot.tk_file) == 0) { if (dot.tk_line - lastlineno <= 1) { lastlineno++; - print("\n"); + printf("\n"); } else { lastlineno = dot.tk_line; if (!options['P']) - print("\n#line %ld \"%s\"\n", + printf("\n#line %ld \"%s\"\n", lastlineno, lastfilenm ); @@ -425,7 +425,7 @@ preprocess() lastfilenm = dot.tk_file; lastlineno = dot.tk_line; if (!options['P']) - print("\n#line %ld \"%s\"\n", + printf("\n#line %ld \"%s\"\n", lastlineno, lastfilenm); } } @@ -433,35 +433,35 @@ preprocess() if (strcmp(lastfilenm, dot.tk_file) != 0) { lastfilenm = dot.tk_file; if (!options['P']) - print("\n#line %ld \"%s\"\n", + printf("\n#line %ld \"%s\"\n", lastlineno, lastfilenm); } switch (DOT) { case IDENTIFIER: case TYPE_IDENTIFIER: - print("%s ", dot.tk_idf->id_text); + printf("%s ", dot.tk_idf->id_text); break; case STRING: { char sbuf[1024]; /* a transient buffer */ char *bts2str(); - print("\"%s\" ", bts2str(dot.tk_bts, dot.tk_len, sbuf)); + printf("\"%s\" ", bts2str(dot.tk_bts, dot.tk_len, sbuf)); break; } case INTEGER: - print("%ld ", dot.tk_ival); + printf("%ld ", dot.tk_ival); break; #ifndef NOFLOAT case FLOATING: - print("%s ", dot.tk_fval); + printf("%s ", dot.tk_fval); break; #endif /* NOFLOAT */ case EOI: case EOF: return; default: /* very expensive... */ - print("%s ", symbol2str(DOT)); + printf("%s ", symbol2str(DOT)); } } } diff --git a/lang/cem/cemcom/stack.c b/lang/cem/cemcom/stack.c index aa45e9d026..fd480c6150 100644 --- a/lang/cem/cemcom/stack.c +++ b/lang/cem/cemcom/stack.c @@ -201,7 +201,7 @@ unstack_world() if (options['a']) { char *symbol2str(); - print("\"%s\", %s, %s, %s, %s\n", + printf("\"%s\", %s, %s, %s, %s\n", idf->id_text, (def->df_alloc == 0) ? "no alloc" : (def->df_alloc == ALLOC_SEEN) ? "alloc seen" : diff --git a/lang/cem/lint/lpass2/l_print3ack.c b/lang/cem/lint/lpass2/l_print3ack.c index b0d8544edb..b76e43bf80 100644 --- a/lang/cem/lint/lpass2/l_print3ack.c +++ b/lang/cem/lint/lpass2/l_print3ack.c @@ -17,7 +17,7 @@ %c = int %s = char * %u = unsigned int $ */ -print(format) char *format; { ; } +printf(format) char *format; { ; } /* FORMAT1 */ fprint(filep, format) File *filep; char *format; { ; } diff --git a/lang/cem/lint/lpass2/lpass2.c b/lang/cem/lint/lpass2/lpass2.c index 0103f9dc51..fcb2e7c240 100644 --- a/lang/cem/lint/lpass2/lpass2.c +++ b/lang/cem/lint/lpass2/lpass2.c @@ -465,11 +465,11 @@ print_id(name, id) struct inpdef *id; { if (!id) { - print("%s: \n", name); + printf("%s: \n", name); return; } - print("%s: %s, %s, %04d, \"%s\", %d, %s", name, + printf("%s: %s, %s, %04d, \"%s\", %d, %s", name, id->id_class == LFDF ? "LFDF" : id->id_class == LVDF ? "LVDF" : id->id_class == PFDF ? "PFDF" : @@ -489,7 +489,7 @@ print_id(name, id) id->id_type ); if (is_class(id, CL_FUNC|CL_DEF) || is_class(id, CL_FUNC|CL_USAGE)) { - print(", %d, %s, %s", + printf(", %d, %s, %s", id->id_nrargs, (id->id_nrargs == 0 ? "" : id->id_argtps), ( id->id_class == FC @@ -509,6 +509,6 @@ print_id(name, id) ) ); } - print("\n"); + printf("\n"); } diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 682421f882..16e2eb7d22 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -118,7 +118,7 @@ struct def *define(struct idf *id, struct scope *scope, int kind) */ struct def *df; - DO_DEBUG(options['S'], print("define %s, %x\n", id->id_text, kind)); + DO_DEBUG(options['S'], printf("define %s, %x\n", id->id_text, kind)); df = lookup(id, scope, D_IMPORT, 0); if ( /* Already in this scope */ df) @@ -411,6 +411,6 @@ void CheckWithDef(struct def *df, struct type *tp) #ifdef DEBUG void PrDef(struct def *df) { - print("n: %s, k: %d\n", df->df_idf->id_text, df->df_kind); + printf("n: %s, k: %d\n", df->df_idf->id_text, df->df_kind); } #endif /* DEBUG */ diff --git a/lang/m2/comp/expression.g b/lang/m2/comp/expression.g index 77a574f468..e29f0b24ef 100644 --- a/lang/m2/comp/expression.g +++ b/lang/m2/comp/expression.g @@ -83,7 +83,7 @@ ConstExpression(struct node **pnd;) * Check that the expression is a constant expression and evaluate! */ { - DO_DEBUG(options['C'], print("CONSTANT EXPRESSION\n")); + DO_DEBUG(options['C'], printf("CONSTANT EXPRESSION\n")); DO_DEBUG(options['C'], PrNode(*pnd, 0)); if (ChkExpression(pnd) && @@ -93,7 +93,7 @@ ConstExpression(struct node **pnd;) error("constant expression expected"); } - DO_DEBUG(options['C'], print("RESULTS IN\n")); + DO_DEBUG(options['C'], printf("RESULTS IN\n")); DO_DEBUG(options['C'], PrNode(*pnd, 0)); } ; diff --git a/lang/m2/comp/lookup.c b/lang/m2/comp/lookup.c index ee7d6f5546..639b4cab93 100644 --- a/lang/m2/comp/lookup.c +++ b/lang/m2/comp/lookup.c @@ -68,7 +68,7 @@ struct def *lookup(struct idf *id, struct scope *scope, int import, int flags) assert(df->imp_def != 0); df = df->imp_def; } - DO_DEBUG(options['S'], print("lookup %s, %x\n", id->id_text, df->df_kind)); + DO_DEBUG(options['S'], printf("lookup %s, %x\n", id->id_text, df->df_kind)); } return df; } diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 2dc10e4756..243d773705 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -149,27 +149,27 @@ void LexScan(void) while (LLlex() > 0) { - print(">>> %s ", symbol2str(tkp->tk_symb)); + printf(">>> %s ", symbol2str(tkp->tk_symb)); switch(tkp->tk_symb) { case IDENT: - print("%s\n", tkp->TOK_IDF->id_text); + printf("%s\n", tkp->TOK_IDF->id_text); break; case INTEGER: - print("%ld\n", tkp->TOK_INT); + printf("%ld\n", tkp->TOK_INT); break; case REAL: - print("%s\n", tkp->TOK_RSTR); + printf("%s\n", tkp->TOK_RSTR); break; case STRING: - print("\"%s\"\n", tkp->TOK_STR); + printf("\"%s\"\n", tkp->TOK_STR); break; default: - print("\n"); + printf("\n"); } } } @@ -278,13 +278,13 @@ void Info(void) cnt_switch_hdr, cnt_case_entry, cnt_scope, cnt_scopelist, cnt_tmpvar; - print("\ + printf("\ %6d def\n%6d node\n%6d paramlist\n%6d type\n%6d switch_hdr\n\ %6d case_entry\n%6d scope\n%6d scopelist\n%6d tmpvar\n", cnt_def, cnt_node, cnt_paramlist, cnt_type, cnt_switch_hdr, cnt_case_entry, cnt_scope, cnt_scopelist, cnt_tmpvar); -print("\nNumber of lines read: %d\n", cntlines); +printf("\nNumber of lines read: %d\n", cntlines); } #endif diff --git a/lang/m2/comp/node.c b/lang/m2/comp/node.c index 55dc39125c..47e7c7abd9 100644 --- a/lang/m2/comp/node.c +++ b/lang/m2/comp/node.c @@ -116,26 +116,26 @@ int PNodeCrash(struct node **expp, int flags) void indnt(int lvl) { while (lvl--) { - print(" "); + printf(" "); } } void printnode(struct node *nd, int lvl) { indnt(lvl); - print("Class: %d; Symbol: %s; Flags: %d\n", nd->nd_class, symbol2str(nd->nd_symb), nd->nd_flags); + printf("Class: %d; Symbol: %s; Flags: %d\n", nd->nd_class, symbol2str(nd->nd_symb), nd->nd_flags); if (nd->nd_type) { indnt(lvl); - print("Type: "); + printf("Type: "); DumpType(nd->nd_type); - print("\n"); + printf("\n"); } } void PrNode(struct node *nd, int lvl) { if (! nd) { - indnt(lvl); print("\n"); + indnt(lvl); printf("\n"); return; } printnode(nd, lvl); diff --git a/lang/m2/comp/scope.c b/lang/m2/comp/scope.c index 98b3f0ce77..c0c8a4c4ff 100644 --- a/lang/m2/comp/scope.c +++ b/lang/m2/comp/scope.c @@ -199,7 +199,7 @@ void close_scope(int flag) sc->sc_end = dot2leaf(Link); if (flag) { - DO_DEBUG(options['S'],(print("List of definitions in currently ended scope:\n"), DumpScope(sc->sc_def))); + DO_DEBUG(options['S'],(printf("List of definitions in currently ended scope:\n"), DumpScope(sc->sc_def))); if (flag & SC_CHKPROC) chk_proc(sc->sc_def); if (flag & SC_CHKFORW) chk_forw(&(sc->sc_def)); if (flag & SC_REVERSE) Reverse(&(sc->sc_def)); diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index 40e3cf3f66..36279249fc 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -794,45 +794,45 @@ void DumpType(struct type *tp) { if (!tp) return; - print("align:%d; size:%ld;", tp->tp_align, (long) tp->tp_size); + printf("align:%d; size:%ld;", tp->tp_align, (long) tp->tp_size); - print(" fund:"); + printf(" fund:"); switch(tp->tp_fund) { case T_RECORD: - print("RECORD"); + printf("RECORD"); break; case T_ENUMERATION: - print("ENUMERATION; ncst:%d", tp->enm_ncst); break; + printf("ENUMERATION; ncst:%d", tp->enm_ncst); break; case T_INTEGER: - print("INTEGER"); break; + printf("INTEGER"); break; case T_CARDINAL: - print("CARDINAL"); break; + printf("CARDINAL"); break; case T_REAL: - print("REAL"); break; + printf("REAL"); break; case T_HIDDEN: - print("HIDDEN"); break; + printf("HIDDEN"); break; case T_EQUAL: - print("EQUAL"); break; + printf("EQUAL"); break; case T_POINTER: - print("POINTER"); break; + printf("POINTER"); break; case T_CHAR: - print("CHAR"); break; + printf("CHAR"); break; case T_WORD: - print("WORD"); break; + printf("WORD"); break; case T_SET: - print("SET"); break; + printf("SET"); break; case T_SUBRANGE: - print("SUBRANGE %ld-%ld", (long) tp->sub_lb, (long) tp->sub_ub); + printf("SUBRANGE %ld-%ld", (long) tp->sub_lb, (long) tp->sub_ub); break; case T_PROCEDURE: { struct paramlist *par = ParamList(tp); - print("PROCEDURE"); + printf("PROCEDURE"); if (par) { - print("("); + printf("("); while(par) { - if (IsVarParam(par)) print("VAR "); + if (IsVarParam(par)) printf("VAR "); DumpType(TypeOfParam(par)); par = par->par_next; } @@ -840,27 +840,27 @@ void DumpType(struct type *tp) break; } case T_ARRAY: - print("ARRAY"); - print("; element:"); + printf("ARRAY"); + printf("; element:"); DumpType(tp->arr_elem); - print("; index:"); + printf("; index:"); DumpType(tp->tp_next); - print(";"); + printf(";"); return; case T_STRING: - print("STRING"); break; + printf("STRING"); break; case T_INTORCARD: - print("INTORCARD"); break; + printf("INTORCARD"); break; default: crash("DumpType"); } if (tp->tp_next && tp->tp_fund != T_POINTER) { /* Avoid printing recursive types! */ - print(" next:("); + printf(" next:("); DumpType(tp->tp_next); - print(")"); + printf(")"); } - print(";"); + printf(";"); } #endif diff --git a/lang/m2/m2mm/main.c b/lang/m2/m2mm/main.c index abb81ca9c1..1ddd3fd129 100644 --- a/lang/m2/m2mm/main.c +++ b/lang/m2/m2mm/main.c @@ -105,11 +105,11 @@ main(argc, argv) init_idf(); reserve(tkidf); - print("IFLAGS ="); + printf("IFLAGS ="); for (i = 1; i < nDEF; i++) { - if (DEFPATH[i]) print(" -I%s", DEFPATH[i]); + if (DEFPATH[i]) printf(" -I%s", DEFPATH[i]); } - print("\nM2FLAGS = %s\nMOD = %s\nSUFFIX = %s\nLIBS = %s\n", mflags, compiler, suff, llibs ? llibs : ""); + printf("\nM2FLAGS = %s\nMOD = %s\nSUFFIX = %s\nLIBS = %s\n", mflags, compiler, suff, llibs ? llibs : ""); init_lib(); ProcessArgs(); find_dependencies(); @@ -231,7 +231,7 @@ find_dependencies() { struct file_list *arg; - print("\nall:\t"); + printf("\nall:\t"); f_walk(arglist, arg) { char *fn = f_filename(arg); char *dotspot = strrchr(fn, '.'); @@ -242,15 +242,15 @@ find_dependencies() if (! f_notfound(arg) && id) { if (id->id_type == PROGRAM) { *dotspot = 0; - print("%s ", fn); + printf("%s ", fn); *dotspot = '.'; } file_dep(id); } } } - print("\n\n"); - print("objects:\t"); + printf("\n\n"); + printf("objects:\t"); f_walk(arglist, arg) { char *fn = f_filename(arg); char *dotspot = strrchr(fn, '.'); @@ -261,13 +261,13 @@ find_dependencies() if (! f_notfound(arg) && id) { if (id->id_type == PROGRAM) { *dotspot = 0; - print("%s_o_files ", fn); + printf("%s_o_files ", fn); *dotspot = '.'; } } } } - print("\n\n\n"); + printf("\n\n\n"); } file_dep(id) @@ -336,9 +336,9 @@ pr_arg(a) char *d = f_dir(a); if (strcmp(d, ".") == 0 || *f == '/' || *f == '.') { - print(f); + printf(f); } - else print("%s/%s", d, f); + else printf("%s/%s", d, f); } print_dep() @@ -355,17 +355,17 @@ print_dep() char *obj = object(arg); struct file_list *a; - print("%s: \\\n\t", obj); + printf("%s: \\\n\t", obj); pr_arg(arg); f_walk(id->id_mdependson, a) { if (*(f_filename(a))) /* ??? */ { - print(" \\\n\t"); + printf(" \\\n\t"); pr_arg(a); } } - print("\n\t$(MOD) -c $(M2FLAGS) $(IFLAGS) "); + printf("\n\t$(MOD) -c $(M2FLAGS) $(IFLAGS) "); pr_arg(arg); - print("\n"); + printf("\n"); } } } @@ -426,25 +426,25 @@ pr_prog_dep(id, a) { struct file_list *p; - print("\nOBS_%s =", id->id_text); + printf("\nOBS_%s =", id->id_text); f_walk(id->id_mdependson, p) { if (module_in_arglist(f_filename(p)) || ! f_dir(p)) { - print(" \\\n\t%s", object(p)); + printf(" \\\n\t%s", object(p)); } } - print("\n\nOBS2_%s =", id->id_text); + printf("\n\nOBS2_%s =", id->id_text); f_walk(id->id_mdependson, p) { if (module_in_arglist(f_filename(p)) || ! f_dir(p)) { /* nothing */ } else if (! is_library_dir(f_dir(p))) { - print(" \\\n\t%s/%s", f_dir(p), object(p)); + printf(" \\\n\t%s/%s", f_dir(p), object(p)); } } - print("\n\n"); - print("%s_o_files:\t$(OBS_%s)\n\n", basename(f_filename(a)), id->id_text); - print("%s:\t$(OBS_%s) $(OBS2_%s)\n", basename(f_filename(a)), id->id_text, id->id_text); - print("\t$(MOD) -o %s $(M2FLAGS) $(OBS_%s) $(OBS2_%s) $(LIBS)\n", basename(f_filename(a)), id->id_text, id->id_text); + printf("\n\n"); + printf("%s_o_files:\t$(OBS_%s)\n\n", basename(f_filename(a)), id->id_text); + printf("%s:\t$(OBS_%s) $(OBS2_%s)\n", basename(f_filename(a)), id->id_text, id->id_text); + printf("\t$(MOD) -o %s $(M2FLAGS) $(OBS_%s) $(OBS2_%s) $(LIBS)\n", basename(f_filename(a)), id->id_text, id->id_text); } programs() diff --git a/lang/m2/test/queens.mod b/lang/m2/test/queens.mod index 52797615a7..0198a16041 100644 --- a/lang/m2/test/queens.mod +++ b/lang/m2/test/queens.mod @@ -37,7 +37,7 @@ FROM InOut IMPORT WriteString, WriteLn; FOR i := 1 TO maxpos DO IF free(k,i) THEN d[k] := i; - print(); + printf(); END; END; ELSE diff --git a/lang/pc/comp/main.c b/lang/pc/comp/main.c index 4d23d50b51..4b48f34318 100644 --- a/lang/pc/comp/main.c +++ b/lang/pc/comp/main.c @@ -147,26 +147,26 @@ void LexScan(void) while( LLlex() > 0 ) { - print(">>> %s ", symbol2str(tkp->tk_symb)); + printf(">>> %s ", symbol2str(tkp->tk_symb)); switch( tkp->tk_symb ) { case IDENT: - print("%s\n", tkp->TOK_IDF->id_text); + printf("%s\n", tkp->TOK_IDF->id_text); break; case INTEGER: - print("%ld\n", tkp->TOK_INT); + printf("%ld\n", tkp->TOK_INT); break; case REAL: - print("%s\n", tkp->TOK_REL); + printf("%s\n", tkp->TOK_REL); break; case STRING: - print("'%s'\n", tkp->TOK_STR); + printf("'%s'\n", tkp->TOK_STR); break; default: - print("\n"); + printf("\n"); } } } @@ -277,10 +277,10 @@ void Info(void) cnt_scopelist, cnt_tmpvar, cnt_withdesig, cnt_case_hdr, cnt_case_entry; - print("\ + printf("\ %6d def\n%6d node\n%6d paramlist\n%6d type\n%6d scope\n%6d scopelist\n\ %6d lab\n%6d tmpvar\n%6d withdesig\n%6d casehdr\n%6d caseentry\n", cnt_def, cnt_node, cnt_paramlist, cnt_type, cnt_scope, cnt_scopelist, cnt_lab, cnt_tmpvar, cnt_withdesig, cnt_case_hdr, cnt_case_entry); -print("\nNumber of lines read: %d\n", cntlines); +printf("\nNumber of lines read: %d\n", cntlines); } #endif diff --git a/lang/pc/comp/node.c b/lang/pc/comp/node.c index 069688fc47..efd67b6e92 100644 --- a/lang/pc/comp/node.c +++ b/lang/pc/comp/node.c @@ -60,25 +60,25 @@ int NodeCrash(struct node *expp) void indnt(int lvl) { while( lvl-- ) - print(" "); + printf(" "); } void printnode(struct node *nd, int lvl) { indnt(lvl); - print("Class: %d; Symbol: %s\n", nd->nd_class, symbol2str(nd->nd_symb)); + printf("Class: %d; Symbol: %s\n", nd->nd_class, symbol2str(nd->nd_symb)); if( nd->nd_type ) { indnt(lvl); - print("Type: "); + printf("Type: "); DumpType(nd->nd_type); - print("\n"); + printf("\n"); } } void PrNode(struct node *nd, int lvl) { if( !nd ) { - indnt(lvl); print("\n"); + indnt(lvl); printf("\n"); return; } PrNode(nd->nd_left, lvl + 1); diff --git a/lang/pc/comp/type.c b/lang/pc/comp/type.c index e44a1ef7b2..e58ed2f1ff 100644 --- a/lang/pc/comp/type.c +++ b/lang/pc/comp/type.c @@ -616,35 +616,35 @@ void DumpType(struct type *tp) { if( !tp ) return; - print("align:%d; size:%ld;", tp->tp_align, (long) tp->tp_size); + printf("align:%d; size:%ld;", tp->tp_align, (long) tp->tp_size); - print(" fund:"); + printf(" fund:"); switch( tp->tp_fund ) { case T_ENUMERATION: - print("ENUMERATION; ncst:%d", tp->enm_ncst); break; + printf("ENUMERATION; ncst:%d", tp->enm_ncst); break; case T_INTEGER: - print("INTEGER"); break; + printf("INTEGER"); break; case T_LONG: - print("LONG"); break; + printf("LONG"); break; case T_REAL: - print("REAL"); break; + printf("REAL"); break; case T_CHAR: - print("CHAR"); break; + printf("CHAR"); break; case T_STRING: - print("STRING"); break; + printf("STRING"); break; case T_PROCEDURE: case T_FUNCTION: { struct paramlist *par = ParamList(tp); if( tp->tp_fund == T_PROCEDURE ) - print("PROCEDURE"); + printf("PROCEDURE"); else - print("FUNCTION"); + printf("FUNCTION"); if( par ) { - print("("); + printf("("); while( par ) { - if( IsVarParam(par) ) print("VAR "); + if( IsVarParam(par) ) printf("VAR "); DumpType(TypeOfParam(par)); par = par->next; } @@ -652,36 +652,36 @@ void DumpType(struct type *tp) break; } case T_FILE: - print("FILE"); break; + printf("FILE"); break; case T_STRINGCONST: - print("STRINGCONST"); break; + printf("STRINGCONST"); break; case T_SUBRANGE: - print("SUBRANGE %ld-%ld", (long) tp->sub_lb, (long) tp->sub_ub); + printf("SUBRANGE %ld-%ld", (long) tp->sub_lb, (long) tp->sub_ub); break; case T_SET: - print("SET"); break; + printf("SET"); break; case T_ARRAY: - print("ARRAY"); - print("; element:"); + printf("ARRAY"); + printf("; element:"); DumpType(tp->arr_elem); - print("; index:"); + printf("; index:"); DumpType(tp->next); - print(";"); + printf(";"); return; case T_RECORD: - print("RECORD"); break; + printf("RECORD"); break; case T_POINTER: - print("POINTER"); break; + printf("POINTER"); break; default: crash("DumpType"); } if( tp->next && tp->tp_fund != T_POINTER ) { /* Avoid printing recursive types! */ - print(" next:("); + printf(" next:("); DumpType(tp->next); - print(")"); + printf(")"); } - print(";"); + printf(";"); } #endif diff --git a/mach/sun3/ce/output.c b/mach/sun3/ce/output.c index 498c2fc1b9..690d3b8c85 100644 --- a/mach/sun3/ce/output.c +++ b/mach/sun3/ce/output.c @@ -85,7 +85,7 @@ output_back() putbuf((char *) u_name, sizeof(struct nlist)*nname); free(u_name); - /* print( "size string_area %d\n", nchar); */ + /* printf( "size string_area %d\n", nchar); */ put_stringtablesize( nchar + 4); putbuf((char *) string_area, nchar); @@ -190,7 +190,7 @@ init_unixheader() u_header.a_entry = 0; u_header.a_trsize = trsize * sizeof(struct relocation_info); u_header.a_drsize = drsize * sizeof(struct relocation_info); - /* print( "header %o %d %d %d %d %d %d %d\n", + /* printf( "header %o %d %d %d %d %d %d %d\n", u_header.a_magic, u_header.a_text, u_header.a_data, u_header.a_bss, u_header.a_syms, u_header.a_entry, u_header.a_trsize, u_header.a_drsize); @@ -241,7 +241,7 @@ convert_name( a_name, u_name) struct outname *a_name; struct nlist *u_name; { - /* print( "naam is %s\n", a_name->on_foff + string_area); */ + /* printf( "naam is %s\n", a_name->on_foff + string_area); */ u_name->n_str = a_name->on_foff + 4; if (a_name->on_type & S_STB) u_name->n_type = a_name->on_type >> 8; diff --git a/mach/sun3/ce/relocation.c b/mach/sun3/ce/relocation.c index 817df5224c..30886d60e4 100644 --- a/mach/sun3/ce/relocation.c +++ b/mach/sun3/ce/relocation.c @@ -10,7 +10,7 @@ do_local_relocation() { struct outrelo *rp; - /* print( "n relocation records %d\n", relo - reloc_info); */ + /* printf( "n relocation records %d\n", relo - reloc_info); */ B_base_address[SEGTXT] = 0; B_base_address[SEGCON] = text - text_area; diff --git a/mach/vax4/ce/output.c b/mach/vax4/ce/output.c index c2db2f6121..04c869913f 100644 --- a/mach/vax4/ce/output.c +++ b/mach/vax4/ce/output.c @@ -85,7 +85,7 @@ output_back() putbuf((char *) u_name, sizeof(struct nlist)*nname); free(u_name); - /* print( "size string_area %d\n", nchar); */ + /* printf( "size string_area %d\n", nchar); */ put_stringtablesize( nchar + 4); putbuf((char *) string_area, nchar); @@ -189,7 +189,7 @@ init_unixheader() u_header.a_entry = 0; u_header.a_trsize = trsize * sizeof(struct relocation_info); u_header.a_drsize = drsize * sizeof(struct relocation_info); - /* print( "header %o %d %d %d %d %d %d %d\n", + /* printf( "header %o %d %d %d %d %d %d %d\n", u_header.a_magic, u_header.a_text, u_header.a_data, u_header.a_bss, u_header.a_syms, u_header.a_entry, u_header.a_trsize, u_header.a_drsize); @@ -241,7 +241,7 @@ convert_name( a_name, u_name) struct outname *a_name; struct nlist *u_name; { - /* print( "naam is %s\n", a_name->on_foff + string_area); */ + /* printf( "naam is %s\n", a_name->on_foff + string_area); */ u_name->n_str = a_name->on_foff + 4; if (a_name->on_type & S_STB) u_name->n_type = a_name->on_type >> 8; diff --git a/mach/vax4/ce/relocation.c b/mach/vax4/ce/relocation.c index 6d7408308b..1a6190c337 100644 --- a/mach/vax4/ce/relocation.c +++ b/mach/vax4/ce/relocation.c @@ -10,7 +10,7 @@ do_local_relocation() { struct outrelo *rp; - /* print( "n relocation records %d\n", relo - reloc_info); */ + /* printf( "n relocation records %d\n", relo - reloc_info); */ B_base_address[SEGTXT] = 0; B_base_address[SEGCON] = text - text_area; diff --git a/modules/src/em_code/em_code.3X b/modules/src/em_code/em_code.3X index 84c051672e..51663e6cc2 100644 --- a/modules/src/em_code/em_code.3X +++ b/modules/src/em_code/em_code.3X @@ -461,7 +461,7 @@ routine replaces the EM_mkcalls routine. .SH MODULES .nf libemk.a: alloc(3), system(3), string(3) -libeme.a: alloc(3), print(3), system(3), string(3) +libeme.a: alloc(3), printf(3), system(3), string(3) .fi .SH SEE ALSO read_em(3), em_mes(3) diff --git a/modules/src/idf/idf_pkg.body b/modules/src/idf/idf_pkg.body index d14fe8b173..d1c831ae6f 100644 --- a/modules/src/idf/idf_pkg.body +++ b/modules/src/idf/idf_pkg.body @@ -74,24 +74,24 @@ void hash_stat(void) register int i; int total_count = 0; - print("Hash table tally:\n"); + printf("Hash table tally:\n"); for (i = 0; i < IDF_HASHSIZE; i++) { register struct idf* notch = IDF_hashtable[i]; register int cnt = 0; - print("%d ", i); + printf("%d ", i); while (notch) { cnt++; - print("'%s' ", notch->id_text); + printf("'%s' ", notch->id_text); notch = notch->id_next; } - print("%d\n", cnt); + printf("%d\n", cnt); total_count += cnt; } - print("total = %d\n", total_count); - print("End hash table tally\n"); + printf("total = %d\n", total_count); + printf("End hash table tally\n"); } void idfappfun(int (*fun)(struct idf *, int), int opt) diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua index 5b09cab6b1..8690de6de4 100644 --- a/modules/src/print/build.lua +++ b/modules/src/print/build.lua @@ -1,7 +1,7 @@ clibrary { name = "lib", srcs = { - "./doprnt.c", "./format.c", "./fprint.c", "./print.c", + "./doprnt.c", "./format.c", "./fprint.c", }, hdrs = { "./print.h" }, deps = { diff --git a/modules/src/print/print.3 b/modules/src/print/print.3 index e40473b974..89838bd635 100644 --- a/modules/src/print/print.3 +++ b/modules/src/print/print.3 @@ -7,8 +7,6 @@ print, fprint, doprnt -- very simple formatted-output routines .B #include .B #include .PP -.B void print(char *format [, arg] ... ) -.PP .B void fprint(File *filep, char *format [, arg] ... ) .PP .B void doprnt(File *filep, char *format, va_list args) @@ -16,8 +14,6 @@ print, fprint, doprnt -- very simple formatted-output routines .B int _format(char *buf, char *format, va_lsit args) .fi .SH DESCRIPTION -.I print -writes output on standard output. .I fprint and .I doprnt diff --git a/modules/src/print/print.c b/modules/src/print/print.c deleted file mode 100644 index 2e1256a546..0000000000 --- a/modules/src/print/print.c +++ /dev/null @@ -1,28 +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 "print.h" -#include "param.h" - -/*FORMAT0v $ - %s = char * - %l = long - %c = int - %[uxbo] = unsigned int - %d = int -$ */ -/*VARARGS*/ -void -print(const char *fmt, ...) -{ - va_list args; - char buf[SSIZE]; - - va_start(args, fmt); - sys_write(STDOUT, buf, _format(buf, fmt, args)); - va_end(args); -} diff --git a/modules/src/print/print.h b/modules/src/print/print.h index 1c7bd0e82c..c9d5de57f6 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -9,7 +9,6 @@ #include #include -void print(const char *fmt, ...); 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); diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 6da1bcf540..72a423b817 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -424,7 +424,7 @@ void get(int argc, char* argv[]) #ifdef AAL if (i != argc) { - print("%s: already in archive\n", argv[i]); + printf("%s: already in archive\n", argv[i]); argv[i] = ""; } #endif @@ -436,7 +436,7 @@ void get(int argc, char* argv[]) #ifndef AAL if (app_fl && i != argc) { - print("%s: already in archive\n", argv[i]); + printf("%s: already in archive\n", argv[i]); argv[i] = ""; } #endif @@ -471,13 +471,13 @@ void get(int argc, char* argv[]) *(date + 16) = '\0'; *(date + 24) = '\0'; - print( + printf( "%s%3u/%u%7ld %s %s %s", mode, (unsigned)(member->ar_uid & 0377), (unsigned)(member->ar_gid & 0377), member->ar_size, date + 4, date + 20, buf); } else - print(buf); + printf(buf); } else if (del_fl) { @@ -506,7 +506,7 @@ void get(int argc, char* argv[]) add(argv[i], ar_f, temp_fd, "a - %s\n"); else { - print("%s: not found\n", argv[i]); + printf("%s: not found\n", argv[i]); } } } @@ -742,7 +742,7 @@ void show(char* s, char* name) while (q <= &name[sizeof(x.ar_name) - 1] && *q) *p++ = *q++; *p++ = '\0'; - print(s, buf); + printf(s, buf); } #ifdef AAL diff --git a/util/ceg/ce_back/obj_back/memory.c b/util/ceg/ce_back/obj_back/memory.c index c860c28a2b..629cd485e5 100644 --- a/util/ceg/ce_back/obj_back/memory.c +++ b/util/ceg/ce_back/obj_back/memory.c @@ -11,7 +11,7 @@ mem_text() { - /* print( "text_area too small %d %d \n", text_area, text); */ + /* printf( "text_area too small %d %d \n", text_area, text); */ int diff = text - text_area; text_area = realloc( text_area, sizeof( char) * 2 * size_text); @@ -23,7 +23,7 @@ mem_text() mem_data() { - /* print( "data_area too small\n"); */ + /* printf( "data_area too small\n"); */ int diff = data - data_area; data_area = realloc( data_area, sizeof( char) * 2 * size_data); @@ -35,13 +35,13 @@ mem_data() mem_symbol_hash() { - /* print( "symbol_table out of memory\n"); */ + /* printf( "symbol_table out of memory\n"); */ size_symbol = 2 * size_symbol; symbol_table = (struct outname *) realloc( (char *) symbol_table, sizeof( struct outname) * size_symbol); - /* print( "hash out of memory\n"); */ + /* printf( "hash out of memory\n"); */ Hashitems = (struct Hashitem *) realloc( (char *) Hashitems, sizeof( struct Hashitem)*(size_symbol+1)); @@ -50,7 +50,7 @@ mem_symbol_hash() mem_relo() { - /* print( "reloc_table out of memory\n"); */ + /* printf( "reloc_table out of memory\n"); */ int diff = relo - reloc_info; reloc_info = (struct outrelo *) realloc( (char *) reloc_info, @@ -64,7 +64,7 @@ mem_string() { int diff = string - string_area; - /* print( "string_area out of memory %d %d \n", string_area, string);*/ + /* printf( "string_area out of memory %d %d \n", string_area, string);*/ size_string = 2 * size_string; string_area = realloc( string_area, sizeof( char) * size_string); diff --git a/util/ceg/ce_back/obj_back/reloc4.c b/util/ceg/ce_back/obj_back/reloc4.c index 297cbb0dfc..0027eb9e04 100644 --- a/util/ceg/ce_back/obj_back/reloc4.c +++ b/util/ceg/ce_back/obj_back/reloc4.c @@ -40,7 +40,7 @@ int pcrel; r->or_addr = cur_value(); gen4( (pcrel) ? off - ( r->or_addr + 4) : off); - /* print( "r %s r %ld s %d in %d adrr %ld off %ld\n", + /* printf( "r %s r %ld s %d in %d adrr %ld off %ld\n", sym, pcrel, cur_seg, r->or_nami, r->or_addr, (pcrel) ? off-cur_value() : off); */ diff --git a/util/ceg/ce_back/obj_back/relocation.c b/util/ceg/ce_back/obj_back/relocation.c index baf62b4a20..8c4cf00334 100644 --- a/util/ceg/ce_back/obj_back/relocation.c +++ b/util/ceg/ce_back/obj_back/relocation.c @@ -63,7 +63,7 @@ do_local_relocation() else fprint( STDERR, "do_relo() : bad relocation size\n"); rp->or_nami = seg_index((np->on_type & S_TYP) - S_MIN); - /* print( + /* printf( "reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n", np->on_foff+string_area, rp->or_addr, rp->or_sect-S_MIN, oldval, newval, np->on_valu); */ diff --git a/util/ego/sr/sr.c b/util/ego/sr/sr.c index b4c613bfc7..b3fa72a1a2 100644 --- a/util/ego/sr/sr.c +++ b/util/ego/sr/sr.c @@ -30,16 +30,16 @@ * The transformations can be expressed in C as: * * [1]: for (i = e1; i <= e2; i++) - * print(118*i); + * printf(118*i); * becomes: * for (i = e1, t = 118*e1; i <= e2; i++, t += 118) - * print(t); + * printf(t); * * [2]: for (i = e1; i <= e2; i++) - * print(a[i]); + * printf(a[i]); * becomes: * for (i = e1, p = &a[i]; i <= e2; i++, p++) - * print(*p); + * printf(*p); * The latter optimization is suppressed if array bound checking * is required. */ From c926f0b1c0b4645ef5a723df5a569574c9e9d78e Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:03:42 +0100 Subject: [PATCH 13/29] The system module now uses FILE* throughout. --- modules/src/system/close.c | 11 ++++--- modules/src/system/create.c | 12 ++++---- modules/src/system/open.c | 60 ++++++++++++++++++------------------- modules/src/system/read.c | 18 ++++------- modules/src/system/seek.c | 11 ++++--- modules/src/system/system.c | 26 +++++++++++----- modules/src/system/system.h | 14 +++++---- modules/src/system/write.c | 15 ++-------- 8 files changed, 82 insertions(+), 85 deletions(-) diff --git a/modules/src/system/close.c b/modules/src/system/close.c index 6ebcdbb8fd..f3176cb9e4 100644 --- a/modules/src/system/close.c +++ b/modules/src/system/close.c @@ -7,12 +7,11 @@ #include #include "system.h" -void -sys_close(File* fp) +void sys_close(File* fp) { - if (fp) { - fp->o_flags = 0; - close(fp->o_fd); - fp->o_fd = -1; + if (fp) + { + fclose(fp->fd); + fp->fd = NULL; } } diff --git a/modules/src/system/create.c b/modules/src/system/create.c index 89449adc7c..db2f5fba9d 100644 --- a/modules/src/system/create.c +++ b/modules/src/system/create.c @@ -7,18 +7,16 @@ #include #include "system.h" -int -sys_create(File** filep, char* path, int mode) +int sys_create(File** filep, char* path, int mode) { int fd; - File *fp; + File* fp; - if ((fp = _get_entry()) == (File *)0) + if ((fp = _get_entry()) == (File*)0) return 0; - if ((fd = creat(path, mode)) < 0) + fp->fd = fopen(path, "wb"); + if (!fp->fd) return 0; - fp->o_fd = fd; - fp->o_flags = OP_WRITE; *filep = fp; return 1; } diff --git a/modules/src/system/open.c b/modules/src/system/open.c index cbf43d2817..dd443b084b 100644 --- a/modules/src/system/open.c +++ b/modules/src/system/open.c @@ -9,45 +9,43 @@ #include #include "system.h" -#if !defined WIN32 -#define O_BINARY 0 -#endif - -int -sys_open(char* path, int flag, File** filep) +int sys_open(char* path, int flag, File** filep) { - int fd; - File *fp; + File* fp; + FILE* fd; - if ((fp = _get_entry()) == (File *)0) + if ((fp = _get_entry()) == (File*)0) return 0; - switch (flag) { - case OP_READ: - if ((fd = open(path, O_RDONLY|O_BINARY)) < 0) - return 0; - break; - case OP_APPEND: - if ((fd = open(path, O_WRONLY|O_BINARY)) < 0) { - if (access(path, 0) == 0) - return 0; - } - else { - if (lseek(fd, 0L, 2) < 0L) { - close(fd); + 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; - } - /* Fall through */ - case OP_WRITE: - if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666)) < 0) + default: return 0; - break; - default: - return 0; } - fp->o_flags = flag; - fp->o_fd = fd; + fp->fd = fd; *filep = fp; return 1; } diff --git a/modules/src/system/read.c b/modules/src/system/read.c index 654ff406db..c407c96f7d 100644 --- a/modules/src/system/read.c +++ b/modules/src/system/read.c @@ -12,19 +12,11 @@ int sys_read(File* fp, char* bufptr, int bufsiz, int* pnbytes) if (!fp) return 0; + FILE* fd = getfd(fp); *pnbytes = 0; - while (bufsiz != 0) - { - int len = read(fp->o_fd, bufptr, bufsiz); - if (len < 0) - return 0; - if (len == 0) - return *pnbytes != 0; - - *pnbytes += len; - bufptr += len; - bufsiz -= len; - } - + 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 index ba52b845de..d385d7f355 100644 --- a/modules/src/system/seek.c +++ b/modules/src/system/seek.c @@ -7,9 +7,12 @@ #include #include "system.h" -int -sys_seek(File* fp, long off, int whence, long* poff) +int sys_seek(File* fp, long off, int whence, long* poff) { - if (! fp) return 0; - return (*poff = lseek(fp->o_fd, off, whence)) >= 0; + 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.c b/modules/src/system/system.c index 84502c05ca..91eb9ddfed 100644 --- a/modules/src/system/system.c +++ b/modules/src/system/system.c @@ -6,18 +6,30 @@ #include "system.h" -File _sys_ftab[SYS_NOPEN] = { - { 0, OP_READ}, - { 1, OP_APPEND}, - { 2, OP_APPEND} -}; +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->o_flags == 0) + { + if (!fp->fd) return fp; - return (File *)0; + } + return NULL; } diff --git a/modules/src/system/system.h b/modules/src/system/system.h index 8e754d4452..dc8e3907a4 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -11,13 +11,15 @@ #include struct _sys_fildes { - int o_fd; /* UNIX filedescriptor */ - int o_flags; /* flags for open; 0 if not used */ + 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 @@ -35,6 +37,8 @@ extern File _sys_ftab[]; #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 *); @@ -58,9 +62,9 @@ NORETURN void sys_stop(int); time_t sys_modtime(char *); /* standard file decsriptors */ -#define STDIN &_sys_ftab[0] -#define STDOUT &_sys_ftab[1] -#define STDERR &_sys_ftab[2] +#define STDIN &sys_stdin +#define STDOUT &sys_stdout +#define STDERR &sys_stderr /* maximum number of open files */ #define SYS_NOPEN 20 diff --git a/modules/src/system/write.c b/modules/src/system/write.c index af996867c2..df31d6472b 100644 --- a/modules/src/system/write.c +++ b/modules/src/system/write.c @@ -11,17 +11,8 @@ int sys_write(File* fp, char* bufptr, int nbytes) { if (!fp) return 0; - - while (nbytes != 0) - { - int len = write(fp->o_fd, bufptr, nbytes); - if (len < 0) - return 0; - bufptr += len; - nbytes -= len; - } - - return 1; + FILE* fd = getfd(fp); + int len = fwrite(bufptr, 1, nbytes, fd); + return (len == nbytes); } - From 2999ca80074b99b221cd06cfa49ff3381be7f09d Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:04:55 +0100 Subject: [PATCH 14/29] Remove the unused sys_chmode. --- modules/src/system/chmode.c | 13 ------------- modules/src/system/system.3 | 10 ---------- modules/src/system/system.h | 1 - 3 files changed, 24 deletions(-) delete mode 100644 modules/src/system/chmode.c diff --git a/modules/src/system/chmode.c b/modules/src/system/chmode.c deleted file mode 100644 index bed6bcd834..0000000000 --- a/modules/src/system/chmode.c +++ /dev/null @@ -1,13 +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_chmode(char* path,int mode) -{ - return chmod(path, (mode_t)mode) == 0; -} diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index 200316e8f9..f1c6057d1c 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -50,10 +50,6 @@ sys_lock, sys_unlock, sys_stop \- system call interface .B long sys_filesize(path) .B char *path; .PP -.B int sys_chmode(path, mode) -.B char *path; -.B int mode; -.PP .B int sys_lock(name) .B char *name; .PP @@ -235,12 +231,6 @@ file specified by if possible. The value \-1L is returned if the size cannot be retrieved for some reason. .PP -.I Sys_chmode -changes the file-protection mode of file -.I path -to -.IR mode . -.PP .I Sys_lock and .I sys_unlock diff --git a/modules/src/system/system.h b/modules/src/system/system.h index dc8e3907a4..d83e41ceaf 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -49,7 +49,6 @@ int sys_access(char *, int); int sys_remove(char *); int sys_rename(char *, char *); off_t sys_filesize(char *); -int sys_chmode(char *, int); /* Return the temporary directory location */ char* sys_gettmpdir(void); /* Call another program. */ From b74bd7b105a4f5994c0bce14f8e14e09720ea619 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:23:53 +0100 Subject: [PATCH 15/29] Remove sys_remove() in favour of real remove(). --- modules/src/em_code/em.c | 2 +- modules/src/system/build.lua | 2 -- modules/src/system/remove.c | 13 ------------- modules/src/system/system.3 | 19 ++----------------- modules/src/system/system.h | 1 - 5 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 modules/src/system/remove.c diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index aaf7fb4267..38016aa3e6 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -143,7 +143,7 @@ void C_close(void) } #ifndef INCORE sys_close(C_tfr); - sys_remove(C_tmpfile); + remove(C_tmpfile); if (C_ibuf) free(C_ibuf); #else free(C_BASE); diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index 982154a64a..dbb7459d7c 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -3,7 +3,6 @@ clibrary { srcs = { "./access.c", "./basename.c", - "./chmode.c", "./close.c", "./create.c", "./filesize.c", @@ -11,7 +10,6 @@ clibrary { "./modtime.c", "./open.c", "./read.c", - "./remove.c", "./rename.c", "./seek.c", "./setbinarymode.c", diff --git a/modules/src/system/remove.c b/modules/src/system/remove.c deleted file mode 100644 index 82b6fd4c68..0000000000 --- a/modules/src/system/remove.c +++ /dev/null @@ -1,13 +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_remove(char* path) -{ - return remove(path) == 0; -} diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index f1c6057d1c..70e69f0e24 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -2,7 +2,7 @@ .ad .SH NAME sys_open, sys_close, sys_read, sys_write, sys_reset, sys_access, -sys_modtime, sys_remove, sys_rename, sys_filesize, sys_chmode, +sys_modtime, sys_rename, sys_filesize, sys_lock, sys_unlock, sys_stop \- system call interface .SH SYNOPSIS .nf @@ -41,9 +41,6 @@ sys_lock, sys_unlock, sys_stop \- system call interface .B char *path; .B int mode; .PP -.B int sys_remove(path) -.B char *path; -.PP .B int sys_rename(path1, path2) .B char *path1, *path2; .PP @@ -203,17 +200,6 @@ returns the last-modified time of the file specified in .IR path . Any failure is indicated by a return value of \-1L. .PP -.I Sys_remove -removes file -.I path -from the system. -It is supposed that, if the file is still open, the contents of -the file are available until the last -.I sys_close -is performed on it. -A non-zero return value indicates successful action whereas 0 -indicates that the given file does not exist or cannot be removed. -.PP .I Sys_rename renames file .I path1 @@ -292,9 +278,8 @@ The routines .IR sys_write , .IR sys_reset , .IR sys_chmode , -.IR sys_rename , and -.I sys_remove +.IR sys_rename return a value of zero upon any failure and a non-zero value if the call succeeds. .SH BUGS diff --git a/modules/src/system/system.h b/modules/src/system/system.h index d83e41ceaf..b20e107ba3 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -46,7 +46,6 @@ int sys_write(File *, char *, int); int sys_seek(File *, long, int, long *); int sys_reset(File *); int sys_access(char *, int); -int sys_remove(char *); int sys_rename(char *, char *); off_t sys_filesize(char *); /* Return the temporary directory location */ From 9e3ce86eb04a2a0ef5d2baf2de97b04c0e90ccec Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:24:51 +0100 Subject: [PATCH 16/29] Remove the unused sys_rename. --- modules/src/system/build.lua | 1 - modules/src/system/rename.c | 14 -------------- modules/src/system/system.3 | 5 +---- modules/src/system/system.h | 1 - 4 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 modules/src/system/rename.c diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index dbb7459d7c..93508ae26d 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -10,7 +10,6 @@ clibrary { "./modtime.c", "./open.c", "./read.c", - "./rename.c", "./seek.c", "./setbinarymode.c", "./stop.c", diff --git a/modules/src/system/rename.c b/modules/src/system/rename.c deleted file mode 100644 index 1111c037a0..0000000000 --- a/modules/src/system/rename.c +++ /dev/null @@ -1,14 +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 "system.h" - -int -sys_rename(char* path1, char* path2) -{ - return rename(path1, path2) == 0; -} - diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index 70e69f0e24..6cb7e5144d 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -2,7 +2,7 @@ .ad .SH NAME sys_open, sys_close, sys_read, sys_write, sys_reset, sys_access, -sys_modtime, sys_rename, sys_filesize, +sys_modtime, sys_filesize, sys_lock, sys_unlock, sys_stop \- system call interface .SH SYNOPSIS .nf @@ -41,9 +41,6 @@ sys_lock, sys_unlock, sys_stop \- system call interface .B char *path; .B int mode; .PP -.B int sys_rename(path1, path2) -.B char *path1, *path2; -.PP .B long sys_filesize(path) .B char *path; .PP diff --git a/modules/src/system/system.h b/modules/src/system/system.h index b20e107ba3..7c7f16587a 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -46,7 +46,6 @@ int sys_write(File *, char *, int); int sys_seek(File *, long, int, long *); int sys_reset(File *); int sys_access(char *, int); -int sys_rename(char *, char *); off_t sys_filesize(char *); /* Return the temporary directory location */ char* sys_gettmpdir(void); From 6545c4f69afee41249376222a557d16046e7634c Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:26:23 +0100 Subject: [PATCH 17/29] Cleanup. --- modules/src/system/Amake.srclist | 21 -------------------- modules/src/system/build.lua | 2 -- modules/src/system/lock.c | 33 -------------------------------- modules/src/system/system.3 | 24 ----------------------- modules/src/system/system.h | 4 ---- modules/src/system/unlock.c | 14 -------------- 6 files changed, 98 deletions(-) delete mode 100644 modules/src/system/Amake.srclist delete mode 100644 modules/src/system/lock.c delete mode 100644 modules/src/system/unlock.c diff --git a/modules/src/system/Amake.srclist b/modules/src/system/Amake.srclist deleted file mode 100644 index c2701701c9..0000000000 --- a/modules/src/system/Amake.srclist +++ /dev/null @@ -1,21 +0,0 @@ -L_ACK_MODULES_SYSTEM = { - $PWD/access.c, - $PWD/break.c, - $PWD/chmode.c, - $PWD/close.c, - $PWD/create.c, - $PWD/filesize.c, - $PWD/lock.c, - $PWD/modtime.c, - $PWD/open.c, - $PWD/read.c, - $PWD/remove.c, - $PWD/rename.c, - $PWD/seek.c, - $PWD/stop.c, - $PWD/system.c, - $PWD/time.c, - $PWD/unlock.c, - $PWD/write.c, - $PWD/system.h -}; diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index 93508ae26d..ed562f4493 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -18,8 +18,6 @@ clibrary { "./system.c", "./tmpdir.c", "./write.c", - --"./lock.c", - --"./unlock.c”, }, hdrs = { "./system.h" }, deps = { diff --git a/modules/src/system/lock.c b/modules/src/system/lock.c deleted file mode 100644 index 6f00a3a169..0000000000 --- a/modules/src/system/lock.c +++ /dev/null @@ -1,33 +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 "system.h" - -int -sys_lock(path) - char *path; -{ - char buf[1024]; - char *tmpf = ".lockXXXXXX"; - char *p; - int ok, fd; - - strcpy(buf, path); - if (p = strrchr(buf, '/')) { - ++p; - strcpy(p, tmpf); - } - else - strcpy(buf, tmpf); - if ((fd = mkstemp(buf)) < 0) - return 0; - close(fd); - ok = (link(buf, path) == 0); - unlink(buf); - return ok; -} diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index 6cb7e5144d..082e90a5df 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -44,12 +44,6 @@ sys_lock, sys_unlock, sys_stop \- system call interface .B long sys_filesize(path) .B char *path; .PP -.B int sys_lock(name) -.B char *name; -.PP -.B int sys_unlock(name) -.B char *name; -.PP .B char *sys_break(incr) .B int incr; .PP @@ -214,24 +208,6 @@ file specified by if possible. The value \-1L is returned if the size cannot be retrieved for some reason. .PP -.I Sys_lock -and -.I sys_unlock -provide a mechanism for setting and clearing symbolic locks for external -objects. -This is done by creating and removing file -.IR name . -.I Sys_lock -returns zero if the lock is already set and a non-zero value if the lock -did not exist and has been created. -.I Sys_unlock -returns a non-zero value if the lock did not exist or if the lock has been -removed succesfully. -Zero is returned otherwise. -The actions performed by these routines are atomic: -race conditions cannot -occur. -.PP .I Sys_break adds .I incr diff --git a/modules/src/system/system.h b/modules/src/system/system.h index 7c7f16587a..d99cb7347d 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -51,10 +51,6 @@ off_t sys_filesize(char *); char* sys_gettmpdir(void); /* Call another program. */ int sys_system(const char* prog, const char* const* argv); -#if 0 -int sys_lock(char *); -int sys_unlock(char *); -#endif NORETURN void sys_stop(int); time_t sys_modtime(char *); diff --git a/modules/src/system/unlock.c b/modules/src/system/unlock.c deleted file mode 100644 index 51ae6f591d..0000000000 --- a/modules/src/system/unlock.c +++ /dev/null @@ -1,14 +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 "system.h" - -int -sys_unlock(path) - char *path; -{ - return unlink(path) == 0; -} From d01d7166f93e535073c786649359b5cab223553e Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:28:00 +0100 Subject: [PATCH 18/29] Remove the unused sys_access. --- modules/src/system/access.c | 14 -------------- modules/src/system/build.lua | 1 - modules/src/system/system.3 | 29 +---------------------------- modules/src/system/system.h | 7 ------- 4 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 modules/src/system/access.c diff --git a/modules/src/system/access.c b/modules/src/system/access.c deleted file mode 100644 index 1c29db08c9..0000000000 --- a/modules/src/system/access.c +++ /dev/null @@ -1,14 +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_access(char* path, int mode) -{ - return access(path, mode) == 0; -} diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index ed562f4493..527cf5703f 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -1,7 +1,6 @@ clibrary { name = "lib", srcs = { - "./access.c", "./basename.c", "./close.c", "./create.c", diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index 082e90a5df..e556b7f39d 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -1,7 +1,7 @@ .TH SYSTEM 3 "$Revision$" .ad .SH NAME -sys_open, sys_close, sys_read, sys_write, sys_reset, sys_access, +sys_open, sys_close, sys_read, sys_write, sys_reset, sys_modtime, sys_filesize, sys_lock, sys_unlock, sys_stop \- system call interface .SH SYNOPSIS @@ -37,10 +37,6 @@ sys_lock, sys_unlock, sys_stop \- system call interface .B int sys_reset(filep) .B File *filep .PP -.B int sys_access(path, mode) -.B char *path; -.B int mode; -.PP .B long sys_filesize(path) .B char *path; .PP @@ -163,29 +159,6 @@ causes the open file known by to be re-opened for reading (cf. open flag OP_READ). This may be useful in reading anonymous files. .PP -.I Sys_access -checks the given file -.I path -for accessibility according to -.I mode -which is the result of -.IR or 'ing -one or more of the following values: -.IP AC_READ 15 -file exists and is readable -.IP AC_WRITE 15 -file exists and is writable -.IP AC_EXEC 15 -file exists and is executable -.LP -Specifying -.I mode -as 0 tests whether the directories leading to the file can be searched and the -file exists. -The return value is either 0 if the -file is not reachable, does not exist or if the access is not allowed, -or 1 if the indicated access is permitted. -.PP .I Sys_modtime returns the last-modified time of the file specified in .IR path . diff --git a/modules/src/system/system.h b/modules/src/system/system.h index d99cb7347d..7930e33d2c 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -26,12 +26,6 @@ extern File sys_stderr; #define OP_WRITE 02 #define OP_APPEND 04 -/* flags for sys_access() */ -#define AC_EXIST 00 -#define AC_READ 04 -#define AC_WRITE 02 -#define AC_EXEC 01 - /* flags for sys_stop() */ #define S_END 0 #define S_EXIT 1 @@ -45,7 +39,6 @@ int sys_read(File *, char *, int, int *); int sys_write(File *, char *, int); int sys_seek(File *, long, int, long *); int sys_reset(File *); -int sys_access(char *, int); off_t sys_filesize(char *); /* Return the temporary directory location */ char* sys_gettmpdir(void); From 96e3657d4e4e056782f721098b3fca4f2360be2a Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 19:30:22 +0100 Subject: [PATCH 19/29] Remove the unused sys_modtime. --- modules/src/system/build.lua | 1 - modules/src/system/modtime.c | 18 ------------------ modules/src/system/system.3 | 19 +------------------ modules/src/system/system.h | 1 - 4 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 modules/src/system/modtime.c diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index 527cf5703f..c7a9f27909 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -6,7 +6,6 @@ clibrary { "./create.c", "./filesize.c", "./maketempfile.c", - "./modtime.c", "./open.c", "./read.c", "./seek.c", diff --git a/modules/src/system/modtime.c b/modules/src/system/modtime.c deleted file mode 100644 index 9fe9455a62..0000000000 --- a/modules/src/system/modtime.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 -#include "system.h" - -time_t sys_modtime(char* path) -{ - struct stat st_buf; - - if (stat(path, &st_buf) != 0) - return -1L; - return st_buf.st_mtime; -} diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index e556b7f39d..d2cec18e64 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -2,7 +2,7 @@ .ad .SH NAME sys_open, sys_close, sys_read, sys_write, sys_reset, -sys_modtime, sys_filesize, +sys_filesize, sys_lock, sys_unlock, sys_stop \- system call interface .SH SYNOPSIS .nf @@ -45,9 +45,6 @@ sys_lock, sys_unlock, sys_stop \- system call interface .PP .B void sys_stop(how) .B int how; -.PP -.B long sys_modtime(path) -.B char *path; .fi .SH DESCRIPTION This package provides a rather system-independent set of "system" calls @@ -159,20 +156,6 @@ causes the open file known by to be re-opened for reading (cf. open flag OP_READ). This may be useful in reading anonymous files. .PP -.I Sys_modtime -returns the last-modified time of the file specified in -.IR path . -Any failure is indicated by a return value of \-1L. -.PP -.I Sys_rename -renames file -.I path1 -to -.IR path2 . -A non-zero return value indicates successful action. If -.I path2 -exists, it is removed first. -.PP The function .I sys_filesize returns the size in bytes of the diff --git a/modules/src/system/system.h b/modules/src/system/system.h index 7930e33d2c..85cf7e2753 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -45,7 +45,6 @@ char* sys_gettmpdir(void); /* Call another program. */ int sys_system(const char* prog, const char* const* argv); NORETURN void sys_stop(int); -time_t sys_modtime(char *); /* standard file decsriptors */ #define STDIN &sys_stdin From 514140fbdfa1bd496387aa48f87d1788621e0568 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 22:32:05 +0100 Subject: [PATCH 20/29] 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); } From 6a4b65dc2052fa88f528347bb59329908a39f447 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 22:46:09 +0100 Subject: [PATCH 21/29] Eliminate sys_stop() in favour of exit() and abort(). --- lang/basic/src/bem.c | 4 ++-- lang/basic/src/llmess.h | 2 +- lang/basic/src/parsepar.c | 2 +- lang/basic/src/util.c | 2 +- lang/cem/cemcom.ansi/error.c | 12 ++++++------ lang/cem/cemcom.ansi/main.c | 2 +- lang/cem/cemcom/error.c | 12 ++++++------ lang/cem/cpp.ansi/error.c | 8 ++++---- lang/cem/cpp.ansi/main.c | 2 +- lang/m2/comp/error.c | 12 ++++++------ lang/m2/comp/main.c | 4 ++-- lang/m2/m2mm/error.c | 12 ++++++------ modules/src/em_code/failed.c | 2 +- modules/src/em_code/internerr.c | 2 +- modules/src/em_opt/nopt.c | 2 +- modules/src/em_opt/outputdfa.c | 6 +++--- modules/src/em_opt/parser.g | 6 +++--- modules/src/system/build.lua | 1 - modules/src/system/stop.c | 21 --------------------- modules/src/system/system.h | 6 ------ util/ceg/ce_back/obj_back/output.c | 2 +- util/ego/em_ego/em_ego.c | 10 +++++----- 22 files changed, 52 insertions(+), 80 deletions(-) delete mode 100644 modules/src/system/stop.c diff --git a/lang/basic/src/bem.c b/lang/basic/src/bem.c index b1cd731012..bca919c82b 100644 --- a/lang/basic/src/bem.c +++ b/lang/basic/src/bem.c @@ -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 */ } diff --git a/lang/basic/src/llmess.h b/lang/basic/src/llmess.h index d0a8198898..37996cff3b 100644 --- a/lang/basic/src/llmess.h +++ b/lang/basic/src/llmess.h @@ -42,7 +42,7 @@ void LLmessage(int insertedtok ) if ( insertedtok < 0 ) { error("Fatal stack overflow\n"); C_close(); - sys_stop( S_EXIT ); + exit(1); } if ( insertedtok == 0 ) diff --git a/lang/basic/src/parsepar.c b/lang/basic/src/parsepar.c index 92e9849103..66400a0339 100644 --- a/lang/basic/src/parsepar.c +++ b/lang/basic/src/parsepar.c @@ -34,7 +34,7 @@ void parseparams(int argc,char **argv) { fprint(stderr,"usage %s \n", argv[0]); - sys_stop(S_EXIT); + exit(1); } for(i=1;iop=mnem; if(++higheststate>MAXSTATES) { fprintf(stderr,"Parser: More than %d states\n",MAXSTATES); - sys_stop(S_EXIT); + exit(1); } p->goto_state= higheststate; p->next=states[currentstate]; @@ -501,9 +501,9 @@ int main(int argc, char **argv) parser(); if(nerrors) { fprintf(stderr,"%d errors detected\n",nerrors); - sys_stop(S_EXIT); + exit(1); } outputnopt(); - sys_stop(S_END); + exit(0); } } diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index 10338bdad2..30a64c1feb 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -5,7 +5,6 @@ clibrary { "./filesize.c", "./maketempfile.c", "./setbinarymode.c", - "./stop.c", "./strndup.c", "./syssystem.c", "./tmpdir.c", diff --git a/modules/src/system/stop.c b/modules/src/system/stop.c deleted file mode 100644 index e771287625..0000000000 --- a/modules/src/system/stop.c +++ /dev/null @@ -1,21 +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" - -NORETURN void sys_stop(int how) -{ - switch(how) { - case S_END: - exit(EXIT_SUCCESS); - case S_EXIT: - exit(EXIT_FAILURE); - case S_ABORT: - default: - abort(); - } -} diff --git a/modules/src/system/system.h b/modules/src/system/system.h index e2a11a96f3..1548d61ec0 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -10,17 +10,11 @@ #include #include -/* flags for sys_stop() */ -#define S_END 0 -#define S_EXIT 1 -#define S_ABORT 2 - extern off_t sys_filesize(char *); /* Return the temporary directory location */ extern char* sys_gettmpdir(void); /* Call another program. */ 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". diff --git a/util/ceg/ce_back/obj_back/output.c b/util/ceg/ce_back/obj_back/output.c index 94d9e6029c..9f59965b78 100644 --- a/util/ceg/ce_back/obj_back/output.c +++ b/util/ceg/ce_back/obj_back/output.c @@ -167,7 +167,7 @@ reduce_name_table() wr_fatal() { fprint( stderr, "write failed\n"); - sys_stop(S_ABORT); + abort(); } diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 95e66bdfb0..a922ee035c 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -119,7 +119,7 @@ static void fatal(const char* s, ...) doprnt(stderr, s, ap); fprint(stderr, "\n"); cleanup(); - sys_stop(S_EXIT); + exit(1); UNREACHABLE_CODE; } @@ -146,7 +146,7 @@ static void catch (int signum) /* Catch interrupts and exit gracefully */ cleanup(); - sys_stop(S_EXIT); + exit(1); } static void old_infiles(void) @@ -293,7 +293,7 @@ static void run_phase(int phase) if (((status >> 8) & 0377) != 0) { cleanup(); - sys_stop(S_EXIT); + exit(1); } } @@ -363,7 +363,7 @@ int main(int argc, char* argv[]) if (nfiles == 2 * NTEMPS + 1) { /* 2*NTEMPS+1 was the starting value; nothing to do */ - sys_stop(S_END); + exit(0); } if (!opt_dir) @@ -408,6 +408,6 @@ int main(int argc, char* argv[]) } run_phase(CA); cleanup(); - sys_stop(S_END); + exit(0); UNREACHABLE_CODE; } From 1eca3e37a7259ff2a76c1e348d6c2c0d08f15417 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 22:49:56 +0100 Subject: [PATCH 22/29] Replace fprint() with fprintf(). --- doc/ceg/ceg.tr | 6 +- lang/basic/src/basic.g | 16 ++-- lang/basic/src/basic.lex | 2 +- lang/basic/src/graph.c | 2 +- lang/basic/src/llmess.h | 8 +- lang/basic/src/parsepar.c | 4 +- lang/basic/src/util.c | 4 +- lang/cem/cemcom.ansi/error.c | 6 +- lang/cem/cemcom/error.c | 6 +- lang/cem/cemcom/main.c | 4 +- lang/cem/cpp.ansi/error.c | 24 ++--- lang/cem/cpp.ansi/main.c | 4 +- lang/cem/lint/lpass2/l_print3ack.c | 2 +- lang/cem/lint/lpass2/report.c | 24 ++--- lang/m2/comp/error.c | 6 +- lang/m2/comp/main.c | 4 +- lang/m2/m2mm/error.c | 6 +- lang/occam/comp/occam.g | 2 +- lang/occam/comp/report.c | 18 ++-- lang/pc/comp/error.c | 6 +- lang/pc/comp/main.c | 4 +- mach/i386/ce/as.c | 10 +- mach/i386/ce/mach.c | 4 +- mach/i86/ce/as.c | 6 +- mach/i86/ce/mach.c | 2 +- mach/m68020/ce/mach.c | 4 +- mach/sparc/ce/back.src/back.h | 2 +- mach/sparc/ce/back.src/do_open.c | 4 +- mach/sparc/ce/back.src/gen_str.c | 10 +- mach/sparc/ce/back.src/symboldef.c | 2 +- mach/sparc/ce/cache.c.x | 44 ++++----- mach/sparc/ce/ce.src/C_exa_dnam.c | 2 +- mach/sparc/ce/ce.src/C_pro.c | 2 +- mach/sparc/ce/ce.src/ms_reg.c | 106 +++++++++++----------- mach/sparc/ce/cegpp | 2 +- mach/sparc/ce/mach.c | 2 +- mach/sparc/ce_cg/convert.c | 6 +- mach/sun3/ce/mach.c | 4 +- mach/sun3/ce/misc.c | 4 +- mach/sun3/ce/output.c | 4 +- mach/sun3/ce/relocation.c | 4 +- mach/vax4/ce/as.c | 4 +- mach/vax4/ce/mach.c | 2 +- mach/vax4/ce/output.c | 4 +- mach/vax4/ce/relocation.c | 4 +- modules/src/em_code/convert.c | 6 +- modules/src/em_opt/nopt.c | 6 +- modules/src/print/build.lua | 2 +- modules/src/print/fprint.c | 28 ------ modules/src/print/print.3 | 2 +- modules/src/print/print.h | 1 - util/ceg/EM_parser/as_EM_pars/error.c | 8 +- util/ceg/EM_parser/common/C_instr2.c | 2 +- util/ceg/EM_parser/common/help.c | 2 +- util/ceg/EM_parser/common/pars.g | 28 +++--- util/ceg/EM_parser/obj_EM_pars/dist.c | 2 +- util/ceg/as_parser/conversion.c | 6 +- util/ceg/as_parser/eval/eval.c | 18 ++-- util/ceg/as_parser/help.c | 20 ++-- util/ceg/as_parser/pars.g | 44 ++++----- util/ceg/assemble/as_assemble/assemble.c | 4 +- util/ceg/assemble/obj_assemble/assemble.c | 8 +- util/ceg/ce_back/as_back/back.h | 2 +- util/ceg/ce_back/as_back/bottom.c | 2 +- util/ceg/ce_back/as_back/bss.c | 2 +- util/ceg/ce_back/as_back/dbsym.c | 6 +- util/ceg/ce_back/as_back/gen1.c | 8 +- util/ceg/ce_back/as_back/gen2.c | 8 +- util/ceg/ce_back/as_back/gen4.c | 8 +- util/ceg/ce_back/as_back/reloc1.c | 2 +- util/ceg/ce_back/as_back/reloc2.c | 2 +- util/ceg/ce_back/as_back/reloc4.c | 2 +- util/ceg/ce_back/as_back/set_global.c | 2 +- util/ceg/ce_back/as_back/set_local.c | 2 +- util/ceg/ce_back/as_back/switchseg.c | 8 +- util/ceg/ce_back/as_back/symboldef.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 | 8 +- util/misc/convert.c | 4 +- 87 files changed, 323 insertions(+), 352 deletions(-) delete mode 100644 modules/src/print/fprint.c diff --git a/doc/ceg/ceg.tr b/doc/ceg/ceg.tr index b5eb464832..31a36e33d3 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 : fprintf( 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 : fprintf( 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 : fprintf( stderr, "Wrong index register %d\en", op->reg); } @text2( %$(op->expr)); diff --git a/lang/basic/src/basic.g b/lang/basic/src/basic.g index 182ab2a73b..e79e8fc308 100644 --- a/lang/basic/src/basic.g +++ b/lang/basic/src/basic.g @@ -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 ]* ; diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index fcbb50c5c8..53b7b57d24 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -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); } diff --git a/lang/basic/src/graph.c b/lang/basic/src/graph.c index f9dba49733..261a832be5 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); + fprintf(stderr, "ERROR: line %d not defined\n",l->linenr); errorcnt++; } l=l->nextlist; diff --git a/lang/basic/src/llmess.h b/lang/basic/src/llmess.h index 37996cff3b..02db7aefe6 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 ) fprintf(stderr, "LINE %d:",basicline); + fprintf(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 ) fprintf(stderr, "LINE %d:",basicline); + fprintf(stderr, format,str); errorcnt++; } diff --git a/lang/basic/src/parsepar.c b/lang/basic/src/parsepar.c index 66400a0339..97acc4c529 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", + fprintf(stderr,"usage %s \n", argv[0]); exit(1); } @@ -46,7 +46,7 @@ void parseparams(int argc,char **argv) case 't': traceflag++; break; /* line tracing */ case 'h': /* split EM file */ - fprint(stderr, + fprintf(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 f47202c5f4..01f583e046 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) fprintf(stderr, "LINE %d:",basicline); + fprintf(stderr, "%s:%s\n",type, str); } diff --git a/lang/cem/cemcom.ansi/error.c b/lang/cem/cemcom.ansi/error.c index e5fa898612..53595bbbd0 100644 --- a/lang/cem/cemcom.ansi/error.c +++ b/lang/cem/cemcom.ansi/error.c @@ -610,9 +610,9 @@ static void _error(int class, char *fn, unsigned int ln, char* fmt, va_list ap) #endif /* LINT */ if (fn) - fprint(ERROUT, "\"%s\", line %u: ", fn, ln); + fprintf(ERROUT, "\"%s\", line %u: ", fn, ln); if (remark) - fprint(ERROUT, "%s ", remark); + fprintf(ERROUT, "%s ", remark); doprnt(ERROUT, fmt, ap); /* contents of error */ - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); } diff --git a/lang/cem/cemcom/error.c b/lang/cem/cemcom/error.c index d6a62a47f5..92717142f0 100644 --- a/lang/cem/cemcom/error.c +++ b/lang/cem/cemcom/error.c @@ -489,9 +489,9 @@ _error(class, fn, ln, fmt, ap) #endif /* LINT */ if (fn) - fprint(ERROUT, "\"%s\", line %u: ", fn, ln); + fprintf(ERROUT, "\"%s\", line %u: ", fn, ln); if (remark) - fprint(ERROUT, "%s ", remark); + fprintf(ERROUT, "%s ", remark); doprnt(ERROUT, fmt, ap); /* contents of error */ - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); } diff --git a/lang/cem/cemcom/main.c b/lang/cem/cemcom/main.c index 6a541e85af..8f1d99684e 100644 --- a/lang/cem/cemcom/main.c +++ b/lang/cem/cemcom/main.c @@ -195,9 +195,9 @@ char *s, *source; return; } if (options['m'] && source) { - fprint(dep_fd, "%s: %s\n", source, s); + fprintf(dep_fd, "%s: %s\n", source, s); } - else fprint(dep_fd, "%s\n", s); + else fprintf(dep_fd, "%s\n", s); } #endif /* NOPP */ diff --git a/lang/cem/cpp.ansi/error.c b/lang/cem/cpp.ansi/error.c index a2bf35cc95..4ee18b12ac 100644 --- a/lang/cem/cpp.ansi/error.c +++ b/lang/cem/cpp.ansi/error.c @@ -27,9 +27,9 @@ int err_occurred; static void err_hdr(char *s) { if (FileName) { - fprint(ERROUT, "\"%s\", line %d: %s", FileName, (int)LineNumber, s); + fprintf(ERROUT, "\"%s\", line %d: %s", FileName, (int)LineNumber, s); } - else fprint(ERROUT, s); + else fprintf(ERROUT, s); } #if __STDC__ @@ -42,7 +42,7 @@ void error(char *fmt, ...) err_hdr(""); va_start(ap, fmt); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); } @@ -54,7 +54,7 @@ void warning(char *fmt, ...) err_hdr("(warning) "); va_start(ap, fmt); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); } @@ -66,7 +66,7 @@ void strict(char *fmt, ...) err_hdr("(strict) "); va_start(ap, fmt); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); } @@ -78,7 +78,7 @@ NORETURN void crash(char *fmt, ...) err_hdr("CRASH\007 "); va_start(ap, fmt); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); abort(); } @@ -91,7 +91,7 @@ NORETURN void fatal(char *fmt, ...) err_hdr("fatal error -- "); va_start(ap, fmt); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); exit(1); } @@ -108,7 +108,7 @@ void error(va_alist) va_start(ap); fmt = va_arg(ap, char *); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); } @@ -123,7 +123,7 @@ void warning(va_alist) va_start(ap); fmt = va_arg(ap, char *); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); } @@ -138,7 +138,7 @@ void strict(va_alist) va_start(ap); fmt = va_arg(ap, char *); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); } @@ -153,7 +153,7 @@ void crash(va_alist) va_start(ap); fmt = va_arg(ap, char *); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); abort(); } @@ -169,7 +169,7 @@ void fatal(va_alist) va_start(ap); fmt = va_arg(ap, char *); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); va_end(ap); exit(1); } diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index abd238c33f..bcb2edcc44 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -159,7 +159,7 @@ static void dependency(char *s, char *source) return; } if (options['m'] && source) { - fprint(dep_fd, "%s: %s\n", source, s); + fprintf(dep_fd, "%s: %s\n", source, s); } - else fprint(dep_fd, "%s\n", s); + else fprintf(dep_fd, "%s\n", s); } diff --git a/lang/cem/lint/lpass2/l_print3ack.c b/lang/cem/lint/lpass2/l_print3ack.c index eb5d86b40c..e368abc8bf 100644 --- a/lang/cem/lint/lpass2/l_print3ack.c +++ b/lang/cem/lint/lpass2/l_print3ack.c @@ -20,7 +20,7 @@ printf(format) char *format; { ; } /* FORMAT1 */ -fprint(filep, format) FILE* filep; char *format; { ; } +fprintf(filep, format) FILE* filep; char *format; { ; } /* FORMAT1 */ sprintf(s, format) char *s; char *format; { ; } /* FORMAT1 */ diff --git a/lang/cem/lint/lpass2/report.c b/lang/cem/lint/lpass2/report.c index 57197f6aa6..5a848004af 100644 --- a/lang/cem/lint/lpass2/report.c +++ b/lang/cem/lint/lpass2/report.c @@ -69,7 +69,7 @@ report(va_alist) /* otherwise, we have used up the argument, so print it here */ - fprint(MSGOUT, "\"%s\", line %d", + fprintf(MSGOUT, "\"%s\", line %d", fn, id->id_line); } while ((fc = *f++)) { @@ -84,11 +84,11 @@ report(va_alist) break; case 's': /* a string item */ s = va_arg(ap, char *); - fprint(MSGOUT, "%s", s); + fprintf(MSGOUT, "%s", s); break; case 'd': /* an int item */ i = va_arg(ap, int); - fprint(MSGOUT, "%d", i); + fprintf(MSGOUT, "%d", i); break; default: panic("internal error: bad format %s", @@ -97,10 +97,10 @@ report(va_alist) } } else { - fprint(MSGOUT, "%c", fc); + fprintf(MSGOUT, "%c", fc); } } - fprint(MSGOUT, "\n"); + fprintf(MSGOUT, "\n"); } va_end(ap); } @@ -111,14 +111,14 @@ rep_loc(id) { /* a definition can come from a number of places */ if (!id) { - fprint(MSGOUT, "format"); + fprintf(MSGOUT, "format"); } else if (is_class(id, CL_LIB)) { - fprint(MSGOUT, "library"); + fprintf(MSGOUT, "library"); } else { - fprint(MSGOUT, "\"%s\", line %d", + fprintf(MSGOUT, "\"%s\", line %d", id->id_file, id->id_line); } } @@ -131,9 +131,9 @@ panic(char *fmt, ...) /* fmt, args */ va_start(ap, fmt); { - fprint(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr); + fprintf(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); } va_end(ap); @@ -150,9 +150,9 @@ panic(va_alist) /* fmt, args */ { char *fmt = va_arg(ap, char *); - fprint(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr); + fprintf(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr); doprnt(ERROUT, fmt, ap); - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); } va_end(ap); diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index faa47bfc36..4856bc0c1e 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -402,10 +402,10 @@ static void _error(int class, struct node *node, char *fmt, va_list ap, int warn break; } - if (FileName) fprint(ERROUT, "\"%s\", line %u: ", FileName, ln); + if (FileName) fprintf(ERROUT, "\"%s\", line %u: ", FileName, ln); - if (remark) fprint(ERROUT, "%s ", remark); + if (remark) fprintf(ERROUT, "%s ", remark); doprnt(ERROUT, fmt, ap); /* contents of error */ - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); } diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index e60134a738..8e4a4e95e1 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); + fprintf(stderr, "%s: Use a file argument\n", ProgName); exit(1); } exit(Compile(Nargv[1], Nargv[2]) ? 0 : 1); @@ -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); + fprintf(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 7a38fd6a09..23e7583bdf 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) fprintf(stderr, "\"%s\", line %u: ", FileName, ln); - if (remark) fprint(stderr, "%s ", remark); + if (remark) fprintf(stderr, "%s ", remark); doprnt(stderr, fmt, argv); /* contents of error */ - fprint(stderr, "\n"); + fprintf(stderr, "\n"); } diff --git a/lang/occam/comp/occam.g b/lang/occam/comp/occam.g index b495602208..cf4f6d7a7d 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"); + fprintf(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 96856b0640..30ee3afa99 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"); + fprintf(stderr, "%s (%d) F: ", curr_file, lineno); + fprintf(stderr, fmt, arg1, arg2, arg3); + fprintf(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"); + fprintf(stderr, "%s (%d) E: ", curr_file, lineno); + fprintf(stderr, fmt, arg1, arg2, arg3); + fprintf(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"); + fprintf(stderr, "%s (%d) X: ", curr_file, lineno); + fprintf(stderr, fmt, arg1, arg2, arg3); + fprintf(stderr,"\n"); exit(1); } diff --git a/lang/pc/comp/error.c b/lang/pc/comp/error.c index 7a7f36ac81..34e6a59aae 100644 --- a/lang/pc/comp/error.c +++ b/lang/pc/comp/error.c @@ -399,10 +399,10 @@ static void _error(int class, struct node *node, char *fmt, va_list ap) } #endif /* DEBUG */ - if( FileName ) fprint(ERROUT, "\"%s\", line %u: ", FileName, ln); + if( FileName ) fprintf(ERROUT, "\"%s\", line %u: ", FileName, ln); - if( remark ) fprint(ERROUT, "%s ", remark); + if( remark ) fprintf(ERROUT, "%s ", remark); doprnt(ERROUT, fmt, ap); /* contents of error */ - fprint(ERROUT, "\n"); + fprintf(ERROUT, "\n"); } diff --git a/lang/pc/comp/main.c b/lang/pc/comp/main.c index d5a98f9e62..bccfae5075 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); + fprintf(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); + fprintf(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 2cde0cf56c..f3074b8ff8 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 : fprintf( 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 : fprintf( 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 : fprintf( 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 : fprintf( 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 : fprintf( 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 c91e98bd08..2dbe88997b 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); + fprintf( stderr, "arg_error %s %d\n", s, arg); } #endif @@ -34,6 +34,6 @@ do_open(filename) if (filename == 0 || ! sys_open(filename, OP_WRITE, &codefile)) return FALSE; - fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); return TRUE; + fprintf( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); return TRUE; } */ diff --git a/mach/i86/ce/as.c b/mach/i86/ce/as.c index 2d43415829..fe088343fb 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 : fprintf( 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 : fprintf( 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 : fprintf( 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 d52895537c..ee30345c22 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); + fprintf( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/m68020/ce/mach.c b/mach/m68020/ce/mach.c index da488aac03..2f088aab92 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); + fprintf( stderr, "arg_error %s %d\n", s, arg); } #endif @@ -21,7 +21,7 @@ char *filename; if ( filename == (char *)0 || !sys_open( filename, OP_WRITE, &codefile)) return( 0); - fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); + fprintf( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); return( 1); } */ diff --git a/mach/sparc/ce/back.src/back.h b/mach/sparc/ce/back.src/back.h index c7fdfbbb5a..ee4a5984df 100644 --- a/mach/sparc/ce/back.src/back.h +++ b/mach/sparc/ce/back.src/back.h @@ -57,7 +57,7 @@ extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(), *extnd_part(), *extnd_cont(), *extnd_main(); #define swtxt() switchseg( SEGTXT) -#define bss(n) fprint(codefile, BSS_FMT, (long)(n)) +#define bss(n) fprintf(codefile, BSS_FMT, (long)(n)) #define SEGTXT 0 #define SEGROM 1 diff --git a/mach/sparc/ce/back.src/do_open.c b/mach/sparc/ce/back.src/do_open.c index 53f7cf05ae..351d822f09 100644 --- a/mach/sparc/ce/back.src/do_open.c +++ b/mach/sparc/ce/back.src/do_open.c @@ -6,7 +6,7 @@ char *filename; if ( filename == (char *) 0) { codefile= stdout; #ifdef __solaris__ - fprint(codefile, ".section \".text\"\n"); + fprintf(codefile, ".section \".text\"\n"); #endif return 1; } @@ -16,7 +16,7 @@ char *filename; if ((codefile = fopen(filename, "wb")) != NULL) { #endif #ifdef __solaris__ - fprint(codefile, ".section \".text\"\n"); + fprintf(codefile, ".section \".text\"\n"); #endif return 1; } diff --git a/mach/sparc/ce/back.src/gen_str.c b/mach/sparc/ce/back.src/gen_str.c index e1046225a4..7f7aff38b2 100644 --- a/mach/sparc/ce/back.src/gen_str.c +++ b/mach/sparc/ce/back.src/gen_str.c @@ -9,19 +9,19 @@ int n; case SEGTXT : case SEGCON : case SEGROM : - fprint( codefile, "%s\"", STR_FMT); + fprintf( codefile, "%s\"", STR_FMT); while (n--) { c= *s++; if (isprint(c) && c != '"' && c != '\\') - fprint(codefile, "%c", c); + fprintf(codefile, "%c", c); else - fprint(codefile, "\\%03o", c); + fprintf(codefile, "\\%03o", c); } - fprint( codefile, "\"\n"); + fprintf( codefile, "\"\n"); break; case SEGBSS : bss( (arith) 1); break; - default : fprint( stderr, "gen1 unkown seg %d\n", cur_seg); + default : fprintf( stderr, "gen1 unkown seg %d\n", cur_seg); } } diff --git a/mach/sparc/ce/back.src/symboldef.c b/mach/sparc/ce/back.src/symboldef.c index a54cb48093..b0ac670fc6 100644 --- a/mach/sparc/ce/back.src/symboldef.c +++ b/mach/sparc/ce/back.src/symboldef.c @@ -5,5 +5,5 @@ char *s; { if (cur_seg == SEGTXT) flush_cache(); /* EXTRA */ - fprint( codefile, SYMBOL_DEF_FMT, s); + fprintf( codefile, SYMBOL_DEF_FMT, s); } diff --git a/mach/sparc/ce/cache.c.x b/mach/sparc/ce/cache.c.x index 65fac31f7a..cbffb7cf08 100644 --- a/mach/sparc/ce/cache.c.x +++ b/mach/sparc/ce/cache.c.x @@ -640,7 +640,7 @@ enter("pop_reg_reg"); *r = tos->reg2; s = tos->reg; POP2; -if (debug) { indent(); fprintf(stderr,"pop_reg_reg()=%s\n", s); fprint(codefile,"\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(stderr,"pop_reg_reg()=%s\n", s); fprintf(codefile,"\t\t! "); dump_cache(codefile); } leave("pop_reg_reg"); return s; } @@ -699,7 +699,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); } sprintf(n, "%d", tos->cst); POP2; } -if (debug) { indent(); fprint(codefile, "\t\t! %s+%s cache:", S1, n); dump_cache(codefile);} +if (debug) { indent(); fprintf(codefile, "\t\t! %s+%s cache:", S1, n); dump_cache(codefile);} leave("pop_reg_c13"); return S1; } @@ -730,7 +730,7 @@ enter("pop_float"); POP2; } else POP2; -if (debug) { indent(); fprint(codefile, "\t\t! %s cache:", S1); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! %s cache:", S1); dump_cache(codefile); } leave("pop_float"); return S1; } @@ -743,7 +743,7 @@ if (debug) { indent(); fprintf(stderr, "inc_tos_reg(%s)\n", r); } if (type_of_tos() != T_reg) push_reg(pop_reg()); tos->reg2 = r; -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("inc_tos_reg"); } @@ -766,7 +766,7 @@ if (debug) { indent(); fprintf(stderr,"inc_tos(%d)\n", n); } push_reg(S1); } tos->cst += n; -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("inc_tos"); } @@ -782,7 +782,7 @@ enter("push_const"); tos->reg2 = reg_g0; tos->ext = 0; tos->cst = n; -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("push_const"); } @@ -796,7 +796,7 @@ enter("push_reg"); tos->reg2 = reg_g0; tos->ext = 0; tos->cst = 0; -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("push_reg"); } @@ -819,7 +819,7 @@ enter("push_double_reg"); tos->cst = 0; tos->reg = i; tos->reg2 = reg_g0; -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("push_double_reg"); } @@ -836,7 +836,7 @@ enter("push_ext"); tos->reg2 = reg_g0; tos->ext = strcpy(p, s); tos->cst = 0; -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("push_ext"); } @@ -851,7 +851,7 @@ enter("pop_const"); POP2; if (n) sprintf(n, "%d", x); -if (debug) { indent(); fprint(codefile, "\t\t! %d cache:", x); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! %d cache:", x); dump_cache(codefile); } leave("pop_const"); return x; } @@ -1079,7 +1079,7 @@ enter("pop_reg"); S1 = alloc_reg(); pop_reg_as(S1); } -if (debug) { indent(); fprint(codefile, "\t\t! %s cache:", S1); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! %s cache:", S1); dump_cache(codefile); } leave("pop_reg"); return S1; } @@ -1159,7 +1159,7 @@ enter("pop_nop"); "add %l0, $reg_tmp, %l0"; } } -if (debug) { indent(); fprint(codefile, "\t\t! %dw cache:",j); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! %dw cache:",j); dump_cache(codefile); } leave("pop_nop"); } @@ -1245,24 +1245,24 @@ FILE* stream; assert (c_count >= 0); for (i = c_count -1; i >= 0; i--) { if (cache[i].ext) - fprint(stream, "%s", cache[i].ext); + fprintf(stream, "%s", cache[i].ext); if (cache[i].reg != reg_g0) { if (cache[i].ext) - fprint(stream, "+"); - fprint(stream, "%s", cache[i].reg); + fprintf(stream, "+"); + fprintf(stream, "%s", cache[i].reg); if (cache[i].reg2 != reg_g0) { - fprint(stream, "+"); - fprint(stream, "%s", cache[i].reg2); + fprintf(stream, "+"); + fprintf(stream, "%s", cache[i].reg2); } } if (cache[i].cst || (!cache[i].ext && cache[i].reg == reg_g0)) { if (cache[i].ext || cache[i].reg != reg_g0) - fprint(stream, "+"); - fprint(stream, "%d", cache[i].cst); + fprintf(stream, "+"); + fprintf(stream, "%d", cache[i].cst); } - fprint(stream, " "); + fprintf(stream, " "); } - fprint(stream, "\n"); + fprintf(stream, "\n"); if (debug) check_cache(); } @@ -1299,6 +1299,6 @@ enter("dup_tos"); tos->reg = a; } } -if (debug) { indent(); fprint(codefile, "\t\t! "); dump_cache(codefile); } +if (debug) { indent(); fprintf(codefile, "\t\t! "); dump_cache(codefile); } leave("dup_tos"); } diff --git a/mach/sparc/ce/ce.src/C_exa_dnam.c b/mach/sparc/ce/ce.src/C_exa_dnam.c index a6cf80dac0..974b67ee2e 100644 --- a/mach/sparc/ce/ce.src/C_exa_dnam.c +++ b/mach/sparc/ce/ce.src/C_exa_dnam.c @@ -9,6 +9,6 @@ char *s; s = extnd_dnam( s); set_global_visible(s); #ifdef __solaris__ - fprint(codefile, "\t.type\t%s,#object\n", s); + fprintf(codefile, "\t.type\t%s,#object\n", s); #endif } diff --git a/mach/sparc/ce/ce.src/C_pro.c b/mach/sparc/ce/ce.src/C_pro.c index e1fb32f869..66ad9f0f58 100644 --- a/mach/sparc/ce/ce.src/C_pro.c +++ b/mach/sparc/ce/ce.src/C_pro.c @@ -15,7 +15,7 @@ arith l; swtxt(); s = extnd_name(s); #ifdef __solaris__ - fprint(codefile, "\t.type\t%s,#function\n", s); + fprintf(codefile, "\t.type\t%s,#function\n", s); if (B_procnam) free(B_procnam); B_procnam = Salloc(s, strlen(s)+1); #endif diff --git a/mach/sparc/ce/ce.src/ms_reg.c b/mach/sparc/ce/ce.src/ms_reg.c index 540e10dd8b..6032d03618 100644 --- a/mach/sparc/ce/ce.src/ms_reg.c +++ b/mach/sparc/ce/ce.src/ms_reg.c @@ -173,35 +173,35 @@ static params_to_regs() /* copy required parameters to registers */ for (i = 0; i < nr_flt_vars; i++) if (flt_dat[i].offset >= 4092) { - fprint(codefile, "set %d, %%l2\n", + fprintf(codefile, "set %d, %%l2\n", flt_dat[i].offset); - fprint(codefile, "ld [%%l1+%%l2], %s\n", + fprintf(codefile, "ld [%%l1+%%l2], %s\n", flt_dat[i].reg); if (flt_dat[i].size == EM_DSIZE) { - fprint(codefile, "set %d, %%l2\n", + fprintf(codefile, "set %d, %%l2\n", flt_dat[i].offset+4); - fprint(codefile, "ld [%%l1+%%l2], %s\n", + fprintf(codefile, "ld [%%l1+%%l2], %s\n", flt_dat[i].reg2); } } else if (flt_dat[i].offset > 0) { - fprint(codefile, "ld [%%l1+%d], %s\n", + fprintf(codefile, "ld [%%l1+%d], %s\n", flt_dat[i].offset, flt_dat[i].reg); if (flt_dat[i].size == EM_DSIZE) - fprint(codefile, "ld [%%l1+%d], %s\n", + fprintf(codefile, "ld [%%l1+%d], %s\n", flt_dat[i].offset + 4, flt_dat[i].reg2); } for (i = 0; i < nr_reg_vars; i++) if (reg_dat[i].offset >= 4096) { - fprint(codefile, "set %d, %s\n", + fprintf(codefile, "set %d, %s\n", reg_dat[i].offset, reg_dat[i].reg); - fprint(codefile, "ld [%%l1+%s], %s\n", + fprintf(codefile, "ld [%%l1+%s], %s\n", reg_dat[i].reg, reg_dat[i].reg); } else if (reg_dat[i].offset > 0) - fprint(codefile, "ld [%%l1+%d], %s\n", + fprintf(codefile, "ld [%%l1+%d], %s\n", reg_dat[i].offset, reg_dat[i].reg); } @@ -232,12 +232,12 @@ static save_float_regs() flt_dat[i].size == EM_FSIZE && flt_dat[i+1].size == EM_FSIZE) || (flt_dat[i].size == EM_DSIZE)) { - fprint(codefile, "std %s, [%%fp + %d]\n", + fprintf(codefile, "std %s, [%%fp + %d]\n", flt_dat[i].reg, FLTSAV_OFFSET + offset); if (flt_dat[i].size != EM_DSIZE) ++i; } else - fprint(codefile, "st %s, [%%fp + %d]\n", + fprintf(codefile, "st %s, [%%fp + %d]\n", flt_dat[i].reg, FLTSAV_OFFSET + offset); } @@ -253,12 +253,12 @@ load_float_regs() flt_dat[i].size == EM_FSIZE && flt_dat[i+1].size == EM_FSIZE) || (flt_dat[i].size == EM_DSIZE)) { - fprint(codefile, "ldd [%%fp + %d], %s\n", + fprintf(codefile, "ldd [%%fp + %d], %s\n", FLTSAV_OFFSET + offset, flt_dat[i].reg); if (flt_dat[i].size != EM_DSIZE) ++i; } else - fprint(codefile, "ld [%%fp + %d], %s\n", + fprintf(codefile, "ld [%%fp + %d], %s\n", FLTSAV_OFFSET + offset, flt_dat[i].reg); } @@ -276,14 +276,14 @@ int ms; if (ms == ms_gto) { free_all_reg_vars(); nr_reg_vars = 0; nr_flt_vars = 0; - fprint(codefile, "ta 3\n"); + fprintf(codefile, "ta 3\n"); } db_mes = (ms == ms_stb || ms == ms_std) ? ms : 0; #ifdef __solaris__ if (db_mes && ! inits) { - fprint(codefile, ".pushsection \".text\"\nBtext.text:\n.popsection\n"); - fprint(codefile, ".pushsection \".data\"\nBdata.data:\n.popsection\n"); - fprint(codefile, ".pushsection \".bss\"\nBbss.bss:\n.popsection\n"); + fprintf(codefile, ".pushsection \".text\"\nBtext.text:\n.popsection\n"); + fprintf(codefile, ".pushsection \".data\"\nBdata.data:\n.popsection\n"); + fprintf(codefile, ".pushsection \".bss\"\nBbss.bss:\n.popsection\n"); inits = 1; } #endif @@ -306,16 +306,16 @@ C_mes_end() #ifdef __solaris__ if (db_mes == ms_std) { if (db_str == 2) { - fprint(codefile, ",1f\n1:\n"); + fprintf(codefile, ",1f\n1:\n"); } else { - fprint(codefile, ",1f-%s\n1:\n", B_procnam); + fprintf(codefile, ",1f-%s\n1:\n", B_procnam); } } #else - if (db_mes == ms_std && db_str == 2) fprint(codefile,",1f\n1:\n"); + if (db_mes == ms_std && db_str == 2) fprintf(codefile,",1f\n1:\n"); #endif - else fprint(codefile, "\n"); + else fprintf(codefile, "\n"); db_str = 0; db_mes = 0; db_kind = 0; @@ -334,7 +334,7 @@ C_mes_end() if (current_reg_mes[RM_OFFSET] >= 0) current_reg_mes[RM_OFFSET] += EM_BSIZE; if (debug) - fprint(codefile, "\t\t! Got reg_mes: %d %d %d %d\n", + fprintf(codefile, "\t\t! Got reg_mes: %d %d %d %d\n", current_reg_mes[0], current_reg_mes[1], current_reg_mes[2], current_reg_mes[3]); if (current_reg_mes[RM_TYPE] == reg_float) { @@ -383,18 +383,18 @@ arith l; if (l == N_SLINE && ! __gdb_flag) { flush_cache(); #ifdef __solaris__ - fprint(codefile, "call $__uX_LiB\nnop\n"); + fprintf(codefile, "call $__uX_LiB\nnop\n"); #else - fprint(codefile, "call ___uX_LiB\nnop\n"); + fprintf(codefile, "call ___uX_LiB\nnop\n"); #endif } #ifdef __solaris__ - fprint(codefile, ".stabn 0x%lx,0", (long) l); + fprintf(codefile, ".stabn 0x%lx,0", (long) l); #else if (db_mes == ms_std) { - fprint(codefile, ".stabd 0x%lx,0", (long) l); + fprintf(codefile, ".stabd 0x%lx,0", (long) l); } - else fprint(codefile, ".stabn 0x%lx,0", (long) l); + else fprintf(codefile, ".stabn 0x%lx,0", (long) l); #endif db_str = 1; db_nul = 1; @@ -403,14 +403,14 @@ arith l; if (correct_offset++ == -1) { l += EM_BSIZE; } - fprint(codefile, ",0x%lx", (long) l); + fprintf(codefile, ",0x%lx", (long) l); } if (! db_nul) { correct_offset = 0; if (l == N_PSYM && __gdb_flag) { correct_offset = -2; } - fprint(codefile, ",0"); + fprintf(codefile, ",0"); db_nul = 1; } } @@ -424,16 +424,16 @@ char *s; arith l; { if (db_mes) { - fprint(codefile, ".stabs \""); + fprintf(codefile, ".stabs \""); while (--l) { int c = *s++; if (isprint(c) && c != '"' && c != '\\') - fprint(codefile, "%c", c); + fprintf(codefile, "%c", c); else - fprint(codefile, "\\%03o", c); + fprintf(codefile, "\\%03o", c); } - fprint(codefile, "\""); + fprintf(codefile, "\""); db_str = 2; } } @@ -444,16 +444,16 @@ label l; arith off; { if (db_mes) { - fprint(codefile,","); - fprint(codefile, DLB_FMT, (long) l); - if (off) fprint(codefile,"+%ld", (long) off); + fprintf(codefile,","); + fprintf(codefile, DLB_FMT, (long) l); + if (off) fprintf(codefile,"+%ld", (long) off); #ifdef __solaris__ switch(db_kind) { case N_LCSYM: - fprint(codefile, "-Bbss.bss"); + fprintf(codefile, "-Bbss.bss"); break; case N_STSYM: - fprint(codefile, "-Bdata.data"); + fprintf(codefile, "-Bdata.data"); break; } #endif @@ -466,16 +466,16 @@ char *l; arith off; { if (db_mes) { - fprint(codefile,","); - fprint(codefile, DNAM_FMT, l); - if (off) fprint(codefile,"+%ld", (long) off); + fprintf(codefile,","); + fprintf(codefile, DNAM_FMT, l); + if (off) fprintf(codefile,"+%ld", (long) off); #ifdef __solaris__ switch(db_kind) { case N_LCSYM: - fprint(codefile, "-Bbss.bss"); + fprintf(codefile, "-Bbss.bss"); break; case N_STSYM: - fprint(codefile, "-Bdata.data"); + fprintf(codefile, "-Bdata.data"); break; } #endif @@ -489,10 +489,10 @@ C_ilb(l) label l; { if (db_mes) { - fprint(codefile,","); - fprint(codefile, ILB_FMT, B_procno, (long)l); + fprintf(codefile,","); + fprintf(codefile, ILB_FMT, B_procno, (long)l); #ifdef __solaris__ - fprint(codefile, "-Btext.text"); + fprintf(codefile, "-Btext.text"); #endif } } @@ -502,10 +502,10 @@ C_pnam(s) char *s; { if (db_mes) { - fprint(codefile,","); - fprint(codefile, NAME_FMT, s); + fprintf(codefile,","); + fprintf(codefile, NAME_FMT, s); #ifdef __solaris__ - fprint(codefile, "-Btext.text"); + fprintf(codefile, "-Btext.text"); #endif } } @@ -516,14 +516,14 @@ FILE *stream; { int i; - fprint(stream, "!offset\tsize\tname (%d regvars)\n", nr_reg_vars); + fprintf(stream, "!offset\tsize\tname (%d regvars)\n", nr_reg_vars); for (i = 0; i < nr_reg_vars; i++) - fprint(stream, "! %d\t%d\t%s\n", reg_dat[i].offset, reg_dat[i].size, + fprintf(stream, "! %d\t%d\t%s\n", reg_dat[i].offset, reg_dat[i].size, reg_dat[i].reg); - fprint(stream, "!offset\tsize\tname (%d fltvars)\n", nr_flt_vars); + fprintf(stream, "!offset\tsize\tname (%d fltvars)\n", nr_flt_vars); for (i = 0; i < nr_flt_vars; i++) - fprint(stream, "! %d\t%d\t%s\n", flt_dat[i].offset, flt_dat[i].size, + fprintf(stream, "! %d\t%d\t%s\n", flt_dat[i].offset, flt_dat[i].size, flt_dat[i].reg); } diff --git a/mach/sparc/ce/cegpp b/mach/sparc/ce/cegpp index 17b79ae909..ddeef48174 100644 --- a/mach/sparc/ce/cegpp +++ b/mach/sparc/ce/cegpp @@ -1,5 +1,5 @@ # dit sed script zet regels van het type "sll $a, $$, $44" om in -# fprint(codefile, "sll %s, $, $44\n", a); +# fprintf(codefile, "sll %s, $, $44\n", a); # en meer.... # Usage: sed -f $0 < EM_table.x > EM_table # remember to include special thingies in "mach.h" diff --git a/mach/sparc/ce/mach.c b/mach/sparc/ce/mach.c index 7d53f9db79..1909efe762 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); + fprintf( 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 06fa3794f8..bf06dd20c2 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, + fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - fprint(stderr,s,a1,a2,a3,a4); - fprint(stderr, "\n"); + fprintf(stderr,s,a1,a2,a3,a4); + fprintf(stderr, "\n"); errors++; } diff --git a/mach/sun3/ce/mach.c b/mach/sun3/ce/mach.c index c7289cea13..3d00dceb87 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); + fprintf( stderr, "arg_error %s %d\n", s, arg); } #endif @@ -21,7 +21,7 @@ char *filename; if ( filename == (char *)0 || !sys_open( filename, OP_WRITE, &codefile)) return( 0); - fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); + fprintf( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); return( 1); } */ diff --git a/mach/sun3/ce/misc.c b/mach/sun3/ce/misc.c index 370c88924e..815fb6ccff 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 : fprintf( 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 : fprintf( stderr, "cur_value() : unknown seg\n"); return -1L; } } diff --git a/mach/sun3/ce/output.c b/mach/sun3/ce/output.c index e89ee67801..e4f2418c29 100644 --- a/mach/sun3/ce/output.c +++ b/mach/sun3/ce/output.c @@ -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 : fprintf( 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", + fprintf(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 7e85a2be67..aafb4e31fa 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, + fprintf( 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, + fprintf( stderr, "do_relo() : bad relocation size\n"); } } diff --git a/mach/vax4/ce/as.c b/mach/vax4/ce/as.c index 29a0d87d1d..011c60e1fa 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); + fprintf( 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 : fprintf( stderr, "error"); } } diff --git a/mach/vax4/ce/mach.c b/mach/vax4/ce/mach.c index 4dff97337a..ec709d0c32 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); + fprintf( stderr, "arg_error %s %d\n", s, arg); } #endif diff --git a/mach/vax4/ce/output.c b/mach/vax4/ce/output.c index c95872bf07..f8f5251027 100644 --- a/mach/vax4/ce/output.c +++ b/mach/vax4/ce/output.c @@ -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 : fprintf( 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", + fprintf(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 b6865631ea..e3d177be17 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, + fprintf( 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, + fprintf( stderr, "do_relo() : bad relocation size\n"); } } diff --git a/modules/src/em_code/convert.c b/modules/src/em_code/convert.c index 1da029ab81..a0e82999f9 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, + fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - fprint(stderr,s,a1,a2,a3,a4); - fprint(stderr, "\n"); + fprintf(stderr,s,a1,a2,a3,a4); + fprintf(stderr, "\n"); errors++; } diff --git a/modules/src/em_opt/nopt.c b/modules/src/em_opt/nopt.c index 14faeddd93..feaaee33a9 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"); + fprintf(stderr, "%s: ", filename ? filename : "standard input"); + fprintf(stderr, s, a); + fprintf(stderr, "\n"); exit(1); } diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua index 8690de6de4..fe7ed35bf7 100644 --- a/modules/src/print/build.lua +++ b/modules/src/print/build.lua @@ -1,7 +1,7 @@ clibrary { name = "lib", srcs = { - "./doprnt.c", "./format.c", "./fprint.c", + "./doprnt.c", "./format.c" }, hdrs = { "./print.h" }, deps = { diff --git a/modules/src/print/fprint.c b/modules/src/print/fprint.c deleted file mode 100644 index d29b0bb1ae..0000000000 --- a/modules/src/print/fprint.c +++ /dev/null @@ -1,28 +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 "print.h" -#include "param.h" - -/*FORMAT1v $ - %s = char * - %l = long - %c = int - %[uxbo] = unsigned int - %d = int -$ */ -/*VARARGS*/ -void -fprint(FILE* fp, const char *fmt, ...) -{ - va_list args; - char buf[SSIZE]; - - va_start(args, fmt); - 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 fed19fff36..e608e3dc14 100644 --- a/modules/src/print/print.3 +++ b/modules/src/print/print.3 @@ -7,7 +7,7 @@ print, fprint, doprnt -- very simple formatted-output routines .B #include .B #include .PP -.B void fprint(FILE* filep, char *format [, arg] ... ) +.B void fprintf(FILE* filep, char *format [, arg] ... ) .PP .B void doprnt(FILE* filep, char *format, va_list args) .PP diff --git a/modules/src/print/print.h b/modules/src/print/print.h index a8db7c9ab5..020cf2819d 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -9,7 +9,6 @@ #include #include -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); diff --git a/util/ceg/EM_parser/as_EM_pars/error.c b/util/ceg/EM_parser/as_EM_pars/error.c index d6575b504e..12d61d3bee 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 : "); + fprintf( stderr, "!! ERROR : "); doprnt( stderr, fmt, pvar); - fprint( stderr, " !!\n"); + fprintf( stderr, " !!\n"); va_end(pvar); nerrors++; } @@ -30,9 +30,9 @@ va_dcl va_start(pvar); fmt = va_arg(pvar, char *); - fprint( stderr, "!! ERROR : "); + fprintf( stderr, "!! ERROR : "); doprnt( stderr, fmt, pvar); - fprint( stderr, " !!\n"); + fprintf( 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 3eff9a595f..782e1a9337 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); + fprintf(stderr, "ERROR : can't find >>%s<< !!\n", instr); abort(); } else if ( rel < 0) diff --git a/util/ceg/EM_parser/common/help.c b/util/ceg/EM_parser/common/help.c index 2f7c0956bc..6d7d2707ad 100644 --- a/util/ceg/EM_parser/common/help.c +++ b/util/ceg/EM_parser/common/help.c @@ -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); + fprintf( 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 2928bf0b7f..e3c0b024a2 100644 --- a/util/ceg/EM_parser/common/pars.g +++ b/util/ceg/EM_parser/common/pars.g @@ -211,20 +211,20 @@ int inserted_token; { nerrors++; if ( inserted_token == 0) { - fprint( stderr, "EM_table : syntax error in line %d, >>", + fprintf( stderr, "EM_table : syntax error in line %d, >>", yylineno); print_token( LLsymb); - fprint( stderr, "<< will be deleted!!\n"); + fprintf( 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", + fprintf(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, >>", + fprintf( stderr, "EM_table : syntax error in line %d, >>", yylineno); print_token( inserted_token); - fprint( stderr, "<< will be inserted!!\n"); + fprintf( 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 : fprintf( stderr, "C_INSTR %s", yytext); break; - case ASSEM_INSTR : fprint( stderr, "STRING %s", yytext); + case ASSEM_INSTR : fprintf( stderr, "STRING %s", yytext); break; - case CALL : fprint( stderr, "CALL %s", yytext); + case CALL : fprintf( stderr, "CALL %s", yytext); break; - case ARROW : fprint( stderr, "==> "); + case ARROW : fprintf( stderr, "==> "); break; - case CONDITION: fprint( stderr, "CONDITION %s", yytext); + case CONDITION: fprintf( stderr, "CONDITION %s", yytext); break; - case DEFAULT : fprint( stderr, "default "); + case DEFAULT : fprintf( stderr, "default "); break; - case ERROR : fprint( stderr, "unmatched %s", yytext); + case ERROR : fprintf( stderr, "unmatched %s", yytext); break; - default : fprint( stderr, " %c", token); + default : fprintf( stderr, " %c", token); break; } } @@ -311,7 +311,7 @@ char **argv; to_change = argv[2]; c_table(); if (to_change) { - fprint( stderr, "No rule for %s\n", to_change); + fprintf( 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 1decd3e411..83422746f4 100644 --- a/util/ceg/EM_parser/obj_EM_pars/dist.c +++ b/util/ceg/EM_parser/obj_EM_pars/dist.c @@ -109,7 +109,7 @@ save_output() oldout = outfile; if ( ! sys_open( ".tmp", OP_WRITE, &outfile)) - fprint( stderr, "can't open .tmp\n"); + fprintf( stderr, "can't open .tmp\n"); cur_pos = 0; n_labs = 0; } diff --git a/util/ceg/as_parser/conversion.c b/util/ceg/as_parser/conversion.c index 9885641f5c..aef6e4dc85 100644 --- a/util/ceg/as_parser/conversion.c +++ b/util/ceg/as_parser/conversion.c @@ -12,7 +12,7 @@ char *str; /* ptr points to '%'-sign */ *ptr = '\0'; - out( "fprint( outfile, \""); + out( "fprintf( outfile, \""); out_string( str); out( "\");"); @@ -20,7 +20,7 @@ char *str; str = pr_conversion( ptr); } - out( "fprint( outfile, \""); + out( "fprintf( outfile, \""); out_string( str); out( "\");"); } @@ -132,7 +132,7 @@ char *str; else if ( strncmp( str+1, "dist", 4) == 0) out( "dist( %s);", start); else - out( "fprint( outfile, \"%%%s\", %s);", str+1, start); + out( "fprintf( outfile, \"%%%s\", %s);", str+1, start); return( ptr+1); } diff --git a/util/ceg/as_parser/eval/eval.c b/util/ceg/as_parser/eval/eval.c index 2a0bcbe8e4..e39922ed3f 100644 --- a/util/ceg/as_parser/eval/eval.c +++ b/util/ceg/as_parser/eval/eval.c @@ -168,9 +168,9 @@ pr_ELSE_or_FI( str) char *str; { if ( strncmp( str, "else", 4) == 0) - printf( "fprint( outfile, \"}\else {\");%s", str+4); + printf( "fprintf( outfile, \"}\else {\");%s", str+4); else if ( strncmp( str, "fi", 2) == 0) - printf( "fprint( outfile, \"}\");%s", str+2); + printf( "fprintf( outfile, \"}\");%s", str+2); else fprintf( stderr, "%s unexpected!!\n", str); } @@ -202,7 +202,7 @@ char *call; printf( "cur_pos += %d;", *(call+5) - '0'); pr_text_with_conversions( call); - printf( "fprint( outfile, \";\");"); + printf( "fprintf( outfile, \";\");"); printf( "}"); for (; ( c = getchar()) != ';' ; putchar( c)); /* skip ';' */ } @@ -210,16 +210,16 @@ char *call; pr_elsif( quest) char *quest; { - printf( "fprint( outfile, \"}\else if\");"); + printf( "fprintf( outfile, \"}\else if\");"); pr_text_with_conversions( quest+5); - printf( "fprint( outfile, \"{\");"); + printf( "fprintf( outfile, \"{\");"); } pr_if( quest) char *quest; { pr_text_with_conversions( quest); - printf( "fprint( outfile, \"{\");"); + printf( "fprintf( outfile, \"{\");"); } @@ -231,13 +231,13 @@ char *str; while ( ptr = next_conversion( str)) { /* ptr points to '%'-sign */ *ptr = '\0'; - printf( "fprint( outfile, \""); + printf( "fprintf( outfile, \""); pr_string( str); printf( "\");"); *ptr = '%'; str = pr_conversion( ptr); } - printf( "fprint( outfile, \""); + printf( "fprintf( outfile, \""); pr_string( str); printf( "\");"); } @@ -340,7 +340,7 @@ char *str; else if ( strncmp( str+1, "dist", 4) == 0) printf( "dist( %s);", start); else - printf( "fprint( outfile, \"%%%s\", %s);", str+1, start); + printf( "fprintf( outfile, \"%%%s\", %s);", str+1, start); return( ptr+1); } diff --git a/util/ceg/as_parser/help.c b/util/ceg/as_parser/help.c index 5138256a2d..97f007c99d 100644 --- a/util/ceg/as_parser/help.c +++ b/util/ceg/as_parser/help.c @@ -142,30 +142,30 @@ char *str; out( "cur_pos += %d;\n", *(str+5) - '0'); pr_text_with_conversions( str); - out( "fprint( outfile, \";\");"); + out( "fprintf( outfile, \";\");"); } pr_end() { - out( "fprint( outfile, \"}\\n\");"); + out( "fprintf( outfile, \"}\\n\");"); } pr_els() { - out( "fprint( outfile, \"else\\n\");"); + out( "fprintf( outfile, \"else\\n\");"); } pr_else() { - out( "fprint( outfile, \"else {\\n\");"); + out( "fprintf( outfile, \"else {\\n\");"); } pr_question( quest) char *quest; { - out( "fprint( outfile, \"if\");"); + out( "fprintf( outfile, \"if\");"); pr_text_with_conversions( quest); - out( "fprint( outfile, \"{\\n\");"); + out( "fprintf( outfile, \"{\\n\");"); } @@ -237,9 +237,9 @@ error(char *fmt, ...) nerrors++; va_start(pvar, fmt); - fprint( stderr, "!! ERROR : "); + fprintf( stderr, "!! ERROR : "); doprnt( stderr, fmt, pvar); - fprint( stderr, " !!\n"); + fprintf( stderr, " !!\n"); va_end(pvar); } #else @@ -268,9 +268,9 @@ va_dcl nerrors++; va_start(pvar); fmt = va_arg(pvar, char *); - fprint( stderr, "!! ERROR : "); + fprintf( stderr, "!! ERROR : "); doprnt( stderr, fmt, pvar); - fprint( stderr, " !!\n"); + fprintf( stderr, " !!\n"); va_end(pvar); } #endif diff --git a/util/ceg/as_parser/pars.g b/util/ceg/as_parser/pars.g index c0cc597370..427b2b0e74 100644 --- a/util/ceg/as_parser/pars.g +++ b/util/ceg/as_parser/pars.g @@ -15,19 +15,19 @@ * { * if ( REG( dst) && EADDR( src)) { * cur_pos += 1; - * fprint( outfile, "text1( 0x23)"); - * fprint( outfile, ";"); + * fprintf( outfile, "text1( 0x23)"); + * fprintf( outfile, ";"); * mod_RM( dst->reg, src); * } * else if ( ACCU( dst) && DATA( src)) { * cur_pos += 1; - * fprint( outfile, "text1( 0x25)"); - * fprint( outfile, ";"); + * fprintf( outfile, "text1( 0x25)"); + * fprintf( outfile, ";"); * cur_pos += 2; - * fprint( outfile, "text2( "); + * fprintf( outfile, "text2( "); * eval( src->expr); - * fprint( outfile, ")"); - * fprint( outfile, ";"); + * fprintf( outfile, ")"); + * fprintf( outfile, ";"); * } * else * error( "No match for and"); @@ -149,18 +149,18 @@ int inserted_token; { nerrors++; if ( inserted_token == 0) { - fprint( stderr, "Sytax error in line %d, ", lineno); + fprintf( stderr, "Sytax error in line %d, ", lineno); print_token( LLsymb); - fprint( stderr, " will be deleted!!\n"); + fprintf( stderr, " will be deleted!!\n"); } else if ( inserted_token < 0) { - fprint( stderr, "Garbage at end, line %d!!\n", + fprintf( stderr, "Garbage at end, line %d!!\n", lineno); } else { - fprint( stderr, "Sytax error in line %d, ", lineno); + fprintf( stderr, "Sytax error in line %d, ", lineno); print_token( inserted_token); - fprint( stderr, " will be inserted!!\n"); + fprintf( 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 : fprintf( stderr, "IDENTIFIER %s", yytext); break; - case CALL : fprint( stderr, "CALL %s", yytext); + case CALL : fprintf( stderr, "CALL %s", yytext); break; - case CONDITION: fprint( stderr, "CONDITION %s", yytext); + case CONDITION: fprintf( stderr, "CONDITION %s", yytext); break; - case IF : fprint( stderr, "@if "); + case IF : fprintf( stderr, "@if "); break; - case ELSIF : fprint( stderr, "@elsif "); + case ELSIF : fprintf( stderr, "@elsif "); break; - case ELSE : fprint( stderr, "@else "); + case ELSE : fprintf( stderr, "@else "); break; - case FI : fprint( stderr, "@fi "); + case FI : fprintf( stderr, "@fi "); break; - case ARROW : fprint( stderr, "==> "); + case ARROW : fprintf( stderr, "==> "); break; - case MORE : fprint( stderr, "... "); + case MORE : fprintf( stderr, "... "); break; - default : fprint( stderr, "%c ", token); + default : fprintf( stderr, "%c ", token); break; } } diff --git a/util/ceg/assemble/as_assemble/assemble.c b/util/ceg/assemble/as_assemble/assemble.c index 8abbb4ada7..d7529bfc69 100644 --- a/util/ceg/assemble/as_assemble/assemble.c +++ b/util/ceg/assemble/as_assemble/assemble.c @@ -20,7 +20,7 @@ char *str; b_ptr = buf; - out( "fprint( codefile,\""); + out( "fprintf( codefile,\""); while ( *str) { switch ( *str) { @@ -35,7 +35,7 @@ char *str; arg_format( nr), C_instr_info->arg_type[nr] == ARITH ? "(long)" : "", C_instr_info->arg_conv[nr]); - out( "fprint( codefile,\""); + out( "fprintf( codefile,\""); b_ptr = buf; str = str + 2; } diff --git a/util/ceg/assemble/obj_assemble/assemble.c b/util/ceg/assemble/obj_assemble/assemble.c index ddb449946e..ae46927ab7 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); + fprintf( stderr, "ERROR in line %d : ", yylineno); doprnt( stderr, fmt, args); - fprint( stderr, "\n"); + fprintf( 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); + fprintf( stderr, "ERROR in line %d : ", yylineno); doprnt( stderr, fmt, args); - fprint( stderr, "\n"); + fprintf( 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 218ca4df84..9b7ce42d92 100644 --- a/util/ceg/ce_back/as_back/back.h +++ b/util/ceg/ce_back/as_back/back.h @@ -56,7 +56,7 @@ extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(), *extnd_part(), *extnd_cont(), *extnd_main(); #define swtxt() switchseg( SEGTXT) -#define bss(n) fprint(codefile, BSS_FMT, (long)(n)) +#define bss(n) fprintf(codefile, BSS_FMT, (long)(n)) #define SEGTXT 0 #define SEGROM 1 diff --git a/util/ceg/ce_back/as_back/bottom.c b/util/ceg/ce_back/as_back/bottom.c index a4191e2dc3..3b8c408b40 100644 --- a/util/ceg/ce_back/as_back/bottom.c +++ b/util/ceg/ce_back/as_back/bottom.c @@ -16,7 +16,7 @@ align_word() { switch ( cur_seg) { case SEGTXT : return; - default : fprint( codefile, ALIGN_FMT); + default : fprintf( codefile, ALIGN_FMT); } } diff --git a/util/ceg/ce_back/as_back/bss.c b/util/ceg/ce_back/as_back/bss.c index 268624c215..47115f0893 100644 --- a/util/ceg/ce_back/as_back/bss.c +++ b/util/ceg/ce_back/as_back/bss.c @@ -8,7 +8,7 @@ arith n; switchseg(SEGBSS); if (saved) { - fprint( codefile, COMM_FMT, labeltje, (long) n); + fprintf( codefile, COMM_FMT, labeltje, (long) n); saved = 0; return; } diff --git a/util/ceg/ce_back/as_back/dbsym.c b/util/ceg/ce_back/as_back/dbsym.c index c18448de85..6ae95d76ab 100644 --- a/util/ceg/ce_back/as_back/dbsym.c +++ b/util/ceg/ce_back/as_back/dbsym.c @@ -6,7 +6,7 @@ char *s, *val; arith added; { if (! s) s = ""; - fprint(codefile, ".symb \"%s\", %s+%ld, 0x%x, %d\n", s, val, (long) added, type, add); + fprintf(codefile, ".symb \"%s\", %s+%ld, 0x%x, %d\n", s, val, (long) added, type, add); } B_symbcst(s, len, type, add, val) @@ -14,13 +14,13 @@ char *s; arith val; { if (! s) s = ""; - fprint(codefile, ".symb \"%s\", %ld, 0x%x, %d\n", s, val, type, add); + fprintf(codefile, ".symb \"%s\", %ld, 0x%x, %d\n", s, val, type, add); } B_symd(s, len, type, add) char *s; { if (! s) s = ""; - fprint(codefile, ".symd \"%s\", 0x%x, %d\n", s, type, add); + fprintf(codefile, ".symd \"%s\", 0x%x, %d\n", s, type, add); } #endif diff --git a/util/ceg/ce_back/as_back/gen1.c b/util/ceg/ce_back/as_back/gen1.c index 385c900e29..f2a59615c2 100644 --- a/util/ceg/ce_back/as_back/gen1.c +++ b/util/ceg/ce_back/as_back/gen1.c @@ -4,14 +4,14 @@ gen1( w) ONE_BYTE w; { switch ( cur_seg) { - case SEGTXT : fprint( codefile, BYTE_FMT, (long) w); + case SEGTXT : fprintf( codefile, BYTE_FMT, (long) w); break; - case SEGCON : fprint( codefile, BYTE_FMT, (long) w); + case SEGCON : fprintf( codefile, BYTE_FMT, (long) w); break; - case SEGROM : fprint( codefile, BYTE_FMT, (long) w); + case SEGROM : fprintf( codefile, BYTE_FMT, (long) w); break; case SEGBSS : bss( (arith) 1); break; - default : fprint( stderr, "gen1 unkown seg %d\n", cur_seg); + default : fprintf( 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 320f3f5070..6ae053ee56 100644 --- a/util/ceg/ce_back/as_back/gen2.c +++ b/util/ceg/ce_back/as_back/gen2.c @@ -4,14 +4,14 @@ gen2( w) TWO_BYTES w; { switch ( cur_seg) { - case SEGTXT : fprint( codefile, WORD_FMT, (long) w); + case SEGTXT : fprintf( codefile, WORD_FMT, (long) w); break; - case SEGCON : fprint( codefile, WORD_FMT, (long) w); + case SEGCON : fprintf( codefile, WORD_FMT, (long) w); break; - case SEGROM : fprint( codefile, WORD_FMT, (long) w); + case SEGROM : fprintf( codefile, WORD_FMT, (long) w); break; case SEGBSS : bss( (arith) 2); break; - default : fprint( stderr, "gen2 unkown seg %d\n", cur_seg); + default : fprintf( 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 12de8bdad0..3971a0dd1e 100644 --- a/util/ceg/ce_back/as_back/gen4.c +++ b/util/ceg/ce_back/as_back/gen4.c @@ -4,14 +4,14 @@ gen4( w) FOUR_BYTES w; { switch ( cur_seg) { - case SEGTXT : fprint( codefile, LONG_FMT, (long) w); + case SEGTXT : fprintf( codefile, LONG_FMT, (long) w); break; - case SEGCON : fprint( codefile, LONG_FMT, (long) w); + case SEGCON : fprintf( codefile, LONG_FMT, (long) w); break; - case SEGROM : fprint( codefile, LONG_FMT, (long) w); + case SEGROM : fprintf( codefile, LONG_FMT, (long) w); break; case SEGBSS : bss( (arith) 4); break; - default : fprint( stderr, "gen4 unkown seg %d\n", cur_seg); + default : fprintf( stderr, "gen4 unkown seg %d\n", cur_seg); } } diff --git a/util/ceg/ce_back/as_back/reloc1.c b/util/ceg/ce_back/as_back/reloc1.c index a32fb61e0b..32f8c32769 100644 --- a/util/ceg/ce_back/as_back/reloc1.c +++ b/util/ceg/ce_back/as_back/reloc1.c @@ -5,5 +5,5 @@ char *s; arith o; int r; { - fprint( codefile, RELOC1_FMT, s, (long) o); + fprintf( codefile, RELOC1_FMT, s, (long) o); } diff --git a/util/ceg/ce_back/as_back/reloc2.c b/util/ceg/ce_back/as_back/reloc2.c index e07d35fec2..0ff3ee9308 100644 --- a/util/ceg/ce_back/as_back/reloc2.c +++ b/util/ceg/ce_back/as_back/reloc2.c @@ -5,5 +5,5 @@ char *s; arith o; int r; { - fprint( codefile, RELOC2_FMT, s, (long) o); + fprintf( codefile, RELOC2_FMT, s, (long) o); } diff --git a/util/ceg/ce_back/as_back/reloc4.c b/util/ceg/ce_back/as_back/reloc4.c index 14d6ad8e2f..d6d4fded98 100644 --- a/util/ceg/ce_back/as_back/reloc4.c +++ b/util/ceg/ce_back/as_back/reloc4.c @@ -5,5 +5,5 @@ char *s; arith o; int r; { - fprint( codefile, RELOC4_FMT, s, (long) o); + fprintf( codefile, RELOC4_FMT, s, (long) o); } diff --git a/util/ceg/ce_back/as_back/set_global.c b/util/ceg/ce_back/as_back/set_global.c index 18f9c1bdc1..65d0d760ac 100644 --- a/util/ceg/ce_back/as_back/set_global.c +++ b/util/ceg/ce_back/as_back/set_global.c @@ -3,5 +3,5 @@ set_global_visible( s) char *s; { - fprint( codefile, GLOBAL_FMT, s); + fprintf( codefile, GLOBAL_FMT, s); } diff --git a/util/ceg/ce_back/as_back/set_local.c b/util/ceg/ce_back/as_back/set_local.c index 6c3d2fd3a4..a071e4ac4a 100644 --- a/util/ceg/ce_back/as_back/set_local.c +++ b/util/ceg/ce_back/as_back/set_local.c @@ -3,5 +3,5 @@ set_local_visible( s) char *s; { - fprint( codefile, LOCAL_FMT, s); + fprintf( codefile, LOCAL_FMT, s); } diff --git a/util/ceg/ce_back/as_back/switchseg.c b/util/ceg/ce_back/as_back/switchseg.c index e3d7d743f1..1356d0a512 100644 --- a/util/ceg/ce_back/as_back/switchseg.c +++ b/util/ceg/ce_back/as_back/switchseg.c @@ -9,13 +9,13 @@ int seg; cur_seg = seg; switch ( cur_seg) { - case SEGTXT : fprint( codefile, SEGTXT_FMT); + case SEGTXT : fprintf( codefile, SEGTXT_FMT); break; - case SEGCON : fprint( codefile, SEGDAT_FMT); + case SEGCON : fprintf( codefile, SEGDAT_FMT); break; - case SEGROM : fprint( codefile, SEGDAT_FMT); + case SEGROM : fprintf( codefile, SEGDAT_FMT); break; - case SEGBSS : fprint( codefile, SEGBSS_FMT); + case SEGBSS : fprintf( codefile, SEGBSS_FMT); break; } diff --git a/util/ceg/ce_back/as_back/symboldef.c b/util/ceg/ce_back/as_back/symboldef.c index 7b4c64440b..f49e71beab 100644 --- a/util/ceg/ce_back/as_back/symboldef.c +++ b/util/ceg/ce_back/as_back/symboldef.c @@ -3,5 +3,5 @@ symbol_definition( s) char *s; { - fprint( codefile, SYMBOL_DEF_FMT, s); + fprintf( codefile, SYMBOL_DEF_FMT, s); } diff --git a/util/ceg/ce_back/obj_back/gen1.c b/util/ceg/ce_back/obj_back/gen1.c index ec46ec3ab2..1a86da121a 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 : fprintf( 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 33c5e0b03a..278bc25c2d 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 : fprintf( 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 0a2eba6777..6bfbe8ddad 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 : fprintf( 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 bf87825238..40a6bdc9b4 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 : fprintf( 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 : fprintf( 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 9f59965b78..c48621bf67 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"); + fprintf( stderr, "write failed\n"); abort(); } diff --git a/util/ceg/ce_back/obj_back/relocation.c b/util/ceg/ce_back/obj_back/relocation.c index d40e9d5f1f..ed4d541e76 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, + fprintf( 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"); + fprintf( 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 cc36ad3ca1..dd745c9726 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); + fprintf( 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 984a165bd0..b6c6dd3b2e 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"); + fprintf( stderr, "wrong word size\n"); exit( -1); } if ( psize != EM_PSIZE) { - fprint( stderr, "wrong pointer size\n"); + fprintf( 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 8a69a1df45..9d8f4b6721 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); + fprintf( 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 a922ee035c..6febcd27b1 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); + fprintf(stderr, "%s: ", prog_name); doprnt(stderr, s, ap); - fprint(stderr, "\n"); + fprintf(stderr, "\n"); cleanup(); exit(1); UNREACHABLE_CODE; @@ -279,10 +279,10 @@ static void run_phase(int phase) while (phargs[i]) { - fprint(stderr, "%s ", phargs[i]); + fprintf(stderr, "%s ", phargs[i]); i++; } - fprint(stderr, "\n"); + fprintf(stderr, "\n"); } status = sys_system(phargs[0], (const char* const*)phargs); diff --git a/util/misc/convert.c b/util/misc/convert.c index 84e7d4a9b6..6c9da3a150 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", + fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); doprnt(stderr, s, ap); - fprint(stderr, "\n"); + fprintf(stderr, "\n"); errors++; va_end(ap); } From dbe0ae077fef3fa4deb376ebb47cad5c1b0ccf25 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 22:55:05 +0100 Subject: [PATCH 23/29] Eliminate dprnt() in favour of vfprintf(). --- lang/cem/cemcom.ansi/error.c | 2 +- lang/cem/cemcom/error.c | 2 +- lang/cem/cpp.ansi/error.c | 20 +++--- lang/cem/libcc.ansi/core/printf/doprnt.c | 2 +- lang/cem/libcc.ansi/core/printf/doprnt.h | 2 +- lang/cem/libcc.ansi/core/printf/vfprintf.c | 2 +- lang/cem/libcc.ansi/core/printf/vsnprintf.c | 2 +- lang/cem/libcc/stdio/doprnt.c | 2 +- lang/cem/libcc/stdio/sprintf.c | 2 +- lang/cem/libcc/stdio/vprintf.c | 2 +- lang/cem/libcc/stdio/vsprintf.c | 2 +- lang/cem/lint/lpass2/l_print3ack.c | 2 +- lang/cem/lint/lpass2/report.c | 4 +- lang/m2/comp/error.c | 2 +- lang/m2/m2mm/error.c | 2 +- lang/pc/comp/error.c | 2 +- modules/src/print/build.lua | 2 +- modules/src/print/doprnt.c | 24 ------- modules/src/print/print.3 | 72 --------------------- modules/src/print/print.h | 1 - util/ceg/EM_parser/as_EM_pars/error.c | 4 +- util/ceg/EM_parser/common/help.c | 4 +- util/ceg/as_parser/help.c | 8 +-- util/ceg/assemble/obj_assemble/assemble.c | 4 +- util/ego/em_ego/em_ego.c | 2 +- util/int/ChangeLog | 2 +- util/misc/convert.c | 2 +- 27 files changed, 40 insertions(+), 137 deletions(-) delete mode 100644 modules/src/print/doprnt.c diff --git a/lang/cem/cemcom.ansi/error.c b/lang/cem/cemcom.ansi/error.c index 53595bbbd0..39b3387989 100644 --- a/lang/cem/cemcom.ansi/error.c +++ b/lang/cem/cemcom.ansi/error.c @@ -613,6 +613,6 @@ static void _error(int class, char *fn, unsigned int ln, char* fmt, va_list ap) fprintf(ERROUT, "\"%s\", line %u: ", fn, ln); if (remark) fprintf(ERROUT, "%s ", remark); - doprnt(ERROUT, fmt, ap); /* contents of error */ + vfprintf(ERROUT, fmt, ap); /* contents of error */ fprintf(ERROUT, "\n"); } diff --git a/lang/cem/cemcom/error.c b/lang/cem/cemcom/error.c index 92717142f0..1d58016da9 100644 --- a/lang/cem/cemcom/error.c +++ b/lang/cem/cemcom/error.c @@ -492,6 +492,6 @@ _error(class, fn, ln, fmt, ap) fprintf(ERROUT, "\"%s\", line %u: ", fn, ln); if (remark) fprintf(ERROUT, "%s ", remark); - doprnt(ERROUT, fmt, ap); /* contents of error */ + vfprintf(ERROUT, fmt, ap); /* contents of error */ fprintf(ERROUT, "\n"); } diff --git a/lang/cem/cpp.ansi/error.c b/lang/cem/cpp.ansi/error.c index 4ee18b12ac..0216d2f879 100644 --- a/lang/cem/cpp.ansi/error.c +++ b/lang/cem/cpp.ansi/error.c @@ -41,7 +41,7 @@ void error(char *fmt, ...) err_occurred = 1; err_hdr(""); va_start(ap, fmt); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); } @@ -53,7 +53,7 @@ void warning(char *fmt, ...) err_hdr("(warning) "); va_start(ap, fmt); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); } @@ -65,7 +65,7 @@ void strict(char *fmt, ...) err_hdr("(strict) "); va_start(ap, fmt); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); } @@ -77,7 +77,7 @@ NORETURN void crash(char *fmt, ...) err_hdr("CRASH\007 "); va_start(ap, fmt); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); abort(); @@ -90,7 +90,7 @@ NORETURN void fatal(char *fmt, ...) err_hdr("fatal error -- "); va_start(ap, fmt); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); exit(1); @@ -107,7 +107,7 @@ void error(va_alist) err_hdr(""); va_start(ap); fmt = va_arg(ap, char *); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); } @@ -122,7 +122,7 @@ void warning(va_alist) err_hdr("(warning) "); va_start(ap); fmt = va_arg(ap, char *); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); } @@ -137,7 +137,7 @@ void strict(va_alist) err_hdr("(strict) "); va_start(ap); fmt = va_arg(ap, char *); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); } @@ -152,7 +152,7 @@ void crash(va_alist) err_hdr("CRASH\007 "); va_start(ap); fmt = va_arg(ap, char *); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); abort(); @@ -168,7 +168,7 @@ void fatal(va_alist) err_hdr("fatal error -- "); va_start(ap); fmt = va_arg(ap, char *); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); va_end(ap); exit(1); diff --git a/lang/cem/libcc.ansi/core/printf/doprnt.c b/lang/cem/libcc.ansi/core/printf/doprnt.c index baa639ce2b..3473539ab7 100644 --- a/lang/cem/libcc.ansi/core/printf/doprnt.c +++ b/lang/cem/libcc.ansi/core/printf/doprnt.c @@ -155,7 +155,7 @@ o_print(va_list* ap, int flags, char* s, char c, int precision, int is_signed) return s; } -int _doprnt(const char* fmt, va_list ap) +int _vfprintf(const char* fmt, va_list ap) { char* s; int j; diff --git a/lang/cem/libcc.ansi/core/printf/doprnt.h b/lang/cem/libcc.ansi/core/printf/doprnt.h index c6fe5a2531..2602398cc4 100644 --- a/lang/cem/libcc.ansi/core/printf/doprnt.h +++ b/lang/cem/libcc.ansi/core/printf/doprnt.h @@ -17,7 +17,7 @@ extern int (*_doprnt_put)(int c); -extern int _doprnt(const char* fmt, va_list ap); +extern int _vfprintf(const char* fmt, va_list ap); extern char* _f_print(va_list* ap, int flags, char* s, char c, int precision); #if ACKCONF_WANT_STDIO_FLOAT diff --git a/lang/cem/libcc.ansi/core/printf/vfprintf.c b/lang/cem/libcc.ansi/core/printf/vfprintf.c index 7e665a22ff..41b2ece21e 100644 --- a/lang/cem/libcc.ansi/core/printf/vfprintf.c +++ b/lang/cem/libcc.ansi/core/printf/vfprintf.c @@ -21,7 +21,7 @@ int vfprintf(FILE* stream, const char* format, va_list arg) { vfprintf_stream = stream; _doprnt_put = vfprintf_putc; - return _doprnt(format, arg); + return _vfprintf(format, arg); } #endif diff --git a/lang/cem/libcc.ansi/core/printf/vsnprintf.c b/lang/cem/libcc.ansi/core/printf/vsnprintf.c index af97b53510..a6e2547783 100644 --- a/lang/cem/libcc.ansi/core/printf/vsnprintf.c +++ b/lang/cem/libcc.ansi/core/printf/vsnprintf.c @@ -29,7 +29,7 @@ int vsnprintf(char* s, size_t len, const char* format, va_list ap) output_buffer = s; output_buffer_len = len; _doprnt_put = snprintf_putc; - retval = _doprnt(format, ap); + retval = _vfprintf(format, ap); snprintf_putc('\0'); return retval; diff --git a/lang/cem/libcc/stdio/doprnt.c b/lang/cem/libcc/stdio/doprnt.c index 3fa80592fa..ea12c91745 100644 --- a/lang/cem/libcc/stdio/doprnt.c +++ b/lang/cem/libcc/stdio/doprnt.c @@ -63,7 +63,7 @@ static char *l_compute(l1,d,s) long l1; char *s; { } #endif -_doprnt(fmt,ap,stream) +_vfprintf(fmt,ap,stream) char *fmt; va_list ap ; FILE *stream; { char *s; diff --git a/lang/cem/libcc/stdio/sprintf.c b/lang/cem/libcc/stdio/sprintf.c index 206c6ce8da..0de07320be 100644 --- a/lang/cem/libcc/stdio/sprintf.c +++ b/lang/cem/libcc/stdio/sprintf.c @@ -21,7 +21,7 @@ char *sprintf(va_alist) _tempfile._ptr = (unsigned char *) buf; _tempfile._count = 32767; - _doprnt(format, ap, &_tempfile); + _vfprintf(format, ap, &_tempfile); putc('\0',&_tempfile); } va_end(ap); diff --git a/lang/cem/libcc/stdio/vprintf.c b/lang/cem/libcc/stdio/vprintf.c index de64d8e5af..ae6731a2ed 100644 --- a/lang/cem/libcc/stdio/vprintf.c +++ b/lang/cem/libcc/stdio/vprintf.c @@ -8,5 +8,5 @@ vprintf(format, arg) char *format; va_list arg; { - return _doprnt(format, arg, stdout); + return _vfprintf(format, arg, stdout); } diff --git a/lang/cem/libcc/stdio/vsprintf.c b/lang/cem/libcc/stdio/vsprintf.c index d53daa4cfb..85e5a0f33b 100644 --- a/lang/cem/libcc/stdio/vsprintf.c +++ b/lang/cem/libcc/stdio/vsprintf.c @@ -17,7 +17,7 @@ vsprintf(s, format, arg) tmp_stream._ptr = (unsigned char *) s; tmp_stream._count = 32767; - _doprnt(format, arg, &tmp_stream); + _vfprintf(format, arg, &tmp_stream); putc('\0',&tmp_stream); return s; diff --git a/lang/cem/lint/lpass2/l_print3ack.c b/lang/cem/lint/lpass2/l_print3ack.c index e368abc8bf..74f95725b0 100644 --- a/lang/cem/lint/lpass2/l_print3ack.c +++ b/lang/cem/lint/lpass2/l_print3ack.c @@ -24,7 +24,7 @@ fprintf(filep, format) FILE* filep; char *format; { ; } /* FORMAT1 */ sprintf(s, format) char *s; char *format; { ; } /* FORMAT1 */ -doprnt(filep, format) FILE* filep; char *format; { ; } +vfprintf(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 5a848004af..1666d8c0b0 100644 --- a/lang/cem/lint/lpass2/report.c +++ b/lang/cem/lint/lpass2/report.c @@ -132,7 +132,7 @@ panic(char *fmt, ...) /* fmt, args */ va_start(ap, fmt); { fprintf(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); } va_end(ap); @@ -151,7 +151,7 @@ panic(va_alist) /* fmt, args */ char *fmt = va_arg(ap, char *); fprintf(ERROUT, "PANIC, lint, pass2: line %d: ", LineNr); - doprnt(ERROUT, fmt, ap); + vfprintf(ERROUT, fmt, ap); fprintf(ERROUT, "\n"); } va_end(ap); diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index 4856bc0c1e..ec5896eccc 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -406,6 +406,6 @@ static void _error(int class, struct node *node, char *fmt, va_list ap, int warn if (remark) fprintf(ERROUT, "%s ", remark); - doprnt(ERROUT, fmt, ap); /* contents of error */ + vfprintf(ERROUT, fmt, ap); /* contents of error */ fprintf(ERROUT, "\n"); } diff --git a/lang/m2/m2mm/error.c b/lang/m2/m2mm/error.c index 23e7583bdf..ff3f2d5ab2 100644 --- a/lang/m2/m2mm/error.c +++ b/lang/m2/m2mm/error.c @@ -232,6 +232,6 @@ _error(class, fmt, argv) if (remark) fprintf(stderr, "%s ", remark); - doprnt(stderr, fmt, argv); /* contents of error */ + vfprintf(stderr, fmt, argv); /* contents of error */ fprintf(stderr, "\n"); } diff --git a/lang/pc/comp/error.c b/lang/pc/comp/error.c index 34e6a59aae..d5cfaf31b0 100644 --- a/lang/pc/comp/error.c +++ b/lang/pc/comp/error.c @@ -403,6 +403,6 @@ static void _error(int class, struct node *node, char *fmt, va_list ap) if( remark ) fprintf(ERROUT, "%s ", remark); - doprnt(ERROUT, fmt, ap); /* contents of error */ + vfprintf(ERROUT, fmt, ap); /* contents of error */ fprintf(ERROUT, "\n"); } diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua index fe7ed35bf7..ab3a022b7c 100644 --- a/modules/src/print/build.lua +++ b/modules/src/print/build.lua @@ -1,7 +1,7 @@ clibrary { name = "lib", srcs = { - "./doprnt.c", "./format.c" + "./format.c" }, hdrs = { "./print.h" }, deps = { diff --git a/modules/src/print/doprnt.c b/modules/src/print/doprnt.c deleted file mode 100644 index e9b32e3f4d..0000000000 --- a/modules/src/print/doprnt.c +++ /dev/null @@ -1,24 +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 "print.h" -#include "param.h" - -/*FORMAT1 $ - %s = char * - %l = long - %c = int - %[uxbo] = unsigned int - %d = int -$ */ -void -doprnt(FILE* fp, const char *fmt, va_list argp) -{ - char buf[SSIZE]; - - fwrite(buf, 1, _format(buf, fmt, argp), fp); -} diff --git a/modules/src/print/print.3 b/modules/src/print/print.3 index e608e3dc14..f4b8eee5d5 100644 --- a/modules/src/print/print.3 +++ b/modules/src/print/print.3 @@ -7,85 +7,13 @@ print, fprint, doprnt -- very simple formatted-output routines .B #include .B #include .PP -.B void fprintf(FILE* filep, char *format [, arg] ... ) -.PP -.B void doprnt(FILE* filep, char *format, va_list args) -.PP .B int _format(char *buf, char *format, va_lsit args) .fi .SH DESCRIPTION -.I fprint -and -.I doprnt -place output on the open file known by -.IR filep . -.I filep could for instance be stdout or stderr. -.PP -Each of these functions converts, formats and prints its arguments, following -the -.I format -argument, under control of -.IR format . -.I Format -is a character string which contains two types of objects: plain characters, -which are simply copied to the output destination, and conversion -specifications, each of which causes conversion and printing of the next -successive argument. -.PP -A conversion specification is introduced by the character %. -Following the %, there may be -.IP \(bu -an optional row of decimal digits specifying the field width; -if the converted integral value has fewer characters than -the field width, it will be blank-padded on the left; -if the field width begins with a zero, zero-padding will be done; -.IP \(bu -the character -.B l -specifying that a following -.BR b , -.BR d , -.BR o , -.B u -or -.B x -corresponds to a long-integer argument; -.IP \(bu -a character which indicates the type of conversion to be applied. -.LP -.PP -The conversion characters and their meanings are -.IP \fBbdox\fP -The next argument is an integer and is converted to binary, decimal, octal -or hexadecimal notation respectively. -.IP \fBc\fP -Next argument is a character and is put directly into the resulting string. -the field width is one character. -.IP \fBs\fP -Next argument is taken to be a character pointer and characters from the -string are taken until a null character is reached; a specified field width -is not taken into account. -.IP \fBu\fP -The unsigned integer argument is converted to decimal. -.LP -.PP -Integral arguments are not truncated, even if their size exceeds the specified -field width. -Padding takes place only if the specified field width exceeds the actual width. -.PP -The printing routines build the string to be printed internally and use -.I sys_write -to print it. -.PP The .I _format routine builds the string, but does not null-terminate it. It returns the length of the string. -.PP -.I doprnt -takes -.I args -as the address of the arguments of the format string. .SH FILES .nf ~em/modules/lib/libprint.a diff --git a/modules/src/print/print.h b/modules/src/print/print.h index 020cf2819d..04a33b623e 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -9,7 +9,6 @@ #include #include -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/util/ceg/EM_parser/as_EM_pars/error.c b/util/ceg/EM_parser/as_EM_pars/error.c index 12d61d3bee..18afe11273 100644 --- a/util/ceg/EM_parser/as_EM_pars/error.c +++ b/util/ceg/EM_parser/as_EM_pars/error.c @@ -15,7 +15,7 @@ error(char *fmt, ...) va_start(pvar, fmt); fprintf( stderr, "!! ERROR : "); - doprnt( stderr, fmt, pvar); + vfprintf( stderr, fmt, pvar); fprintf( stderr, " !!\n"); va_end(pvar); nerrors++; @@ -31,7 +31,7 @@ va_dcl va_start(pvar); fmt = va_arg(pvar, char *); fprintf( stderr, "!! ERROR : "); - doprnt( stderr, fmt, pvar); + vfprintf( stderr, fmt, pvar); fprintf( stderr, " !!\n"); va_end(pvar); nerrors++; diff --git a/util/ceg/EM_parser/common/help.c b/util/ceg/EM_parser/common/help.c index 6d7d2707ad..2bc3428650 100644 --- a/util/ceg/EM_parser/common/help.c +++ b/util/ceg/EM_parser/common/help.c @@ -111,7 +111,7 @@ out(char *fmt, ...) va_list pvar; va_start(pvar, fmt); - doprnt( outfile, fmt, pvar); + vfprintf( outfile, fmt, pvar); va_end(pvar); } #else @@ -124,7 +124,7 @@ va_dcl va_start(pvar); fmt = va_arg(pvar, char *); - doprnt( outfile, fmt, pvar); + vfprintf( outfile, fmt, pvar); va_end(pvar); } #endif diff --git a/util/ceg/as_parser/help.c b/util/ceg/as_parser/help.c index 97f007c99d..accb13f362 100644 --- a/util/ceg/as_parser/help.c +++ b/util/ceg/as_parser/help.c @@ -224,7 +224,7 @@ out(char *fmt, ...) va_list pvar; va_start(pvar, fmt); - doprnt( outfile, fmt, pvar); + vfprintf( outfile, fmt, pvar); va_end(pvar); } @@ -238,7 +238,7 @@ error(char *fmt, ...) nerrors++; va_start(pvar, fmt); fprintf( stderr, "!! ERROR : "); - doprnt( stderr, fmt, pvar); + vfprintf( stderr, fmt, pvar); fprintf( stderr, " !!\n"); va_end(pvar); } @@ -252,7 +252,7 @@ va_dcl va_start(pvar); fmt = va_arg(pvar, char *); - doprnt( outfile, fmt, pvar); + vfprintf( outfile, fmt, pvar); va_end(pvar); } @@ -269,7 +269,7 @@ va_dcl va_start(pvar); fmt = va_arg(pvar, char *); fprintf( stderr, "!! ERROR : "); - doprnt( stderr, fmt, pvar); + vfprintf( stderr, fmt, pvar); fprintf( stderr, " !!\n"); va_end(pvar); } diff --git a/util/ceg/assemble/obj_assemble/assemble.c b/util/ceg/assemble/obj_assemble/assemble.c index ae46927ab7..76f608c4e4 100644 --- a/util/ceg/assemble/obj_assemble/assemble.c +++ b/util/ceg/assemble/obj_assemble/assemble.c @@ -239,7 +239,7 @@ error(char *fmt, ...) va_start(args, fmt); fprintf( stderr, "ERROR in line %d : ", yylineno); - doprnt( stderr, fmt, args); + vfprintf( stderr, fmt, args); fprintf( stderr, "\n"); va_end(args); nerrors++; @@ -257,7 +257,7 @@ error(va_alist) va_start(args); fmt = va_arg(args, char *); fprintf( stderr, "ERROR in line %d : ", yylineno); - doprnt( stderr, fmt, args); + vfprintf( stderr, fmt, args); fprintf( stderr, "\n"); va_end(args); nerrors++; diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 6febcd27b1..146465840e 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -116,7 +116,7 @@ static void fatal(const char* s, ...) va_start(ap, s); fprintf(stderr, "%s: ", prog_name); - doprnt(stderr, s, ap); + vfprintf(stderr, s, ap); fprintf(stderr, "\n"); cleanup(); exit(1); diff --git a/util/int/ChangeLog b/util/int/ChangeLog index e8da90df33..37d5669106 100644 --- a/util/int/ChangeLog +++ b/util/int/ChangeLog @@ -134,7 +134,7 @@ 25-Apr-88 Dick Grune (dick) at dick With the advent of the Sun 4 RISC machine, the use of variable length argument lists has become a liability. The answer is the include file - . It appears that _doprnt() is sufficiently universal, + . It appears that _vfprintf() is sufficiently universal, fortunately. 24-Apr-88 Dick Grune (dick) at dick diff --git a/util/misc/convert.c b/util/misc/convert.c index 6c9da3a150..387b773d4e 100644 --- a/util/misc/convert.c +++ b/util/misc/convert.c @@ -90,7 +90,7 @@ void error(const char *s, ...) va_start(ap, s); fprintf(stderr, "%s, line %d: ", filename ? filename : "standard input", EM_lineno); - doprnt(stderr, s, ap); + vfprintf(stderr, s, ap); fprintf(stderr, "\n"); errors++; va_end(ap); From 280f50ff41eb262507dff36ece4c0ced4c2856d9 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 22:56:00 +0100 Subject: [PATCH 24/29] Remove the unused _format(). --- modules/src/print/format.c | 106 ------------------------------------- modules/src/print/print.h | 2 - 2 files changed, 108 deletions(-) delete mode 100644 modules/src/print/format.c diff --git a/modules/src/print/format.c b/modules/src/print/format.c deleted file mode 100644 index fcd5bcf6fd..0000000000 --- a/modules/src/print/format.c +++ /dev/null @@ -1,106 +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 "print.h" - -static int -integral(int c) -{ - switch (c) { - case 'b': - return -2; - case 'd': - return 10; - case 'o': - return -8; - case 'u': - return -10; - case 'x': - return -16; - } - return 0; -} - -/*FORMAT1 $ - %s = char * - %l = long - %c = int - %[uxbo] = unsigned int - %d = int -$ */ -int -_format(char *buf, const char *fmt, va_list argp) -{ - const char *pf = fmt; - char *pb = buf; - - while (*pf) { - if (*pf == '%') { - int width, base, pad, npad; - char *arg; - char cbuf[2]; - char *badformat = ""; - - /* get padder */ - if (*++pf == '0') { - pad = '0'; - ++pf; - } - else - pad = ' '; - - /* get width */ - width = 0; - while (*pf >= '0' && *pf <= '9') - width = 10 * width + *pf++ - '0'; - - if (*pf == 's') { - arg = va_arg(argp, char *); - } - else - if (*pf == 'c') { - cbuf[0] = va_arg(argp, int); - cbuf[1] = '\0'; - arg = &cbuf[0]; - } - else - if (*pf == 'l') { - /* alignment ??? */ - if (base = integral(*++pf)) { - arg = long2str(va_arg(argp,long), base); - } - else { - pf--; - arg = badformat; - } - } - else - if (base = integral(*pf)) { - arg = long2str((long)va_arg(argp,int), base); - } - else - if (*pf == '%') - arg = "%"; - else - arg = badformat; - - npad = width - strlen(arg); - - while (npad-- > 0) - *pb++ = pad; - - while (*pb++ = *arg++); - pb--; - pf++; - } - else - *pb++ = *pf++; - } - return pb - buf; -} diff --git a/modules/src/print/print.h b/modules/src/print/print.h index 04a33b623e..ca193b26ca 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -9,6 +9,4 @@ #include #include -int _format(char *buf, const char *fmt, va_list ap); - #endif /* __PRINT_INCLUDED__ */ From 424dabdb5e6460307a3f41fe6fb0a7a2e8b88ec8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 23:09:33 +0100 Subject: [PATCH 25/29] Remove the print module completely, as it's now no longer used. --- lang/basic/src/bem.h | 1 - lang/basic/src/build.lua | 1 - lang/basic/src/llmess.h | 1 - lang/basic/src/parsepar.c | 1 - lang/cem/cemcom.ansi/build.lua | 1 - lang/cem/cemcom.ansi/dataflow.c | 2 +- lang/cem/cemcom.ansi/dumpidf.c | 1 - lang/cem/cemcom.ansi/error.c | 1 - lang/cem/cemcom.ansi/idf.c | 2 +- lang/cem/cemcom.ansi/stab.c | 3 ++- lang/cem/cpp.ansi/build.lua | 1 - lang/cem/cpp.ansi/error.c | 3 ++- lang/cem/cpp.ansi/init.c | 1 - lang/cem/cpp.ansi/main.c | 1 - lang/cem/cpp.ansi/preprocess.c | 1 - lang/m2/comp/build.lua | 1 - lang/m2/comp/chk_expr.c | 1 - lang/m2/comp/def.c | 2 +- lang/m2/comp/error.c | 1 - lang/m2/comp/f_info.h | 2 -- lang/m2/comp/main.c | 1 - lang/m2/comp/program.g | 1 + lang/m2/comp/stab.c | 3 ++- lang/m2/comp/typequiv.c | 2 +- lang/m2/m2mm/f_info.h | 2 -- lang/pc/comp/build.lua | 1 - lang/pc/comp/chk_expr.c | 2 +- lang/pc/comp/declar.g | 3 ++- lang/pc/comp/error.c | 1 - lang/pc/comp/main.c | 1 - lang/pc/comp/misc.c | 2 +- lang/pc/comp/node.c | 1 - lang/pc/comp/readwrite.c | 2 +- lang/pc/comp/stab.c | 4 +++- modules/src/em_code/build.lua | 1 - modules/src/em_code/em.c | 1 - modules/src/print/build.lua | 12 ------------ modules/src/print/param.h | 7 ------- modules/src/print/print.3 | 29 ----------------------------- modules/src/print/print.h | 12 ------------ util/arch/archiver.c | 1 - util/arch/build.lua | 1 - util/ego/build.lua | 1 - util/ego/em_ego/em_ego.c | 1 - util/misc/build.lua | 2 -- util/misc/convert.c | 2 +- util/opt/build.lua | 1 - 47 files changed, 20 insertions(+), 105 deletions(-) delete mode 100644 modules/src/print/build.lua delete mode 100644 modules/src/print/param.h delete mode 100644 modules/src/print/print.3 delete mode 100644 modules/src/print/print.h diff --git a/lang/basic/src/bem.h b/lang/basic/src/bem.h index e216a5f65b..09d4d21b21 100644 --- a/lang/basic/src/bem.h +++ b/lang/basic/src/bem.h @@ -9,7 +9,6 @@ #include #include #include "system.h" -#include "print.h" #include "em.h" #include "em_mes.h" diff --git a/lang/basic/src/build.lua b/lang/basic/src/build.lua index 24f38da812..4d88da3ebb 100644 --- a/lang/basic/src/build.lua +++ b/lang/basic/src/build.lua @@ -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", } diff --git a/lang/basic/src/llmess.h b/lang/basic/src/llmess.h index 02db7aefe6..a5b77ee1ac 100644 --- a/lang/basic/src/llmess.h +++ b/lang/basic/src/llmess.h @@ -6,7 +6,6 @@ #include #include "tokentab.h" #include "system.h" -#include "print.h" /* Mod van gertjan */ extern int LLsymb; diff --git a/lang/basic/src/parsepar.c b/lang/basic/src/parsepar.c index 97acc4c529..3f74e85fd6 100644 --- a/lang/basic/src/parsepar.c +++ b/lang/basic/src/parsepar.c @@ -6,7 +6,6 @@ #include "parsepar.h" #include "bem.h" #include -#include "print.h" #include "system.h" #include "util.h" diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index 51554e7283..4d941cc880 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -181,7 +181,6 @@ cprogram { "modules/src/flt_arith+lib", "modules/src/idf+lib", "modules/src/input+lib", - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", }, diff --git a/lang/cem/cemcom.ansi/dataflow.c b/lang/cem/cemcom.ansi/dataflow.c index a20e307584..c565359d5a 100644 --- a/lang/cem/cemcom.ansi/dataflow.c +++ b/lang/cem/cemcom.ansi/dataflow.c @@ -9,9 +9,9 @@ Use the compiler option --d. */ +#include #include "parameters.h" /* UF */ #include "dataflow.h" -#include "print.h" #ifdef DATAFLOW char *CurrentFunction = 0; diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index d5fe62727b..aa4594478b 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -19,7 +19,6 @@ #include "proto.h" #include "struct.h" #include "field.h" -#include "print.h" #include "Lpars.h" #include "label.h" #include "expr.h" diff --git a/lang/cem/cemcom.ansi/error.c b/lang/cem/cemcom.ansi/error.c index 39b3387989..54176715fd 100644 --- a/lang/cem/cemcom.ansi/error.c +++ b/lang/cem/cemcom.ansi/error.c @@ -26,7 +26,6 @@ #include "label.h" #include "expr.h" #include "def.h" -#include "print.h" #include "LLlex.h" /* This file contains the error-message and diagnostic diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 94d6ebb395..96fdcace07 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -7,6 +7,7 @@ #include #include +#include #include #include "parameters.h" #include @@ -26,7 +27,6 @@ #include "declarator.h" #include "decspecs.h" #include "sizes.h" -#include "print.h" #include "util.h" #include "stab.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/stab.c b/lang/cem/cemcom.ansi/stab.c index c0732f1c83..e99a7bf005 100644 --- a/lang/cem/cemcom.ansi/stab.c +++ b/lang/cem/cemcom.ansi/stab.c @@ -9,6 +9,8 @@ /* $Id$ */ +#include +#include #include "parameters.h" #ifdef DBSYMTAB @@ -30,7 +32,6 @@ #include "field.h" #include "Lpars.h" #include "level.h" -#include "print.h" #define INCR_SIZE 64 diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index 0ce67c5c79..1c4050b428 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -115,7 +115,6 @@ cprogram { "modules/src/alloc+lib", "modules/src/idf+lib", "modules/src/input+lib", - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", } diff --git a/lang/cem/cpp.ansi/error.c b/lang/cem/cpp.ansi/error.c index 0216d2f879..592f879cb6 100644 --- a/lang/cem/cpp.ansi/error.c +++ b/lang/cem/cpp.ansi/error.c @@ -14,7 +14,8 @@ #include "parameters.h" #include "arith.h" -#include "print.h" + + #include "LLlex.h" /* This file contains the (non-portable) error-message and diagnostic diff --git a/lang/cem/cpp.ansi/init.c b/lang/cem/cpp.ansi/init.c index 0c52973e52..b204851d4c 100644 --- a/lang/cem/cpp.ansi/init.c +++ b/lang/cem/cpp.ansi/init.c @@ -13,7 +13,6 @@ #include "time.h" #include "class.h" #include "macro.h" -#include "print.h" #include "error.h" #include "idf.h" #include "domacro.h" diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index bcb2edcc44..6fe6df1ef8 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -16,7 +16,6 @@ #include "file_info.h" #include "idf.h" #include "init.h" -#include "print.h" #include "options.h" #include "error.h" #include "input.h" diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index 141ef2fcec..85e79aff85 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -22,7 +22,6 @@ #include "error.h" #include "bits.h" #include "skip.h" -#include "print.h" char _obuf[OBUFSIZE]; #ifdef DOBITS diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua index 352dd9d6a3..1dd19beeb8 100644 --- a/lang/m2/comp/build.lua +++ b/lang/m2/comp/build.lua @@ -109,7 +109,6 @@ cprogram { "modules/src/flt_arith+lib", "modules/src/idf+lib", "modules/src/input+lib", - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", } diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index 14da1a2dd7..78dc09ee79 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -38,7 +38,6 @@ #include "typequiv.h" #include "misc.h" #include "lookup.h" -#include "print.h" #include "warning.h" #include "main.h" diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 16e2eb7d22..161824d796 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -10,6 +10,7 @@ /* $Id$ */ #include +#include #include #include "parameters.h" #include "debug.h" @@ -27,7 +28,6 @@ #include "def.h" #include "type.h" #include "idf.h" -#include "print.h" #include "scope.h" #include "lookup.h" #include "node.h" diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index ec5896eccc..0b2623b9e2 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -31,7 +31,6 @@ #include "input.h" #include "f_info.h" -#include "print.h" #include "LLlex.h" #include "main.h" #include "node.h" diff --git a/lang/m2/comp/f_info.h b/lang/m2/comp/f_info.h index f7f4277188..ba2ea84016 100644 --- a/lang/m2/comp/f_info.h +++ b/lang/m2/comp/f_info.h @@ -9,8 +9,6 @@ /* $Id$ */ -#include "print.h" - struct f_info { unsigned short f_lineno; char *f_filename; diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 8e4a4e95e1..111daf7989 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -18,7 +18,6 @@ #include "em_arith.h" #include "em_label.h" #include "em_code.h" -#include "print.h" #include "alloc.h" #include diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index 788a6187fb..73e444e3b1 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -11,6 +11,7 @@ { #include +#include #include #include "parameters.h" #include "debug.h" diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index e07a099faf..b6e43296a3 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -9,6 +9,8 @@ /* $Id$ */ +#include +#include #include "parameters.h" #ifdef DBSYMTAB @@ -28,7 +30,6 @@ #include "error.h" #include "stab.h" #include "main.h" -#include "print.h" #include diff --git a/lang/m2/comp/typequiv.c b/lang/m2/comp/typequiv.c index 6ad0a737b4..33b89c893b 100644 --- a/lang/m2/comp/typequiv.c +++ b/lang/m2/comp/typequiv.c @@ -16,6 +16,7 @@ #include "debug.h" #include +#include #include #include #include @@ -32,7 +33,6 @@ #include "main.h" #include "stab.h" #include "Lpars.h" -#include "print.h" #include "chk_expr.h" diff --git a/lang/m2/m2mm/f_info.h b/lang/m2/m2mm/f_info.h index 3b5d8ca1cf..7645d732ae 100644 --- a/lang/m2/m2mm/f_info.h +++ b/lang/m2/m2mm/f_info.h @@ -9,8 +9,6 @@ /* $Id$ */ -#include "print.h" - struct f_info { unsigned short f_lineno; char *f_fn; diff --git a/lang/pc/comp/build.lua b/lang/pc/comp/build.lua index 2aff765382..d8bf331697 100644 --- a/lang/pc/comp/build.lua +++ b/lang/pc/comp/build.lua @@ -160,7 +160,6 @@ cprogram { "modules/src/flt_arith+lib", "modules/src/idf+lib", "modules/src/input+lib", - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", }, diff --git a/lang/pc/comp/chk_expr.c b/lang/pc/comp/chk_expr.c index 1c8ffe8e58..85d6ceb0ef 100644 --- a/lang/pc/comp/chk_expr.c +++ b/lang/pc/comp/chk_expr.c @@ -7,11 +7,11 @@ #include "debug.h" #include +#include #include #include #include #include -#include "print.h" #include "LLlex.h" #include "Lpars.h" diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index 92bcdb5ecb..c71afbd1de 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -5,6 +5,8 @@ /* next line DEBUG */ #include "debug.h" +#include +#include #include #include #include @@ -12,7 +14,6 @@ #include #include -#include "print.h" #include "LLlex.h" #include "chk_expr.h" #include "def.h" diff --git a/lang/pc/comp/error.c b/lang/pc/comp/error.c index d5cfaf31b0..6f08108cce 100644 --- a/lang/pc/comp/error.c +++ b/lang/pc/comp/error.c @@ -18,7 +18,6 @@ #include #include #include -#include "print.h" #include "system.h" #include "LLlex.h" diff --git a/lang/pc/comp/main.c b/lang/pc/comp/main.c index bccfae5075..9cf3a40930 100644 --- a/lang/pc/comp/main.c +++ b/lang/pc/comp/main.c @@ -10,7 +10,6 @@ #include #include -#include "print.h" #include "LLlex.h" #include "Lpars.h" #include "class.h" diff --git a/lang/pc/comp/misc.c b/lang/pc/comp/misc.c index 44409013d4..c85da6b550 100644 --- a/lang/pc/comp/misc.c +++ b/lang/pc/comp/misc.c @@ -1,6 +1,7 @@ /* M I S C E L L A N E O U S R O U T I N E S */ #include +#include #include #include #include @@ -12,7 +13,6 @@ #include "main.h" #include "misc.h" #include "node.h" -#include "print.h" #include "error.h" struct idf *gen_anon_idf(void) diff --git a/lang/pc/comp/node.c b/lang/pc/comp/node.c index efd67b6e92..ee672f0b3a 100644 --- a/lang/pc/comp/node.c +++ b/lang/pc/comp/node.c @@ -6,7 +6,6 @@ #include #include #include -#include "print.h" #include "LLlex.h" #include "node.h" diff --git a/lang/pc/comp/readwrite.c b/lang/pc/comp/readwrite.c index 5f16185341..d5a1aaa816 100644 --- a/lang/pc/comp/readwrite.c +++ b/lang/pc/comp/readwrite.c @@ -1,12 +1,12 @@ /* R E A D ( L N ) & W R I T E ( L N ) */ +#include #include "parameters.h" #include "debug.h" #include #include -#include "print.h" #include "LLlex.h" #include "def.h" #include "main.h" diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index 1902d8a240..69590130bc 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -9,6 +9,9 @@ /* $Id$ */ +#include +#include +#include #include "parameters.h" #ifdef DBSYMTAB @@ -27,7 +30,6 @@ #include "scope.h" #include "main.h" #include "node.h" -#include "print.h" #define INCR_SIZE 64 diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua index 0c050fd9cf..edfa413796 100644 --- a/modules/src/em_code/build.lua +++ b/modules/src/em_code/build.lua @@ -89,7 +89,6 @@ local function build_variant(code, cflags) "modules+headers", "modules/src/alloc+lib", "modules/src/em_data+lib", - "modules/src/print+lib", "modules/src/system+lib", "modules/src/string+lib", }, diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index 610f66fdf4..992ce7e330 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -14,7 +14,6 @@ #include #include "system.h" #include "alloc.h" -#include "print.h" #include "em_arith.h" #include "insert.h" #include "em_private.h" diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua deleted file mode 100644 index ab3a022b7c..0000000000 --- a/modules/src/print/build.lua +++ /dev/null @@ -1,12 +0,0 @@ -clibrary { - name = "lib", - srcs = { - "./format.c" - }, - hdrs = { "./print.h" }, - deps = { - "./param.h", - "modules/src/string+lib", - "modules/src/system+lib", - } -} diff --git a/modules/src/print/param.h b/modules/src/print/param.h deleted file mode 100644 index 86a4148494..0000000000 --- a/modules/src/print/param.h +++ /dev/null @@ -1,7 +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$ */ - -#define SSIZE 1024 diff --git a/modules/src/print/print.3 b/modules/src/print/print.3 deleted file mode 100644 index f4b8eee5d5..0000000000 --- a/modules/src/print/print.3 +++ /dev/null @@ -1,29 +0,0 @@ -.TH PRINT 3 "$Revision$" -.ad -.SH NAME -print, fprint, doprnt -- very simple formatted-output routines -.SH SYNOPSIS -.nf -.B #include -.B #include -.PP -.B int _format(char *buf, char *format, va_lsit args) -.fi -.SH DESCRIPTION -The -.I _format -routine builds the string, but does not null-terminate it. It returns the -length of the string. -.SH FILES -.nf -~em/modules/lib/libprint.a -.fi -.SH MODULES -system(3), string(3) -.SH DIAGNOSTICS -.PP -Each illegal conversion specification is replaced by the string "". -.SH BUGS -The maximum length of the string to be printed is 1024 characters. -.SH SEE ALSO -printf(3) diff --git a/modules/src/print/print.h b/modules/src/print/print.h deleted file mode 100644 index ca193b26ca..0000000000 --- a/modules/src/print/print.h +++ /dev/null @@ -1,12 +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". - */ - -#ifndef __PRINT_INCLUDED__ -#define __PRINT_INCLUDED__ - -#include -#include - -#endif /* __PRINT_INCLUDED__ */ diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 72a423b817..3d7b218f6e 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -35,7 +35,6 @@ #include #include #include -#include "print.h" #include "system.h" #include "object.h" #include "arch.h" diff --git a/util/arch/build.lua b/util/arch/build.lua index eff8e22ad6..83ec95cb66 100644 --- a/util/arch/build.lua +++ b/util/arch/build.lua @@ -5,7 +5,6 @@ cprogram { "h+emheaders", "modules/src/data+lib", "modules/src/object+lib", - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib" }, diff --git a/util/ego/build.lua b/util/ego/build.lua index 8749fe40d8..5ddf2d2adc 100644 --- a/util/ego/build.lua +++ b/util/ego/build.lua @@ -274,7 +274,6 @@ cprogram { name = "em_ego", srcs = { "./em_ego/em_ego.c" }, deps = { - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", "modules/src/data+lib", diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 146465840e..e0a98a888f 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -15,7 +15,6 @@ #include #include "em_path.h" #include "system.h" -#include "print.h" enum { diff --git a/util/misc/build.lua b/util/misc/build.lua index e8dfbca33f..7b6b110677 100644 --- a/util/misc/build.lua +++ b/util/misc/build.lua @@ -11,7 +11,6 @@ cprogram { "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+lib_k", - "modules/src/print+lib", "modules/src/read_em+lib_ev", "modules/src/string+lib", "modules/src/system+lib", @@ -27,7 +26,6 @@ cprogram { "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+lib_e", - "modules/src/print+lib", "modules/src/read_em+lib_kv", "modules/src/string+lib", "modules/src/system+lib", diff --git a/util/misc/convert.c b/util/misc/convert.c index 387b773d4e..0fedc75621 100644 --- a/util/misc/convert.c +++ b/util/misc/convert.c @@ -16,9 +16,9 @@ static char rcsid[] = "$Id$"; linked. */ +#include #include #include -#include "print.h" #include "em_pseu.h" #include "em_mnem.h" #include "em_spec.h" diff --git a/util/opt/build.lua b/util/opt/build.lua index ec213d879b..780fdae8de 100644 --- a/util/opt/build.lua +++ b/util/opt/build.lua @@ -81,7 +81,6 @@ local function variant(name, cflags) headers, "h+emheaders", "modules/src/alloc+lib", - "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", "modules/src/data+lib", From a5c1726463792fec80ac355379022f662565510a Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 8 Dec 2024 23:55:00 +0100 Subject: [PATCH 26/29] Rip out Salloc() and replace it with strdup(). --- lang/cem/cemcom.ansi/LLlex.c | 7 +- lang/cem/cemcom.ansi/LLmessage.c | 5 +- lang/cem/cemcom.ansi/main.c | 2 +- lang/cem/cemcom/LLlex.c | 4 +- lang/cem/cemcom/LLmessage.c | 4 +- lang/cem/cemcom/arith.c | 2 +- lang/cem/cemcom/idf.c | 2 +- lang/cem/cemcom/input.c | 2 +- lang/cem/cpp.ansi/input.c | 2 +- lang/cem/cpp.ansi/options.c | 4 +- lang/m2/comp/LLlex.c | 1033 ++++++++++++--------- lang/m2/comp/LLmessage.c | 5 +- lang/m2/comp/chk_expr.c | 10 +- lang/m2/comp/def.c | 8 +- lang/m2/comp/defmodule.c | 2 +- lang/m2/comp/enter.c | 3 +- lang/m2/comp/program.g | 2 +- lang/m2/m2mm/LLlex.c | 2 +- lang/m2/m2mm/main.c | 40 +- lang/pc/comp/LLlex.c | 6 +- lang/pc/comp/LLmessage.c | 6 +- lang/pc/comp/cstoper.c | 2 +- lang/pc/comp/misc.c | 2 +- mach/sparc/ce/ce.src/C_pro.c | 2 +- modules/src/alloc/Salloc.c | 33 - modules/src/alloc/alloc.3 | 5 - modules/src/alloc/alloc.h | 3 - modules/src/alloc/build.lua | 1 - util/ceg/EM_parser/common/action.c | 2 +- util/ceg/EM_parser/obj_EM_pars/dist.c | 4 +- util/ceg/as_parser/help.c | 8 +- util/ceg/assemble/obj_assemble/assemble.c | 4 +- util/cmisc/cclash.c | 15 +- util/cmisc/cid.c | 14 +- util/cmisc/prid.c | 12 +- util/cmisc/tabgen.c | 16 +- util/grind/c.c | 2 +- util/grind/modula-2.c | 2 +- util/grind/pascal.c | 2 +- util/grind/symbol.c | 2 +- 40 files changed, 659 insertions(+), 623 deletions(-) delete mode 100644 modules/src/alloc/Salloc.c diff --git a/lang/cem/cemcom.ansi/LLlex.c b/lang/cem/cemcom.ansi/LLlex.c index e85637f40a..177a56e960 100644 --- a/lang/cem/cemcom.ansi/LLlex.c +++ b/lang/cem/cemcom.ansi/LLlex.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "parameters.h" #include "input.h" #include "arith.h" @@ -363,7 +364,7 @@ int GetToken(struct token* ptok) if ((flags & FLG_DOTSEEN) || (flags & FLG_ESEEN && !(ch == '0' && (*np == 'x' || *np == 'X')))) { - ptok->tk_fval = Salloc("0.0", (unsigned)4); + ptok->tk_fval = strdup("0.0"); ptok->tk_fund = DOUBLE; return ptok->tk_symb = FLOATING; } @@ -584,11 +585,11 @@ static void strflt2tok(char fltbuf[], struct token* ptok) if (malformed) { lexerror("malformed floating constant"); - ptok->tk_fval = Salloc("0.0", (unsigned)4); + ptok->tk_fval = strdup("0.0"); } else { - ptok->tk_fval = Salloc(fltbuf, (unsigned)(cp - fltbuf + 1)); + ptok->tk_fval = strdup(fltbuf); } } diff --git a/lang/cem/cemcom.ansi/LLmessage.c b/lang/cem/cemcom.ansi/LLmessage.c index 291d6d5f13..94ff745717 100644 --- a/lang/cem/cemcom.ansi/LLmessage.c +++ b/lang/cem/cemcom.ansi/LLmessage.c @@ -5,6 +5,7 @@ /* $Id$ */ /* PARSER ERROR ADMINISTRATION */ +#include #include #include "idf.h" #include "arith.h" @@ -57,7 +58,7 @@ static void insert_token(int tk) dot.tk_idf = str2idf("int", 0); break; case STRING: - dot.tk_bts = Salloc("", 1); + dot.tk_bts = strdup(""); dot.tk_len = 1; break; case INTEGER: @@ -65,7 +66,7 @@ static void insert_token(int tk) dot.tk_ival = 1; break; case FLOATING: - dot.tk_fval = Salloc("0.0", 4); + dot.tk_fval = strdup("0.0"); break; } } diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 26e83a52aa..60c40a378c 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -164,7 +164,7 @@ void compile(int argc, char *argv[]) FileName = source = argv[0]; else { source = 0; - FileName = Salloc("standard input", (unsigned) 16); + FileName = strdup("standard input"); } if (!InsertFile(source, (char **) 0, &result)) /* read the source file */ diff --git a/lang/cem/cemcom/LLlex.c b/lang/cem/cemcom/LLlex.c index 8f0f5dccea..0e362e46ca 100644 --- a/lang/cem/cemcom/LLlex.c +++ b/lang/cem/cemcom/LLlex.c @@ -422,10 +422,10 @@ GetToken(ptok) buf[0] = '-'; /* good heavens... */ if (np == &buf[NUMSIZE+1]) { lexerror("floating constant too long"); - ptok->tk_fval = Salloc("-0.0",(unsigned) 5) + 1; + ptok->tk_fval = strdup("-0.0") + 1; } else - ptok->tk_fval = Salloc(buf,(unsigned) (np - buf)) + 1; + ptok->tk_fval = strdup(buf) + 1; return ptok->tk_symb = FLOATING; #endif /* NOFLOAT */ } diff --git a/lang/cem/cemcom/LLmessage.c b/lang/cem/cemcom/LLmessage.c index d33623d366..16e6c6be07 100644 --- a/lang/cem/cemcom/LLmessage.c +++ b/lang/cem/cemcom/LLmessage.c @@ -51,7 +51,7 @@ insert_token(tk) dot.tk_idf = str2idf("int"); break; case STRING: - dot.tk_bts = Salloc("", 1); + dot.tk_bts = strdup(""); dot.tk_len = 1; break; case INTEGER: @@ -60,7 +60,7 @@ insert_token(tk) break; #ifndef NOFLOAT case FLOATING: - dot.tk_fval = Salloc("0.0", 4); + dot.tk_fval = strdup("0.0"); break; #endif /* NOFLOAT */ } diff --git a/lang/cem/cemcom/arith.c b/lang/cem/cemcom/arith.c index 26b192a605..3e27cadf26 100644 --- a/lang/cem/cemcom/arith.c +++ b/lang/cem/cemcom/arith.c @@ -286,7 +286,7 @@ int2float(expp, tp) exp = *expp; exp->ex_type = tp; exp->ex_class = Float; - exp->FL_VALUE = Salloc(buf, (unsigned)strlen(buf)+2) + 1; + exp->FL_VALUE = strdup(buf) + 1; exp->FL_DATLAB = 0; } else *expp = arith2arith(tp, INT2FLOAT, *expp); diff --git a/lang/cem/cemcom/idf.c b/lang/cem/cemcom/idf.c index 8b089f94e3..1485242127 100644 --- a/lang/cem/cemcom/idf.c +++ b/lang/cem/cemcom/idf.c @@ -91,7 +91,7 @@ idf_hashed(tg, size, hc) notch = new_idf(); notch->next = *hook; *hook = notch; /* hooked in */ - notch->id_text = Salloc(tg, (unsigned) size); + notch->id_text = strdup(tg); #ifndef NOPP notch->id_resmac = 0; #endif /* NOPP */ diff --git a/lang/cem/cemcom/input.c b/lang/cem/cemcom/input.c index c35ea4d727..c94d9c045c 100644 --- a/lang/cem/cemcom/input.c +++ b/lang/cem/cemcom/input.c @@ -43,7 +43,7 @@ getwdir(fn) return ""; if (p) { *p = '\0'; - fn = Salloc(fn, p - &fn[0] + 1); + fn = strdup(fn); *p = '/'; return fn; } diff --git a/lang/cem/cpp.ansi/input.c b/lang/cem/cpp.ansi/input.c index 52c71c3127..92b62854cd 100644 --- a/lang/cem/cpp.ansi/input.c +++ b/lang/cem/cpp.ansi/input.c @@ -36,7 +36,7 @@ char* getwdir(char* fn) if (p) { *p = '\0'; - fn = Salloc(fn, (unsigned)(p - &fn[0] + 1)); + fn = strdup(fn); *p = '/'; return fn; } diff --git a/lang/cem/cpp.ansi/options.c b/lang/cem/cpp.ansi/options.c index f89e6a12b9..382ac06873 100644 --- a/lang/cem/cpp.ansi/options.c +++ b/lang/cem/cpp.ansi/options.c @@ -73,12 +73,12 @@ void do_option(char *text) ++cp; if (!*cp) { /* -Dname */ maclen = 1; - mactext = Salloc("1", 2); + mactext = strdup("1"); } else if (*cp == '=') { /* -Dname=text */ *cp++ = '\0'; /* end of name */ maclen = strlen(cp); - mactext = Salloc(cp, maclen + 1); + mactext = strdup(cp); } else { /* -Dname?? */ error("malformed option -D%s", text); diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index 7729d34c52..46730b22ed 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -9,110 +9,123 @@ /* $Id$ */ -#include -#include -#include +#include +#include +#include #include "parameters.h" -#include "debug.h" - -#include "alloc.h" -#include "em_arith.h" -#include "em_label.h" -#include "assert.h" - -#include "LLlex.h" -#include "input.h" -#include "f_info.h" -#include "Lpars.h" -#include "class.h" -#include "error.h" -#include "idf.h" -#include "def.h" -#include "type.h" -#include "warning.h" -#include "defmodule.h" - -t_token dot, - aside; -struct type *toktype; -int idfsize = IDFSIZE; -int ForeignFlag; +#include "debug.h" + +#include "alloc.h" +#include "em_arith.h" +#include "em_label.h" +#include "assert.h" + +#include "LLlex.h" +#include "input.h" +#include "f_info.h" +#include "Lpars.h" +#include "class.h" +#include "error.h" +#include "idf.h" +#include "def.h" +#include "type.h" +#include "warning.h" +#include "defmodule.h" + +t_token dot, aside; +struct type* toktype; +int idfsize = IDFSIZE; +int ForeignFlag; #ifdef DEBUG -extern int cntlines; +extern int cntlines; #endif -int token_nmb = 0; -int tk_nmb_at_last_syn_err = -ERR_SHADOW; +int token_nmb = 0; +int tk_nmb_at_last_syn_err = -ERR_SHADOW; -extern char options[]; -extern int flt_status; +extern char options[]; +extern int flt_status; static void SkipComment(void) { /* Skip Modula-2 comments (* ... *). - Note that comments may be nested (par. 3.5). + Note that comments may be nested (par. 3.5). */ int ch, c; int CommentLevel = 0; LoadChar(ch); - if (ch == '$') { + if (ch == '$') + { LoadChar(ch); - switch(ch) { - case 'F': - /* Foreign; This definition module has an - implementation in another language. - In this case, don't generate prefixes in front - of the names. Also, don't generate call to - initialization routine. - */ - ForeignFlag = D_FOREIGN; - break; - case 'U': - inidf['_'] = 1; - break; - case 'A': /* Extra array bound checks, on or off */ - case 'R': /* Range checks, on or off */ + switch (ch) { - int on_on_minus = ch == 'R'; - LoadChar(c); - if (c == '-') { - options[ch] = on_on_minus; + case 'F': + /* Foreign; This definition module has an + implementation in another language. + In this case, don't generate prefixes in front + of the names. Also, don't generate call to + initialization routine. + */ + ForeignFlag = D_FOREIGN; break; - } - if (c == '+') { - options[ch] = !on_on_minus; + case 'U': + inidf['_'] = 1; break; + case 'A': /* Extra array bound checks, on or off */ + case 'R': /* Range checks, on or off */ + { + int on_on_minus = ch == 'R'; + LoadChar(c); + if (c == '-') + { + options[ch] = on_on_minus; + break; + } + if (c == '+') + { + options[ch] = !on_on_minus; + break; + } + ch = c; } - ch = c; - } - /* fall through */ - default: - break; + /* fall through */ + default: + break; } } - for (;;) { - if (!(ch & 0200) && class(ch) == STNL) { + for (;;) + { + if (!(ch & 0200) && class(ch) == STNL) + { LineNumber++; #ifdef DEBUG cntlines++; #endif } - else if (ch == '(') { + else if (ch == '(') + { LoadChar(ch); - if (ch == '*') CommentLevel++; - else continue; + if (ch == '*') + CommentLevel++; + else + continue; } - else if (ch == '*') { + else if (ch == '*') + { LoadChar(ch); - if (ch == ')') { + if (ch == ')') + { CommentLevel--; - if (CommentLevel < 0) break; + if (CommentLevel < 0) + break; } - else continue; + else + continue; } - else if (ch == EOI) { + else if (ch == EOI) + { lexerror("unterminated comment"); PushBack(); break; @@ -121,20 +134,21 @@ static void SkipComment(void) } } -static struct string *GetString(int upto) +static struct string* GetString(int upto) { /* Read a Modula-2 string, delimited by the character "upto". - */ + */ int ch; - struct string *str = (struct string *) - malloc((unsigned) sizeof(struct string)); - char *p; + struct string* str = (struct string*)malloc((unsigned)sizeof(struct string)); + char* p; int len; - + len = ISTRSIZE; - str->s_str = p = malloc((unsigned int) ISTRSIZE); - while (LoadChar(ch), ch != upto) { - if (!(ch & 0200) && class(ch) == STNL) { + str->s_str = p = malloc((unsigned int)ISTRSIZE); + while (LoadChar(ch), ch != upto) + { + if (!(ch & 0200) && class(ch) == STNL) + { lexerror("newline in string"); LineNumber++; #ifdef DEBUG @@ -142,36 +156,40 @@ static struct string *GetString(int upto) #endif break; } - if (ch == EOI) { + if (ch == EOI) + { lexerror("end-of-file in string"); break; } *p++ = ch; - if (p - str->s_str == len) { - str->s_str = realloc(str->s_str, - (unsigned int) len + RSTRSIZE); + if (p - str->s_str == len) + { + str->s_str = realloc(str->s_str, (unsigned int)len + RSTRSIZE); p = str->s_str + len; len += RSTRSIZE; } } str->s_length = p - str->s_str; - len = (str->s_length+(int)word_size) & ~((int)word_size-1); - while (p - str->s_str < len) { + len = (str->s_length + (int)word_size) & ~((int)word_size - 1); + while (p - str->s_str < len) + { *p++ = '\0'; } - str->s_str = realloc(str->s_str, (unsigned) len); - if (str->s_length == 0) str->s_length = 1; + str->s_str = realloc(str->s_str, (unsigned)len); + if (str->s_length == 0) + str->s_length = 1; /* ??? string length at least 1 ??? */ return str; } -static char *s_error = "illegal line directive"; +static char* s_error = "illegal line directive"; static int getch(void) { int ch; - while (LoadChar(ch), (ch & 0200) && ch != EOI) { + while (LoadChar(ch), (ch & 0200) && ch != EOI) + { error("non-ascii '\\%03o' read", ch & 0377); } return ch; @@ -180,57 +198,68 @@ static int getch(void) void CheckForLineDirective(void) { int ch = getch(); - int i = 0; - char buf[IDFSIZE]; - char *c = buf; - + int i = 0; + char buf[IDFSIZE]; + char* c = buf; - for (;;) { - if (ch != '#') { + for (;;) + { + if (ch != '#') + { PushBack(); return; } - do { /* - * Skip to next digit - * Do not skip newlines - */ + do + { /* + * Skip to next digit + * Do not skip newlines + */ ch = getch(); - if (class(ch) == STNL || class(ch) == STEOI) { + if (class(ch) == STNL || class(ch) == STEOI) + { LineNumber++; error(s_error); return; } } while (class(ch) != STNUM); - while (class(ch) == STNUM) { - i = i*10 + (ch - '0'); + while (class(ch) == STNUM) + { + i = i * 10 + (ch - '0'); ch = getch(); } while (ch != '"' && class(ch) != STNL && class(ch) != STEOI) ch = getch(); - if (ch == '"') { + if (ch == '"') + { c = buf; - do { + do + { ch = getch(); - if (c < &buf[IDFSIZE]) *c++ = ch; - if (class(ch) == STNL || class(ch) == STEOI) { + if (c < &buf[IDFSIZE]) + *c++ = ch; + if (class(ch) == STNL || class(ch) == STEOI) + { LineNumber++; error(s_error); return; } } while (ch != '"'); *--c = '\0'; - do { + do + { ch = getch(); } while (class(ch) != STNL && class(ch) != STEOI); /* * Remember the file name */ - if (class(ch) == STNL && strcmp(FileName,buf)) { - FileName = Salloc(buf,(unsigned) strlen(buf) + 1); + if (class(ch) == STNL && strcmp(FileName, buf)) + { + FileName = strdup(buf); WorkingDir = getwdir(FileName); } } - if (class(ch) == STEOI) { + if (class(ch) == STEOI) + { error(s_error); return; } @@ -243,8 +272,10 @@ static void CheckForLet(void) int ch; LoadChar(ch); - if (ch != EOI) { - if (class(ch) == STIDF) { + if (ch != EOI) + { + if (class(ch) == STIDF) + { lexerror("token separator required between identifier and number"); } PushBack(); @@ -254,15 +285,16 @@ static void CheckForLet(void) int LLlex(void) { /* LLlex() is the Lexical Analyzer. - The putting aside of tokens is taken into account. + The putting aside of tokens is taken into account. */ - t_token *tk = ˙ + t_token* tk = ˙ char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 2]; int ch, nch; toktype = error_type; - if (ASIDE) { /* a token is put aside */ + if (ASIDE) + { /* a token is put aside */ *tk = aside; ASIDE = 0; return tk->tk_symb; @@ -273,397 +305,482 @@ int LLlex(void) ch = getch(); tk->tk_lineno = LineNumber; - switch (class(ch)) { + switch (class(ch)) + { - case STNL: - LineNumber++; + case STNL: + LineNumber++; #ifdef DEBUG - cntlines++; + cntlines++; #endif - CheckForLineDirective(); - goto again; + CheckForLineDirective(); + goto again; - case STSKIP: - goto again; + case STSKIP: + goto again; - case STGARB: - if ((unsigned) ch - 040 < 0137) { - lexerror("garbage char %c", ch); - } - else lexerror("garbage char \\%03o", ch); - goto again; + case STGARB: + if ((unsigned)ch - 040 < 0137) + { + lexerror("garbage char %c", ch); + } + else + lexerror("garbage char \\%03o", ch); + goto again; + + case STSIMP: + if (ch == '(') + { + LoadChar(nch); + if (nch == '*') + { + SkipComment(); + goto again; + } + PushBack(); + } + if (ch == '&') + return tk->tk_symb = AND; + if (ch == '~') + return tk->tk_symb = NOT; + return tk->tk_symb = ch; - case STSIMP: - if (ch == '(') { + case STCOMP: LoadChar(nch); - if (nch == '*') { - SkipComment(); - goto again; - } - PushBack(); - } - if (ch == '&') return tk->tk_symb = AND; - if (ch == '~') return tk->tk_symb = NOT; - return tk->tk_symb = ch; + switch (ch) + { - case STCOMP: - LoadChar(nch); - switch (ch) { + case '.': + if (nch == '.') + { + return tk->tk_symb = UPTO; + } + break; - case '.': - if (nch == '.') { - return tk->tk_symb = UPTO; - } - break; + case ':': + if (nch == '=') + { + return tk->tk_symb = BECOMES; + } + break; - case ':': - if (nch == '=') { - return tk->tk_symb = BECOMES; - } - break; + case '<': + if (nch == '=') + { + return tk->tk_symb = LESSEQUAL; + } + if (nch == '>') + { + return tk->tk_symb = '#'; + } + break; - case '<': - if (nch == '=') { - return tk->tk_symb = LESSEQUAL; - } - if (nch == '>') { - return tk->tk_symb = '#'; - } - break; + case '>': + if (nch == '=') + { + return tk->tk_symb = GREATEREQUAL; + } + break; - case '>': - if (nch == '=') { - return tk->tk_symb = GREATEREQUAL; + default: + crash("(LLlex, STCOMP)"); } - break; + PushBack(); + return tk->tk_symb = ch; - default : - crash("(LLlex, STCOMP)"); - } - PushBack(); - return tk->tk_symb = ch; + case STIDF: + { + char* tag = &buf[0]; + struct idf* id; - case STIDF: - { - char *tag = &buf[0]; - struct idf *id; + do + { + if (tag - buf < idfsize) + *tag++ = ch; + LoadChar(ch); + if (ch == '_' && *(tag - 1) == '_') + { + lexerror("an identifier may not contain two consecutive underscores"); + } + } while (in_idf(ch)); - do { - if (tag - buf < idfsize) *tag++ = ch; - LoadChar(ch); - if (ch == '_' && *(tag-1) == '_') { - lexerror("an identifier may not contain two consecutive underscores"); + PushBack(); + *tag = '\0'; + if (*(tag - 1) == '_') + { + lexerror("last character of an identifier may not be an underscore"); } - } while(in_idf(ch)); - PushBack(); - *tag = '\0'; - if (*(tag - 1) == '_') { - lexerror("last character of an identifier may not be an underscore"); + tk->TOK_IDF = id = str2idf(buf, 1); + return tk->tk_symb = id->id_reserved ? id->id_reserved : IDENT; } - tk->TOK_IDF = id = str2idf(buf, 1); - return tk->tk_symb = id->id_reserved ? id->id_reserved : IDENT; - } - - case STSTR: { - struct string *str = GetString(ch); - - if (str->s_length == 1) { - tk->TOK_INT = *(str->s_str) & 0377; - toktype = char_type; - free(str->s_str); - free((char *) str); - } - else { - tk->tk_data.tk_str = str; - if (! fit((arith)(str->s_length), (int) word_size)) { - lexerror("string too long"); + case STSTR: + { + struct string* str = GetString(ch); + + if (str->s_length == 1) + { + tk->TOK_INT = *(str->s_str) & 0377; + toktype = char_type; + free(str->s_str); + free((char*)str); } - toktype = standard_type(T_STRING, 1, (arith)(str->s_length)); - } - return tk->tk_symb = STRING; - } - - case STNUM: - { - /* The problem arising with the "parsing" of a number - is that we don't know the base in advance so we - have to read the number with the help of a rather - complex finite automaton. - */ - enum statetp {Oct,OptHex,Hex,Dec,OctEndOrHex,End,OptReal,Real}; - enum statetp state; - int base = 8; - char *np = &buf[0]; - - *np++ = ch; - state = is_oct(ch) ? Oct : Dec; - LoadChar(ch); - for (;;) { - switch(state) { - case Oct: - while (is_oct(ch)) { - if (np < &buf[NUMSIZE]) *np++ = ch; - LoadChar(ch); - } - if (ch == 'B' || ch == 'C') { - state = OctEndOrHex; - break; - } - /* Fall Through */ - case Dec: - base = 10; - while (is_dig(ch)) { - if (np < &buf[NUMSIZE]) { - *np++ = ch; - } - LoadChar(ch); + else + { + tk->tk_data.tk_str = str; + if (!fit((arith)(str->s_length), (int)word_size)) + { + lexerror("string too long"); } - if (ch == 'D') state = OptHex; - else if (is_hex(ch)) state = Hex; - else if (ch == '.') state = OptReal; - else { - state = End; - if (ch == 'H') base = 16; - else PushBack(); - } - break; + toktype = standard_type(T_STRING, 1, (arith)(str->s_length)); + } + return tk->tk_symb = STRING; + } - case OptHex: - LoadChar(ch); - if (is_hex(ch)) { - if (np < &buf[NUMSIZE]) *np++ = 'D'; - state = Hex; - } - else { - state = End; - ch = 'D'; - PushBack(); - } - break; + case STNUM: + { + /* The problem arising with the "parsing" of a number + is that we don't know the base in advance so we + have to read the number with the help of a rather + complex finite automaton. + */ + enum statetp + { + Oct, + OptHex, + Hex, + Dec, + OctEndOrHex, + End, + OptReal, + Real + }; + enum statetp state; + int base = 8; + char* np = &buf[0]; + + *np++ = ch; + state = is_oct(ch) ? Oct : Dec; + LoadChar(ch); + for (;;) + { + switch (state) + { + case Oct: + while (is_oct(ch)) + { + if (np < &buf[NUMSIZE]) + *np++ = ch; + LoadChar(ch); + } + if (ch == 'B' || ch == 'C') + { + state = OctEndOrHex; + break; + } + /* Fall Through */ + case Dec: + base = 10; + while (is_dig(ch)) + { + if (np < &buf[NUMSIZE]) + { + *np++ = ch; + } + LoadChar(ch); + } + if (ch == 'D') + state = OptHex; + else if (is_hex(ch)) + state = Hex; + else if (ch == '.') + state = OptReal; + else + { + state = End; + if (ch == 'H') + base = 16; + else + PushBack(); + } + break; - case Hex: - while (is_hex(ch)) { - if (np < &buf[NUMSIZE]) *np++ = ch; - LoadChar(ch); - } - base = 16; - state = End; - if (ch != 'H') { - lexerror("H expected after hex number"); - PushBack(); - } - break; + case OptHex: + LoadChar(ch); + if (is_hex(ch)) + { + if (np < &buf[NUMSIZE]) + *np++ = 'D'; + state = Hex; + } + else + { + state = End; + ch = 'D'; + PushBack(); + } + break; + + case Hex: + while (is_hex(ch)) + { + if (np < &buf[NUMSIZE]) + *np++ = ch; + LoadChar(ch); + } + base = 16; + state = End; + if (ch != 'H') + { + lexerror("H expected after hex number"); + PushBack(); + } + break; - case OctEndOrHex: - if (np < &buf[NUMSIZE]) *np++ = ch; - LoadChar(ch); - if (ch == 'H') { - base = 16; - state = End; - break; - } - if (is_hex(ch)) { - state = Hex; - break; - } - PushBack(); - ch = *--np; - *np++ = '\0'; - /* Fall through */ - - case End: { - int ovfl = 0; - - *np = '\0'; - if (np >= &buf[NUMSIZE]) { - tk->TOK_INT = 1; - lexerror("constant too long"); - } - else { - /* The upperbound will be the same as - when computed with something like - max(unsigned long) / base (when base - is even). The problem is that - unsigned long or unsigned arith is - not accepted by all compilers - */ - arith ubound = max_int[sizeof(arith)] - / (base >> 1); - np = &buf[0]; - while (*np == '0') np++; - tk->TOK_INT = 0; - while (*np) { - int c; - - if (is_dig(*np)) { - c = *np++ - '0'; + case OctEndOrHex: + if (np < &buf[NUMSIZE]) + *np++ = ch; + LoadChar(ch); + if (ch == 'H') + { + base = 16; + state = End; + break; } - else { - assert(is_hex(*np)); - c = *np++ - 'A' + 10; + if (is_hex(ch)) + { + state = Hex; + break; } - if (tk->TOK_INT < 0 || - tk->TOK_INT > ubound) { - ovfl++; + PushBack(); + ch = *--np; + *np++ = '\0'; + /* Fall through */ + + case End: + { + int ovfl = 0; + + *np = '\0'; + if (np >= &buf[NUMSIZE]) + { + tk->TOK_INT = 1; + lexerror("constant too long"); } - tk->TOK_INT = tk->TOK_INT*base; - if (tk->TOK_INT < 0 && - tk->TOK_INT + c >= 0) { - ovfl++; + else + { + /* The upperbound will be the same as + when computed with something like + max(unsigned long) / base (when base + is even). The problem is that + unsigned long or unsigned arith is + not accepted by all compilers + */ + arith ubound = max_int[sizeof(arith)] / (base >> 1); + np = &buf[0]; + while (*np == '0') + np++; + tk->TOK_INT = 0; + while (*np) + { + int c; + + if (is_dig(*np)) + { + c = *np++ - '0'; + } + else + { + assert(is_hex(*np)); + c = *np++ - 'A' + 10; + } + if (tk->TOK_INT < 0 || tk->TOK_INT > ubound) + { + ovfl++; + } + tk->TOK_INT = tk->TOK_INT * base; + if (tk->TOK_INT < 0 && tk->TOK_INT + c >= 0) + { + ovfl++; + } + tk->TOK_INT += c; + } } - tk->TOK_INT += c; - } - } - toktype = card_type; - if (ch == 'C' && base == 8) { - toktype = char_type; - if (ovfl != 0 || tk->TOK_INT>255 || - tk->TOK_INT < 0) { -lexwarning(W_ORDINARY, "character constant out of range"); + toktype = card_type; + if (ch == 'C' && base == 8) + { + toktype = char_type; + if (ovfl != 0 || tk->TOK_INT > 255 || tk->TOK_INT < 0) + { + lexwarning(W_ORDINARY, "character constant out of range"); + } + CheckForLet(); + return tk->tk_symb = INTEGER; + } + if (options['l']) + { + if (base != 10) + { + LoadChar(ch); + if (ch != 'D') + { + PushBack(); + } + } + } + if (ch == 'D' && (options['l'] || base == 10)) + { + if (options['l']) + { + /* Local extension: LONGCARD exists, + so internally also longintorcard_type + exists. + */ + toktype = longcard_type; + if (ovfl == 0 && tk->TOK_INT >= 0 + && tk->TOK_INT <= max_int[(int)long_size]) + { + toktype = longintorcard_type; + } + else if (!chk_bounds( + tk->TOK_INT, full_mask[(int)long_size], T_CARDINAL)) + { + ovfl = 1; + } + } + else + { + if (ovfl != 0 || tk->TOK_INT > max_int[(int)long_size] + || tk->TOK_INT < 0) + { + ovfl = 1; + } + toktype = longint_type; + } + } + else if ( + ovfl == 0 && tk->TOK_INT >= 0 && tk->TOK_INT <= max_int[(int)int_size]) + { + toktype = intorcard_type; + } + else if (!chk_bounds(tk->TOK_INT, full_mask[(int)int_size], T_CARDINAL)) + { + ovfl = 1; + } + if (ovfl) + lexwarning(W_ORDINARY, "overflow in constant"); + CheckForLet(); + return tk->tk_symb = INTEGER; } - CheckForLet(); - return tk->tk_symb = INTEGER; - } - if (options['l']) { - if (base != 10) { + + case OptReal: + /* The '.' could be the first of the '..' + token. At this point, we need a + look-ahead of two characters. + */ LoadChar(ch); - if (ch != 'D') { + if (ch == '.') + { + /* Indeed the '..' token + */ + PushBack(); PushBack(); + state = End; + base = 10; + break; } - } - } - if (ch == 'D' && (options['l'] || base == 10)) { - if (options['l']) { - /* Local extension: LONGCARD exists, - so internally also longintorcard_type - exists. - */ - toktype = longcard_type; - if (ovfl == 0 && tk->TOK_INT >= 0 && - tk->TOK_INT<=max_int[(int)long_size]) { - toktype = longintorcard_type; - } - else if (! chk_bounds(tk->TOK_INT, - full_mask[(int)long_size], - T_CARDINAL)) { - ovfl = 1; - } - } - else { - if (ovfl != 0 || - tk->TOK_INT > max_int[(int)long_size] || - tk->TOK_INT < 0) { - ovfl = 1; - } - toktype = longint_type; - } - } - else if (ovfl == 0 && tk->TOK_INT >= 0 && - tk->TOK_INT<=max_int[(int)int_size]) { - toktype = intorcard_type; - } - else if (! chk_bounds(tk->TOK_INT, - full_mask[(int)int_size], - T_CARDINAL)) { - ovfl = 1; - } - if (ovfl) -lexwarning(W_ORDINARY, "overflow in constant"); - CheckForLet(); - return tk->tk_symb = INTEGER; + state = Real; + break; } - - case OptReal: - /* The '.' could be the first of the '..' - token. At this point, we need a - look-ahead of two characters. - */ - LoadChar(ch); - if (ch == '.') { - /* Indeed the '..' token - */ - PushBack(); - PushBack(); - state = End; - base = 10; + if (state == Real) break; - } - state = Real; - break; } - if (state == Real) break; - } - - /* a real real constant */ - if (np < &buf[NUMSIZE]) *np++ = '.'; - toktype = real_type; + /* a real real constant */ + if (np < &buf[NUMSIZE]) + *np++ = '.'; - while (is_dig(ch)) { - /* Fractional part - */ - if (np < &buf[NUMSIZE]) *np++ = ch; - LoadChar(ch); - } + toktype = real_type; - if (ch == 'D') { - toktype = longreal_type; - LoadChar(ch); - if (ch == '+' || ch == '-' || is_dig(ch)) { - ch = 'E'; - PushBack(); + while (is_dig(ch)) + { + /* Fractional part + */ + if (np < &buf[NUMSIZE]) + *np++ = ch; + LoadChar(ch); } - } - if (ch == 'E') { - /* Scale factor - */ - if (np < &buf[NUMSIZE]) *np++ = ch; - LoadChar(ch); - if (ch == '+' || ch == '-') { - /* Signed scalefactor - */ - if (np < &buf[NUMSIZE]) *np++ = ch; + + if (ch == 'D') + { + toktype = longreal_type; LoadChar(ch); + if (ch == '+' || ch == '-' || is_dig(ch)) + { + ch = 'E'; + PushBack(); + } } - if (is_dig(ch)) { - do { - if (np < &buf[NUMSIZE]) *np++ = ch; + if (ch == 'E') + { + /* Scale factor + */ + if (np < &buf[NUMSIZE]) + *np++ = ch; + LoadChar(ch); + if (ch == '+' || ch == '-') + { + /* Signed scalefactor + */ + if (np < &buf[NUMSIZE]) + *np++ = ch; LoadChar(ch); - } while (is_dig(ch)); - } - else { - lexerror("bad scale factor"); + } + if (is_dig(ch)) + { + do + { + if (np < &buf[NUMSIZE]) + *np++ = ch; + LoadChar(ch); + } while (is_dig(ch)); + } + else + { + lexerror("bad scale factor"); + } } - } - *np++ = '\0'; - PushBack(); + *np++ = '\0'; + PushBack(); - tk->tk_data.tk_real = new_real(); - if (np >= &buf[NUMSIZE]) { - tk->TOK_RSTR = Salloc("0.0", 4); - lexerror("real constant too long"); - } - else tk->TOK_RSTR = Salloc(buf, (unsigned) (np - buf)); - CheckForLet(); - flt_str2flt(tk->TOK_RSTR, &(tk->TOK_RVAL)); - if (flt_status == FLT_OVFL) { -lexwarning(W_ORDINARY, "overflow in floating point constant"); - } - return tk->tk_symb = REAL; + tk->tk_data.tk_real = new_real(); + if (np >= &buf[NUMSIZE]) + { + tk->TOK_RSTR = strdup("0.0"); + lexerror("real constant too long"); + } + else + tk->TOK_RSTR = strdup(buf); + CheckForLet(); + flt_str2flt(tk->TOK_RSTR, &(tk->TOK_RVAL)); + if (flt_status == FLT_OVFL) + { + lexwarning(W_ORDINARY, "overflow in floating point constant"); + } + return tk->tk_symb = REAL; - UNREACHABLE_CODE; - } + UNREACHABLE_CODE; + } - case STEOI: - return tk->tk_symb = -1; + case STEOI: + return tk->tk_symb = -1; - case STCHAR: - default: - crash("(LLlex) Impossible character class"); - UNREACHABLE_CODE; + case STCHAR: + default: + crash("(LLlex) Impossible character class"); + UNREACHABLE_CODE; } UNREACHABLE_CODE; } diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index 56ec472bb6..f9c8ce5626 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "parameters.h" #include "idf.h" @@ -51,14 +52,14 @@ void LLmessage(int tk) dotp->tk_data.tk_str = (struct string *) malloc(sizeof (struct string)); dotp->TOK_SLE = 1; - dotp->TOK_STR = Salloc("", 1); + dotp->TOK_STR = strdup(""); break; case INTEGER: dotp->TOK_INT = 1; break; case REAL: dotp->tk_data.tk_real = new_real(); - dotp->TOK_RSTR = Salloc("0.0", 4); + dotp->TOK_RSTR = strdup("0.0"); flt_str2flt(dotp->TOK_RSTR, &dotp->TOK_RVAL); break; } diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index 78dc09ee79..eba29ae112 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -387,8 +387,7 @@ static int ChkExSelOrName(struct node **expp, int flags) exp->nd_REAL = new_real(); *(exp->nd_REAL) = *p; if (p->r_real) { - p->r_real = Salloc(p->r_real, - (unsigned)(strlen(p->r_real)+1)); + p->r_real = strdup(p->r_real); } } FreeNode(*expp); @@ -1463,16 +1462,15 @@ void TryToString(struct node *nd, struct type *tp) { /* Try a coercion from character constant to string. */ - static char buf[8]; - assert(nd->nd_symb == STRING); if (tp->tp_fund == T_ARRAY && nd->nd_type == char_type) { - buf[0] = nd->nd_INT; + char value = nd->nd_INT; nd->nd_type = standard_type(T_STRING, 1, (arith) 2); nd->nd_SSTR = (struct string *) malloc(sizeof(struct string)); - nd->nd_STR = Salloc(buf, (unsigned) word_size); + nd->nd_STR = calloc(1, word_size); + nd->nd_STR[0] = value; nd->nd_SLE = 1; } } diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 161824d796..612801c50b 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -17,6 +17,7 @@ #include #include "alloc.h" +#include "system.h" #include "em_arith.h" #include "em_label.h" #include "em_code.h" @@ -287,8 +288,7 @@ struct def * DeclProc(int type, struct idf *id) } else { - sprintf(buf, "%s_%s", CurrentScope->sc_name, id->id_text); - df->prc_name = Salloc(buf, (unsigned) (strlen(buf) + 1)); + df->prc_name = aprintf("%s_%s", CurrentScope->sc_name, id->id_text); } if (CurrVis == Defined->mod_vis) { @@ -312,7 +312,7 @@ struct def * DeclProc(int type, struct idf *id) { df = define(id, CurrentScope, type); sprintf(buf, "_%d_%s", ++nmcount, id->id_text); - df->prc_name = Salloc(buf, (unsigned) (strlen(buf) + 1)); + df->prc_name = strdup(buf); internal(buf); df->df_flags |= D_DEFINED; } @@ -371,7 +371,7 @@ struct def * DefineLocalModule(struct idf *id) sc = CurrentScope; sc->sc_level = proclevel; sc->sc_definedby = df; - sc->sc_name = Salloc(buf, (unsigned) (strlen(buf) + 1)); + sc->sc_name = strdup(buf); /* Create a type for it */ diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index 3e88839e86..b2b9b793e9 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -56,7 +56,7 @@ char* getwdir(char *fn) if (p) { *p = '\0'; - fn = Salloc(fn, (unsigned)(p - &fn[0] + 1)); + fn = strdup(fn); *p = '/'; return fn; } diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 89704d0976..c3043a7fdc 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -161,8 +161,7 @@ void EnterVarList(struct node *Idlist, struct type *type, int local) else { sprintf(buf,"%s_%s", sc->sc_scope->sc_name, df->df_idf->id_text); - df->var_name = Salloc(buf, - (unsigned)(strlen(buf)+1)); + df->var_name = strdup(buf); } df->df_flags |= D_NOREG; diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index 73e444e3b1..0957641862 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -158,7 +158,7 @@ DefinitionModule df->df_idf->id_text, DefId->id_text); } sprintf(buf, "_%s_", df->df_idf->id_text); - currscope->sc_name = Salloc(buf, (unsigned) strlen(buf) + 1); + currscope->sc_name = strdup(buf); df->mod_vis = CurrVis; df->df_type = standard_type(T_RECORD, 1, (arith) 1); df->df_type->rec_scope = currscope; diff --git a/lang/m2/m2mm/LLlex.c b/lang/m2/m2mm/LLlex.c index 3d54d3a033..0c4acabba3 100644 --- a/lang/m2/m2mm/LLlex.c +++ b/lang/m2/m2mm/LLlex.c @@ -161,7 +161,7 @@ CheckForLineDirective() * Remember the file name */ if (class(ch) == STNL && strcmp(FileName,buf)) { - FileName = Salloc(buf,(unsigned) strlen(buf) + 1); + FileName = strdup(buf); WorkingDir = getwdir(FileName); } } diff --git a/lang/m2/m2mm/main.c b/lang/m2/m2mm/main.c index 1ddd3fd129..094c3d0fe1 100644 --- a/lang/m2/m2mm/main.c +++ b/lang/m2/m2mm/main.c @@ -42,32 +42,34 @@ basename(s) return buf; } -char * -getwdir(fn) - char *fn; +char* getwdir(char* fn) { - char *p; + char* p; - p = strrchr(fn, '/'); - while (p && *(p + 1) == '\0') { /* remove trailing /'s */ - *p = '\0'; - p = strrchr(fn, '/'); - } + p = strrchr(fn, '/'); + while (p && *(p + 1) == '\0') + { /* remove trailing /'s */ + *p = '\0'; + p = strrchr(fn, '/'); + } - if (p) { - char **d = DEFPATH; + if (p) + { + char** d = DEFPATH; - *p = '\0'; - while (*d && strcmp(*d, fn) != 0) d++; - if (*d) { - *p = '/'; + *p = '\0'; + while (*d && strcmp(*d, fn) != 0) + d++; + if (*d) + { + *p = '/'; return *d; } - fn = Salloc(fn, (unsigned) (p - &fn[0] + 1)); + fn = strdup(fn); *p = '/'; return fn; - } - return "."; + } + return "."; } static struct file_list *arglist; @@ -153,7 +155,7 @@ Add(parglist, f, d, copy) if (a) return 0; a = new_file_list(); if (copy) { - a->a_filename = Salloc(f, (unsigned) (strlen(f)+1)); + a->a_filename = strdup(f); } else { a->a_filename = f; diff --git a/lang/pc/comp/LLlex.c b/lang/pc/comp/LLlex.c index 518ee07274..c50eb0a8de 100644 --- a/lang/pc/comp/LLlex.c +++ b/lang/pc/comp/LLlex.c @@ -261,7 +261,7 @@ void CheckForLineDirective(void) * Remember the filename */ if( !eofseen && strcmp(FileName, buf) ) { - FileName = Salloc(buf,(unsigned) strlen(buf) + 1); + FileName = strdup(buf); } } if( eofseen ) { @@ -542,12 +542,12 @@ int LLlex(void) tk->TOK_RIV->r_lab = 0; if( np > &buf[NUMSIZE+1] ) { - tk->TOK_REL = Salloc("0.0", 4); + tk->TOK_REL = strdup("0.0"); tk->TOK_RIV->r_real = tk->TOK_REL; lexerror("floating constant too long"); } else { - tk->TOK_RIV->r_real = Salloc(buf,(unsigned) (np - buf)); + tk->TOK_RIV->r_real = strdup(buf); tk->TOK_REL = tk->TOK_RIV->r_real + 1; } diff --git a/lang/pc/comp/LLmessage.c b/lang/pc/comp/LLmessage.c index 4a979d9c7a..10df9f3d48 100644 --- a/lang/pc/comp/LLmessage.c +++ b/lang/pc/comp/LLmessage.c @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include @@ -45,7 +47,7 @@ void LLmessage(int tk) dotp->tk_data.tk_str = (struct string *) malloc(sizeof (struct string)); dotp->TOK_SLE = 1; - dotp->TOK_STR = Salloc("", 1); + dotp->TOK_STR = strdup(""); toktype = standard_type(T_STRINGCONST, 1, (arith) 1); break; case INTEGER: @@ -63,7 +65,7 @@ void LLmessage(int tk) malloc(sizeof(struct real)); dotp->TOK_RIV->r_inverse = dotp->tk_data.tk_real; - dotp->TOK_REL = Salloc("0.0", 4); + dotp->TOK_REL = strdup("0.0"); dotp->TOK_RIV->r_real = dotp->TOK_REL; toktype = real_type; break; diff --git a/lang/pc/comp/cstoper.c b/lang/pc/comp/cstoper.c index c86480bc98..58ceb5edef 100644 --- a/lang/pc/comp/cstoper.c +++ b/lang/pc/comp/cstoper.c @@ -486,7 +486,7 @@ void InitCst(void) max_int = full_mask[int_size] & ~(1L << (int_size * 8 - 1)); min_int = - max_int; maxint_str = long2str(max_int, 10); - maxint_str = Salloc(maxint_str, (unsigned int) strlen(maxint_str)+sizeof(char)); + maxint_str = strdup(maxint_str); wrd_bits = 8 * (int) word_size; if( !max_intset ) max_intset = wrd_bits - 1; } diff --git a/lang/pc/comp/misc.c b/lang/pc/comp/misc.c index c85da6b550..62d1f800c8 100644 --- a/lang/pc/comp/misc.c +++ b/lang/pc/comp/misc.c @@ -50,7 +50,7 @@ char *gen_proc_name(struct idf *id, int inp) if( inp ) { sprintf(buf, "_%d%s", ++name_cnt, id->id_text); C_inp(buf); - return Salloc(buf, (unsigned) (strlen(buf) + 1)); + return strdup(buf); } else { C_exp(id->id_text); diff --git a/mach/sparc/ce/ce.src/C_pro.c b/mach/sparc/ce/ce.src/C_pro.c index 66ad9f0f58..316eb55199 100644 --- a/mach/sparc/ce/ce.src/C_pro.c +++ b/mach/sparc/ce/ce.src/C_pro.c @@ -17,7 +17,7 @@ arith l; #ifdef __solaris__ fprintf(codefile, "\t.type\t%s,#function\n", s); if (B_procnam) free(B_procnam); - B_procnam = Salloc(s, strlen(s)+1); + B_procnam = strdup(s); #endif symbol_definition( s); diff --git a/modules/src/alloc/Salloc.c b/modules/src/alloc/Salloc.c deleted file mode 100644 index 9921ab9636..0000000000 --- a/modules/src/alloc/Salloc.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* M E M O R Y A L L O C A T I O N R O U T I N E S */ - -/* The memory allocation routines offered in this file are: - - char *Salloc(str, n) : allocate n bytes, initialized with the string - str -*/ - -#if __STDC__ -#include -#else -extern char* malloc(); -#endif - -#include "alloc.h" - -char* Salloc(char* str, unsigned int sz) -{ - /* Salloc() is not a primitive function: it just allocates a - piece of storage and copies a given string into it. - */ - char* res = malloc(sz); - char* m = res; - - while (sz--) - *m++ = *str++; - return res; -} diff --git a/modules/src/alloc/alloc.3 b/modules/src/alloc/alloc.3 index 512816276b..194bbbbc20 100644 --- a/modules/src/alloc/alloc.3 +++ b/modules/src/alloc/alloc.3 @@ -5,8 +5,6 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc .SH SYNOPSIS .B #include .PP -.B char *Salloc(char *str, unsigned int size) -.PP .B char *st_alloc(char **phead, unsigned int size, int count) .PP .B st_free(char *ptr, char **phead, unsigned int size) @@ -14,9 +12,6 @@ Malloc, Salloc, Realloc, Srealloc, st_alloc, st_free\ \-\ low level memory alloc .SH DESCRIPTION This set of routines provides a checking memory allocation mechanism. .PP -\fISalloc\fR returns a pointer to a block of at least \fIsize\fR -bytes, initialized with the null-terminated string \fIstr\fR. -.PP All these routines use \fImalloc\fR and \fIrealloc\fR. The routine \fIfree\fR can be used on pointers returned by these routines. .PP diff --git a/modules/src/alloc/alloc.h b/modules/src/alloc/alloc.h index 91ce8883a3..cde1fb1281 100644 --- a/modules/src/alloc/alloc.h +++ b/modules/src/alloc/alloc.h @@ -11,11 +11,8 @@ memory allocating routines. There are 3 memory allocation routines: char *malloc(n) allocate n bytes - char *Salloc(str, n) allocate n bytes and fill them with - string str */ -char* Salloc(char*, unsigned int); char* st_alloc(char**, unsigned int, int); char* std_alloc(char**, unsigned int, int, int*); diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua index 461062ca0a..847d5a8321 100644 --- a/modules/src/alloc/build.lua +++ b/modules/src/alloc/build.lua @@ -1,7 +1,6 @@ clibrary { name = "lib", srcs = { - "./Salloc.c", "./st_alloc.c", "./std_alloc.c", }, diff --git a/util/ceg/EM_parser/common/action.c b/util/ceg/EM_parser/common/action.c index 4776295059..6b6f723f4f 100644 --- a/util/ceg/EM_parser/common/action.c +++ b/util/ceg/EM_parser/common/action.c @@ -40,7 +40,7 @@ char *instr; quantum*sizeof( char *)); } - as_instructions[nr_instr++] = Salloc( instr, strlen( instr) + 1); + as_instructions[nr_instr++] = strdup(instr); } do_block_assemble() diff --git a/util/ceg/EM_parser/obj_EM_pars/dist.c b/util/ceg/EM_parser/obj_EM_pars/dist.c index 83422746f4..944b1e31c2 100644 --- a/util/ceg/EM_parser/obj_EM_pars/dist.c +++ b/util/ceg/EM_parser/obj_EM_pars/dist.c @@ -32,12 +32,10 @@ char *lab; /* Record position of this label */ { - char *Salloc(); - if ( n_labs >= MAX_LABEL) error( "Too many labels!!\n"); else { - label_list[ n_labs].lab = Salloc( lab, strlen( lab) + 1); + label_list[ n_labs].lab = strdup(lab); label_list[ n_labs++].position = cur_pos; } process_label( lab); diff --git a/util/ceg/as_parser/help.c b/util/ceg/as_parser/help.c index accb13f362..3714925dc3 100644 --- a/util/ceg/as_parser/help.c +++ b/util/ceg/as_parser/help.c @@ -31,21 +31,21 @@ save_instr( instr, len) char *instr; int len; { - assem_instr = Salloc( instr, len + 1); + assem_instr = strdup( instr); } save_name( name, len) char *name; int len; { - op_info[ n_ops].name = Salloc( name, len + 1); + op_info[ n_ops].name = strdup( name); } save_type( type, len) char *type; int len; { - op_info[ n_ops].type = Salloc( type, len + 1); + op_info[ n_ops].type = strdup( type); restriction = TRUE; } @@ -293,7 +293,7 @@ char *mnem; error( "too many assembler instructions!! MAX_MNEMONICS = %d", MAX_MNEMONICS); else - mnemonic[ n_mnems++] = Salloc( mnem, strlen( mnem) + 1); + mnemonic[ n_mnems++] = strdup(mnem); } diff --git a/util/ceg/assemble/obj_assemble/assemble.c b/util/ceg/assemble/obj_assemble/assemble.c index 76f608c4e4..d83e25f03b 100644 --- a/util/ceg/assemble/obj_assemble/assemble.c +++ b/util/ceg/assemble/obj_assemble/assemble.c @@ -46,7 +46,7 @@ struct t_operand operand[ MAX_OPERANDS]; char *skip_space(), *parse_label(), *parse_mnemonic(), *parse_operand(), - *skip_string(), *match_ch(), *Salloc(), *skip_operand(); + *skip_string(), *match_ch(), *skip_operand(); int label(); @@ -58,7 +58,7 @@ assemble( instr) char *ptr, *copy, *mnem; int n_ops = 0; - copy = ptr = Salloc( instr, strlen( instr)+1); + copy = ptr = strdup(instr); ptr = skip_space( ptr); if ( label( ptr)) { /* Look for a label */ diff --git a/util/cmisc/cclash.c b/util/cmisc/cclash.c index d4df485a4a..a4b9058c08 100644 --- a/util/cmisc/cclash.c +++ b/util/cmisc/cclash.c @@ -60,7 +60,6 @@ char* keywords[] void InsertId(char*, int); char* malloc(unsigned int); -char* Salloc(char*); int EnHash(char*); void EndOfProgram(void); void DoOption(char*); @@ -111,7 +110,7 @@ void DoOption(char* str) struct idf* hash_tab[HASHSIZE]; -char *malloc(), *Salloc(); +char *malloc(); void InsertId(char* id, int key) { @@ -133,7 +132,7 @@ void InsertId(char* id, int key) hash_tab[hash_val] = idp; else p->id_next = idp; - idp->id_name = Salloc(id); + idp->id_name = strdup(id); idp->id_same = 0; } @@ -150,7 +149,7 @@ void InsertId(char* id, int key) p = (struct idf*)malloc(sizeof(struct idf)); p->id_next = 0; p->id_same = 0; - p->id_name = Salloc(id); + p->id_name = strdup(id); idp->id_same = p; } @@ -169,14 +168,6 @@ char* malloc(unsigned n) return mem; } -char* Salloc(char* str) -{ - if (str == 0) - str = ""; - - return strcpy(malloc((unsigned)strlen(str) + 1), str); -} - int EnHash(char* id) { unsigned hash_val = 0; diff --git a/util/cmisc/cid.c b/util/cmisc/cid.c index 1245e5e238..480e1b6c46 100644 --- a/util/cmisc/cid.c +++ b/util/cmisc/cid.c @@ -35,7 +35,6 @@ struct idf struct idf* hash_tab[HASHSIZE]; char* malloc(unsigned int); -char* Salloc(char*); int EnHash(char*); void EndOfProgram(void); void DoOption(char*); @@ -155,8 +154,8 @@ void InsertMacro(char* id, char* text) } idp->id_next = hash_tab[hash_val]; - idp->id_name = Salloc(id); - idp->id_text = Salloc(text); + idp->id_name = strdup(id); + idp->id_text = strdup(text); hash_tab[hash_val] = idp; } @@ -172,15 +171,6 @@ char* malloc(unsigned int n) return mem; } -char* Salloc(char* str) -{ - if (str == 0) - { - str = ""; - } - return strcpy(malloc((unsigned)strlen(str) + 1), str); -} - struct idf* FindId(char* id) { int hash_val = EnHash(id); diff --git a/util/cmisc/prid.c b/util/cmisc/prid.c index fca8b632bc..25250d1ba0 100644 --- a/util/cmisc/prid.c +++ b/util/cmisc/prid.c @@ -27,7 +27,6 @@ int maxlen = DEF_LENGTH; void InsertId(char*); char* malloc(unsigned int); -char* Salloc(char*); int EnHash(char*); void EndOfProgram(void); void DoOption(char*); @@ -94,7 +93,7 @@ void InsertId(char* id) hash_tab[hash_val] = idp; else p->id_next = idp; - idp->id_name = Salloc(id); + idp->id_name = strdup(id); } } @@ -110,15 +109,6 @@ char* malloc(unsigned int n) return mem; } -char* Salloc(char* str) -{ - - if (str == 0) - str = ""; - - return strcpy(malloc((unsigned)strlen(str) + 1), str); -} - int EnHash(char* id) { unsigned hash_val = 0; diff --git a/util/cmisc/tabgen.c b/util/cmisc/tabgen.c index 1cd4e8268d..9382f9b552 100644 --- a/util/cmisc/tabgen.c +++ b/util/cmisc/tabgen.c @@ -64,18 +64,6 @@ int main(int argc, char* argv[]) UNREACHABLE_CODE; } -char* Salloc(char* s) -{ - char* ns = strdup(s); - - if (!ns) - { - fprintf(stderr, "%s: out of memory\n", ProgCall); - exit(1); - } - return ns; -} - void option(char* str) { /* note that *str indicates the source of the option: @@ -171,7 +159,7 @@ void InitTable(char* ival) InitialValue = 0; if (ival) { - InitialValue = Salloc(ival); + InitialValue = strdup(ival); } } @@ -234,7 +222,7 @@ int process(char* str, int format) int c_proc(char* str, char* Name) { int ch, ch2; - char* name = Salloc(Name); + char* name = strdup(Name); while (*str) { diff --git a/util/grind/c.c b/util/grind/c.c index 2e28083cf8..bf15a15b39 100644 --- a/util/grind/c.c +++ b/util/grind/c.c @@ -461,7 +461,7 @@ getstring(c) tok.ival = val; return INTEGER; } - tok.str = Salloc(buf, (unsigned) len); + tok.str = strdup(buf); return STRING; } diff --git a/util/grind/modula-2.c b/util/grind/modula-2.c index d6ddb6ced2..af6a4b4f1e 100644 --- a/util/grind/modula-2.c +++ b/util/grind/modula-2.c @@ -454,7 +454,7 @@ getstring(c) buf[len++] = ch; } buf[len++] = 0; - tok.str = Salloc(buf, (unsigned) len); + tok.str = strdup(buf); return STRING; } diff --git a/util/grind/pascal.c b/util/grind/pascal.c index 9f2437c1db..44c1c44f55 100644 --- a/util/grind/pascal.c +++ b/util/grind/pascal.c @@ -377,7 +377,7 @@ getstring(c) buf[len++] = ch; } buf[len++] = 0; - tok.str = Salloc(buf, (unsigned) len); + tok.str = strdup(buf); return STRING; } diff --git a/util/grind/symbol.c b/util/grind/symbol.c index 23b94b0ae2..001aeed6bb 100644 --- a/util/grind/symbol.c +++ b/util/grind/symbol.c @@ -118,7 +118,7 @@ add_file(s) p_symbol sym1; *p = 0; - s = Salloc(s, (unsigned) strlen(s)+1); + s = strdup(s); *p = c; sym1 = NewSymbol(s, PervasiveScope, From c1c1d145742fc5894d3d7839ffb5b7b1116af6fb Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 9 Dec 2024 00:01:10 +0100 Subject: [PATCH 27/29] Replace btscpy with memcpy. --- modules/src/em_opt/nopt.c | 3 --- modules/src/read_em/reade.c | 2 +- modules/src/string/ack_string.h | 1 - modules/src/string/btscpy.c | 18 ------------------ modules/src/string/build.lua | 2 +- modules/src/string/string.3 | 18 ++---------------- 6 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 modules/src/string/btscpy.c diff --git a/modules/src/em_opt/nopt.c b/modules/src/em_opt/nopt.c index feaaee33a9..102f50a180 100644 --- a/modules/src/em_opt/nopt.c +++ b/modules/src/em_opt/nopt.c @@ -41,9 +41,6 @@ int OO_wrstats = 1; /* pattern statistics output */ #define printstate(s) #endif /* DEBUG */ -/**** WHICH IS FASTER? **** - #define BTSCPY(pp,qq,i,p,q,n) btscpy(p,q,(n)*sizeof(struct e_instr)) - **************************/ #define BTSCPY(pp,qq,i,p,q,n) for(pp=(p),qq=(q),i=(n);i--;*pp++ = *qq++) static void allocmem(void); diff --git a/modules/src/read_em/reade.c b/modules/src/read_em/reade.c index 18c5814a2c..7f04e09f9a 100644 --- a/modules/src/read_em/reade.c +++ b/modules/src/read_em/reade.c @@ -575,7 +575,7 @@ static void line_line(void) gettyp(ptyp(sp_cst2), &dummy); EM_lineno = dummy.ema_cst; gettyp(str_ptyp, &dummy); - btscpy(filebuf, dummy.ema_string, (int) dummy.ema_szoroff); + memcpy(filebuf, dummy.ema_string, (int) dummy.ema_szoroff); EM_filename = filebuf; } diff --git a/modules/src/string/ack_string.h b/modules/src/string/ack_string.h index 22aa0b226b..2dd3e47806 100644 --- a/modules/src/string/ack_string.h +++ b/modules/src/string/ack_string.h @@ -8,7 +8,6 @@ #define __ACK_STRING_INCLUDED__ char *long2str(long l, int b); -char *btscpy(char *b1, char *b2, int n); char *bts2str(char *b, int n, char *s); #endif /* __ACK_STRING_INCLUDED__ */ diff --git a/modules/src/string/btscpy.c b/modules/src/string/btscpy.c deleted file mode 100644 index 86e608cdfa..0000000000 --- a/modules/src/string/btscpy.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* btscpy() -*/ - -#include "ack_string.h" - -char *btscpy(char *b1, char *b2, int n) -{ - char *b1s = b1; - - while (n-- > 0) - *b1++ = *b2++; - return b1s; -} diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua index a3cf03a414..8c74df2f25 100644 --- a/modules/src/string/build.lua +++ b/modules/src/string/build.lua @@ -2,7 +2,7 @@ clibrary { name = "lib", srcs = { "./bts2str.c", - "./btscpy.c","./long2str.c", + "./long2str.c", }, hdrs = { "./ack_string.h", }, } diff --git a/modules/src/string/string.3 b/modules/src/string/string.3 index bdabb97548..520ad4f6e2 100644 --- a/modules/src/string/string.3 +++ b/modules/src/string/string.3 @@ -1,18 +1,14 @@ .TH STRING 3 "$Revision$" .ad .SH NAME -strindex, strrindex, strzero, str2bts, -long2str, str2long, -btscpy, btscat, btscmp, btszero, bts2str \- operations on and -conversions between strings and row of bytes +long2str, +bts2str \- operations on and conversions between strings and row of bytes .SH SYNOPSIS .nf .B #include .PP .B char *long2str(long l, int b) .PP -.B char *btscpy(char *b1, char *b2, int n) -.PP .B char *bts2str(char *b, int n, char *s) .fi .SH DESCRIPTION @@ -58,16 +54,6 @@ This base may be any of 2..16. A negative base (in the range -16..-2) indicates that the long must be seen as unsigned. A pointer to the string is returned. -.PP -.I btscpy -copies -.I n -bytes from the string of bytes -.I b2 -to -.I b1 -and returns -.IR b1 . .SH FILES ~em/modules/lib/libstring.a .SH "SEE ALSO" From c25cd3952d455ed14214f83064298d489311b85d Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 9 Dec 2024 00:07:17 +0100 Subject: [PATCH 28/29] Fix oddity with OSX and Windows. --- util/ack/util.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/util/ack/util.c b/util/ack/util.c index bf23ff5c96..2906365a0c 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 OUTF stdout #else -#define stdout stderr +#define OUTF 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(OUTF, "%s: fatal internal error, ", progname); + vfprintf(OUTF, fmt, ap); + fprintf(OUTF, "\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(OUTF, 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(OUTF, "%s: ", progname); + vfprintf(OUTF, fmt, ap); + fprintf(OUTF, "\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(OUTF, "%s: warning, ", progname); + vfprintf(OUTF, fmt, ap); + fprintf(OUTF, "\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(OUTF, "%s: ", progname); + vfprintf(OUTF, fmt, ap); + fprintf(OUTF, "\n"); n_error++; va_end(ap); } From cea6b9a140c93f947d4e6071204f064bfd184094 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 9 Dec 2024 02:41:03 +0100 Subject: [PATCH 29/29] Remember to open files in binary mode to avoid stupid translation issues. --- modules/src/input/inp_pkg.body | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/src/input/inp_pkg.body b/modules/src/input/inp_pkg.body index 1d89b26b9b..07569dea79 100644 --- a/modules/src/input/inp_pkg.body +++ b/modules/src/input/inp_pkg.body @@ -259,7 +259,7 @@ int InsertFile(char *filnam, char *table[], char **result) else { if (table == 0 || filnam[0] == '/') { /* don't look in the table! */ - fd = fopen(filnam, "r"); + fd = fopen(filnam, "rb"); if (!fd) return 0; } else { @@ -268,7 +268,7 @@ int InsertFile(char *filnam, char *table[], char **result) if (!INP_mk_filename(*table++, filnam, &newfn)) { return 0; } - fd = fopen(newfn, "r"); + fd = fopen(newfn, "rb"); if (fd) { /* free filnam ??? NO we don't know where it comes from!