Reg Expr bugs in vi? - (nf)

David Elliott dce at tekecs.UUCP
Thu Sep 29 02:53:50 AEST 1983


NONONONO - You are wrong Rich. Here's why :

*************************************
>From tektronix!uw-beaver!cornell!vax135!ariel!houti!hogpc!houxm!ihnp4!ixn5c!inuxc!pur-ee!uiucdcs!uiuccsb!emrath Mon Sep 26 19:36:47 1983
Subject: Reg Expr bugs in vi? - (nf)
Newsgroups: net.bugs.4bsd

#N:uiuccsb:6300001:000:929
uiuccsb!emrath    Sep 26 04:34:00 1983

There seems to be bugs in the reg expr searcher of vi.
Create a file of random text, such as:
skd jflksd jfsdlk
llkwejrlkw hllejrljlkajioerumm
jlrkwejrkw2345kld';l./,l sdfl

The following search patterns all seem to behave the same way.
/^[a-z]
/.*[a-z]
/[a-z].*
*************************************

	He's right! These do all act the same. They shouldn't!
	/^[a-z]/ says '[a-z] at the beginning of a line'.
	/.*[a-z]/ says '[a-z] after anything or nothing'.
	/[a-z].*/ says '[a-z] followed by anything'.

	What they all do is go to the next line containing an
	alphabetic lower-case character. The second expression
	should just move the cursor to the next alpha lower-case
	character, not the next line.

*************************************
Furthermore, making the . a real non-letter, say "3", giving the expr:
/3*[a-z]
 
causes the search to NOT find a letter if it is the character right
after(before) the cursor.
/[a-z]3*  seems to work, however.

*************************************

	Right again. /3*[a-z]/ should also find the next alphabetic
	lower case character. Instead, it skips a letter.
	/[a-z]3*/ doesn't skip the character.

*************************************
It seems to me, any time a "*"ed expr appears at either end of an expr,
it should be dropped off.  (Hmmmm,  "/3*" moves the cursor by two chars,
until you hit a blank line.)

I realize these are rather meaningless searches, but I ran across this
when I wanted to do:
/,.*[0-9]
and mistakenly entered:
/,*[0-9]
The fact that these cases don't seem to work lowers my faith in the searcher's
ability to produce the correct results on a meaningful pattern.

*************************************

I looked at the vi reference and it says that regular expressions look
for the next 'string' that matches the expression, not the next
line, so there is definitely a bug.

When I first read this, I thought that the submitter was wrong, but
he obviously isn't, he just didn't explain well enough.

			David



More information about the Comp.bugs.4bsd.ucb-fixes mailing list