[comp.sources.unix] v10i097: Bug-fix for regexp

rs@uunet.UU.NET (Rich Salz) (08/07/87)

Submitted-by: seismo!ai.toronto.edu!utzoo!henry
Posting-number: Volume 10, Issue 97
Archive-name: regexp.pch

[  Regexp was published by itself in volume 6, and also as part of the
   "fastest grep around" earlier in this volume.  --r$  ]

Jeff Mc Carrell at Berkeley has found (gasp! choke! the horror! the horror!)
another bug in my regexp functions.  One thing my test set did not include
was very large regular expressions.  The bug is in the NEXT macro, which
digs out the offset to the next node of the regexp:  a parenthesization
botch makes trouble if the offset is ever larger than 255.  How humiliating.
Here is the fix to regexp.c:

116c116
< #define	NEXT(p)	(((*((p)+1)&0377)<<8) + *((p)+2)&0377)
---
> #define	NEXT(p)	(((*((p)+1)&0377)<<8) + (*((p)+2)&0377))

and here are some more lines for the "tests" file:

[ -~]*	abc	y	&	abc
[ -~ -~]*	abc	y	&	abc
[ -~ -~ -~]*	abc	y	&	abc
[ -~ -~ -~ -~]*	abc	y	&	abc
[ -~ -~ -~ -~ -~]*	abc	y	&	abc
[ -~ -~ -~ -~ -~ -~]*	abc	y	&	abc
[ -~ -~ -~ -~ -~ -~ -~]*	abc	y	&	abc


Just to let people know:  there is some prospect of me coming out with
a second edition of my regexp stuff, including a number of improvements
that various people have suggested/contributed.  However, it will not be
soon, because I'm very busy right now.  I can't spare the time to sort
it all out, decide what belongs and what doesn't, write the missing bits
of code, and integrate it all.  Sometime later this year, maybe.

				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry


-- 

Rich $alz			"Anger is an energy"
Cronus Project, BBN Labs	rsalz@bbn.com
Moderator, comp.sources.unix	sources@uunet.uu.net