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?!
|
|
|
|
|
2010-09-05 00:51:07 +05:30
|
|
|
enum {
|
|
|
|
SCAN_MOVE_FROM_LEFT = (1 << 0),
|
|
|
|
SCAN_MOVE_FROM_RIGHT = (1 << 1),
|
|
|
|
SCAN_MATCH_LEFT_HALF = (1 << 2),
|
|
|
|
SCAN_MATCH_RIGHT_HALF = (1 << 3),
|
|
|
|
};
|
2009-04-07 11:33:22 +05:30
|
|
|
|
2010-09-05 00:51:07 +05:30
|
|
|
char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags);
|
2009-04-07 11:33:22 +05:30
|
|
|
|
2010-09-05 00:51:07 +05:30
|
|
|
static inline unsigned pick_scan(char op1, char op2)
|
2009-04-07 11:33:22 +05:30
|
|
|
{
|
2010-09-05 00:51:07 +05:30
|
|
|
unsigned scan_flags;
|
2009-04-07 11:33:22 +05:30
|
|
|
if (op1 == '#') {
|
2010-09-05 00:51:07 +05:30
|
|
|
scan_flags = SCAN_MATCH_LEFT_HALF +
|
|
|
|
(op1 == op2 ? SCAN_MOVE_FROM_RIGHT : SCAN_MOVE_FROM_LEFT);
|
|
|
|
} else { /* % */
|
|
|
|
scan_flags = SCAN_MATCH_RIGHT_HALF +
|
|
|
|
(op1 == op2 ? SCAN_MOVE_FROM_LEFT : SCAN_MOVE_FROM_RIGHT);
|
2009-04-07 11:33:22 +05:30
|
|
|
}
|
2010-09-05 00:51:07 +05:30
|
|
|
return scan_flags;
|
2009-04-07 11:33:22 +05:30
|
|
|
}
|
2009-04-09 18:05:13 +05:30
|
|
|
|
|
|
|
POP_SAVED_FUNCTION_VISIBILITY
|
2010-01-13 02:41:24 +05:30
|
|
|
|
|
|
|
#endif
|