4 # Merge two boot loader help files for FreeBSD 3.0
5 # Joe Abley <jabley@patho.gen.nz>
14 # beginning of first command
15 /^###/ && (state == 0) \
22 /^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \
24 match($0, " T[[:graph:]]+");
25 T = substr($0, RSTART + 2, RLENGTH - 2);
26 match($0, " S[[:graph:]]+");
28 S = (RLENGTH == -1) ? "" : substr($0, RSTART + 2, RLENGTH - 2);
29 match($0, " D[[:graph:]][[:print:]]*$");
30 D = substr($0, RSTART + 2);
34 # find a suitable place to store this one...
41 help[ind, "link"] = -1;
44 while (help[i, "T"] help[i, "S"] < T S)
53 help[j, "link"] = ind;
54 help[ind, "link"] = -1;
56 help[ind, "link"] = i;
60 help[j, "link"] = ind;
69 help[ind, "text"] = 0;
73 # end of last command, beginning of next one
74 /^###/ && (state == 2) \
81 sub("[[:blank:]]+$", "");
82 if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next;
83 help[ind, "text", help[ind, "text"]] = $0;
88 # show them what we have (it's already sorted in help[])
94 printf "################################################################################\n";
95 printf "# T%s ", help[node, "T"];
96 if (help[node, "S"] != "") printf "S%s ", help[node, "S"];
97 printf "D%s\n\n", help[node, "D"];
98 for (i = 0; i < help[node, "text"]; i++)
99 printf "%s\n", help[node, "text", i];
100 node = help[node, "link"];
102 printf "################################################################################\n";