bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Empty RE behavior in sed 3.02


From: W . BRISCOE
Subject: Empty RE behavior in sed 3.02
Date: Wed, 28 Feb 2001 12:43:00 0000

I sent the enclosure directly to Ken Pizzini rather than use thre regular
channel. Is Ken OK? I see no report of him doing any Usenet posting this year.
I have a workround for test 8.16 locking up with sed 3.02.
(I leave support for dynamic last matches to GNU!)
I shall now have to find somebody to admit responsibility for these tests!

*** 506,526 ****
        mark '8.16'
        if [ $BSD -eq 1 ] ; then
                echo 'BSD sed does not handle branch defined REs'
-       elif [ $AIX -eq 1 ] ; then
-               echo 'AIX sed does not handle branch defined REs'
        else
                echo 'eeefff' | $SED -e 'p' -e 's/e/X/p' -e ':x' \
!                   -e 's//Y/p' \
!                     -e x \
!                     -e /.\{10\}/{s/.*/ERROR/ -e b -e } -e s/.*/&./ \
!                     -e x \
!                     -e '/f/bx'
        fi
  }

  test_error()
  {
!       exec 3<&0 4>&1 5>&2 # exec 0>&3 4>&1 5>&2
        exec 0</dev/null
        exec 2>&1
        set -x

Walter Briscoe
------------------( Forwarded letter 1 follows )---------------------
Date: Monday, 19 February 2001 16:31
To: address@hidden
From: address@hidden
Subject: Empty RE behavior in sed 3.02

Ken,
I recently found a bug in the 1991 sed I mostly use in Windoze systems.
(An off by one error so that /^[1-9][0-9]\{1,3\}$/ matches 999 but not 9999).
I am in touch with simtelnet and have their agreement that I can fix it.
Needless to say, I will not let it loose until I have done my best to break
it. There is a set of BSD sed tests which can easily be found with a search
engine. The following breaks sed 3.02. sed locks up!

16:14:17 05 sed.test: echo eeefff |
> sed -e p -e s/e/X/p -e :x -e s//Y/p -e /f/bx
eeefff
Xeefff
XYefff
XYYfff
^C16:16:04 05 sed.test:

I think I remember seeing this failure a long time ago and not understanding
it. I now DO understand it and think it is a bug in sed 3.02.
/f/bx should set the default RE to f so that s//Y/p should replace f by Y and
the loop should terminate fairly quickly. I think the test could be improved
so that failure does not cause seizure but will leave that for the moment.

I quote from the latest draft of P1003.1.
If an RE is empty (that is, no pattern is specified) sed shall behave as if
the last RE used in the
last command applied (either as an address or as part of a substitute command)
was specified.

i.e. I read that as requiring that // be evaluated dynamically rather than
statically.

The document is better than its predecessors. It describes ; as a command
separator. (for a restricted set of commands.) It also requires sed to match
Basic REs rather than Extended REs. I will forward you a copy of it if you
like. (9 pages). I would already have done so but it is a .PDF and i do not
know how to put more than one page at a time into the clipboard.

Walter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]