Fix stringify that got broken by other changes
[smatch.git] / test-lexing.c
blobd186f31bd8ca395019366f89c95e6234a5f0708f
1 /*
2 * Example test program that just uses the tokenization and
3 * preprocessing phases, and prints out the results.
5 * Copyright (C) 2003 Linus Torvalds, all rights reserved.
6 */
7 #include <stdarg.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include <unistd.h>
13 #include <fcntl.h>
15 #include "token.h"
16 #include "symbol.h"
18 char *includepath[] = {
19 "/usr/lib/gcc-lib/i386-redhat-linux/3.2.1/include/",
20 #if 1
21 "/home/torvalds/v2.5/linux/include/",
22 "/home/torvalds/v2.5/linux/include/asm-i386/mach-default/",
23 #else
24 "/usr/include/",
25 "/usr/local/include/",
26 #endif
27 "",
28 NULL
32 int main(int argc, char **argv)
34 int fd = open(argv[1], O_RDONLY);
35 struct token *token;
37 if (fd < 0)
38 die("No such file: %s", argv[1]);
40 init_symbols();
41 token = tokenize(argv[1], fd, NULL);
42 close(fd);
43 token = preprocess(token);
45 while (!eof_token(token)) {
46 struct token *next = token->next;
47 char * separator = "";
48 if (next->whitespace)
49 separator = " ";
50 if (next->newline)
51 separator = "\n";
52 printf("%s%s", show_token(token), separator);
53 token = next;
55 putchar('\n');
56 show_identifier_stats();
57 return 0;