]> git.draconx.ca Git - cdecl99.git/blobdiff - src/gen-cmdlist.awk
cdecl99: Fix "help" command on ULTRIX.
[cdecl99.git] / src / gen-cmdlist.awk
index ea096eb195f2b533340e84a07cda60d9795ab050..42cd593dc7c4652faa8eb1662563b0c660c8aaa8 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/awk -f
 #
-# Copyright © 2021 Nick Bowler
+# Copyright © 2021, 2023 Nick Bowler
 #
 # Hackjob to try and find all the relevant wordlist items from the gperf
 # output, in order to produce (at runtime) a list of those commands, in
@@ -28,10 +28,10 @@ END {
 
 BEGIN { maxline = 0 }
 
-$1 == "char" && (id = get_stringpool_id($2)) {
+$1 == "char" && get_stringpool_id($2) {
   sub(/[^"]*"/, "", $2)
   sub(/".*/, "", $2)
-  pool[id] = $2
+  pool[ID] = $2
 }
 
 $1 ~ /^#line/ {
@@ -41,9 +41,9 @@ $1 ~ /^#line/ {
   }
 }
 
-(id = get_stringpool_id($0)) && $0 ~ "cmd_" pool[id] {
-  sub(/^stringpool_str/, "", id)
-  indices[line] = id
+get_stringpool_id($0) && $0 ~ "cmd_" pool[ID] {
+  sub(/^stringpool_str/, "", ID)
+  indices[line] = ID
 }
 
 END {
@@ -64,8 +64,9 @@ END {
 function get_stringpool_id(s)
 {
   if (sub(/.*stringpool_str/, "stringpool_str", s) && sub(/[,[].*/, "", s)) {
-    return s
+    ID = s;
+    return 1
   }
 
-  return ""
+  return 0
 }