match.h 658 B

1234567891011121314151617181920212223242526
  1. /* match.h - interface to shell ##/%% matching code */
  2. PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
  3. typedef char *(*scan_t)(char *string, char *match, bool match_at_left);
  4. char *scanleft(char *string, char *match, bool match_at_left);
  5. char *scanright(char *string, char *match, bool match_at_left);
  6. static inline scan_t pick_scan(char op1, char op2, bool *match_at_left)
  7. {
  8. /* # - scanleft
  9. * ## - scanright
  10. * % - scanright
  11. * %% - scanleft
  12. */
  13. if (op1 == '#') {
  14. *match_at_left = true;
  15. return op1 == op2 ? scanright : scanleft;
  16. } else {
  17. *match_at_left = false;
  18. return op1 == op2 ? scanleft : scanright;
  19. }
  20. }
  21. POP_SAVED_FUNCTION_VISIBILITY