diff options
author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-03-15 10:59:46 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 20:59:18 -0700 |
commit | 44885a47c759cc87206c1f6f341869575f36199f (patch) | |
tree | 5658a5da6830e98c44957ccbb32a456873b4dd6c /test-lexing.c | |
parent | Parse structure-or-union-specifiers. (diff) | |
download | sparse-44885a47c759cc87206c1f6f341869575f36199f.tar.gz sparse-44885a47c759cc87206c1f6f341869575f36199f.tar.bz2 sparse-44885a47c759cc87206c1f6f341869575f36199f.zip |
Make lexing tester print out string constants properly.
Make string constants contain the final '\0' at the end.
Diffstat (limited to 'test-lexing.c')
-rw-r--r-- | test-lexing.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/test-lexing.c b/test-lexing.c index 007f404..d4638bb 100644 --- a/test-lexing.c +++ b/test-lexing.c @@ -8,14 +8,8 @@ #include "token.h" -void callback(struct token *token) -{ - printf("%s ", show_token(token)); -} - int main(int argc, char **argv) { - int line; int fd = open(argv[1], O_RDONLY); struct token *token; @@ -23,14 +17,13 @@ int main(int argc, char **argv) die("No such file: %s", argv[1]); token = tokenize(argv[1], fd); - line = token->line; while (token) { - callback(token); - token = token->next; - if (token && token->line != line) { - line = token->line; - putchar('\n'); - } + struct token *next = token->next; + char separator = '\n'; + if (next && next->line == token->line) + separator = ' '; + printf("%s%c", show_token(token), separator); + token = next; } putchar('\n'); show_identifier_stats(); |