]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 59881] Handle vertical TAB consistently
authorPaul Smith <psmith@gnu.org>
Sun, 14 Mar 2021 23:12:24 +0000 (19:12 -0400)
committerPaul Smith <psmith@gnu.org>
Mon, 15 Mar 2021 05:16:32 +0000 (01:16 -0400)
While parsing makefiles get_next_mword() was treating VTAB as a word
character rather than a word separator.  However, when using
find_next_token(), for example in patsubst_expand_pat(), we treated
VTAB as a word separator causing multiple words to appear where we
didn't expect them.

* src/makeint.h (END_OF_TOKEN): Change from a loop to a boolean check.
* src/misc.c (end_of_token): Move the loop here.
* src/read.c (get_next_mword): Skip whitespace, not just blank, to
find the start of the word and use END_OF_TOKEN() to decide when the
current word is finished.

src/makeint.h
src/misc.c
src/read.c

index 015bf5c2796cfb59e83acd4548b48142ad5ff440..fcfb7bdf0f312411faa356533269d7f6fe90dbd4 100644 (file)
@@ -463,8 +463,8 @@ extern int unixy_shell;
 
 #define ISBLANK(c)      STOP_SET((c),MAP_BLANK)
 #define ISSPACE(c)      STOP_SET((c),MAP_SPACE)
+#define END_OF_TOKEN(c) STOP_SET((c),MAP_SPACE|MAP_NUL)
 #define NEXT_TOKEN(s)   while (ISSPACE (*(s))) ++(s)
-#define END_OF_TOKEN(s) while (! STOP_SET (*(s), MAP_SPACE|MAP_NUL)) ++(s)
 
 /* We can't run setrlimit when using posix_spawn.  */
 #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN)
index bc5060a38af529b38b9cecc6b73f5e211f271e3b..3072952c66e3d5f2830cffbbac29abba2c14054f 100644 (file)
@@ -308,7 +308,8 @@ lindex (const char *s, const char *limit, int c)
 char *
 end_of_token (const char *s)
 {
-  END_OF_TOKEN (s);
+  while (! END_OF_TOKEN (*s))
+    ++s;
   return (char *)s;
 }
 
index 3b4b0fe48c27d794ea513365ca6c883d2609dfcf..ac4dc8458e73599a9b3f57c8d894f03cedebfef1 100644 (file)
@@ -2735,7 +2735,7 @@ get_next_mword (char *buffer, char **startp, size_t *length)
   char c;
 
   /* Skip any leading whitespace.  */
-  while (ISBLANK (*p))
+  while (ISSPACE (*p))
     ++p;
 
   beg = p;
@@ -2821,11 +2821,11 @@ get_next_mword (char *buffer, char **startp, size_t *length)
       char closeparen;
       int count;
 
+      if (END_OF_TOKEN (c))
+        goto done_word;
+
       switch (c)
         {
-        case '\0':
-        case ' ':
-        case '\t':
         case '=':
           goto done_word;