summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2011-10-09 14:18:11 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-10-09 14:24:00 (GMT)
commit1fdfe0ec055c5e8c080dd1427d98730885ac8bd4 (patch) (side-by-side diff)
treed6c496e08fbd85f3e4aa60a52c82f4db19c8b6c6 /src
parent404a540341683e29cbdbc6a958a762d9f8c5d6bd (diff)
downloadcflow-1fdfe0ec055c5e8c080dd1427d98730885ac8bd4.tar.gz
cflow-1fdfe0ec055c5e8c080dd1427d98730885ac8bd4.tar.bz2
Allow for wrappers following the structure definition.
* src/c.l (get_token): do not call yylex if previous call returned EOF. (source): Clear EOF indicator. * src/linked-list.c: Placate gcc warnings. * src/output.c: Likewise. * src/parser.c (skip_balanced): New function. (skip_struct): Allow for a wrapper after closing brace. * tests/struct00.at: New testcase. * tests/struct01.at: New testcase. * tests/Makefile.am: Add new testcases. * tests/testsuite.at: Likewise. * NEWS, configure.ac: Set version 1.4 * THANKS: Update.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/c.l17
-rw-r--r--src/linked-list.c4
-rw-r--r--src/output.c4
-rw-r--r--src/parser.c29
4 files changed, 47 insertions, 7 deletions
diff --git a/src/c.l b/src/c.l
index c1e6fad..bb38d17 100644
--- a/src/c.l
+++ b/src/c.l
@@ -342,11 +342,21 @@ yywrap()
return 1;
}
+static int hit_eof;
+
int
get_token()
{
- int tok = yylex();
- prev_token = tok;
+ int tok;
+
+ if (hit_eof)
+ tok = 0;
+ else {
+ tok = yylex();
+ prev_token = tok;
+ if (!tok)
+ hit_eof = 1;
+ }
return tok;
}
@@ -371,7 +381,8 @@ source(char *name)
canonical_filename = filename;
line_num = 1;
input_file_count++;
-
+ hit_eof = 0;
+
yyrestart(fp);
return 0;
}
diff --git a/src/linked-list.c b/src/linked-list.c
index 9b71276..e81fd1c 100644
--- a/src/linked-list.c
+++ b/src/linked-list.c
@@ -100,12 +100,12 @@ linked_list_unlink(struct linked_list *list, struct linked_list_entry *ent)
{
struct linked_list_entry *p;
- if (p = ent->prev)
+ if ((p = ent->prev))
p->next = ent->next;
else
list->head = ent->next;
- if (p = ent->next)
+ if ((p = ent->next))
p->prev = ent->prev;
else
list->tail = ent->prev;
diff --git a/src/output.c b/src/output.c
index bef37fd..519a332 100644
--- a/src/output.c
+++ b/src/output.c
@@ -144,6 +144,7 @@ separator()
output_driver[driver_index].handler_data);
}
+#if 0
static void
print_text(char *buf)
{
@@ -152,6 +153,7 @@ print_text(char *buf)
buf,
output_driver[driver_index].handler_data);
}
+#endif
static int
print_symbol (int direct, int level, int last, Symbol *sym)
@@ -288,7 +290,7 @@ is_printable(struct linked_list_entry *p)
static int
is_last(struct linked_list_entry *p)
{
- while (p = p->next)
+ while ((p = p->next))
if (is_printable(p))
return 0;
return 1;
diff --git a/src/parser.c b/src/parser.c
index cdfea4e..af0d0ab 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1,5 +1,5 @@
/* This file is part of GNU cflow
- Copyright (C) 1997, 2005, 2006, 2007, 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 1997, 2005, 2006, 2007, 2009, 2010, 2011 Sergey Poznyakoff
GNU cflow is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -305,6 +305,28 @@ skip_to(int c)
}
int
+skip_balanced(int open_tok, int close_tok, int level)
+{
+ if (level == 0) {
+ if (nexttoken() != open_tok) {
+ putback();
+ return 1;
+ }
+ }
+ while (nexttoken()) {
+ if (tok.type == open_tok)
+ level++;
+ else if (tok.type == close_tok) {
+ if (level-- == 0) {
+ nexttoken();
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
+
+int
yyparse()
{
Ident identifier;
@@ -644,6 +666,11 @@ skip_struct()
nexttoken();
} while (lev);
}
+
+ while (tok.type == PARM_WRAPPER) {
+ if (skip_balanced('(', ')', 0) == -1)
+ file_error(_("unexpected end of file in struct"), 0);
+ }
}
void

Return to:

Send suggestions and report system problems to the System administrator.