]> git.draconx.ca Git - dxcommon.git/commitdiff
gen-strtab.awk: Allow repeated whitespace in one-line strings.
authorNick Bowler <nbowler@draconx.ca>
Tue, 5 Dec 2023 01:36:17 +0000 (20:36 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 5 Dec 2023 01:36:17 +0000 (20:36 -0500)
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
tests/scripts.at

index 716a8ec46f1b5e057c17e014a0c33f9278279e57..56f0807998c9fe2fbe527fb1a31f82b9d047a3ef 100755 (executable)
@@ -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 != "" {
index 3a91bd0689887cb3ba98ba8a4e8920b45fc24024..7a873a9086fcdaa4b4007f935ad34dcbd938ebb6 100644 (file)
@@ -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.def >test.h])
@@ -407,6 +408,8 @@ nonewline
 ---
 oneline
 ---
+with   nontrivial   whitespace
+---
 ], [ignore])
 
 AT_CLEANUP