linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 6/6] fix: spaces in macro definition on the command line
Date: Wed, 13 Dec 2017 18:15:31 +0100	[thread overview]
Message-ID: <20171213171531.43707-7-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20171213171531.43707-1-luc.vanoostenryck@gmail.com>

GCC's manual or POSIX say about the '-D' option something like:
    '−D name[=value]' should be treated as if in directive
    '#define name value' (with '1' as default for the value),
    including its tokenization.
So an option like '-DM(X, Y)=...' should be processed like a
directive '#define M(X, Y) ...'.

However, the current code treat a space as a separator between
the macro and its definition, just like the '='. As consequence,
the above option is processed like the directive would be
'#define M(X, Y)=...', with 'M(X,' as the macro (name) and
'Y)=...' as its definition.

Fix this by stopping to treat the space character specially,
thus only using '=' as the separator.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 lib.c                                 | 2 +-
 validation/preprocessor/cli-D-space.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib.c b/lib.c
index 236d58fc9..e4bb639e5 100644
--- a/lib.c
+++ b/lib.c
@@ -335,7 +335,7 @@ static char **handle_switch_D(char *arg, char **next)
 		c = *arg;
 		if (!c)
 			break;
-		if (isspace((unsigned char)c) || c == '=') {
+		if (c == '=') {
 			*arg = '\0';
 			value = arg + 1;
 			break;
diff --git a/validation/preprocessor/cli-D-space.c b/validation/preprocessor/cli-D-space.c
index d104d66da..8343bf1ac 100644
--- a/validation/preprocessor/cli-D-space.c
+++ b/validation/preprocessor/cli-D-space.c
@@ -2,7 +2,6 @@ M(0,1)
 /*
  * check-name: cli: allow spaces in macros
  * check-command: sparse -E '-DM(X, Y)=a' $file
- * check-known-to-fail
  *
  * check-output-start
 
-- 
2.15.0


  parent reply	other threads:[~2017-12-13 17:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 17:15 [PATCH 0/6] whitespace & '-D' option Luc Van Oostenryck
2017-12-13 17:15 ` [PATCH 1/6] add testcase for 'sparse -D M...' Luc Van Oostenryck
2017-12-13 17:15 ` [PATCH 2/6] fix: accept " Luc Van Oostenryck
2017-12-13 17:15 ` [PATCH 3/6] testsuite: add test case for quoting of command's arguments Luc Van Oostenryck
2017-12-13 17:15 ` [PATCH 4/6] testsuite: respect command line's quotes & whitespaces Luc Van Oostenryck
2017-12-13 17:15 ` [PATCH 5/6] add test case for space within command line Luc Van Oostenryck
2017-12-13 17:15 ` Luc Van Oostenryck [this message]
2017-12-15  6:15 ` [PATCH 0/6] whitespace & '-D' option Christopher Li
2017-12-17 14:58   ` Luc Van Oostenryck

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=20171213171531.43707-7-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.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).