MINIX squeezing with strings, fixed small preprocessor bug
This commit is contained in:
parent
2b6d2c8407
commit
c4e0fddf5b
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue