2009-04-07 06:03:22 +00:00
|
|
|
/* match.h - interface to shell ##/%% matching code */
|
|
|
|
|
2010-01-12 21:11:24 +00:00
|
|
|
#ifndef SHELL_MATCH_H
|
|
|
|
#define SHELL_MATCH_H 1
|
|
|
|
|
2009-04-09 12:35:13 +00:00
|
|
|
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
|
|
|
|
2010-01-12 22:29:57 +00:00
|
|
|
//TODO! Why ash.c still uses internal version?!
|
|
|
|
|
2009-04-26 11:25:19 +00:00
|
|
|
typedef char *(*scan_t)(char *string, char *match, bool match_at_left);
|
2009-04-07 06:03:22 +00:00
|
|
|
|
2009-04-26 11:25:19 +00:00
|
|
|
char *scanleft(char *string, char *match, bool match_at_left);
|
|
|
|
char *scanright(char *string, char *match, bool match_at_left);
|
2009-04-07 06:03:22 +00:00
|
|
|
|
2009-04-26 11:25:19 +00:00
|
|
|
static inline scan_t pick_scan(char op1, char op2, bool *match_at_left)
|
2009-04-07 06:03:22 +00:00
|
|
|
{
|
|
|
|
/* # - scanleft
|
|
|
|
* ## - scanright
|
|
|
|
* % - scanright
|
|
|
|
* %% - scanleft
|
|
|
|
*/
|
|
|
|
if (op1 == '#') {
|
2009-04-26 11:25:19 +00:00
|
|
|
*match_at_left = true;
|
2009-04-07 06:03:22 +00:00
|
|
|
return op1 == op2 ? scanright : scanleft;
|
|
|
|
} else {
|
2009-04-26 11:25:19 +00:00
|
|
|
*match_at_left = false;
|
2009-04-07 06:03:22 +00:00
|
|
|
return op1 == op2 ? scanleft : scanright;
|
|
|
|
}
|
|
|
|
}
|
2009-04-09 12:35:13 +00:00
|
|
|
|
|
|
|
POP_SAVED_FUNCTION_VISIBILITY
|
2010-01-12 21:11:24 +00:00
|
|
|
|
|
|
|
#endif
|