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>
+
+ * 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>
* src/reader.c (parse_expect_decl): Use `skip_white_space' and
2000-10-16 Akim Demaille <akim@epita.fr>
* src/reader.c (parse_expect_decl): Use `skip_white_space' and
-/*---------------------------------------------------------------.
-| Dump the comment from IN to OUT1 and OUT2. C is either `*' or |
-| `/', depending upon the type of comments used. OUT2 might be |
-| NULL. |
-`---------------------------------------------------------------*/
+/*----------------------------------------------------------------.
+| Dump the wannabee comment from IN to OUT1 and OUT2. In fact we |
+| just saw a `/', which might or might not be a comment. In any |
+| case, copy what we saw. |
+| |
+| OUT2 might be NULL. |
+`----------------------------------------------------------------*/
-copy_comment2 (FILE *in, FILE *out1, FILE *out2, int c)
+copy_comment2 (FILE *fin, FILE *out1, FILE *out2)
{
int cplus_comment;
int ended;
{
int cplus_comment;
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);
if (out2)
putc (c, out2);
putc (c, out1);
if (out2)
putc (c, out2);
ended = 0;
while (!ended)
ended = 0;
while (!ended)
putc (c, out1);
if (out2)
putc (c, out2);
putc (c, out1);
if (out2)
putc (c, out2);
if (cplus_comment)
ended = 1;
else
if (cplus_comment)
ended = 1;
else
}
else if (c == EOF)
fatal (_("unterminated comment"));
}
else if (c == EOF)
fatal (_("unterminated comment"));
putc (c, out1);
if (out2)
putc (c, out2);
putc (c, out1);
if (out2)
putc (c, out2);
-/*------------------------------------------------------------.
-| Dump the comment from FIN to FOUT. C is either `*' or `/', |
-| depending upon the type of comments used. |
-`------------------------------------------------------------*/
+/*-------------------------------------------------------------------.
+| Dump the comment (actually the current string starting with a `/') |
+| from FIN to FOUT. |
+`-------------------------------------------------------------------*/
-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);
- putc (c, fattrs);
- c = getc (finput);
- if (c != '*' && c != '/')
- continue;
- copy_comment (finput, fattrs, c);
+ copy_comment (finput, fattrs);
- c = getc (finput);
- if (c != '*' && c != '/')
- continue;
- copy_comment2 (finput, fattrs, fdefines, c);
+ copy_comment2 (finput, fattrs, fdefines);
case '{':
count++;
break;
case '{':
count++;
break;
- putc (c, faction);
- c = getc (finput);
- if (c != '*' && c != '/')
- continue;
- copy_comment (finput, faction, c);
+ copy_comment (finput, faction);
- putc (c, fguard);
- c = getc (finput);
- if (c != '*' && c != '/')
- continue;
- copy_comment (finput, fguard, c);
+ copy_comment (finput, fguard);