home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Tex / lgrind.zoo / retest.c < prev    next >
C/C++ Source or Header  |  1992-09-28  |  1KB  |  76 lines

  1. /* Test program for the regular expression routines */
  2.  
  3. #ifndef lint
  4. static char *sccsid="@(#)retest.c    1.1 (LBL) 3/29/85";
  5. static char sccsid[] = "@(#)retest.c    4.1    (Berkeley)    10/19/82";
  6. static char Version[] =
  7.    "$Id: retest.c,v 1.2 91/10/01 00:29:31 gvr Exp $";
  8. #endif
  9.  
  10. #include <stdio.h>
  11. #include <ctype.h>
  12.  
  13. int    l_onecase = 0;
  14. char    *_start;
  15. char    *_escaped;
  16. char    *convexp();
  17. char    *expmatch();
  18.  
  19.  
  20.  
  21. main()
  22. {
  23.    char reg[132];
  24.    char *ireg;
  25.    char str[132];
  26.    char *match;
  27.    char matstr[132];
  28.    char c;
  29.    
  30.    for (;;) {
  31.       printf ("\nexpr: ");
  32.       scanf ("%s", reg);
  33.       ireg = convexp(reg);
  34.       match = ireg;
  35.       while(*match) {
  36.      switch (*match) {
  37.         
  38.      case '\\':
  39.      case '(':
  40.      case ')':
  41.      case '|':
  42.         printf ("%c", *match);
  43.         break;
  44.         
  45.      default:
  46.         if (isalnum(*match))
  47.            printf("%c", *match);
  48.         else
  49.            printf ("<%03o>", *match);
  50.         break;
  51.      }
  52.      match++;
  53.       }
  54.       printf("\n");
  55.       getchar();
  56.       for (;;) {
  57.      printf ("string: ");
  58.      match = str;
  59.      while ((c = getchar()) != '\n')
  60.         *match++ = c;
  61.      *match = 0;
  62.      if (str[0] == '#')
  63.         break;
  64.      matstr[0] = 0;
  65.      _start = str;
  66.      _escaped = 0;
  67.      match = expmatch (str, ireg, matstr);
  68.      if (match == 0)
  69.         printf ("FAILED\n");
  70.      else
  71.         printf ("match\nmatstr = %s\n", matstr);
  72.       }
  73.       
  74.    }
  75. }
  76.