HAMMER 59C/Many: Stabilization pass - fixes for large file issues
[dragonfly.git] / sys / boot / common / merge_help.awk
bloba5dd388f43772f79436f123c61fc2a7b183327a7
1 #!/usr/bin/awk -f
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>
9 BEGIN \
11 state = 0;
12 first = -1;
13 ind = 0;
16 # beginning of first command
17 /^###/ && (state == 0) \
19 state = 1;
20 next;
23 # entry header
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...
34 ind++;
35 if (ind == 1)
37 first = ind;
38 help[ind, "T"] = T;
39 help[ind, "S"] = S;
40 help[ind, "link"] = -1;
41 } else {
42 i = first; j = -1;
43 while (help[i, "T"] help[i, "S"] < T S)
45 j = i;
46 i = help[i, "link"];
47 if (i == -1) break;
50 if (i == -1)
52 help[j, "link"] = ind;
53 help[ind, "link"] = -1;
54 } else {
55 help[ind, "link"] = i;
56 if (j == -1)
57 first = ind;
58 else
59 help[j, "link"] = ind;
62 help[ind, "T"] = T;
63 help[ind, "S"] = S;
64 help[ind, "D"] = D;
66 # set our state
67 state = 2;
68 help[ind, "text"] = 0;
69 next;
72 # end of last command, beginning of next one
73 /^###/ && (state == 2) \
75 state = 1;
78 (state == 2) \
80 sub("[[:blank:]]+$", "");
81 if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next;
82 help[ind, "text", help[ind, "text"]] = $0;
83 help[ind, "text"]++;
84 next;
87 # show them what we have (it's already sorted in help[])
88 END \
90 node = first;
91 while (node != -1)
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";