Bug 5246 - sed global replace misses replacements
Summary: sed global replace misses replacements
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-25 15:44 UTC by bugdal
Modified: 2012-06-04 12:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bugdal 2012-05-25 15:44:37 UTC
For example:

$ echo hello | busybox sed 's/l*/@/g'                                           
@he@o                                                                           
$ echo hello | sed 's/l*/@/g'                                                   
@h@e@o@                                                                         

The latter behavior (GNU sed) is the expected, conformant behavior.

It looks to me like sed has an off-by-one error advancing the position to search for the next match after making one replacement.
Comment 1 Denys Vlasenko 2012-06-04 12:56:25 UTC
Fixed in git:

commit 21f6fbf545e7fa58f0eaa444001a9d25bc37c4eb
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Mon Jun 4 14:44:47 2012 +0200

    sed: fix zero chars match/replace