test_rand.c 683 B

12345678910111213141516171819202122232425262728
  1. /*
  2. This program tries to match a given regular expression with text given as input to stdin.
  3. If the text is a match for the pattern, the program returns 0.
  4. If the text doesn't match the pattern, the program returns -2.
  5. This program is used in random testing to test a lot of random text and regex together.
  6. See ./scripts/regex_test.py and the Makefile for this project for the gritty details.
  7. */
  8. #include <stdio.h>
  9. #include "re.h"
  10. int main(int argc, char** argv)
  11. {
  12. if (argc == 3)
  13. {
  14. int m = re_match(argv[1], argv[2]);
  15. if (m != -1)
  16. return 0;
  17. }
  18. else
  19. {
  20. printf("\nUsage: %s <PATTERN> <TEXT> \n", argv[0]);
  21. }
  22. return -2;
  23. }