Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 1 | /* match.h - interface to shell ##/%% matching code */ |
| 2 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 3 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
| 4 | |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 5 | typedef char *(*scan_t)(char *string, char *match, bool zero); |
| 6 | |
| 7 | char *scanleft(char *string, char *match, bool zero); |
| 8 | char *scanright(char *string, char *match, bool zero); |
| 9 | |
| 10 | static inline scan_t pick_scan(char op1, char op2, bool *zero) |
| 11 | { |
| 12 | /* # - scanleft |
| 13 | * ## - scanright |
| 14 | * % - scanright |
| 15 | * %% - scanleft |
| 16 | */ |
| 17 | if (op1 == '#') { |
| 18 | *zero = true; |
| 19 | return op1 == op2 ? scanright : scanleft; |
| 20 | } else { |
| 21 | *zero = false; |
| 22 | return op1 == op2 ? scanleft : scanright; |
| 23 | } |
| 24 | } |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 25 | |
| 26 | POP_SAVED_FUNCTION_VISIBILITY |