From a49a9f1f9f8c50a7f749a7e3b9ca69e1ccb6bcb1 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Tue, 2 Jan 2024 22:13:31 -0500 Subject: [PATCH] tests: Fix gen-typegen.awk on AIX. With AIX 7.2 awk, assigning $0 in an END action does not update NF, leaving it with its prior value from the last record: aix72% echo a b c | awk 'END { $0 = "x"; print NF; }' 3 In the case of gen-typegen.awk, this does not result in any syntax errors in the generated typegen.h file. However, the resulting randomdecl executable fails to produce any declarations with more than one type specifier in any given specifier list. Fortunately the randomdecl sanity test caught this problem, because the _Imaginary and _Complex specifiers were not being generated (as these are the only type specifiers that never appear by themselves). Work around the problem by using split instead. --- t/gen-typegen.awk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/gen-typegen.awk b/t/gen-typegen.awk index a3a1527..ee94b0e 100755 --- a/t/gen-typegen.awk +++ b/t/gen-typegen.awk @@ -1,6 +1,6 @@ #!/bin/awk -f # -# Copyright © 2021-2022 Nick Bowler +# Copyright © 2021-2022, 2024 Nick Bowler # # Generate a mapping from a (random) integer to a list of type specifiers # represented by struct cdecl_declspec. Used internally by declgen to @@ -45,15 +45,15 @@ END { print "\tswitch (rngval) {" for (i = 0; i < count; i++) { - print "\tcase " i ":" - $0 = specs[i] + print "\tcase " i ":"; - for (j = 1; j <= NF; j++) { + n = split(specs[i], parts); + for (j = 1; j <= n; j++) { prefix = j == 1 ? "return" : ""; - printf "\t\t%6s gen_raw_typespec_(%s,\n", prefix, $j + printf "\t\t%6s gen_raw_typespec_(%s,\n", prefix, parts[j]; } - printf "\t\t%25sNULL%s;\n", "", substr("))))))))", 1, NF); + printf "\t\t%25sNULL%s;\n", "", substr("))))))))", 1, n); } print "\tdefault:\n\t\tassert(0);\n\t}" print "}\n" -- 2.43.2