From: Robert Anisko Date: Mon, 27 Aug 2001 14:55:39 +0000 (+0000) Subject: * src/output.c (output): Remove the initialization of the macro X-Git-Tag: pre-merge-of-1-29-branch~54 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/82e236e2d66e4876663586d30a44ebb57f9cdf6c?hp=b0cfa28a1274c014b7bbff301f9421d7d09dd21e * src/output.c (output): Remove the initialization of the macro obstack. It was done too late here. * src/reader.c (parse_macro_decl): Fix. Use of the macro obstack was completely wrong. (reader): Initialize the macro obstack here, since we need it to grow '%define' directives. * src/reader.h: Declare the macro obstack as extern. --- diff --git a/ChangeLog b/ChangeLog index 4636c077..c082330f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-08-27 Robert Anisko + + * src/output.c (output): Remove the initialization of the macro + obstack. It was done too late here. + + * src/reader.c (parse_macro_decl): Fix. Use of the macro obstack was + completely wrong. + (reader): Initialize the macro obstack here, since we need it to grow + '%define' directives. + + * src/reader.h: Declare the macro obstack as extern. + 2001-08-27 Robert Anisko * src/output.c (output_parser): Fix. Store single '%' characters in diff --git a/src/output.c b/src/output.c index 254927d0..be07ff6f 100644 --- a/src/output.c +++ b/src/output.c @@ -1103,7 +1103,6 @@ prepare (void) void output (void) { - obstack_init (¯o_obstack); obstack_init (&output_obstack); #if 0 diff --git a/src/reader.c b/src/reader.c index cc8f90a0..aa6ec516 100644 --- a/src/reader.c +++ b/src/reader.c @@ -907,9 +907,6 @@ parse_macro_decl (void) int ch = ungetc (skip_white_space (), finput); char* macro_key; char* macro_value; - struct obstack macro_obstack; - - obstack_init (¯o_obstack); /* Read key. */ if (!isalpha (ch) && ch != '_') @@ -919,6 +916,7 @@ parse_macro_decl (void) return; } copy_identifier (finput, ¯o_obstack); + obstack_1grow (¯o_obstack, 0); macro_key = obstack_finish (¯o_obstack); /* Read value. */ @@ -935,11 +933,10 @@ parse_macro_decl (void) else fatal (_("Premature EOF after %s"), "\""); } - copy_string (finput, ¯o_obstack, '"'); + copy_string2 (finput, ¯o_obstack, '"', 0); + obstack_1grow (¯o_obstack, 0); macro_value = obstack_finish (¯o_obstack); - obstack_free (¯o_obstack, 0); - /* Store the (key, value) pair in the environment. */ macro_insert (macro_key, macro_value); } @@ -1991,6 +1988,9 @@ reader (void) init_lex (); lineno = 1; + /* Initialize the macro obstack. */ + obstack_init (¯o_obstack); + /* Initialize the symbol table. */ tabinit (); diff --git a/src/reader.h b/src/reader.h index c2988911..7cdd6941 100644 --- a/src/reader.h +++ b/src/reader.h @@ -36,4 +36,6 @@ extern int lineno; extern char **tags; extern short *user_toknums; +extern struct obstack macro_obstack; + #endif /* !READER_H_ */