gordonl@microsoft.UUCP (Gordon Letwin) (07/29/85)
I've just discovered what appears to be a "day 1" bug in fgrep. Its present in our V7, SYS III, and SYS 5 sources, so its probably present in all fgrep sources out there. The bug is in fgrep's handling of -y for multiple search strings. Fgrep works by building a binary decision tree from its multiple search strings. It starts at the root of the tree, comparing the character therin to the text character. If there is a match it follows the "success pointer" and reads another character. If there is a miss it follows the "fail pointer" Thus, for a pattern space of DEVBANG DevTyp If D fails we read another character and start over. If D succeeds we check for E, if E fails we check for e, and if that fails we read another and start over, etc. The problem is, fgrep only looks at the -y switch when its doing the compares, not when it builds this tree. Thus, with -y set the tree should be |-> "D"? -> "E" -> "V" -> etc. | | | | ---<---------<-----------<------ but instead the tables show |-> "D"? -> "E" -> "V" -> etc. | | | ---<--- "e" etc. This means that if our text file has a "DevTyp" in it fgrep matches the DEV in DEVBANG. When it gets to the B, however, the tables say "give up" instead of trying for "T". Has anyone seen and fixed this bug? It shouldn't be too hard to fix.... if someone doesn't post a fix we'll fix it and post. gordon letwin microsoft
al@mot.UUCP (Al Filipski) (08/02/85)
> The bug is in fgrep's handling of -y for multiple search strings.
What's "-y"? My System V fgrep doesn't know about any -y option.
--------------------------------
Alan Filipski, UNIX group, Motorola Microsystems, Tempe, AZ U.S.A
{seismo|ihnp4}!ut-sally!oakhill!mot!al
ucbvax!arizona!asuvax!mot!al
--------------------------------
henry@utzoo.UUCP (Henry Spencer) (08/02/85)
> I've just discovered what appears to be a "day 1" bug in fgrep. Its > present in our V7, SYS III, and SYS 5 sources, so its probably present > in all fgrep sources out there. This may be one of those cases where an option is undocumented because it doesn't work. Note that the V7 manual page says "(grep only)" for the -y option, i.e. it claims that fgrep doesn't take -y. (For anyone mystified by this discussion: -y is the "dualcase" option that makes lowercase pattern letters match either lowercase or uppercase data letters.) -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry
edwards@h-sc1.UUCP (william edwards) (08/05/85)
In article <5856@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >(For anyone mystified by this discussion: -y is the "dualcase" option >that makes lowercase pattern letters match either lowercase or uppercase >data letters.) In 4.2 BSD, the '-i' option to fgrep and grep makes them ignore case distinctions in pattern matching. Bill Edwards