3 # $FreeBSD: src/sys/boot/common/merge_help.awk,v 1.5 2001/11/07 17:53:25 fenner Exp $
4 # $DragonFly: src/sys/boot/common/merge_help.awk,v 1.3 2003/11/10 06:08:31 dillon Exp $
6 # Merge two boot loader help files for FreeBSD 3.0
7 # Joe Abley <jabley@patho.gen.nz>
16 # beginning of first command
17 /^###/ && (state == 0) \
24 /^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \
26 match($0, " T[[:graph:]]+");
27 T = substr($0, RSTART + 2, RLENGTH - 2);
28 match($0, " S[[:graph:]]+");
29 S = (RLENGTH == -1) ? "" : substr($0, RSTART + 2, RLENGTH - 2);
30 match($0, " D[[:graph:]][[:print:]]*$");
31 D = substr($0, RSTART + 2);
33 # find a suitable place to store this one...
40 help[ind, "link"] = -1;
43 while (help[i, "T"] help[i, "S"] < T S)
52 help[j, "link"] = ind;
53 help[ind, "link"] = -1;
55 help[ind, "link"] = i;
59 help[j, "link"] = ind;
68 help[ind, "text"] = 0;
72 # end of last command, beginning of next one
73 /^###/ && (state == 2) \
80 sub("[[:blank:]]+$", "");
81 if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next;
82 help[ind, "text", help[ind, "text"]] = $0;
87 # show them what we have (it's already sorted in help[])
93 printf "################################################################################\n";
94 printf "# T%s ", help[node, "T"];
95 if (help[node, "S"] != "") printf "S%s ", help[node, "S"];
96 printf "D%s\n\n", help[node, "D"];
97 for (i = 0; i < help[node, "text"]; i++)
98 printf "%s\n", help[node, "text", i];
99 node = help[node, "link"];
101 printf "################################################################################\n";