summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorGlenn L McGrath2003-09-13 15:12:22 +0000
committerGlenn L McGrath2003-09-13 15:12:22 +0000
commitf36635cec6da728fe06b849089ce2f6c1690dc67 (patch)
treeb30e5d8216a515f0e549f29802d915eee9991e08 /editors
parentc18ce373a21f72b23259c9c15503ac8800d605c7 (diff)
downloadbusybox-f36635cec6da728fe06b849089ce2f6c1690dc67.zip
busybox-f36635cec6da728fe06b849089ce2f6c1690dc67.tar.gz
Fix the following testcase by disabling global substitution if the regex
is anchored to the start of line, there can be only one subst. echo "aah" | sed 's/^a/b/g'
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 5bfe924..75ed53e 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -43,11 +43,11 @@
Unsupported features:
- GNU extensions
- - and lots, lots more.
+ - and more.
Bugs:
- - Cant subst globally using ^ or $ in regex, eg. "aah" | sed 's/^a/b/g'
+ - lots
Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
*/
@@ -299,7 +299,9 @@ static int parse_subst_cmd(sed_cmd_t * const sed_cmd, const char *substr)
while (substr[++idx]) {
switch (substr[idx]) {
case 'g':
- sed_cmd->sub_g = 1;
+ if (match[0] != '^') {
+ sed_cmd->sub_g = 1;
+ }
break;
/* Hmm, i dont see the I option mentioned in the standard */
case 'I':