Keep "gpg_homedir" and list file settings across SIGHUP.
[libpwmd.git] / doc / extract-help-text.awk
blob02e4c78012ff2562ac8b3b39dca96f4198426d9e
1 # Read in commands.c and add texinfo commands. See Makefile.am.
3 BEGIN {
6 while (getline > 0)
7 if ($0 ~ /!BEGIN-HELP-TEXT!/) {
8 list_total = 1
10 while (getline > 0)
11 if ($0 ~ /!END-HELP-TEXT!/) {
12 exit
14 else if ($0 ~ /new_command\(/) {
15 desc = ""
16 getline
17 sub(/^\"/,"")
18 sub(/\\n\"$/,"")
19 name = sub(/^[^ ]*/,"&");
20 info = "@node " $name ", !NEXT!, !PREV!, Commands\n"
21 info = info "@chapter " $name " command\n"
22 info = info "@cindex " $name " command\n"
23 info = info "Syntax:\n"
24 info = info "@example\n"
25 info = info $0 "\n"
26 info = info "@end example\n"
27 list[list_total "," "name"] = $name
29 while (getline > 0)
30 if ($0 ~ /^\)\);/) {
31 break
33 else {
34 gsub(/\\n\"$/,"")
35 gsub(/"/,"")
36 gsub(/\n/,"")
37 desc = desc $0 "\n"
40 desc = desc "\n"
41 list[list_total "," "info"] = info
42 list[list_total "," "desc"] = desc
43 list_total++
50 # Borrowed from http://awk.info/?TenLiners
52 function qsort(A, left, right, i, last) {
53 if (left >= right)
54 return
55 swap(A, left, left+int((right-left+1)*rand()))
56 last = left
57 for (i = left+1; i <= right; i++)
58 if (A[i "," "name"] < A[left "," "name"])
59 swap(A, ++last, i)
60 swap(A, left, last)
61 qsort(A, left, last-1)
62 qsort(A, last+1, right)
65 function swap(A, i, j, hrm) {
66 name = A[i "," "name"];
67 info = A[i "," "info"];
68 desc = A[i "," "desc"];
69 A[i "," "name"] = A[j "," "name"]
70 A[i "," "info"] = A[j "," "info"]
71 A[i "," "desc"] = A[j "," "desc"]
72 A[j "," "name"] = name;
73 A[j "," "info"] = info;
74 A[j "," "desc"] = desc;
77 END {
78 qsort(list, 1, list_total-1)
80 for (t = 1; t < list_total; t++) {
81 if (t == 1) {
82 sub(/!PREV!/, "", list[t "," "info"])
84 else {
85 sub(/!PREV!/, list[t-1 "," "name"], list[t "," "info"])
88 if (t == list_total-1) {
89 sub(/!NEXT!/, "", list[t "," "info"])
91 else {
92 sub(/!NEXT!/, list[t+1 "," "name"], list[t "," "info"])
95 print list[t "," "info"] "\n" list[t "," "desc"]
96 print "* " list[t "," "name"] "::" > "menu.texi.in"
99 close("menu.texi.in")