[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [BusyBox] Re: Bug Report:BB 1.00 sed
From:       Rob Landley <rob () landley ! net>
Date:       2004-10-30 6:48:29
Message-ID: 200410300148.29664.rob () landley ! net
[Download RAW message or body]

On Friday 29 October 2004 11:58, Hiroshi Ito wrote:
> Hello,
>
> sed "y" command also has little bug.
> when I put g flag to y command ( y command does not have flag.
> it is illegal case) sed shows garbage.
> I think sed searches beyond the buffer.
>
> / #  (echo;echo;echo) | sed -e '0y/test/test/g'

Ooh, nasty.  I got a segfault when I tried it.  Thanks for spotting this one.

The problem actually has nothing to do with the "y" command.  (And feeding it 
a match of line 0, again, is ignored and treated as a global match.)  Since 
the y command ends with the second backslash, the next character is taken as 
the start of a new command.  You'd get the same results from sed -e 'g' (and 
I tried it, and I get the same segfault).

Okay, the problem is that on line 1009 I free pattern_space and then have a 
conditional that only assigns a new value to pattern_space if the if 
statement is true.  Potentially leaving the old stale value in pattern_space.  
Oops.  Embarassing.


By the way, the following test cases proves something about GNU sed:

echo -n woo > woo
sed -e h -e g woo
echo "fish" | sed -e '/woo/h' -e "izap" -e 's/woo/thingy/' -e '/fish/g' woo -

 It proves that the lack of newline is not a quality of the line being edited, 
but is stored by a simplistic "what did we just read in" flag like I'm doing.  
(I haven't looked at the actual gnu code for sed yet.  GNU code is icky.)

It ALSO shows that the hold buffer needs to be persistent across files, which 
means it needs to be a global...

Fixed.  I'll check the result into CVS, with a fix to the previous problem 
too...

Rob

_______________________________________________
busybox mailing list
busybox@mail.busybox.net
http://codepoet.org/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic