Re: sed behavior

2011-06-19 Thread pablo caballero
On Sat, Jun 18, 2011 at 3:31 PM, Ingo Schwarze schwa...@usta.de wrote: Hi Otto, from careful code inspection, your patch looks correct. Replacing the by = is wrong, it would breaks this test case: echo abc | ./obj/sed -E 's/(b|())/x/g' However, the code is hard to follow, and i suggest

Re: sed behavior

2011-06-18 Thread sven falempin
Hello, looks like it worked, but what about this diff,just adding the new when rm_so is 0 (how to run the regression test ?): Index: process.c === RCS file: /cvs/src/usr.bin/sed/process.c,v retrieving revision 1.15 diff -r1.15

Re: sed behavior

2011-06-18 Thread Ingo Schwarze
Hi Sven, but what about this diff, 1) Please use diff -up. 2) It doesn't apply to my tree. If i understand your intention correctly, that is, replacing the } else { by just } and doing the content of the else clause unconditionally, that's plain wrong. It makes sed miss one out of two

Re: sed behavior

2011-06-18 Thread Ingo Schwarze
Hi Otto, from careful code inspection, your patch looks correct. Replacing the by = is wrong, it would breaks this test case: echo abc | ./obj/sed -E 's/(b|())/x/g' However, the code is hard to follow, and i suggest the following refactoring such that people doing a review can more easily

Re: sed behavior

2011-06-18 Thread sven falempin
Hello, Well, i failed to apply your second patch :s (patch ./process.c ./yourdiff) doing it manually (twice), it pass test but does not correct the initial problem. # echo 'aba' | sed -E 's/a|$/x/g' xbx Maybe i'm wrong ? Nevertheless, my attempt is not that much better, it destroy the leading

Re: sed behavior

2011-06-18 Thread sven falempin
Good for me: Index: process.c === RCS file: /cvs/src/usr.bin/sed/process.c,v retrieving revision 1.15 diff -u -p -r1.15 process.c --- process.c 27 Oct 2009 23:59:43 - 1.15 +++ process.c 18 Jun 2011 21:04:39 - @@

Re: sed behavior

2011-06-18 Thread sven falempin
not that good :'( # echo -n 'aba' | sed -E 's/a|$/x/g' xbx# # 2011/6/18 sven falempin sven.falem...@gmail.com Good for me: Index: process.c === RCS file: /cvs/src/usr.bin/sed/process.c,v retrieving revision 1.15 diff -u -p

Re: sed behavior

2011-06-18 Thread sven falempin
the diff, sorry for spaming, last send diff was bad: Index: process.c === RCS file: /cvs/src/usr.bin/sed/process.c,v retrieving revision 1.15 diff -u -p -r1.15 process.c --- process.c 27 Oct 2009 23:59:43 - 1.15 +++

Re: sed behavior

2011-06-15 Thread Otto Moerbeek
On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello, Indeed there is a small problem: # echo 'abf' | sed -E 's/[a$]/x/g' xbf That is expected. $ is only special when

Re: sed behavior

2011-06-15 Thread Alexander Hall
On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello, Indeed there is a small problem: # echo 'abf' | sed -E 's/[a$]/x/g' xbf That is

Re: sed behavior

2011-06-15 Thread Alexander Hall
On 06/15/11 08:58, Alexander Hall wrote: On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello, Indeed there is a small problem: # echo 'abf' | sed -E

Re: sed behavior

2011-06-15 Thread Alexander Hall
On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello, Indeed there is a small problem: # echo 'abf' | sed -E 's/[a$]/x/g' xbf That is

Re: sed behavior

2011-06-15 Thread sven falempin
Hi, So what 'sed' shall do when match[0].rm_so i==0 ? Regards. 2011/6/15 Alexander Hall ha...@openbsd.org On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello,

Re: sed behavior

2011-06-15 Thread Otto Moerbeek
On Wed, Jun 15, 2011 at 09:50:29AM +0200, Alexander Hall wrote: On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello, Indeed there is a small problem: # echo

