From: ceriel Date: Fri, 20 Mar 1987 08:30:31 +0000 (+0000) Subject: many minor fixes and modifications X-Git-Tag: release-5-5~4359 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4e03fc78dd35d366a13844ae4e38d0092f5c2c3e;p=ack.git many minor fixes and modifications --- diff --git a/lang/cem/cemcom/LLlex.c b/lang/cem/cemcom/LLlex.c index 86e7e5823..a94cde373 100644 --- a/lang/cem/cemcom/LLlex.c +++ b/lang/cem/cemcom/LLlex.c @@ -435,10 +435,10 @@ firstline: buf[0] = '-'; /* good heavens... */ if (np == &buf[NUMSIZE+1]) { lexerror("floating constant too long"); - ptok->tk_fval = Salloc("0.0", 5) + 1; + ptok->tk_fval = Salloc("0.0",(unsigned) 5) + 1; } else - ptok->tk_fval = Salloc(buf, np - buf) + 1; + ptok->tk_fval = Salloc(buf,(unsigned) (np - buf)) + 1; return ptok->tk_symb = FLOATING; #endif NOFLOAT } @@ -489,7 +489,7 @@ string_token(nm, stop_char, plen) { register int ch; register int str_size; - register char *str = Malloc(str_size = ISTRSIZE); + register char *str = Malloc((unsigned) (str_size = ISTRSIZE)); register int pos = 0; LoadChar(ch); @@ -514,7 +514,7 @@ string_token(nm, stop_char, plen) } str[pos++] = ch; if (pos == str_size) - str = Srealloc(str, str_size += RSTRSIZE); + str = Srealloc(str, (unsigned) (str_size += RSTRSIZE)); LoadChar(ch); } str[pos++] = '\0'; /* for filenames etc. */ diff --git a/lang/cem/cemcom/atw.h b/lang/cem/cemcom/atw.h index 1ebb24236..c5138a28e 100644 --- a/lang/cem/cemcom/atw.h +++ b/lang/cem/cemcom/atw.h @@ -5,6 +5,6 @@ /* $Header$ */ /* Align To Word boundary Definition */ -extern int word_align; /* align of a word */ +extern arith word_size; -#define ATW(arg) ((((arg) + word_align - 1) / word_align) * word_align) +#define ATW(arg) ((((arg) + word_size - 1) / word_size) * word_size) diff --git a/lang/cem/cemcom/blocks.c b/lang/cem/cemcom/blocks.c index 531b59715..255ade376 100644 --- a/lang/cem/cemcom/blocks.c +++ b/lang/cem/cemcom/blocks.c @@ -9,9 +9,11 @@ #include "arith.h" #include "sizes.h" #include "atw.h" +#include "align.h" #ifndef STB #include "label.h" #include "stack.h" +extern arith tmp_pointer_var(); #endif STB /* Because EM does not support the loading and storing of diff --git a/lang/cem/cemcom/code.c b/lang/cem/cemcom/code.c index 85591a780..04a5b6c13 100644 --- a/lang/cem/cemcom/code.c +++ b/lang/cem/cemcom/code.c @@ -30,6 +30,7 @@ #include "specials.h" #include "atw.h" #include "assert.h" +#include "align.h" label lab_count = 1; label datlab_count = 1; @@ -368,7 +369,7 @@ code_declaration(idf, expr, lvl, sc) error("size of %s unknown", text); size = (arith)0; } - C_bss_cst(align(size, word_align), (arith)0, 1); + C_bss_cst(ATW(size), (arith)0, 1); } break; case EXTERN: @@ -460,7 +461,7 @@ bss(idf) warning("actual array of size 0"); */ C_df_dnam(idf->id_text); - C_bss_cst(align(size, word_align), (arith)0, 1); + C_bss_cst(ATW(size), (arith)0, 1); } formal_cvt(df) diff --git a/lang/cem/cemcom/cstoper.c b/lang/cem/cemcom/cstoper.c index b33863b1b..d313efa7f 100644 --- a/lang/cem/cemcom/cstoper.c +++ b/lang/cem/cemcom/cstoper.c @@ -193,6 +193,12 @@ cut_size(expr) int size = (int) expr->ex_type->tp_size; ASSERT(expr->ex_class == Value); + if (expr->ex_type->tp_fund == POINTER) { + /* why warn on "ptr-3" ? + This quick hack fixes it + */ + uns = 0; + } if (uns) { if (o1 & ~full_mask[size]) expr_warning(expr, diff --git a/lang/cem/cemcom/domacro.c b/lang/cem/cemcom/domacro.c index 208e5b49d..ada513c03 100644 --- a/lang/cem/cemcom/domacro.c +++ b/lang/cem/cemcom/domacro.c @@ -656,7 +656,7 @@ domacro() SkipRestOfLine(); return; } - do_line(tk.tk_ival); + do_line((unsigned int) tk.tk_ival); EoiForNewline = 0; SkipEscNewline = 0; } diff --git a/lang/cem/cemcom/idf.c b/lang/cem/cemcom/idf.c index 78dd898b8..9cccef469 100644 --- a/lang/cem/cemcom/idf.c +++ b/lang/cem/cemcom/idf.c @@ -78,7 +78,7 @@ idf_hashed(tg, size, hc) notch = new_idf(); notch->next = *hook; *hook = notch; /* hooked in */ - notch->id_text = Salloc(tg, size); + notch->id_text = Salloc(tg, (unsigned) size); #ifndef NOPP notch->id_resmac = 0; #endif NOPP @@ -551,7 +551,7 @@ init_idf(idf) error("multiple initialization of %s", idf->id_text); if (def->df_sc == TYPEDEF) { warning("typedef cannot be initialized"); - def->df_sc == EXTERN; /* ??? *//* What else ? */ + def->df_sc = EXTERN; /* ??? *//* What else ? */ } def->df_initialized = 1; } diff --git a/lang/cem/cemcom/ival.c b/lang/cem/cemcom/ival.c index 655ade29f..b439afeca 100644 --- a/lang/cem/cemcom/ival.c +++ b/lang/cem/cemcom/ival.c @@ -29,6 +29,7 @@ char *symbol2str(); char *long2str(); +char *strncpy(); struct expr *do_array(), *do_struct(), *IVAL(); extern char options[]; @@ -482,7 +483,7 @@ ch_array(tpp, ex) if (tp->tp_size == (arith)-1) { /* set the dimension */ tp = *tpp = construct_type(ARRAY, tp->tp_up, length); - ntopad = align(tp->tp_size, word_align) - tp->tp_size; + ntopad = align(tp->tp_size, word_size) - tp->tp_size; } else { arith dim = tp->tp_size / tp->tp_up->tp_size; @@ -498,12 +499,13 @@ ch_array(tpp, ex) length = dim; } } - ntopad = align(dim, word_align) - length; + ntopad = align(dim, word_size) - length; } /* throw out the characters of the already prepared string */ - s = Malloc((int) (length + ntopad)); + s = Malloc((unsigned) (length + ntopad)); clear(s, (int) (length + ntopad)); strncpy(s, ex->SG_VALUE, (int) length); + free(ex->SG_VALUE); str_cst(s, (int) (length + ntopad)); free(s); } diff --git a/lang/cem/cemcom/main.c b/lang/cem/cemcom/main.c index b9dc93659..ba7748f88 100644 --- a/lang/cem/cemcom/main.c +++ b/lang/cem/cemcom/main.c @@ -117,6 +117,7 @@ char *source = 0; char *nmlist = 0; #ifdef USE_TMP +extern char *strcpy(), *strcat(); extern char *mktemp(); /* library routine */ char *tmpfdir = "/tmp"; /* where to keep the temporary file */ static char *tmpfname = "/Cem.XXXXXX"; @@ -158,7 +159,12 @@ compile(argc, argv) fatal("use: %s source destination [namelist]", prog_name); break; } - source = strcmp(argv[0], "-") ? argv[0] : 0; + if (strcmp(argv[0], "-")) + FileName = source = argv[0]; + else { + source = 0; + FileName = "standard input"; + } #ifdef USE_TMP if (! options['N']) { @@ -171,11 +177,9 @@ compile(argc, argv) if (destination && strcmp(destination, "-") == 0) destination = 0; if (!InsertFile(source, (char **) 0, &result)) /* read the source file */ - fatal("%s: no source file %s\n", prog_name, - source ? source : "stdin"); + fatal("%s: no source file %s\n", prog_name, FileName); File_Inserted = 1; init(); - FileName = source; LineNumber = 0; #ifndef NOPP WorkingDir = getwdir(source); @@ -410,3 +414,13 @@ AppendFile(src, dst) sys_close(fp_dst); } #endif USE_TMP + +No_Mem() +{ + fatal("out of memory"); +} + +C_failed() +{ + fatal("write failed"); +}