many minor fixes and modifications
authorceriel <none@none>
Fri, 20 Mar 1987 08:30:31 +0000 (08:30 +0000)
committerceriel <none@none>
Fri, 20 Mar 1987 08:30:31 +0000 (08:30 +0000)
lang/cem/cemcom/LLlex.c
lang/cem/cemcom/atw.h
lang/cem/cemcom/blocks.c
lang/cem/cemcom/code.c
lang/cem/cemcom/cstoper.c
lang/cem/cemcom/domacro.c
lang/cem/cemcom/idf.c
lang/cem/cemcom/ival.c
lang/cem/cemcom/main.c

index 86e7e58..a94cde3 100644 (file)
@@ -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. */
index 1ebb242..c5138a2 100644 (file)
@@ -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)
index 531b597..255ade3 100644 (file)
@@ -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
index 85591a7..04a5b6c 100644 (file)
@@ -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)
index b33863b..d313efa 100644 (file)
@@ -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,
index 208e5b4..ada513c 100644 (file)
@@ -656,7 +656,7 @@ domacro()
                SkipRestOfLine();
                return;
        }
-       do_line(tk.tk_ival);
+       do_line((unsigned int) tk.tk_ival);
        EoiForNewline = 0;
        SkipEscNewline = 0;
 }
index 78dd898..9cccef4 100644 (file)
@@ -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;
 }
index 655ade2..b439afe 100644 (file)
@@ -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);
 }
index b9dc936..ba7748f 100644 (file)
@@ -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");
+}