* [PATCH] - add --version to command line
@ 2008-04-30 17:07 Joe Perches
0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2008-04-30 17:07 UTC (permalink / raw)
To: linux-sparse
sparse doesn't support --version.
Perhaps a patch like this is acceptable?
Signed-off-by: Joe Perches <joe@perches.com>
diff --git a/Makefile b/Makefile
index 3eab17e..dfcb6b7 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ OS ?= linux
CC ?= gcc
CFLAGS ?= -O2 -finline-functions -fno-strict-aliasing -g
CFLAGS += -Wall -Wwrite-strings
+CFLAGS += -DSPARSE_VERSION=$(VERSION)
LDFLAGS ?= -g
AR ?= ar
diff --git a/lib.c b/lib.c
index 0abcc9a..7f29174 100644
--- a/lib.c
+++ b/lib.c
@@ -823,6 +823,19 @@ static struct symbol_list *sparse_initial(void)
return sparse_tokenstream(token);
}
+#define stringize_1(x) #x
+#define stringize(x) stringize_1(x)
+
+static void handle_version(char *name)
+{
+ char* exe = strrchr(name, '/');
+ if (exe)
+ exe++;
+ else
+ exe = name;
+ die("%s %s", exe, stringize(SPARSE_VERSION));
+}
+
struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **filelist)
{
char **args;
@@ -838,7 +851,11 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
break;
if (arg[0] == '-' && arg[1]) {
- args = handle_switch(arg+1, args);
+ if (!strcmp("-version", &arg[1])) {
+ handle_version(argv[0]);
+ } else {
+ args = handle_switch(arg+1, args);
+ }
continue;
}
add_ptr_list_notag(filelist, arg);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-04-30 17:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-30 17:07 [PATCH] - add --version to command line Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).