hush: fix handling of backslashes in variable assignment

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko
2010-09-04 19:52:44 +02:00
parent 8ae6e9be5c
commit e298ce69ba
5 changed files with 74 additions and 41 deletions

View File

@ -31,26 +31,23 @@ char *scanleft(char *string, char *pattern, bool match_at_left)
char c;
char *loc = string;
do {
while (1) {
int match;
const char *s;
c = *loc;
if (match_at_left) {
*loc = '\0';
s = string;
} else
s = loc;
match = pmatch(pattern, s);
*loc = c;
match = pmatch(pattern, string);
*loc = c;
} else {
match = pmatch(pattern, loc);
}
if (match)
return loc;
if (!c)
return NULL;
loc++;
} while (c);
return NULL;
}
}
char *scanright(char *string, char *pattern, bool match_at_left)
@ -60,20 +57,17 @@ char *scanright(char *string, char *pattern, bool match_at_left)
while (loc >= string) {
int match;
const char *s;
c = *loc;
if (match_at_left) {
*loc = '\0';
s = string;
} else
s = loc;
match = pmatch(pattern, s);
*loc = c;
match = pmatch(pattern, string);
*loc = c;
} else {
match = pmatch(pattern, loc);
}
if (match)
return loc;
loc--;
}