blob: 90597ee54ba62955977ab8773e486e54559267f3 [file] [log] [blame]
Mike Frysingera4f331d2009-04-07 06:03:22 +00001/* match.h - interface to shell ##/%% matching code */
2
Denis Vlasenkof81e8db2009-04-09 12:35:13 +00003PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
4
Denis Vlasenko5b7589e2009-04-26 11:25:19 +00005typedef char *(*scan_t)(char *string, char *match, bool match_at_left);
Mike Frysingera4f331d2009-04-07 06:03:22 +00006
Denis Vlasenko5b7589e2009-04-26 11:25:19 +00007char *scanleft(char *string, char *match, bool match_at_left);
8char *scanright(char *string, char *match, bool match_at_left);
Mike Frysingera4f331d2009-04-07 06:03:22 +00009
Denis Vlasenko5b7589e2009-04-26 11:25:19 +000010static inline scan_t pick_scan(char op1, char op2, bool *match_at_left)
Mike Frysingera4f331d2009-04-07 06:03:22 +000011{
12 /* # - scanleft
13 * ## - scanright
14 * % - scanright
15 * %% - scanleft
16 */
17 if (op1 == '#') {
Denis Vlasenko5b7589e2009-04-26 11:25:19 +000018 *match_at_left = true;
Mike Frysingera4f331d2009-04-07 06:03:22 +000019 return op1 == op2 ? scanright : scanleft;
20 } else {
Denis Vlasenko5b7589e2009-04-26 11:25:19 +000021 *match_at_left = false;
Mike Frysingera4f331d2009-04-07 06:03:22 +000022 return op1 == op2 ? scanleft : scanright;
23 }
24}
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000025
26POP_SAVED_FUNCTION_VISIBILITY