]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 45049] Check for '$' being the last character in a string.
authorPaul Smith <psmith@gnu.org>
Sun, 12 Jul 2015 17:25:16 +0000 (13:25 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 12 Jul 2015 17:25:16 +0000 (13:25 -0400)
* expand.c (variable_expand_string): Add a single '$' if '$' ends the
string.
* read.c (find_char_unquote, get_next_mword): Stop if '$' ends the
string.
* variable.c (parse_variable_definition): Ditto.

expand.c
read.c
variable.c

index 1c87db10a5b9c5e863b1ae36ff1a12f6034358e3..866e8a75c721c2a3a90910b8262f8b4bedefb0f5 100644 (file)
--- a/expand.c
+++ b/expand.c
@@ -235,8 +235,10 @@ variable_expand_string (char *line, const char *string, long length)
       switch (*p)
         {
         case '$':
-          /* $$ seen means output one $ to the variable output buffer.  */
-          o = variable_buffer_output (o, p, 1);
+        case '\0':
+          /* $$ or $ at the end of the string means output one $ to the
+             variable output buffer.  */
+          o = variable_buffer_output (o, p1, 1);
           break;
 
         case '(':
@@ -381,9 +383,6 @@ variable_expand_string (char *line, const char *string, long length)
           }
           break;
 
-        case '\0':
-          break;
-
         default:
           if (isblank ((unsigned char)p[-1]))
             break;
diff --git a/read.c b/read.c
index 2b5f08d11183e627a28e4a81543eb447a3d45311..d3747ce80c43af7532ef064dfbed00a20789623a 100644 (file)
--- a/read.c
+++ b/read.c
@@ -2262,6 +2262,10 @@ find_char_unquote (char *string, int map)
         {
           char openparen = p[1];
 
+          /* Check if '$' is the last character in the string.  */
+          if (openparen == '\0')
+            break;
+
           p += 2;
 
           /* Skip the contents of a non-quoted, multi-char variable ref.  */
@@ -2735,6 +2739,8 @@ get_next_mword (char *buffer, char *delim, char **startp, unsigned int *length)
           c = *(p++);
           if (c == '$')
             break;
+          if (c == '\0')
+            goto done_word;
 
           /* This is a variable reference, so note that it's expandable.
              Then read it to the matching close paren.  */
index 0b89d37c61ecf010e63c74bddb196a21cd111d81..40d691d088be4e3d1ec906f3b668b2d1ade33fdd 100644 (file)
@@ -1445,6 +1445,8 @@ parse_variable_definition (const char *p, struct variable *var)
             closeparen = ')';
           else if (c == '{')
             closeparen = '}';
+          else if (c == '\0')
+            return NULL;
           else
             /* '$$' or '$X'.  Either way, nothing special to do here.  */
             continue;