aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-09-13 15:12:22 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-09-13 15:12:22 +0000
commitf36635cec6da728fe06b849089ce2f6c1690dc67 (patch)
treeb30e5d8216a515f0e549f29802d915eee9991e08
parentc18ce373a21f72b23259c9c15503ac8800d605c7 (diff)
downloadbusybox-w32-f36635cec6da728fe06b849089ce2f6c1690dc67.tar.gz
busybox-w32-f36635cec6da728fe06b849089ce2f6c1690dc67.tar.bz2
busybox-w32-f36635cec6da728fe06b849089ce2f6c1690dc67.zip
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'
-rw-r--r--editors/sed.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 5bfe924a5..75ed53eb7 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -43,11 +43,11 @@
43 Unsupported features: 43 Unsupported features:
44 44
45 - GNU extensions 45 - GNU extensions
46 - and lots, lots more. 46 - and more.
47 47
48 Bugs: 48 Bugs:
49 49
50 - Cant subst globally using ^ or $ in regex, eg. "aah" | sed 's/^a/b/g' 50 - lots
51 51
52 Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html 52 Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
53*/ 53*/
@@ -299,7 +299,9 @@ static int parse_subst_cmd(sed_cmd_t * const sed_cmd, const char *substr)
299 while (substr[++idx]) { 299 while (substr[++idx]) {
300 switch (substr[idx]) { 300 switch (substr[idx]) {
301 case 'g': 301 case 'g':
302 sed_cmd->sub_g = 1; 302 if (match[0] != '^') {
303 sed_cmd->sub_g = 1;
304 }
303 break; 305 break;
304 /* Hmm, i dont see the I option mentioned in the standard */ 306 /* Hmm, i dont see the I option mentioned in the standard */
305 case 'I': 307 case 'I':