summaryrefslogtreecommitdiff
path: root/shell/match.c
diff options
context:
space:
mode:
authorDenys Vlasenko2010-09-04 19:52:44 +0200
committerDenys Vlasenko2010-09-04 19:52:44 +0200
commite298ce69baef029f3951dd1d5ed50fdbc6c55c80 (patch)
tree85060a1578474d8ca4e1d5f89e1b0c8241235ba5 /shell/match.c
parent8ae6e9be5c1c7e7a1e9ce96f463c7d6ab1c9500f (diff)
downloadbusybox-e298ce69baef029f3951dd1d5ed50fdbc6c55c80.zip
busybox-e298ce69baef029f3951dd1d5ed50fdbc6c55c80.tar.gz
hush: fix handling of backslashes in variable assignment
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'shell/match.c')
-rw-r--r--shell/match.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/shell/match.c b/shell/match.c
index 8b1ddac..01b8439 100644
--- a/shell/match.c
+++ b/shell/match.c
@@ -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--;
}