sed behaving strangely when -n and the delete command are combined
Denys Vlasenko
vda.linux at googlemail.com
Thu Jul 9 13:50:31 UTC 2009
On Thu, Jul 9, 2009 at 1:36 PM, Rob Landley<rob at landley.net> wrote:
> On Wednesday 08 July 2009 07:28:42 Denys Vlasenko wrote:
>> On Wed, Jul 8, 2009 at 12:16 PM, Rob Landley<rob at landley.net> wrote:
>> > As far as I can tell, we're in compliance with SUSv4 and your sed command
>> > isn't. (Of course gnu has magic extensions out the wazoo and your
>> > program expects them. I guess what you're asking is "please implement
>> > this funky gnu extension that makes numeric addresses special, even when
>> > the ending case is a regex...)
>>
>> I think he just wants hit eglibc build to finish, and
>> currently the obstacle is that our sed differs from GNU one.
>>
>> In order to "take over the world" (as documented in our FAQ) ;]
>> it makes sense to emulate GNU sed.
>
> *shrug* Ok.
>
> However, the desired behavior is a little more complex than it appears. This
> range starts with a number and ends with a regex, so you can't just say that
> it continues until < endpoint because the endpoint isn't a number.
>
> Also remember that ranges that both start and end with a regex can trigger
> more than once. Therefore, in order to make the start work as >= instead of
> ==, you have to _disable_ the starting condition after the first time it
> triggers. (Otherwise, every line after that is >=, including the line after
> the ending regex, so the range never ends. Or more accurately, immediately
> restarts itself.)
That's what the patch did:
+ if (n && sed_cmd->beg_line > 0) {
+ /* Once matched, "n,regex"
range is dead, disabling it */
+ regfree(sed_cmd->end_match);
+ free(sed_cmd->end_match);
+ sed_cmd->end_match = NULL;
+ }
> That said, this change isn't nearly complex enough to justify 250 lines worth
> of changes:
>
> editors/sed.c | 462
> ++++++++++++++++++++++++++--------------------------
> testsuite/sed.tests | 13 +
> 2 files changed, 252 insertions(+), 223 deletions(-)
>
> I only looked through the first two pages of that patch, which seemed to be
> full of random unrelated stuff, and then started doing range comparisons that
> don't seem right. But the way this patch is structured, it's really hard to
> see what you actually changed and what's noise.
Please find attached patch which has indentation change filtered out.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: z.diff
Type: text/x-patch
Size: 4804 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090709/82a2564b/attachment.bin>
More information about the busybox
mailing list