* 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.
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 '(':
}
break;
- case '\0':
- break;
-
default:
if (isblank ((unsigned char)p[-1]))
break;
{
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. */
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. */
closeparen = ')';
else if (c == '{')
closeparen = '}';
+ else if (c == '\0')
+ return NULL;
else
/* '$$' or '$X'. Either way, nothing special to do here. */
continue;