diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-12 13:54:13 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-12 13:54:13 +0000 |
commit | 67b5eeb93324f7484836be705698e72008498fe5 (patch) | |
tree | 146cb9dc174befb20d6a0d75f88bf3cef9cc82ee | |
parent | 32a385f5b0a74ca886e69472aaa1de8045a1ddbd (diff) | |
download | busybox-w32-67b5eeb93324f7484836be705698e72008498fe5.tar.gz busybox-w32-67b5eeb93324f7484836be705698e72008498fe5.tar.bz2 busybox-w32-67b5eeb93324f7484836be705698e72008498fe5.zip |
awk: fix long field separators case. By Ian Wienand (ianw AT vmware.com)
-rw-r--r-- | editors/awk.c | 5 | ||||
-rwxr-xr-x | testsuite/awk.tests | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c index 9b15b3cd6..89ce2cfc8 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -1574,7 +1574,10 @@ static int awk_split(const char *s, node *spl, char **slist) | |||
1574 | if (s[l]) pmatch[0].rm_eo++; | 1574 | if (s[l]) pmatch[0].rm_eo++; |
1575 | } | 1575 | } |
1576 | memcpy(s1, s, l); | 1576 | memcpy(s1, s, l); |
1577 | s1[l] = '\0'; | 1577 | /* make sure we remove *all* of the separator chars */ |
1578 | while (l < pmatch[0].rm_eo) { | ||
1579 | s1[l++] = '\0'; | ||
1580 | } | ||
1578 | nextword(&s1); | 1581 | nextword(&s1); |
1579 | s += pmatch[0].rm_eo; | 1582 | s += pmatch[0].rm_eo; |
1580 | } while (*s); | 1583 | } while (*s); |
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 8e72dd38f..0db99ab21 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -22,6 +22,12 @@ testing "awk hex const 1" "awk '{ print or(0xffffffff,1) }'" "4.29497e+09\n" "" | |||
22 | testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n" | 22 | testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n" |
23 | testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n" | 23 | testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n" |
24 | 24 | ||
25 | # long field seps requiring regex | ||
26 | testing "awk long field sep" "awk -F-- '{ print NF, length(\$NF), \$NF }'" \ | ||
27 | "2 0 \n3 0 \n4 0 \n5 0 \n" \ | ||
28 | "" \ | ||
29 | "a--\na--b--\na--b--c--\na--b--c--d--" | ||
30 | |||
25 | # '@(samp|code|file)\{' is an invalid extended regex (unmatched '{'), | 31 | # '@(samp|code|file)\{' is an invalid extended regex (unmatched '{'), |
26 | # but gawk 3.1.5 does not bail out on it. | 32 | # but gawk 3.1.5 does not bail out on it. |
27 | testing "awk gsub falls back to non-extended-regex" \ | 33 | testing "awk gsub falls back to non-extended-regex" \ |