match.h 762 B

123456789101112131415161718192021222324252627282930313233
  1. /* match.h - interface to shell ##/%% matching code */
  2. #ifndef SHELL_MATCH_H
  3. #define SHELL_MATCH_H 1
  4. PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
  5. //TODO! Why ash.c still uses internal version?!
  6. typedef char *(*scan_t)(char *string, char *match, bool match_at_left);
  7. char *scanleft(char *string, char *match, bool match_at_left);
  8. char *scanright(char *string, char *match, bool match_at_left);
  9. static inline scan_t pick_scan(char op1, char op2, bool *match_at_left)
  10. {
  11. /* # - scanleft
  12. * ## - scanright
  13. * % - scanright
  14. * %% - scanleft
  15. */
  16. if (op1 == '#') {
  17. *match_at_left = true;
  18. return op1 == op2 ? scanright : scanleft;
  19. } else {
  20. *match_at_left = false;
  21. return op1 == op2 ? scanleft : scanright;
  22. }
  23. }
  24. POP_SAVED_FUNCTION_VISIBILITY
  25. #endif