diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-11-23 23:18:58 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:04:40 -0700 |
commit | 95e9f97b9d68cb0146c8c8047eaeaa4971243d88 (patch) | |
tree | 70036f67bd73c0195ac9ea4501c78be5eb18fb1e /compile.c | |
parent | Clean up test-parsing too. (diff) | |
download | sparse-95e9f97b9d68cb0146c8c8047eaeaa4971243d88.tar.gz sparse-95e9f97b9d68cb0146c8c8047eaeaa4971243d88.tar.bz2 sparse-95e9f97b9d68cb0146c8c8047eaeaa4971243d88.zip |
Make "compile" use the sparse() helper function too.
It did some extra work to get the filename for the output,
so it needed some more care.
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 61 |
1 files changed, 6 insertions, 55 deletions
@@ -36,67 +36,18 @@ static void clean_up_symbols(struct symbol_list *list) int main(int argc, char **argv) { - int fd; - char *basename, *filename = NULL, **args; - struct token *token; + const char *basename, *filename; struct symbol_list *list; - // Initialize symbol stream first, so that we can add defines etc - init_symbols(); - - create_builtin_stream(); - - args = argv; - for (;;) { - char *arg = *++args; - if (!arg) - break; - if (arg[0] == '-') { - args = handle_switch(arg + 1, args); - continue; - } - filename = arg; - } - - // Initialize type system - init_ctype(); - - if (filename == NULL) - die("No file specified"); + list = sparse(argc, argv); + filename = input_streams[1].name; basename = strrchr(filename, '/'); - if (!basename) - basename = filename; - else if ((basename == filename) && (basename[1] == 0)) { - fprintf(stderr, "um\n"); - exit(1); - } else { - basename++; - if (*basename == 0) { - fprintf(stderr, "um\n"); - exit(1); - } - } - - fd = open(filename, O_RDONLY); - if (fd < 0) - die("No such file: %s", filename); - - // Tokenize the input stream - token = tokenize(filename, fd, NULL, includepath); - close(fd); - - // Prepend the initial built-in stream - token = tokenize_buffer(pre_buffer, pre_buffer_size, token); - - // Pre-process the stream - token = preprocess(token); - - // Parse the resulting C code - list = translation_unit(token); + if (basename) + filename = basename+1; // Do type evaluation and simplification - emit_unit_begin(basename); + emit_unit_begin(filename); clean_up_symbols(list); emit_unit_end(); |