From e8fe9f96356a6b19ec907ea30cffc829c539a7ff Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 27 Jan 2021 11:19:14 +0000 Subject: awk: allow printf('%c') to output NUL, closes 13486 Treat the output of printf as binary rather than a null-terminated string so that NUL characters can be output. This is considered to be a GNU extension, though it's also available in mawk and FreeBSD's awk. function old new delta evaluate 3487 3504 +17 awk_printf 504 519 +15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- testsuite/awk.tests | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'testsuite') diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 92c83d719..cf9b722dc 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -383,6 +383,11 @@ testing "awk errors on missing delete arg" \ "awk -e '{delete}' 2>&1" "awk: cmd. line:1: Too few arguments\n" "" "" SKIP= +optional FEATURE_AWK_GNU_EXTENSIONS +testing "awk printf('%c') can output NUL" \ + "awk '{printf(\"hello%c null\n\", 0)}'" "hello\0 null\n" "" "\n" +SKIP= + # testing "description" "command" "result" "infile" "stdin" testing 'awk negative field access' \ 'awk 2>&1 -- '\''{ $(-1) }'\' \ -- cgit v1.2.3