3 # $FreeBSD: src/sys/boot/common/merge_help.awk,v 1.2 1999/08/28 00:39:50 peter Exp $
5 # Merge two boot loader help files for FreeBSD 3.0
6 # Joe Abley <jabley@patho.gen.nz>
15 # beginning of first command
16 /^###/ && (state == 0) \
23 /^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \
25 match($0, " T[[:graph:]]+");
26 T = substr($0, RSTART + 2, RLENGTH - 2);
27 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);
32 # find a suitable place to store this one...
39 help[ind, "link"] = -1;
42 while (help[i, "T"] help[i, "S"] < T S)
51 help[j, "link"] = ind;
52 help[ind, "link"] = -1;
54 help[ind, "link"] = i;
58 help[j, "link"] = ind;
67 help[ind, "text"] = 0;
71 # end of last command, beginning of next one
72 /^###/ && (state == 2) \
79 sub("[[:blank:]]+$", "");
80 if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next;
81 help[ind, "text", help[ind, "text"]] = $0;
86 # show them what we have (it's already sorted in help[])
92 printf "################################################################################\n";
93 printf "# T%s ", help[node, "T"];
94 if (help[node, "S"] != "") printf "S%s ", help[node, "S"];
95 printf "D%s\n\n", help[node, "D"];
96 for (i = 0; i < help[node, "text"]; i++)
97 printf "%s\n", help[node, "text", i];
98 node = help[node, "link"];
100 printf "################################################################################\n";