xref: /netbsd-src/usr.bin/vgrind/RETEST/retest.c (revision 89aaa1bb64ba8db54daf131749fe578e804d9382)
1*89aaa1bbSagc /*	$NetBSD: retest.c,v 1.5 2003/08/07 11:17:02 agc Exp $	*/
2b2fe91d9Sjtc 
331ce5c89Sjtc /*
431ce5c89Sjtc  * Copyright (c) 1980, 1993
531ce5c89Sjtc  *	The Regents of the University of California.  All rights reserved.
631ce5c89Sjtc  *
731ce5c89Sjtc  * Redistribution and use in source and binary forms, with or without
831ce5c89Sjtc  * modification, are permitted provided that the following conditions
931ce5c89Sjtc  * are met:
1031ce5c89Sjtc  * 1. Redistributions of source code must retain the above copyright
1131ce5c89Sjtc  *    notice, this list of conditions and the following disclaimer.
1231ce5c89Sjtc  * 2. Redistributions in binary form must reproduce the above copyright
1331ce5c89Sjtc  *    notice, this list of conditions and the following disclaimer in the
1431ce5c89Sjtc  *    documentation and/or other materials provided with the distribution.
15*89aaa1bbSagc  * 3. Neither the name of the University nor the names of its contributors
1631ce5c89Sjtc  *    may be used to endorse or promote products derived from this software
1731ce5c89Sjtc  *    without specific prior written permission.
1831ce5c89Sjtc  *
1931ce5c89Sjtc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2031ce5c89Sjtc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2131ce5c89Sjtc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2231ce5c89Sjtc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2331ce5c89Sjtc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2431ce5c89Sjtc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2531ce5c89Sjtc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2631ce5c89Sjtc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2731ce5c89Sjtc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2831ce5c89Sjtc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2931ce5c89Sjtc  * SUCH DAMAGE.
3031ce5c89Sjtc  */
3131ce5c89Sjtc 
3231ce5c89Sjtc #ifndef lint
3331ce5c89Sjtc static char copyright[] =
3431ce5c89Sjtc "@(#) Copyright (c) 1980, 1993\n\
3531ce5c89Sjtc 	The Regents of the University of California.  All rights reserved.\n";
3631ce5c89Sjtc #endif /* not lint */
3731ce5c89Sjtc 
3831ce5c89Sjtc #ifndef lint
39b2fe91d9Sjtc #if 0
4031ce5c89Sjtc static char sccsid[] = "@(#)retest.c	8.1 (Berkeley) 6/6/93";
41b2fe91d9Sjtc #endif
42*89aaa1bbSagc static char rcsid[] = "$NetBSD: retest.c,v 1.5 2003/08/07 11:17:02 agc Exp $";
4331ce5c89Sjtc #endif /* not lint */
4431ce5c89Sjtc 
4531ce5c89Sjtc #include <ctype.h>
4631ce5c89Sjtc 
4731ce5c89Sjtc int l_onecase = 0;
48b2d8a552Saymeric char * x_start;
49b2d8a552Saymeric char * x_escaped;
5031ce5c89Sjtc char * convexp();
5131ce5c89Sjtc char * expmatch();
main()5231ce5c89Sjtc main()
5331ce5c89Sjtc {
5431ce5c89Sjtc     char reg[132];
5531ce5c89Sjtc     char *ireg;
5631ce5c89Sjtc     char str[132];
5731ce5c89Sjtc     char *match;
5831ce5c89Sjtc     char matstr[132];
5931ce5c89Sjtc     char c;
6031ce5c89Sjtc 
6131ce5c89Sjtc     while (1) {
6231ce5c89Sjtc 	printf ("\nexpr: ");
639e248e08Sitojun 	scanf ("%131s", reg);
6431ce5c89Sjtc 	ireg = convexp(reg);
6531ce5c89Sjtc 	match = ireg;
6631ce5c89Sjtc 	while(*match) {
6731ce5c89Sjtc 	    switch (*match) {
6831ce5c89Sjtc 
6931ce5c89Sjtc 	    case '\\':
7031ce5c89Sjtc 	    case '(':
7131ce5c89Sjtc 	    case ')':
7231ce5c89Sjtc 	    case '|':
7331ce5c89Sjtc 		printf ("%c", *match);
7431ce5c89Sjtc 		break;
7531ce5c89Sjtc 
7631ce5c89Sjtc 	    default:
7731ce5c89Sjtc 		if (isalnum(*match))
7831ce5c89Sjtc 		    printf("%c", *match);
7931ce5c89Sjtc 		else
8031ce5c89Sjtc 		    printf ("<%03o>", *match);
8131ce5c89Sjtc 		break;
8231ce5c89Sjtc 	    }
8331ce5c89Sjtc 	    match++;
8431ce5c89Sjtc 	}
8531ce5c89Sjtc 	printf("\n");
8631ce5c89Sjtc 	getchar();
8731ce5c89Sjtc 	while(1) {
8831ce5c89Sjtc 	    printf ("string: ");
8931ce5c89Sjtc 	    match = str;
9031ce5c89Sjtc 	    while ((c = getchar()) != '\n')
9131ce5c89Sjtc 		*match++ = c;
9231ce5c89Sjtc 	    *match = 0;
9331ce5c89Sjtc 	    if (str[0] == '#')
9431ce5c89Sjtc 		break;
9531ce5c89Sjtc 	    matstr[0] = 0;
96b2d8a552Saymeric 	    x_start = str;
97b2d8a552Saymeric 	    x_escaped = 0;
9831ce5c89Sjtc 	    match = expmatch (str, ireg, matstr);
9931ce5c89Sjtc 	    if (match == 0)
10031ce5c89Sjtc 		printf ("FAILED\n");
10131ce5c89Sjtc 	    else
10231ce5c89Sjtc 		printf ("match\nmatstr = %s\n", matstr);
10331ce5c89Sjtc 	}
10431ce5c89Sjtc 
10531ce5c89Sjtc     }
10631ce5c89Sjtc }
107