xref: /original-bsd/usr.bin/vgrind/RETEST/retest.c (revision c3e32dec)
1 /*
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1980, 1993\n\
11 	The Regents of the University of California.  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)retest.c	8.1 (Berkeley) 06/06/93";
16 #endif /* not lint */
17 
18 #include <ctype.h>
19 
20 int l_onecase = 0;
21 char * _start;
22 char * _escaped;
23 char * convexp();
24 char * expmatch();
25 main()
26 {
27     char reg[132];
28     char *ireg;
29     char str[132];
30     char *match;
31     char matstr[132];
32     char c;
33 
34     while (1) {
35 	printf ("\nexpr: ");
36 	scanf ("%s", reg);
37 	ireg = convexp(reg);
38 	match = ireg;
39 	while(*match) {
40 	    switch (*match) {
41 
42 	    case '\\':
43 	    case '(':
44 	    case ')':
45 	    case '|':
46 		printf ("%c", *match);
47 		break;
48 
49 	    default:
50 		if (isalnum(*match))
51 		    printf("%c", *match);
52 		else
53 		    printf ("<%03o>", *match);
54 		break;
55 	    }
56 	    match++;
57 	}
58 	printf("\n");
59 	getchar();
60 	while(1) {
61 	    printf ("string: ");
62 	    match = str;
63 	    while ((c = getchar()) != '\n')
64 		*match++ = c;
65 	    *match = 0;
66 	    if (str[0] == '#')
67 		break;
68 	    matstr[0] = 0;
69 	    _start = str;
70 	    _escaped = 0;
71 	    match = expmatch (str, ireg, matstr);
72 	    if (match == 0)
73 		printf ("FAILED\n");
74 	    else
75 		printf ("match\nmatstr = %s\n", matstr);
76 	}
77 
78     }
79 }
80