svn commit: [26072] trunk/busybox: editors testsuite

vda at busybox.net vda at busybox.net
Sun Apr 12 13:54:13 UTC 2009


Author: vda
Date: 2009-04-12 13:54:13 +0000 (Sun, 12 Apr 2009)
New Revision: 26072

Log:
awk: fix long field separators case. By Ian Wienand (ianw AT vmware.com)



Modified:
   trunk/busybox/editors/awk.c
   trunk/busybox/testsuite/awk.tests


Changeset:
Modified: trunk/busybox/editors/awk.c
===================================================================
--- trunk/busybox/editors/awk.c	2009-04-12 13:05:40 UTC (rev 26071)
+++ trunk/busybox/editors/awk.c	2009-04-12 13:54:13 UTC (rev 26072)
@@ -1574,7 +1574,10 @@
 				if (s[l]) pmatch[0].rm_eo++;
 			}
 			memcpy(s1, s, l);
-			s1[l] = '\0';
+			/* make sure we remove *all* of the separator chars */
+			while (l < pmatch[0].rm_eo) {
+				s1[l++] = '\0';
+			}
 			nextword(&s1);
 			s += pmatch[0].rm_eo;
 		} while (*s);

Modified: trunk/busybox/testsuite/awk.tests
===================================================================
--- trunk/busybox/testsuite/awk.tests	2009-04-12 13:05:40 UTC (rev 26071)
+++ trunk/busybox/testsuite/awk.tests	2009-04-12 13:54:13 UTC (rev 26072)
@@ -22,6 +22,12 @@
 testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n"
 testing "awk oct const"   "awk '{ print or(01234,1) }'"      "669\n"         "" "\n"
 
+# long field seps requiring regex
+testing "awk long field sep" "awk -F-- '{ print NF, length(\$NF), \$NF }'" \
+	"2 0 \n3 0 \n4 0 \n5 0 \n" \
+	"" \
+	"a--\na--b--\na--b--c--\na--b--c--d--"
+
 # '@(samp|code|file)\{' is an invalid extended regex (unmatched '{'),
 # but gawk 3.1.5 does not bail out on it.
 testing "awk gsub falls back to non-extended-regex" \



More information about the busybox-cvs mailing list