1*2204Sroot #include <ctype.h> 2*2204Sroot 3*2204Sroot int l_onecase = 0; 4*2204Sroot char * _start; 5*2204Sroot char * _escaped; 6*2204Sroot char * convexp(); 7*2204Sroot char * expmatch(); main()8*2204Srootmain() 9*2204Sroot { 10*2204Sroot char reg[132]; 11*2204Sroot char *ireg; 12*2204Sroot char str[132]; 13*2204Sroot char *match; 14*2204Sroot char matstr[132]; 15*2204Sroot char c; 16*2204Sroot 17*2204Sroot while (1) { 18*2204Sroot printf ("\nexpr: "); 19*2204Sroot scanf ("%s", reg); 20*2204Sroot ireg = convexp(reg); 21*2204Sroot match = ireg; 22*2204Sroot while(*match) { 23*2204Sroot switch (*match) { 24*2204Sroot 25*2204Sroot case '\\': 26*2204Sroot case '(': 27*2204Sroot case ')': 28*2204Sroot case '|': 29*2204Sroot printf ("%c", *match); 30*2204Sroot break; 31*2204Sroot 32*2204Sroot default: 33*2204Sroot if (isalnum(*match)) 34*2204Sroot printf("%c", *match); 35*2204Sroot else 36*2204Sroot printf ("<%03o>", *match); 37*2204Sroot break; 38*2204Sroot } 39*2204Sroot match++; 40*2204Sroot } 41*2204Sroot printf("\n"); 42*2204Sroot getchar(); 43*2204Sroot while(1) { 44*2204Sroot printf ("string: "); 45*2204Sroot match = str; 46*2204Sroot while ((c = getchar()) != '\n') 47*2204Sroot *match++ = c; 48*2204Sroot *match = 0; 49*2204Sroot if (str[0] == '#') 50*2204Sroot break; 51*2204Sroot matstr[0] = 0; 52*2204Sroot _start = str; 53*2204Sroot _escaped = 0; 54*2204Sroot match = expmatch (str, ireg, matstr); 55*2204Sroot if (match == 0) 56*2204Sroot printf ("FAILED\n"); 57*2204Sroot else 58*2204Sroot printf ("match\nmatstr = %s\n", matstr); 59*2204Sroot } 60*2204Sroot 61*2204Sroot } 62*2204Sroot } 63