[PATCH] - add --version to command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



sparse doesn't support --version.
Perhaps a patch like this is acceptable?

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>

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);


--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux