summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-05-02 03:59:36 +0000
committerBruno Haible <bruno@clisp.org>2003-05-02 03:59:36 +0000
commit31f7c8a49ebd4e8ccd4b4d01c7aca9922ff407f0 (patch)
tree77357a74f570488c06f7eebc0ed48e71aa380888 /src
parentc170151d6755c4229439882784e275f9584ab186 (diff)
downloadgperf-31f7c8a49ebd4e8ccd4b4d01c7aca9922ff407f0.tar.gz
Ignore comments at the beginning of the declarations section.
Diffstat (limited to 'src')
-rw-r--r--src/input.cc50
1 files changed, 46 insertions, 4 deletions
diff --git a/src/input.cc b/src/input.cc
index dc9a2c6..0c0c819 100644
--- a/src/input.cc
+++ b/src/input.cc
@@ -620,15 +620,57 @@ Input::read_input ()
{
if (struct_decl)
{
- /* Drop leading whitespace. */
+ /* Drop leading whitespace and comments. */
{
char *p = struct_decl;
unsigned int *l = struct_decl_linenos;
- while (p[0] == '\n' || p[0] == ' ' || p[0] == '\t')
+ for (;;)
{
+ if (p[0] == ' ' || p[0] == '\t')
+ {
+ p++;
+ continue;
+ }
if (p[0] == '\n')
- l++;
- p++;
+ {
+ l++;
+ p++;
+ continue;
+ }
+ if (p[0] == '/')
+ {
+ if (p[1] == '*')
+ {
+ /* Skip over ANSI C style comment. */
+ p += 2;
+ while (p[0] != '\0')
+ {
+ if (p[0] == '*' && p[1] == '/')
+ {
+ p += 2;
+ break;
+ }
+ if (p[0] == '\n')
+ l++;
+ p++;
+ }
+ continue;
+ }
+ if (p[1] == '/')
+ {
+ /* Skip over ISO C99 or C++ style comment. */
+ p += 2;
+ while (p[0] != '\0' && p[0] != '\n')
+ p++;
+ if (p[0] == '\n')
+ {
+ l++;
+ p++;
+ }
+ continue;
+ }
+ }
+ break;
}
if (p != struct_decl)
{