3 # Copyright © 2021 Nick Bowler
5 # Hackjob to try and find all the relevant wordlist items from the gperf
6 # output, in order to produce (at runtime) a list of those commands, in
7 # the same order as they are listed in the gperf input file.
9 # The output is a definition of the object-like macro CMD_SEQ, which
10 # can be used to initialize an array with static storage duration.
11 # Each element of the array represents offsets into the wordlist table,
14 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
15 # This is free software: you are free to do what the fuck you want to.
16 # There is NO WARRANTY, to the extent permitted by law.
21 print " * Automatically generated by gen-cmdlist.awk from " FILENAME
23 print " * Automatically generated by gen-cmdlist.awk"
25 print " * Do not edit."
31 $1 == "char" && (id = get_stringpool_id($2)) {
44 (id = get_stringpool_id($0)) && $0 ~ "cmd_" pool[id] {
45 sub(/^stringpool_str/, "", id)
51 for (i = 1; i <= maxline; i++) {
54 seq = seq ", " indices[i]
61 print "#define CMD_SEQ { " seq " }"
64 function get_stringpool_id(s)
66 if (sub(/.*stringpool_str/, "stringpool_str", s) && sub(/[,[].*/, "", s)) {