1 /* 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 char copyright[] = 20 "@(#) Copyright (c) 1980 The Regents of the University of California.\n\ 21 All rights reserved.\n"; 22 #endif /* not lint */ 23 24 #ifndef lint 25 static char sccsid[] = "@(#)retest.c 5.2 (Berkeley) 10/25/88"; 26 #endif /* not lint */ 27 28 #include <ctype.h> 29 30 int l_onecase = 0; 31 char * _start; 32 char * _escaped; 33 char * convexp(); 34 char * expmatch(); 35 main() 36 { 37 char reg[132]; 38 char *ireg; 39 char str[132]; 40 char *match; 41 char matstr[132]; 42 char c; 43 44 while (1) { 45 printf ("\nexpr: "); 46 scanf ("%s", reg); 47 ireg = convexp(reg); 48 match = ireg; 49 while(*match) { 50 switch (*match) { 51 52 case '\\': 53 case '(': 54 case ')': 55 case '|': 56 printf ("%c", *match); 57 break; 58 59 default: 60 if (isalnum(*match)) 61 printf("%c", *match); 62 else 63 printf ("<%03o>", *match); 64 break; 65 } 66 match++; 67 } 68 printf("\n"); 69 getchar(); 70 while(1) { 71 printf ("string: "); 72 match = str; 73 while ((c = getchar()) != '\n') 74 *match++ = c; 75 *match = 0; 76 if (str[0] == '#') 77 break; 78 matstr[0] = 0; 79 _start = str; 80 _escaped = 0; 81 match = expmatch (str, ireg, matstr); 82 if (match == 0) 83 printf ("FAILED\n"); 84 else 85 printf ("match\nmatstr = %s\n", matstr); 86 } 87 88 } 89 } 90