ash: fix dequoting error detected by var_bash4 test
But the test still fails (one more bug to fix) function old new delta changepath 195 192 -3 readtoken1 3247 3240 -7 subevalvar 1204 1184 -20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-30) Total: -30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
f56fe82542
commit
f02c82f38c
13
shell/ash.c
13
shell/ash.c
@ -6267,7 +6267,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags)
|
|||||||
|
|
||||||
#if ENABLE_ASH_BASH_COMPAT
|
#if ENABLE_ASH_BASH_COMPAT
|
||||||
static char *
|
static char *
|
||||||
parse_sub_pattern(char *arg, int inquotes)
|
parse_sub_pattern(char *arg, int varflags)
|
||||||
{
|
{
|
||||||
char *idx, *repl = NULL;
|
char *idx, *repl = NULL;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@ -6285,7 +6285,7 @@ parse_sub_pattern(char *arg, int inquotes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*idx++ = c;
|
*idx++ = c;
|
||||||
if (!inquotes && c == '\\' && arg[1] == '\\')
|
if (!(varflags & VSQUOTE) && c == '\\' && arg[1] == '\\')
|
||||||
arg++; /* skip both \\, not just first one */
|
arg++; /* skip both \\, not just first one */
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
@ -6427,7 +6427,7 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
|
|||||||
char *idx, *end;
|
char *idx, *end;
|
||||||
|
|
||||||
if (!repl) {
|
if (!repl) {
|
||||||
repl = parse_sub_pattern(str, varflags & VSQUOTE);
|
repl = parse_sub_pattern(str, varflags);
|
||||||
//bb_error_msg("repl:'%s'", repl);
|
//bb_error_msg("repl:'%s'", repl);
|
||||||
if (!repl)
|
if (!repl)
|
||||||
repl = nullstr;
|
repl = nullstr;
|
||||||
@ -6496,12 +6496,11 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (subtype == VSREPLACE) {
|
if (subtype == VSREPLACE) {
|
||||||
|
//bb_error_msg("tail:'%s', quotes:%x", idx, quotes);
|
||||||
while (*idx) {
|
while (*idx) {
|
||||||
char *restart_detect = stackblock();
|
char *restart_detect = stackblock();
|
||||||
if (quotes && *idx == '\\') {
|
if (quotes && (unsigned char)*idx == CTLESC)
|
||||||
STPUTC(CTLESC, expdest);
|
idx++;
|
||||||
len++;
|
|
||||||
}
|
|
||||||
STPUTC(*idx, expdest);
|
STPUTC(*idx, expdest);
|
||||||
if (stackblock() != restart_detect)
|
if (stackblock() != restart_detect)
|
||||||
goto restart;
|
goto restart;
|
||||||
|
Loading…
Reference in New Issue
Block a user