mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
* src/reader.c (copy_comment2): Expect the input stream to be on
the `/' which is suspected to open a comment, instead of being called after `//' or `/*' was read. (copy_comment, copy_definition, parse_union_decl, copy_action) (copy_guard): Adjust.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2000-10-16 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/reader.c (copy_comment2): Expect the input stream to be on
|
||||||
|
the `/' which is suspected to open a comment, instead of being
|
||||||
|
called after `//' or `/*' was read.
|
||||||
|
(copy_comment, copy_definition, parse_union_decl, copy_action)
|
||||||
|
(copy_guard): Adjust.
|
||||||
|
|
||||||
|
|
||||||
2000-10-16 Akim Demaille <akim@epita.fr>
|
2000-10-16 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reader.c (parse_expect_decl): Use `skip_white_space' and
|
* src/reader.c (parse_expect_decl): Use `skip_white_space' and
|
||||||
|
|||||||
78
src/reader.c
78
src/reader.c
@@ -195,23 +195,43 @@ copy_string (FILE *fin, FILE *fout, int match)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------.
|
/*----------------------------------------------------------------.
|
||||||
| Dump the comment from IN to OUT1 and OUT2. C is either `*' or |
|
| Dump the wannabee comment from IN to OUT1 and OUT2. In fact we |
|
||||||
| `/', depending upon the type of comments used. OUT2 might be |
|
| just saw a `/', which might or might not be a comment. In any |
|
||||||
| NULL. |
|
| case, copy what we saw. |
|
||||||
`---------------------------------------------------------------*/
|
| |
|
||||||
|
| OUT2 might be NULL. |
|
||||||
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_comment2 (FILE *in, FILE *out1, FILE *out2, int c)
|
copy_comment2 (FILE *fin, FILE *out1, FILE *out2)
|
||||||
{
|
{
|
||||||
int cplus_comment;
|
int cplus_comment;
|
||||||
int ended;
|
int ended;
|
||||||
|
int c;
|
||||||
|
|
||||||
|
/* We read a `/', output it. */
|
||||||
|
putc ('/', out1);
|
||||||
|
if (out2)
|
||||||
|
putc ('/', out2);
|
||||||
|
|
||||||
|
switch ((c = getc (fin)))
|
||||||
|
{
|
||||||
|
case '/':
|
||||||
|
cplus_comment = 1;
|
||||||
|
break;
|
||||||
|
case '*':
|
||||||
|
cplus_comment = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ungetc (c, fin);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cplus_comment = (c == '/');
|
|
||||||
putc (c, out1);
|
putc (c, out1);
|
||||||
if (out2)
|
if (out2)
|
||||||
putc (c, out2);
|
putc (c, out2);
|
||||||
c = getc (in);
|
c = getc (fin);
|
||||||
|
|
||||||
ended = 0;
|
ended = 0;
|
||||||
while (!ended)
|
while (!ended)
|
||||||
@@ -223,7 +243,7 @@ copy_comment2 (FILE *in, FILE *out1, FILE *out2, int c)
|
|||||||
putc (c, out1);
|
putc (c, out1);
|
||||||
if (out2)
|
if (out2)
|
||||||
putc (c, out2);
|
putc (c, out2);
|
||||||
c = getc (in);
|
c = getc (fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '/')
|
if (c == '/')
|
||||||
@@ -243,7 +263,7 @@ copy_comment2 (FILE *in, FILE *out1, FILE *out2, int c)
|
|||||||
if (cplus_comment)
|
if (cplus_comment)
|
||||||
ended = 1;
|
ended = 1;
|
||||||
else
|
else
|
||||||
c = getc (in);
|
c = getc (fin);
|
||||||
}
|
}
|
||||||
else if (c == EOF)
|
else if (c == EOF)
|
||||||
fatal (_("unterminated comment"));
|
fatal (_("unterminated comment"));
|
||||||
@@ -252,21 +272,21 @@ copy_comment2 (FILE *in, FILE *out1, FILE *out2, int c)
|
|||||||
putc (c, out1);
|
putc (c, out1);
|
||||||
if (out2)
|
if (out2)
|
||||||
putc (c, out2);
|
putc (c, out2);
|
||||||
c = getc (in);
|
c = getc (fin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
| Dump the comment from FIN to FOUT. C is either `*' or `/', |
|
| Dump the comment (actually the current string starting with a `/') |
|
||||||
| depending upon the type of comments used. |
|
| from FIN to FOUT. |
|
||||||
`------------------------------------------------------------*/
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_comment (FILE *fin, FILE *fout, int c)
|
copy_comment (FILE *fin, FILE *fout)
|
||||||
{
|
{
|
||||||
copy_comment2 (fin, fout, NULL, c);
|
copy_comment2 (fin, fout, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -416,11 +436,7 @@ copy_definition (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
putc (c, fattrs);
|
copy_comment (finput, fattrs);
|
||||||
c = getc (finput);
|
|
||||||
if (c != '*' && c != '/')
|
|
||||||
continue;
|
|
||||||
copy_comment (finput, fattrs, c);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOF:
|
case EOF:
|
||||||
@@ -732,13 +748,9 @@ parse_union_decl (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
c = getc (finput);
|
copy_comment2 (finput, fattrs, fdefines);
|
||||||
if (c != '*' && c != '/')
|
|
||||||
continue;
|
|
||||||
copy_comment2 (finput, fattrs, fdefines, c);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case '{':
|
case '{':
|
||||||
count++;
|
count++;
|
||||||
break;
|
break;
|
||||||
@@ -1011,11 +1023,7 @@ copy_action (symbol_list *rule, int stack_offset)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
putc (c, faction);
|
copy_comment (finput, faction);
|
||||||
c = getc (finput);
|
|
||||||
if (c != '*' && c != '/')
|
|
||||||
continue;
|
|
||||||
copy_comment (finput, faction, c);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
@@ -1108,11 +1116,7 @@ copy_guard (symbol_list *rule, int stack_offset)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
putc (c, fguard);
|
copy_comment (finput, fguard);
|
||||||
c = getc (finput);
|
|
||||||
if (c != '*' && c != '/')
|
|
||||||
continue;
|
|
||||||
copy_comment (finput, fguard, c);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
|
|||||||
Reference in New Issue
Block a user