diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c.l | 17 | ||||
-rw-r--r-- | src/linked-list.c | 4 | ||||
-rw-r--r-- | src/output.c | 4 | ||||
-rw-r--r-- | src/parser.c | 29 |
4 files changed, 47 insertions, 7 deletions
@@ -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 |