From 428046f8d4365e2cd60f8a5f645c2f3e23e3f7af Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 15 Dec 2001 15:13:36 +0000 Subject: [PATCH] * src/lex.c, src/lex.h (xgetc): No longer static. * src/reader.c (parse_union_decl): Revamp. --- ChangeLog | 5 +++++ src/lex.c | 2 +- src/lex.h | 1 + src/reader.c | 33 ++++++++++++++++----------------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae9d826f..1acdebe8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-12-15 Akim Demaille + + * src/lex.c, src/lex.h (xgetc): No longer static. + * src/reader.c (parse_union_decl): Revamp. + 2001-12-15 Akim Demaille Still making progress in separating Bison into (i) input, (ii) diff --git a/src/lex.c b/src/lex.c index 60e392ce..deb6eb7a 100644 --- a/src/lex.c +++ b/src/lex.c @@ -130,7 +130,7 @@ skip_white_space (void) | Do a getc, but give error message if EOF encountered | `-----------------------------------------------------*/ -static int +int xgetc (FILE *f) { int c = getc (f); diff --git a/src/lex.h b/src/lex.h index 267843f1..9f3cfe3a 100644 --- a/src/lex.h +++ b/src/lex.h @@ -66,6 +66,7 @@ void lex_free PARAMS ((void)); int skip_white_space PARAMS ((void)); void unlex PARAMS ((token_t)); void read_type_name PARAMS ((FILE *fin)); +int xgetc PARAMS ((FILE *fin)); /* Return one of the token-type codes. When an identifier is seen, the code IDENTIFIER is returned and the name is looked up in the diff --git a/src/reader.c b/src/reader.c index d4046ed9..c06f4399 100644 --- a/src/reader.c +++ b/src/reader.c @@ -753,6 +753,7 @@ parse_union_decl (void) { int c; int count = 0; + bool done = FALSE; struct obstack union_obstack; const char *prologue = "\ #ifndef YYSTYPE\n\ @@ -779,10 +780,10 @@ typedef union"; if (defines_flag) obstack_sgrow (&defines_obstack, prologue); - c = getc (finput); - - while (c != EOF) + while (!done) { + c = xgetc (finput); + /* If C contains '/', it is output by copy_comment (). */ if (c != '/') { @@ -806,26 +807,24 @@ typedef union"; break; case '}': + /* FIXME: Errr. How could this happen???. --akim */ if (count == 0) complain (_("unmatched %s"), "`}'"); count--; - if (count <= 0) - { - if (defines_flag) - obstack_sgrow (&defines_obstack, epilogue); - /* JF don't choke on trailing semi */ - c = skip_white_space (); - if (c != ';') - ungetc (c, finput); - obstack_1grow (&union_obstack, 0); - muscle_insert ("stype", obstack_finish (&union_obstack)); - return; - } + if (!count) + done = TRUE; + break; } - - c = getc (finput); } + if (defines_flag) + obstack_sgrow (&defines_obstack, epilogue); + /* JF don't choke on trailing semi */ + c = skip_white_space (); + if (c != ';') + ungetc (c, finput); + obstack_1grow (&union_obstack, 0); + muscle_insert ("stype", obstack_finish (&union_obstack)); } -- 2.45.2