Apply post-1.17.3 fixes, bump version to 1.17.4
[oweals/busybox.git] / shell / match.h
1 /* match.h - interface to shell ##/%% matching code */
2
3 #ifndef SHELL_MATCH_H
4 #define SHELL_MATCH_H 1
5
6 PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
7
8 //TODO! Why ash.c still uses internal version?!
9
10 typedef char *(*scan_t)(char *string, char *match, bool match_at_left);
11
12 char *scanleft(char *string, char *match, bool match_at_left);
13 char *scanright(char *string, char *match, bool match_at_left);
14
15 static inline scan_t pick_scan(char op1, char op2, bool *match_at_left)
16 {
17         /* #  - scanleft
18          * ## - scanright
19          * %  - scanright
20          * %% - scanleft
21          */
22         if (op1 == '#') {
23                 *match_at_left = true;
24                 return op1 == op2 ? scanright : scanleft;
25         } else {
26                 *match_at_left = false;
27                 return op1 == op2 ? scanleft : scanright;
28         }
29 }
30
31 POP_SAVED_FUNCTION_VISIBILITY
32
33 #endif