diff options
author | Ron Yorston <rmy@pobox.com> | 2023-01-30 10:33:59 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-01-30 10:33:59 +0000 |
commit | 7a537eb71874cd6c8d0e9ab1f906e6466e7f793c (patch) | |
tree | af7b8c0218c5bc8b3e7c7aa5d86beca68350446f /testsuite | |
parent | 33ae88c40cf56b53c06e627e0535c9c740767aa4 (diff) | |
download | busybox-w32-7a537eb71874cd6c8d0e9ab1f906e6466e7f793c.tar.gz busybox-w32-7a537eb71874cd6c8d0e9ab1f906e6466e7f793c.tar.bz2 busybox-w32-7a537eb71874cd6c8d0e9ab1f906e6466e7f793c.zip |
awk: CRLF handling
Previous efforts at handling DOS-style line endings in awk have
included commits ee7e00dc5 and 1a3717342.
The use of remove_cr() is unwise:
- It's overzealous, removing all CRs, not just those in CRLF pairs.
- Even if that were fixed awk reads input in chunks. There's a
remote chance a CRLF might appear at a chunk boundary and be
missed.
remove_cr() will be fixed separately. In awk treat all data input
as being in text mode.
Skipping CRs in skip_spaces() is also flawed. Instead read scripts
in text mode.
Add a couple of test cases. One of these (awk backslash+CRLF eaten
with no trace) fails without this patch.
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/awk.tests | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index bbf0fbff1..11beb1b10 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -485,4 +485,18 @@ testing 'awk assign while test' \ | |||
485 | "" \ | 485 | "" \ |
486 | "foo" | 486 | "foo" |
487 | 487 | ||
488 | optional PLATFORM_MINGW32 | ||
489 | testing 'awk match line ending' \ | ||
490 | "awk '/world$/'" \ | ||
491 | "world\n" \ | ||
492 | "" \ | ||
493 | "hello\r\nworld\r\n" | ||
494 | |||
495 | testing 'awk backslash+CRLF eaten with no trace' \ | ||
496 | "awk -f -" \ | ||
497 | "Hello world\n" \ | ||
498 | '' \ | ||
499 | 'BEGIN { printf "Hello\\\r\n world\\n" }\n' | ||
500 | SKIP= | ||
501 | |||
488 | exit $FAILCOUNT | 502 | exit $FAILCOUNT |