sh: Don't scan word twice in ${param+-word}.

There is no longer a case where argbackq has already been advanced but the
string pointer needs to be advanced.
This commit is contained in:
Jilles Tjoelker 2017-04-02 12:37:43 +00:00
parent 3f4760c8e1
commit 9e1bb30e23

View File

@ -753,15 +753,14 @@ evalvar(const char *p, struct nodelist **restrict argbackq, int flag,
break;
case VSNORMAL:
break;
return p;
case VSPLUS:
case VSMINUS:
if (!set) {
argstr(p, argbackq,
return argstr(p, argbackq,
flag | (flag & EXP_SPLIT ? EXP_SPLIT_LIT : 0) |
(varflags & VSQUOTE ? EXP_LIT_QUOTED : 0), dst);
break;
}
break;
@ -769,10 +768,8 @@ evalvar(const char *p, struct nodelist **restrict argbackq, int flag,
case VSTRIMLEFTMAX:
case VSTRIMRIGHT:
case VSTRIMRIGHTMAX:
if (!set) {
set = 1;
if (!set)
break;
}
/*
* Terminate the string and start recording the pattern
* right after it
@ -805,15 +802,14 @@ evalvar(const char *p, struct nodelist **restrict argbackq, int flag,
abort();
}
if (subtype != VSNORMAL) { /* skip to end of alternative */
{ /* skip to end of alternative */
int nesting = 1;
for (;;) {
if ((c = *p++) == CTLESC)
p++;
else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE)) {
if (set)
*argbackq = (*argbackq)->next;
} else if (c == CTLVAR) {
else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE))
*argbackq = (*argbackq)->next;
else if (c == CTLVAR) {
if ((*p++ & VSTYPE) != VSNORMAL)
nesting++;
} else if (c == CTLENDVAR) {