]> git.draconx.ca Git - rrace.git/blob - src/mkstrtab.awk
motif: Optimize widget string table a bit.
[rrace.git] / src / mkstrtab.awk
1 #!/bin/awk -f
2 #
3 # Copyright © 2023 Nick Bowler
4 #
5 # Helper script used by the RRace makefile to combine gen-tree.awk and
6 # gen-strtab.awk inputs into a single source file and build rule.
7 #
8 # Usage: awk -f mkstrtab.awk -f gen-strtab.awk input.dat
9 #
10 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
11 # This is free software: you are free to do what the fuck you want to.
12 # There is NO WARRANTY, to the extent permitted by law.
13
14 {
15   if (sub(/^#&/, "\\&")) {
16     # Lines beginning with #& are taken verbatim (with the # removed)
17     explicit[$1] = 1;
18   } else if (sub(/,$/, "", $1) && !("&"$1 in explicit)) {
19     # Put tree node ids into the strtab, unless explicitly defined earlier.
20     $0 = "&&" $1 " " $1;
21   } else {
22     next;
23   }
24 }