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 #pragma ident "%Z%%M% %I% %E% SMI" 8*7c478bd9Sstevel@tonic-gate /* from UCB 5.1 (Berkeley) 6/5/85 */ 9*7c478bd9Sstevel@tonic-gate 10*7c478bd9Sstevel@tonic-gate #include <ctype.h> 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate int l_onecase = 0; 13*7c478bd9Sstevel@tonic-gate 14*7c478bd9Sstevel@tonic-gate char *l_idchars = "_"; /* characters legal in identifiers in addition 15*7c478bd9Sstevel@tonic-gate to alphanumerics */ 16*7c478bd9Sstevel@tonic-gate 17*7c478bd9Sstevel@tonic-gate char * Start; 18*7c478bd9Sstevel@tonic-gate char * _escaped; 19*7c478bd9Sstevel@tonic-gate char * convexp(); 20*7c478bd9Sstevel@tonic-gate char * expmatch(); main()21*7c478bd9Sstevel@tonic-gatemain() 22*7c478bd9Sstevel@tonic-gate { 23*7c478bd9Sstevel@tonic-gate char reg[132]; 24*7c478bd9Sstevel@tonic-gate char *ireg; 25*7c478bd9Sstevel@tonic-gate char str[132]; 26*7c478bd9Sstevel@tonic-gate char *match; 27*7c478bd9Sstevel@tonic-gate char matstr[132]; 28*7c478bd9Sstevel@tonic-gate char c; 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate while (1) { 31*7c478bd9Sstevel@tonic-gate printf ("\nexpr: "); 32*7c478bd9Sstevel@tonic-gate scanf ("%s", reg); 33*7c478bd9Sstevel@tonic-gate ireg = convexp(reg); 34*7c478bd9Sstevel@tonic-gate match = ireg; 35*7c478bd9Sstevel@tonic-gate while(*match) { 36*7c478bd9Sstevel@tonic-gate switch (*match) { 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate case '\\': 39*7c478bd9Sstevel@tonic-gate case '(': 40*7c478bd9Sstevel@tonic-gate case ')': 41*7c478bd9Sstevel@tonic-gate case '|': 42*7c478bd9Sstevel@tonic-gate printf ("%c", *match); 43*7c478bd9Sstevel@tonic-gate break; 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate default: 46*7c478bd9Sstevel@tonic-gate if (isalnum(*match)) 47*7c478bd9Sstevel@tonic-gate printf("%c", *match); 48*7c478bd9Sstevel@tonic-gate else 49*7c478bd9Sstevel@tonic-gate printf ("<%03o>", *match); 50*7c478bd9Sstevel@tonic-gate break; 51*7c478bd9Sstevel@tonic-gate } 52*7c478bd9Sstevel@tonic-gate match++; 53*7c478bd9Sstevel@tonic-gate } 54*7c478bd9Sstevel@tonic-gate printf("\n"); 55*7c478bd9Sstevel@tonic-gate getchar(); 56*7c478bd9Sstevel@tonic-gate while(1) { 57*7c478bd9Sstevel@tonic-gate printf ("string: "); 58*7c478bd9Sstevel@tonic-gate match = str; 59*7c478bd9Sstevel@tonic-gate while ((c = getchar()) != '\n') 60*7c478bd9Sstevel@tonic-gate *match++ = c; 61*7c478bd9Sstevel@tonic-gate *match = 0; 62*7c478bd9Sstevel@tonic-gate if (str[0] == '#') 63*7c478bd9Sstevel@tonic-gate break; 64*7c478bd9Sstevel@tonic-gate matstr[0] = 0; 65*7c478bd9Sstevel@tonic-gate Start = str; 66*7c478bd9Sstevel@tonic-gate _escaped = 0; 67*7c478bd9Sstevel@tonic-gate match = expmatch (str, ireg, matstr); 68*7c478bd9Sstevel@tonic-gate if (match == 0) 69*7c478bd9Sstevel@tonic-gate printf ("FAILED\n"); 70*7c478bd9Sstevel@tonic-gate else 71*7c478bd9Sstevel@tonic-gate printf ("match\nmatstr = %s\n", matstr); 72*7c478bd9Sstevel@tonic-gate } 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate } 75*7c478bd9Sstevel@tonic-gate } 76