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 | |
Denis Vlasenko | 5b7589e | 2009-04-26 11:25:19 +0000 | [diff] [blame] | 5 | typedef char *(*scan_t)(char *string, char *match, bool match_at_left); |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 6 | |
Denis Vlasenko | 5b7589e | 2009-04-26 11:25:19 +0000 | [diff] [blame] | 7 | char *scanleft(char *string, char *match, bool match_at_left); |
| 8 | char *scanright(char *string, char *match, bool match_at_left); |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 9 | |
Denis Vlasenko | 5b7589e | 2009-04-26 11:25:19 +0000 | [diff] [blame] | 10 | static inline scan_t pick_scan(char op1, char op2, bool *match_at_left) |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 11 | { |
| 12 | /* # - scanleft |
| 13 | * ## - scanright |
| 14 | * % - scanright |
| 15 | * %% - scanleft |
| 16 | */ |
| 17 | if (op1 == '#') { |
Denis Vlasenko | 5b7589e | 2009-04-26 11:25:19 +0000 | [diff] [blame] | 18 | *match_at_left = true; |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 19 | return op1 == op2 ? scanright : scanleft; |
| 20 | } else { |
Denis Vlasenko | 5b7589e | 2009-04-26 11:25:19 +0000 | [diff] [blame] | 21 | *match_at_left = false; |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 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 |