X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=shell%2Fmatch.h;h=aa393ed1ab8247b803cbbb35ff11e4f167d9e472;hb=7fdb764e2e12119949cc17046d5ad4a13a9be4c6;hp=98ff8745abe3070ae775bf9afc0dc6cb85b9a9bb;hpb=7306727d1b2ed05afc91548ba374f7400a2389e3;p=oweals%2Fbusybox.git diff --git a/shell/match.h b/shell/match.h index 98ff8745a..aa393ed1a 100644 --- a/shell/match.h +++ b/shell/match.h @@ -5,25 +5,28 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN -typedef char *(*scan_t)(char *string, char *match, bool match_at_left); +//TODO! Why ash.c still uses internal version?! -char *scanleft(char *string, char *match, bool match_at_left); -char *scanright(char *string, char *match, bool match_at_left); +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), +}; -static inline scan_t pick_scan(char op1, char op2, bool *match_at_left) +char* FAST_FUNC scan_and_match(char *string, const char *pattern, unsigned flags); + +static inline unsigned pick_scan(char op1, char op2) { - /* # - scanleft - * ## - scanright - * % - scanright - * %% - scanleft - */ + unsigned scan_flags; if (op1 == '#') { - *match_at_left = true; - return op1 == op2 ? scanright : scanleft; - } else { - *match_at_left = false; - return op1 == op2 ? scanleft : scanright; + 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); } + return scan_flags; } POP_SAVED_FUNCTION_VISIBILITY