1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 3*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 4*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 5*7c478bd9Sstevel@tonic-gate */ 6*7c478bd9Sstevel@tonic-gate 7*7c478bd9Sstevel@tonic-gate #include <ctype.h> 8*7c478bd9Sstevel@tonic-gate 9*7c478bd9Sstevel@tonic-gate int l_onecase = 0; 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate char *l_idchars = "_"; /* characters legal in identifiers in addition 12*7c478bd9Sstevel@tonic-gate to alphanumerics */ 13*7c478bd9Sstevel@tonic-gate 14*7c478bd9Sstevel@tonic-gate char * Start; 15*7c478bd9Sstevel@tonic-gate char * _escaped; 16*7c478bd9Sstevel@tonic-gate char * convexp(); 17*7c478bd9Sstevel@tonic-gate char * expmatch(); main()18*7c478bd9Sstevel@tonic-gatemain() 19*7c478bd9Sstevel@tonic-gate { 20*7c478bd9Sstevel@tonic-gate char reg[132]; 21*7c478bd9Sstevel@tonic-gate char *ireg; 22*7c478bd9Sstevel@tonic-gate char str[132]; 23*7c478bd9Sstevel@tonic-gate char *match; 24*7c478bd9Sstevel@tonic-gate char matstr[132]; 25*7c478bd9Sstevel@tonic-gate char c; 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate while (1) { 28*7c478bd9Sstevel@tonic-gate printf ("\nexpr: "); 29*7c478bd9Sstevel@tonic-gate scanf ("%s", reg); 30*7c478bd9Sstevel@tonic-gate ireg = convexp(reg); 31*7c478bd9Sstevel@tonic-gate match = ireg; 32*7c478bd9Sstevel@tonic-gate while(*match) { 33*7c478bd9Sstevel@tonic-gate switch (*match) { 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate case '\\': 36*7c478bd9Sstevel@tonic-gate case '(': 37*7c478bd9Sstevel@tonic-gate case ')': 38*7c478bd9Sstevel@tonic-gate case '|': 39*7c478bd9Sstevel@tonic-gate printf ("%c", *match); 40*7c478bd9Sstevel@tonic-gate break; 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate default: 43*7c478bd9Sstevel@tonic-gate if (isalnum(*match)) 44*7c478bd9Sstevel@tonic-gate printf("%c", *match); 45*7c478bd9Sstevel@tonic-gate else 46*7c478bd9Sstevel@tonic-gate printf ("<%03o>", *match); 47*7c478bd9Sstevel@tonic-gate break; 48*7c478bd9Sstevel@tonic-gate } 49*7c478bd9Sstevel@tonic-gate match++; 50*7c478bd9Sstevel@tonic-gate } 51*7c478bd9Sstevel@tonic-gate printf("\n"); 52*7c478bd9Sstevel@tonic-gate getchar(); 53*7c478bd9Sstevel@tonic-gate while(1) { 54*7c478bd9Sstevel@tonic-gate printf ("string: "); 55*7c478bd9Sstevel@tonic-gate match = str; 56*7c478bd9Sstevel@tonic-gate while ((c = getchar()) != '\n') 57*7c478bd9Sstevel@tonic-gate *match++ = c; 58*7c478bd9Sstevel@tonic-gate *match = 0; 59*7c478bd9Sstevel@tonic-gate if (str[0] == '#') 60*7c478bd9Sstevel@tonic-gate break; 61*7c478bd9Sstevel@tonic-gate matstr[0] = 0; 62*7c478bd9Sstevel@tonic-gate Start = str; 63*7c478bd9Sstevel@tonic-gate _escaped = 0; 64*7c478bd9Sstevel@tonic-gate match = expmatch (str, ireg, matstr); 65*7c478bd9Sstevel@tonic-gate if (match == 0) 66*7c478bd9Sstevel@tonic-gate printf ("FAILED\n"); 67*7c478bd9Sstevel@tonic-gate else 68*7c478bd9Sstevel@tonic-gate printf ("match\nmatstr = %s\n", matstr); 69*7c478bd9Sstevel@tonic-gate } 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate } 72*7c478bd9Sstevel@tonic-gate } 73