aboutsummaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
authorChristopher Li <sparse@chrisli.org>2006-11-30 02:11:36 -0800
committerJosh Triplett <josh@freedesktop.org>2006-12-04 23:27:58 -0800
commit4ad8ad708f80c91e70f8491e4d62dccc40358887 (patch)
tree7d09aa58e537095a1567568913ab233408dfc835 /lib.c
parentdelay removing file scope (diff)
downloadsparse-4ad8ad708f80c91e70f8491e4d62dccc40358887.tar.gz
sparse-4ad8ad708f80c91e70f8491e4d62dccc40358887.tar.bz2
sparse-4ad8ad708f80c91e70f8491e4d62dccc40358887.zip
cleanup write to argument array hack
The sparse interface is a kind of snaky that it change the input argument array. The function sparse() does the same hack just to skip the files. This patch add the ptr list for string. So sparse_initialize will return list of file to compile. The string pointer is not aligned at word boundary. This patch introduce non taged version of the ptr list iteration function. Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/lib.c b/lib.c
index 525c64f..171ce59 100644
--- a/lib.c
+++ b/lib.c
@@ -612,10 +612,9 @@ static struct symbol_list *sparse_initial(void)
return sparse_tokenstream(token);
}
-struct symbol_list *sparse_initialize(int argc, char **argv)
+struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **filelist)
{
char **args;
- int files = 0;
struct symbol_list *list;
// Initialize symbol stream first, so that we can add defines etc
@@ -631,17 +630,11 @@ struct symbol_list *sparse_initialize(int argc, char **argv)
args = handle_switch(arg+1, args);
continue;
}
-
- /*
- * Hacky hacky hacky: we re-use the argument space
- * to save the filenames.
- */
- argv[files++] = arg;
+ add_ptr_list_notag(filelist, arg);
}
list = NULL;
- argv[files] = NULL;
- if (files) {
+ if (!ptr_list_empty(filelist)) {
// Initialize type system
init_ctype();
@@ -661,22 +654,13 @@ struct symbol_list *sparse_initialize(int argc, char **argv)
return list;
}
-struct symbol_list * __sparse(char **argv)
+struct symbol_list * __sparse(char *filename)
{
struct symbol_list *res;
- char *filename, *next;
/* Clear previous symbol list */
translation_unit_used_list = NULL;
- filename = *argv;
- if (!filename)
- return NULL;
- do {
- next = argv[1];
- *argv++ = next;
- } while (next);
-
new_file_scope();
res = sparse_file(filename);
@@ -687,9 +671,9 @@ struct symbol_list * __sparse(char **argv)
return res;
}
-struct symbol_list * sparse(char **argv)
+struct symbol_list * sparse(char *filename)
{
- struct symbol_list *res = __sparse(argv);
+ struct symbol_list *res = __sparse(filename);
/* Evaluate the complete symbol list */
evaluate_symbol_list(res);