retest.c revision 216370
1236099Sdes/* 2236099Sdes * Copyright (c) 1980, 1993 3236099Sdes * The Regents of the University of California. All rights reserved. 4236099Sdes * 5236099Sdes * Redistribution and use in source and binary forms, with or without 6236099Sdes * modification, are permitted provided that the following conditions 7236099Sdes * are met: 8236099Sdes * 1. Redistributions of source code must retain the above copyright 9255376Sdes * notice, this list of conditions and the following disclaimer. 10236099Sdes * 2. Redistributions in binary form must reproduce the above copyright 11236099Sdes * notice, this list of conditions and the following disclaimer in the 12236099Sdes * documentation and/or other materials provided with the distribution. 13236099Sdes * 4. Neither the name of the University nor the names of its contributors 14236099Sdes * may be used to endorse or promote products derived from this software 15236099Sdes * without specific prior written permission. 16236099Sdes * 17236099Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18236099Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19236099Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20236099Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21236099Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22236099Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23236099Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24236099Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25236099Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26236099Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27236099Sdes * SUCH DAMAGE. 28236099Sdes * 29255376Sdes * $FreeBSD: head/usr.bin/vgrind/RETEST/retest.c 216370 2010-12-11 08:32:16Z joel $ 30236099Sdes */ 31236099Sdes 32236099Sdes#ifndef lint 33236099Sdesstatic char copyright[] = 34236099Sdes"@(#) Copyright (c) 1980, 1993\n\ 35236099Sdes The Regents of the University of California. All rights reserved.\n"; 36236099Sdes#endif /* not lint */ 37236099Sdes 38236099Sdes#ifndef lint 39236099Sdesstatic char sccsid[] = "@(#)retest.c 8.1 (Berkeley) 6/6/93"; 40236099Sdes#endif /* not lint */ 41236099Sdes 42236099Sdes#include <ctype.h> 43236099Sdes 44236099Sdesint l_onecase = 0; 45236099Sdeschar * _start; 46236099Sdeschar * _escaped; 47236099Sdeschar * convexp(); 48236099Sdeschar * expmatch(); 49236099Sdesmain() 50236099Sdes{ 51236099Sdes char reg[132]; 52236099Sdes char *ireg; 53236099Sdes char str[132]; 54236099Sdes char *match; 55236099Sdes char matstr[132]; 56236099Sdes char c; 57236099Sdes 58236099Sdes while (1) { 59236099Sdes printf ("\nexpr: "); 60236099Sdes scanf ("%s", reg); 61236099Sdes ireg = convexp(reg); 62236099Sdes match = ireg; 63236099Sdes while(*match) { 64236099Sdes switch (*match) { 65236099Sdes 66236099Sdes case '\\': 67236099Sdes case '(': 68236099Sdes case ')': 69 case '|': 70 printf ("%c", *match); 71 break; 72 73 default: 74 if (isalnum(*match)) 75 printf("%c", *match); 76 else 77 printf ("<%03o>", *match); 78 break; 79 } 80 match++; 81 } 82 printf("\n"); 83 getchar(); 84 while(1) { 85 printf ("string: "); 86 match = str; 87 while ((c = getchar()) != '\n') 88 *match++ = c; 89 *match = 0; 90 if (str[0] == '#') 91 break; 92 matstr[0] = 0; 93 _start = str; 94 _escaped = 0; 95 match = expmatch (str, ireg, matstr); 96 if (match == 0) 97 printf ("FAILED\n"); 98 else 99 printf ("match\nmatstr = %s\n", matstr); 100 } 101 102 } 103} 104