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?!
|
|
|
|
|
2010-09-04 19:21:07 +00:00
|
|
|
enum {
|
|
|
|
SCAN_MOVE_FROM_LEFT = (1 << 0),
|
|
|
|
SCAN_MOVE_FROM_RIGHT = (1 << 1),
|
|
|
|
SCAN_MATCH_LEFT_HALF = (1 << 2),
|
2014-11-01 14:46:02 +00:00
|
|
|
SCAN_MATCH_RIGHT_HALF = (1 << 3)
|
2010-09-04 19:21:07 +00:00
|
|
|
};
|
2009-04-07 06:03:22 +00:00
|
|
|
|
2010-09-04 19:21:07 +00:00
|
|
|
char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags);
|
2009-04-07 06:03:22 +00:00
|
|
|
|
2010-09-04 19:21:07 +00:00
|
|
|
static inline unsigned pick_scan(char op1, char op2)
|
2009-04-07 06:03:22 +00:00
|
|
|
{
|
2010-09-04 19:21:07 +00:00
|
|
|
unsigned scan_flags;
|
2009-04-07 06:03:22 +00:00
|
|
|
if (op1 == '#') {
|
2010-09-04 19:21:07 +00:00
|
|
|
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 06:03:22 +00:00
|
|
|
}
|
2010-09-04 19:21:07 +00:00
|
|
|
return scan_flags;
|
2009-04-07 06:03:22 +00:00
|
|
|
}
|
2009-04-09 12:35:13 +00:00
|
|
|
|
|
|
|
POP_SAVED_FUNCTION_VISIBILITY
|
2010-01-12 21:11:24 +00:00
|
|
|
|
|
|
|
#endif
|