From c3f53b697f5dd5ecd5a5f74e94ec0fd55b0f2764 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Mon, 4 Dec 2023 20:36:17 -0500 Subject: [PATCH] gen-strtab.awk: Allow repeated whitespace in one-line strings. The documentation says that, for a one-line string, all whitespace immediately following the identifier is deleted. It does not say that anything happens to other withespace on the line, but it turns out that consecutive sequences of whitespace are replaced by a single space. This is unexpected. Fix up the script so that doesn't happen, and add a test for this. --- scripts/gen-strtab.awk | 5 +++-- tests/scripts.at | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/gen-strtab.awk b/scripts/gen-strtab.awk index 716a8ec..56f0807 100755 --- a/scripts/gen-strtab.awk +++ b/scripts/gen-strtab.awk @@ -116,11 +116,12 @@ sub(/^[&]/, "") { vars[num_vars++] = ident; } - current_l10n = !sub(/^[&]/, "", $1); + current_l10n = !sub(/^[&]/, ""); startline = NR; ident = $1; - $1 = collected = ""; + collected = ""; + sub(/^[^ \t]*/, ""); } ident != "" { diff --git a/tests/scripts.at b/tests/scripts.at index 3a91bd0..7a873a9 100644 --- a/tests/scripts.at +++ b/tests/scripts.at @@ -356,6 +356,7 @@ newline\ \ leading whitespace &j oneline # with a comment +&k with nontrivial whitespace ]]) AT_CHECK([$AWK -f "$srcdir/scripts/gen-strtab.awk" test.h]) @@ -407,6 +408,8 @@ nonewline --- oneline --- +with nontrivial whitespace +--- ], [ignore]) AT_CLEANUP -- 2.43.2