diff options
Diffstat (limited to 'shell/match.h')
-rw-r--r-- | shell/match.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/shell/match.h b/shell/match.h index c022ceb25..aa393ed1a 100644 --- a/shell/match.h +++ b/shell/match.h | |||
@@ -7,25 +7,26 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
7 | 7 | ||
8 | //TODO! Why ash.c still uses internal version?! | 8 | //TODO! Why ash.c still uses internal version?! |
9 | 9 | ||
10 | typedef char *(*scan_t)(char *string, char *match, bool match_at_left); | 10 | enum { |
11 | SCAN_MOVE_FROM_LEFT = (1 << 0), | ||
12 | SCAN_MOVE_FROM_RIGHT = (1 << 1), | ||
13 | SCAN_MATCH_LEFT_HALF = (1 << 2), | ||
14 | SCAN_MATCH_RIGHT_HALF = (1 << 3), | ||
15 | }; | ||
11 | 16 | ||
12 | char *scanleft(char *string, char *match, bool match_at_left); | 17 | char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags); |
13 | char *scanright(char *string, char *match, bool match_at_left); | ||
14 | 18 | ||
15 | static inline scan_t pick_scan(char op1, char op2, bool *match_at_left) | 19 | static inline unsigned pick_scan(char op1, char op2) |
16 | { | 20 | { |
17 | /* # - scanleft | 21 | unsigned scan_flags; |
18 | * ## - scanright | ||
19 | * % - scanright | ||
20 | * %% - scanleft | ||
21 | */ | ||
22 | if (op1 == '#') { | 22 | if (op1 == '#') { |
23 | *match_at_left = true; | 23 | scan_flags = SCAN_MATCH_LEFT_HALF + |
24 | return op1 == op2 ? scanright : scanleft; | 24 | (op1 == op2 ? SCAN_MOVE_FROM_RIGHT : SCAN_MOVE_FROM_LEFT); |
25 | } else { | 25 | } else { /* % */ |
26 | *match_at_left = false; | 26 | scan_flags = SCAN_MATCH_RIGHT_HALF + |
27 | return op1 == op2 ? scanleft : scanright; | 27 | (op1 == op2 ? SCAN_MOVE_FROM_LEFT : SCAN_MOVE_FROM_RIGHT); |
28 | } | 28 | } |
29 | return scan_flags; | ||
29 | } | 30 | } |
30 | 31 | ||
31 | POP_SAVED_FUNCTION_VISIBILITY | 32 | POP_SAVED_FUNCTION_VISIBILITY |