From 391d115b4dd91211c25d97313398e3f9ebc85472 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 27 Sep 1988 11:16:04 +0000 Subject: [PATCH] fixes from bruce: there are four, not three types of pattern that the routine findworst should look for --- modules/src/em_opt/Makefile | 9 ++++++++- modules/src/em_opt/findworst.c | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/src/em_opt/Makefile b/modules/src/em_opt/Makefile index 246829b94..8949792a7 100644 --- a/modules/src/em_opt/Makefile +++ b/modules/src/em_opt/Makefile @@ -5,6 +5,7 @@ COMPARE = $(EMHOME)/modules/compare LINT = lint BINDIR = $(EMHOME)/lib LIBOPT = libemopt.a +LIBCEOPT = libemoptCE.a # set HOWMUCH to head -20 to limit number of patterns used #HOWMUCH = head -20 @@ -26,7 +27,7 @@ CMD = '$(CC) -c $(CFLAGS)' .SUFFIXES: .d .r -.r.d: ; CMD=$(CMD); export CMD; awk -f makefuns.awk $*.r | sh +.r.d: ; CMD=$(CMD); export CMD; awk -f makefuns.awk $*.r | sh -x touch $@ CSRC = main.c nopt.c mkstrct.c aux.c outputdfa.c outcalls.c\ @@ -100,6 +101,12 @@ $(LIBOPT): dfadummy $(NOFILES) mkstrct.o pseudo.d incalls.d ar rc $(LIBOPT) O_*.o $(NOFILES) mkstrct.o -sh -c 'ranlib $(LIBOPT)' +libCEopt.a: + make clean + make PREFLAGS='$(INCLDIR) -DPRIVATE=static -DCODE_EXPANDER' $(LIBOPT) + mv $(LIBOPT) libCEopt.a + make clean + dfadummy: patterns parser -/lib/cpp patterns | $(HOWMUCH) >/tmp/patts parser starts a pattern. - /* requires a backup of n-i+1 instructions and a goto to state 0. + /* requires a backup of j-i+1 instructions and a goto to state 0. + /* d) pattern of the form: ri ri+1 ... rj + /* i.e. a substring of is a complete pattern + /* requires a backup of j-i+1 instructions and a goto to state 0. */ int n = repl.m_len; int diff = patt.m_len - repl.m_len; - int first,i; + int first,i,j; int s; int mostbackups = 0; if(n==0) { @@ -56,6 +59,16 @@ findworst(patt,repl) UPDATEWORST(n-i+1); } } + /* look for case d */ + for(i=2;i<=n;i++) { + for(j=n-1;j>i;j--) { + if((first=leftmatch(patterns[s],repl,i,j)) && + (first==1)&& + (j-i+1 == patterns[s].m_len)) { + UPDATEWORST(n-i+1); + } + } + } } fprintf(ofile,"\t\tOO_mkrepl(%d,%d,%d);\n",n,diff,mostbackups); }