linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: linux-sparse@vger.kernel.org
Subject: [PATCH] - add --version to command line
Date: Wed, 30 Apr 2008 10:07:29 -0700	[thread overview]
Message-ID: <1209575249.2064.3.camel@localhost> (raw)

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



                 reply	other threads:[~2008-04-30 17:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1209575249.2064.3.camel@localhost \
    --to=joe@perches.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).