svn commit: trunk/busybox/shell

vda at busybox.net vda at busybox.net
Mon Apr 14 01:59:54 UTC 2008


Author: vda
Date: 2008-04-13 18:59:53 -0700 (Sun, 13 Apr 2008)
New Revision: 21731

Log:
ash: fix breakage introduced in rev 21481.
Fixes ash-vars/var_posix1.tests testsuite entry.



Modified:
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2008-04-13 22:41:27 UTC (rev 21730)
+++ trunk/busybox/shell/ash.c	2008-04-14 01:59:53 UTC (rev 21731)
@@ -5691,13 +5691,39 @@
 scanleft(char *startp, char *rmesc, char *rmescend ATTRIBUTE_UNUSED, char *str, int quotes,
 	int zero)
 {
-	char *loc, *loc2, *full;
+// This commented out code was added by James Simmons <jsimmons at infradead.org>
+// as part of a larger change when he added support for ${var/a/b}.
+// However, it broke # and % operators:
+//
+//var=ababcdcd
+//                 ok       bad
+//echo ${var#ab}   abcdcd   abcdcd
+//echo ${var##ab}  abcdcd   abcdcd
+//echo ${var#a*b}  abcdcd   ababcdcd  (!)
+//echo ${var##a*b} cdcd     cdcd
+//echo ${var#?}    babcdcd  ababcdcd  (!)
+//echo ${var##?}   babcdcd  babcdcd
+//echo ${var#*}    ababcdcd babcdcd   (!)
+//echo ${var##*}
+//echo ${var%cd}   ababcd   ababcd
+//echo ${var%%cd}  ababcd   abab      (!)
+//echo ${var%c*d}  ababcd   ababcd
+//echo ${var%%c*d} abab     ababcdcd  (!)
+//echo ${var%?}    ababcdc  ababcdc
+//echo ${var%%?}   ababcdc  ababcdcd  (!)
+//echo ${var%*}    ababcdcd ababcdcd
+//echo ${var%%*}
+//
+// Commenting it back out helped. Remove it completely if it really
+// is not needed.
+
+	char *loc, *loc2; //, *full;
 	char c;
 
 	loc = startp;
 	loc2 = rmesc;
 	do {
-		int match = strlen(str);
+		int match; // = strlen(str);
 		const char *s = loc2;
 
 		c = *loc2;
@@ -5705,23 +5731,24 @@
 			*loc2 = '\0';
 			s = rmesc;
 		}
+		match = pmatch(str, s); // this line was deleted
 
-		// chop off end if its '*'
-		full = strrchr(str, '*');
-		if (full && full != str)
-			match--;
-
-		// If str starts with '*' replace with s.
-		if ((*str == '*') && strlen(s) >= match) {
-			full = xstrdup(s);
-			strncpy(full+strlen(s)-match+1, str+1, match-1);
-		} else
-			full = xstrndup(str, match);
-		match = strncmp(s, full, strlen(full));
-		free(full);
-
+//		// chop off end if its '*'
+//		full = strrchr(str, '*');
+//		if (full && full != str)
+//			match--;
+//
+//		// If str starts with '*' replace with s.
+//		if ((*str == '*') && strlen(s) >= match) {
+//			full = xstrdup(s);
+//			strncpy(full+strlen(s)-match+1, str+1, match-1);
+//		} else
+//			full = xstrndup(str, match);
+//		match = strncmp(s, full, strlen(full));
+//		free(full);
+//
 		*loc2 = c;
-		if (!match)
+		if (match) // if (!match)
 			return loc;
 		if (quotes && *loc == CTLESC)
 			loc++;




More information about the busybox-cvs mailing list