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