s/A*./B/g editor bug?

9704 bink at aplcen.apl.jhu.edu
Wed Oct 18 11:17:28 AEST 1989


I've noticed the ED s///g command works incorrectly when given the command
	s/b*a/c/g
on the input line
	aaaaaaaaaaaaaaaaaaaaa
-- the result is:
	cacacacacacacacacacac
and it should be:
	ccccccccccccccccccccc

This is incorrect according to ED(1):

     (.,.)s/RE/replacement/g
                         The substitute command searches each
                         addressed line for an occurrence of the
                         specified RE.  In each line in which a
                         match is found, ALL (NON-OVERLAPPED)
                         matched strings are replaced by the
                         replacement if the global replacement
                         indicator g appears after the command.

These occurrences ARE non-overlapping.  The form s/ab*/c/g works as expected.
Both VI and ED behave this way, on at least System V.2 and Ultrix-32 V3.1.
Is this a confirmed bug in the RE matcher or the substitute code, and has
it been resolved?  This sounds trivial, but it did cause real problems.

					-- Greg Ubben
					   bink at aplcen.apl.jhu.edu
					   ...!uunet!mimsy!aplcen!bink



More information about the Comp.bugs.sys5 mailing list