[BusyBox-cvs] busybox/editors sed.c,1.132,1.133

Glenn McGrath bug1 at busybox.net
Sat Sep 13 15:12:26 UTC 2003


Update of /var/cvs/busybox/editors
In directory winder:/tmp/cvs-serv2725/editors

Modified Files:
	sed.c 
Log Message:
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'


Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- sed.c	13 Sep 2003 06:57:39 -0000	1.132
+++ sed.c	13 Sep 2003 15:12:22 -0000	1.133
@@ -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 @@
 	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':




More information about the busybox-cvs mailing list