On Wed, Jun 15, 2011 at 11:41:51PM -0300, pablo caballero wrote:
> On Wed, Jun 15, 2011 at 7:17 AM, Otto Moerbeek <[email protected]> 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 falempin wrote:
> >> >>
> >> >>> Hello,
> >> >>>
> >> >>> Indeed there is a small problem:
> >> >>>
> >> >>> # echo 'abbbbbbbbbbbbbfffff' | sed -E 's/[a$]/x/g'
> >> >>> xbbbbbbbbbbbbbfffff
> >> >>
> >> >> That is expected. $ is only special when it ocurs as the list char of
> >> >> a re.
> >> >>
> >> >>> # echo 'abbbbbbbbbbbbbfffff' | sed -E 's/a|$/x/g'
> >> >>> x
> >> >>
> >> >> This is likely to be a real bug.
> >> >>
> >> >>>
> >> >>> String modification is done inside the 'case 0:'
> >> >>> substitute(struct s_command *cp) in src/usr.bin/process.c
> >> >>>
> >> >>> But the problem may comme from regexec_e.
> >> >>>
> >> >>> Maybe openbsd devs should test another regexp code version ?
> >> >>
> >> >> Why? If we should change libs on every bug encountered, nothing will
> >> >> be left.
> >> >>
> >> >> Anyway, thanks for the report.
> >> >>
> >> >> -Otto
> >> >>
> >> >>>
> >> >>> Hope it helps,
> >> >>> Who still use sed anyway :)
> >> >>>
> >> >>> Regards.
> >> >>>
> >> >>> 2011/6/12 Ingo Schwarze <[email protected]>
> >> >>>
> >> >>>> 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" continue_to_process = "b\n",
> >> >>>> and then the second application
> >> >>>> appends "\n" to dst (should rather append "b", i think).
> >> >>>> Maybe something is wrong here with character/pointer counting,
> >> >>>> but i'm somewhat out of time now for tracing.
> >> >>>>
> >> >>>> This is worth more investigation.
> >> >>>>
> >> >>>> Yours,
> >> >>>> Ingo
> >> >>>>
> >> >>>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> () ascii ribbon campaign - against html e-mail
> >> >>> /\
> >> >
> >> > 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 final '$' if the last match went to eol.
> >>
> >> /Alexander
> >
> > Right.
> >
> > I took a look at freebsd, thay have some patches in this area. But
> > applying the changes did not have the desired effect. Have to look deeper.
> >
> > -Otto
> >
> >
>
> HI Otto.
>
> I think that with a minor change (>= instead of > in the last line)
> your diff works.
>
> Regards
>
> + if (lastempty || match[0].rm_so != match[0].rm_eo ||
> + (match[0].rm_so == match[0].rm_eo &&
> + match[0].rm_so >= 0)) {
>From a first look I'm not sure about that. YOu might end up doing a
second append later in the match[0].rm_so == 0 case.
-Otto