diff options
Diffstat (limited to 'shell/match.c')
-rw-r--r-- | shell/match.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/shell/match.c b/shell/match.c index 47038d667..a7101ef7e 100644 --- a/shell/match.c +++ b/shell/match.c | |||
@@ -11,8 +11,6 @@ | |||
11 | * Kenneth Almquist. | 11 | * Kenneth Almquist. |
12 | * | 12 | * |
13 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | 13 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
14 | * | ||
15 | * Original BSD copyright notice is retained at the end of this file. | ||
16 | */ | 14 | */ |
17 | #ifdef STANDALONE | 15 | #ifdef STANDALONE |
18 | # include <stdbool.h> | 16 | # include <stdbool.h> |
@@ -28,7 +26,7 @@ | |||
28 | 26 | ||
29 | #define pmatch(a, b) !fnmatch((a), (b), 0) | 27 | #define pmatch(a, b) !fnmatch((a), (b), 0) |
30 | 28 | ||
31 | char *scanleft(char *string, char *pattern, bool zero) | 29 | char *scanleft(char *string, char *pattern, bool match_at_left) |
32 | { | 30 | { |
33 | char c; | 31 | char c; |
34 | char *loc = string; | 32 | char *loc = string; |
@@ -38,7 +36,7 @@ char *scanleft(char *string, char *pattern, bool zero) | |||
38 | const char *s; | 36 | const char *s; |
39 | 37 | ||
40 | c = *loc; | 38 | c = *loc; |
41 | if (zero) { | 39 | if (match_at_left) { |
42 | *loc = '\0'; | 40 | *loc = '\0'; |
43 | s = string; | 41 | s = string; |
44 | } else | 42 | } else |
@@ -55,7 +53,7 @@ char *scanleft(char *string, char *pattern, bool zero) | |||
55 | return NULL; | 53 | return NULL; |
56 | } | 54 | } |
57 | 55 | ||
58 | char *scanright(char *string, char *pattern, bool zero) | 56 | char *scanright(char *string, char *pattern, bool match_at_left) |
59 | { | 57 | { |
60 | char c; | 58 | char c; |
61 | char *loc = string + strlen(string); | 59 | char *loc = string + strlen(string); |
@@ -65,7 +63,7 @@ char *scanright(char *string, char *pattern, bool zero) | |||
65 | const char *s; | 63 | const char *s; |
66 | 64 | ||
67 | c = *loc; | 65 | c = *loc; |
68 | if (zero) { | 66 | if (match_at_left) { |
69 | *loc = '\0'; | 67 | *loc = '\0'; |
70 | s = string; | 68 | s = string; |
71 | } else | 69 | } else |
@@ -88,7 +86,7 @@ int main(int argc, char *argv[]) | |||
88 | char *string; | 86 | char *string; |
89 | char *op; | 87 | char *op; |
90 | char *pattern; | 88 | char *pattern; |
91 | bool zero; | 89 | bool match_at_left; |
92 | char *loc; | 90 | char *loc; |
93 | 91 | ||
94 | int i; | 92 | int i; |
@@ -117,15 +115,15 @@ int main(int argc, char *argv[]) | |||
117 | continue; | 115 | continue; |
118 | } | 116 | } |
119 | op = string + off; | 117 | op = string + off; |
120 | scan = pick_scan(op[0], op[1], &zero); | 118 | scan = pick_scan(op[0], op[1], &match_at_left); |
121 | pattern = op + 1; | 119 | pattern = op + 1; |
122 | if (op[0] == op[1]) | 120 | if (op[0] == op[1]) |
123 | op[1] = '\0', ++pattern; | 121 | op[1] = '\0', ++pattern; |
124 | op[0] = '\0'; | 122 | op[0] = '\0'; |
125 | 123 | ||
126 | loc = scan(string, pattern, zero); | 124 | loc = scan(string, pattern, match_at_left); |
127 | 125 | ||
128 | if (zero) { | 126 | if (match_at_left) { |
129 | printf("'%s'\n", loc); | 127 | printf("'%s'\n", loc); |
130 | } else { | 128 | } else { |
131 | *loc = '\0'; | 129 | *loc = '\0'; |