From: Nick Bowler Date: Tue, 5 Dec 2023 01:36:17 +0000 (-0500) Subject: gen-strtab.awk: Allow repeated whitespace in one-line strings. X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/commitdiff_plain/c3f53b697f5dd5ecd5a5f74e94ec0fd55b0f2764 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. --- 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