retest.c revision 1590
1217309Snwhitehorn/*
2217309Snwhitehorn * Copyright (c) 1980, 1993
3217309Snwhitehorn *	The Regents of the University of California.  All rights reserved.
4217309Snwhitehorn *
5217309Snwhitehorn * Redistribution and use in source and binary forms, with or without
6217309Snwhitehorn * modification, are permitted provided that the following conditions
7217309Snwhitehorn * are met:
8217309Snwhitehorn * 1. Redistributions of source code must retain the above copyright
9217309Snwhitehorn *    notice, this list of conditions and the following disclaimer.
10217309Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
11217309Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
12217309Snwhitehorn *    documentation and/or other materials provided with the distribution.
13217309Snwhitehorn * 3. All advertising materials mentioning features or use of this software
14217309Snwhitehorn *    must display the following acknowledgement:
15217309Snwhitehorn *	This product includes software developed by the University of
16217309Snwhitehorn *	California, Berkeley and its contributors.
17217309Snwhitehorn * 4. Neither the name of the University nor the names of its contributors
18217309Snwhitehorn *    may be used to endorse or promote products derived from this software
19217309Snwhitehorn *    without specific prior written permission.
20217309Snwhitehorn *
21217309Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22217309Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23217309Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24217309Snwhitehorn * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25217309Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26217309Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27217309Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28217309Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29217309Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30217309Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31217309Snwhitehorn * SUCH DAMAGE.
32217309Snwhitehorn */
33217309Snwhitehorn
34217309Snwhitehorn#ifndef lint
35217309Snwhitehornstatic char copyright[] =
36217309Snwhitehorn"@(#) Copyright (c) 1980, 1993\n\
37217309Snwhitehorn	The Regents of the University of California.  All rights reserved.\n";
38217309Snwhitehorn#endif /* not lint */
39217309Snwhitehorn
40217309Snwhitehorn#ifndef lint
41217309Snwhitehornstatic char sccsid[] = "@(#)retest.c	8.1 (Berkeley) 6/6/93";
42217309Snwhitehorn#endif /* not lint */
43217309Snwhitehorn
44217309Snwhitehorn#include <ctype.h>
45217309Snwhitehorn
46217309Snwhitehornint l_onecase = 0;
47217309Snwhitehornchar * _start;
48217309Snwhitehornchar * _escaped;
49217309Snwhitehornchar * convexp();
50217309Snwhitehornchar * expmatch();
51217309Snwhitehornmain()
52217309Snwhitehorn{
53217309Snwhitehorn    char reg[132];
54217309Snwhitehorn    char *ireg;
55217309Snwhitehorn    char str[132];
56217309Snwhitehorn    char *match;
57217309Snwhitehorn    char matstr[132];
58217309Snwhitehorn    char c;
59217309Snwhitehorn
60217309Snwhitehorn    while (1) {
61217309Snwhitehorn	printf ("\nexpr: ");
62	scanf ("%s", reg);
63	ireg = convexp(reg);
64	match = ireg;
65	while(*match) {
66	    switch (*match) {
67
68	    case '\\':
69	    case '(':
70	    case ')':
71	    case '|':
72		printf ("%c", *match);
73		break;
74
75	    default:
76		if (isalnum(*match))
77		    printf("%c", *match);
78		else
79		    printf ("<%03o>", *match);
80		break;
81	    }
82	    match++;
83	}
84	printf("\n");
85	getchar();
86	while(1) {
87	    printf ("string: ");
88	    match = str;
89	    while ((c = getchar()) != '\n')
90		*match++ = c;
91	    *match = 0;
92	    if (str[0] == '#')
93		break;
94	    matstr[0] = 0;
95	    _start = str;
96	    _escaped = 0;
97	    match = expmatch (str, ireg, matstr);
98	    if (match == 0)
99		printf ("FAILED\n");
100	    else
101		printf ("match\nmatstr = %s\n", matstr);
102	}
103
104    }
105}
106