aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-09-01 12:46:28 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:01 -0700
commit2e34026cba4bc35539f9039a6ee5801a96fc2290 (patch)
tree058e162367e44e25e76a99b84caac2bf09f6df6d
parent80b880d61d0cbcee8bb6561d14f7cae841cfa2e2 (diff)
downloadsparse-dev-2e34026cba4bc35539f9039a6ee5801a96fc2290.tar.gz
Make "-nostdinc" command line flag actually work.
Also add some infrastructure to make it easier to add new random command line options.
-rw-r--r--lib.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib.c b/lib.c
index ce30d306..fe8b6380 100644
--- a/lib.c
+++ b/lib.c
@@ -679,9 +679,25 @@ char **handle_switch_W(char *arg, char **next)
return next;
}
+char **handle_nostdinc(char *arg, char **next)
+{
+ add_pre_buffer("#nostdinc\n");
+ return next;
+}
+
+struct switches {
+ const char *name;
+ char **(*fn)(char *, char**);
+};
+
char **handle_switch(char *arg, char **next)
{
char **rc = next;
+ static struct switches cmd[] = {
+ { "nostdinc", handle_nostdinc },
+ { NULL, NULL }
+ };
+ struct switches *s;
switch (*arg) {
case 'D': rc = handle_switch_D(arg, next); break;
@@ -694,12 +710,20 @@ char **handle_switch(char *arg, char **next)
case 'o': rc = handle_switch_o(arg, next); break;
case 'W': rc = handle_switch_W(arg, next); break;
default:
- /*
- * Ignore unknown command line options:
- * they're probably gcc switches
- */
break;
}
+
+ s = cmd;
+ while (s->name) {
+ if (!strcmp(s->name, arg))
+ return s->fn(arg, next);
+ s++;
+ }
+
+ /*
+ * Ignore unknown command line options:
+ * they're probably gcc switches
+ */
return rc;
}