MINIX squeezing with strings, fixed small preprocessor bug
authoreck <none@none>
Tue, 16 Jan 1990 15:21:15 +0000 (15:21 +0000)
committereck <none@none>
Tue, 16 Jan 1990 15:21:15 +0000 (15:21 +0000)
lang/cem/cemcom.ansi/code.c
lang/cem/cemcom.ansi/code.str
lang/cem/cemcom.ansi/domacro.c
lang/cem/cemcom.ansi/ival.g
lang/cem/cemcom.ansi/program.g
lang/cem/cemcom.ansi/replace.c

index dd1ad15..2d40ed6 100644 (file)
@@ -98,12 +98,21 @@ def_strings(sc)
                struct string_cst *sc1 = sc;
 
                C_df_dlb(sc->sc_dlb);
-               str_cst(sc->sc_value, sc->sc_len);
+               str_cst(sc->sc_value, sc->sc_len, 1);   /* string in rom */
                sc = sc->next;
+               free(sc1->sc_value);
                free_string_cst(sc1);
        }
 }
 
+/* flush_strings() is called from program.g after each external definition */
+flush_strings() {
+       if (str_list) {
+               def_strings(str_list);
+               str_list = 0;
+       }
+}
+
 end_code()
 {
        /*      end_code() performs the actions to be taken when closing
@@ -113,8 +122,6 @@ end_code()
                /* floating point used  */
                C_ms_flt();
        }
-       def_strings(str_list);
-       str_list = 0;
        C_ms_src((int)(LineNumber - 2), FileName);
        C_close();
 }
index 6fa088c..926fb25 100644 (file)
@@ -14,7 +14,7 @@ struct string_cst     {       /* storing string constants */
 
 extern struct string_cst *str_list;
 
-/* ALLOCDEF "string_cst" 10 */
+/* ALLOCDEF "string_cst" 5 */
 
 #define        LVAL    0
 #define        RVAL    1
index 5c60232..7286646 100644 (file)
@@ -765,6 +765,12 @@ do_line(l)
 
        SkipToNewLine();
        LineNumber = l;         /* the number of the next input line */
-       if (t == STRING)        /* is there a filespecifier? */
+       if (t == STRING) {      /* is there a filespecifier? */
+               extern char *source;    /* defined in main.c */
+
+               if (FileName != source) {       /* source points into argv */
+                       free(FileName);
+               }
                FileName = tk.tk_bts;
+       }
 }
index 487d71e..e6c185b 100644 (file)
@@ -596,25 +596,30 @@ ch_array(tpp, ex)
                *to++ = *from++;
        }
        free(ex->SG_VALUE);
-       str_cst(s, length);
+       str_cst(s, length, 0);          /* a string, but not in rom */
        free(s);
 }
 
 /*     As long as some parts of the pipeline cannot handle very long string
        constants, string constants are written out in chunks
 */
-str_cst(str, len)
+str_cst(str, len, inrom)
        register char *str;
        register int len;
+       int inrom;
 {
        int chunksize = ((127 + (int) word_size) / (int) word_size) * (int) word_size;
 
        while (len > chunksize) {
-               C_con_scon(str, (arith) chunksize);
+               if (inrom)
+                       C_rom_scon(str, (arith) chunksize);
+               else    C_con_scon(str, (arith) chunksize);
                len -= chunksize;
                str += chunksize;
        }
-       C_con_scon(str, (arith) len);
+       if (inrom)
+               C_rom_scon(str, (arith) len);
+       else    C_con_scon(str, (arith) len);
 }
 
 #ifndef NOBITFIELD
index 0e180e6..e50865d 100644 (file)
@@ -150,7 +150,7 @@ external_definition
                }
                function(&Ds, &Dc)
        ]
-       {remove_declarator(&Dc);}
+       {remove_declarator(&Dc); flush_strings(); }
 ;
 
 non_function(register struct decspecs *ds; register struct declarator *dc;)
index 7fae3a9..61a7346 100644 (file)
@@ -204,6 +204,7 @@ expand_defined(repl)
        if (parens && ch != ')') error(") missing");
        if (!parens || ch != ')') UnGetChar();
        add2repl(repl, (id && id->id_macro) ? '1' : '0');
+       add2repl(repl, ' ');
 }
 
 newarg(args)