[PATCH 6/6] fix: spaces in macro definition on the command line

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

 



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@xxxxxxxxx>
---
 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

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