Re: sed behavior

2011-06-15 Thread Otto Moerbeek
On Wed, Jun 15, 2011 at 12:02:44PM +0200, sven falempin wrote: Hi, So what 'sed' shall do when match[0].rm_so i==0 ? lastempty is true in that case. -Otto

Re: sed behavior

2011-06-15 Thread Otto Moerbeek
On Wed, Jun 15, 2011 at 12:17:09PM +0200, Otto Moerbeek wrote: It differs from perl like this: $ echo 'l1_1' | perl -pe 's/1|$/X/g' lX_XX $ echo 'l1_1' | sed -E 's/1|$/X/g' lX_X Meaning we don't hit that final '$' if the last match went to eol. /Alexander Right. I

Re: sed behavior

2011-06-15 Thread Nicholas Marriott
FWIW GNU sed also appears to have the same behaviour (different from perl). On Wed, Jun 15, 2011 at 12:26:39PM +0200, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 12:17:09PM +0200, Otto Moerbeek wrote: It differs from perl like this: $ echo 'l1_1' | perl -pe 's/1|$/X/g' lX_XX

Re: sed behavior

2011-06-15 Thread Stuart Henderson
On 2011-06-15, Alexander Hall ha...@openbsd.org wrote: This dif fixes your problem here. Big question is of course: does it break other cases? It differs from perl like this: $ echo 'l1_1' | perl -pe 's/1|$/X/g' lX_XX $ echo 'l1_1' | sed -E 's/1|$/X/g' lX_X Meaning we don't hit that

Re: sed behavior

2011-06-15 Thread pablo caballero
On Wed, Jun 15, 2011 at 7:17 AM, Otto Moerbeek o...@drijf.net wrote: On Wed, Jun 15, 2011 at 09:50:29AM +0200, Alexander Hall wrote: On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto Moerbeek wrote: On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven

Re: sed behavior

2011-06-15 Thread Otto Moerbeek
On Wed, Jun 15, 2011 at 11:41:51PM -0300, pablo caballero wrote: On Wed, Jun 15, 2011 at 7:17 AM, Otto Moerbeek o...@drijf.net wrote: On Wed, Jun 15, 2011 at 09:50:29AM +0200, Alexander Hall wrote: On 06/15/11 08:35, Otto Moerbeek wrote: On Wed, Jun 15, 2011 at 07:44:20AM +0200, Otto

Re: sed behavior

2011-06-14 Thread sven falempin
Hello, Indeed there is a small problem: # echo 'abf' | sed -E 's/[a$]/x/g' xbf # echo 'abf' | sed -E 's/a|$/x/g' x String modification is done inside the 'case 0:' substitute(struct s_command *cp) in src/usr.bin/process.c But the problem may

Re: sed behavior

2011-06-14 Thread Otto Moerbeek
On Tue, Jun 14, 2011 at 11:56:27PM +0200, sven falempin wrote: Hello, Indeed there is a small problem: # echo 'abf' | sed -E 's/[a$]/x/g' xbf That is expected. $ is only special when it ocurs as the list char of a re. # echo 'abf' | sed

sed behavior

2011-06-12 Thread Nils Anspach
Hello list, I have an issue with sed. Why does echo 'ab' | sed -E 's/a|$/x/g' give 'x' whereas echo 'ab' | perl -e 'my $var = ; $var =~ s/a|$/x/g; print $var' and GNU's sed yield 'xbx' (which I expected to be the result in the first case)? Thanks Nils

Re: sed behavior

2011-06-12 Thread Ingo Schwarze
Hi Nils, Nils Anspach wrote on Sun, Jun 12, 2011 at 12:49:42PM +0200: I have an issue with sed. Why does echo 'ab' | sed -E 's/a|$/x/g' give 'x' whereas I sense a bug here. Tracing a bit around process(), it looks like the first application of the s command yields dst = x