From owner-freebsd-hackers Wed Jan 13 12:11:26 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA19436 for freebsd-hackers-outgoing; Wed, 13 Jan 1999 12:11:26 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from fep2-orange.clear.net.nz (fep2-orange.clear.net.nz [203.97.32.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA19412 for ; Wed, 13 Jan 1999 12:11:22 -0800 (PST) (envelope-from jabley@buddha.clear.net.nz) Received: from buddha.clear.net.nz (buddha.clear.net.nz [192.168.24.106]) by fep2-orange.clear.net.nz (1.5/1.9) with ESMTP id JAA25111; Thu, 14 Jan 1999 09:10:13 +1300 (NZDT) Received: (from jabley@localhost) by buddha.clear.net.nz (8.9.1/8.9.1) id JAA02990; Thu, 14 Jan 1999 09:10:07 +1300 (NZDT) (envelope-from jabley) Date: Thu, 14 Jan 1999 09:10:07 +1300 From: Joe Abley To: Andrzej Bialecki Cc: "Daniel C. Sobral" , Mike Smith , freebsd-hackers@FreeBSD.ORG, jabley@clear.co.nz Subject: Re: FICL and setting BTX variables Message-ID: <19990114091007.D2686@clear.co.nz> References: <19990113204253.D1312@clear.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i In-Reply-To: ; from Andrzej Bialecki on Wed, Jan 13, 1999 at 11:31:48AM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Jan 13, 1999 at 11:31:48AM +0100, Andrzej Bialecki wrote: > On Wed, 13 Jan 1999, Joe Abley wrote: > > > Has anybody had a chance to look at the boot help merge script I posted the > > other day? Just interested as to whether I had got the right end of the stick. > > Yes, I tried it. There are several things which should be corrected - see > the diffs attached below. Besides obvious errors, I think we should > preserve blank lines inside the help topics in order to improve > readability. Aah... I just found the perl script which does this right now, so I know a bit more about what I am doing now. I was treating the initial "synopsis" lines as different and required, but it seems this is not the case - they're just part of the help text. Also, the enforced tab formatting and blank line removal is not required, as you mentioned. I'm still stripping blank characters from the end of lines, though, so you will see some (non-printable) diffs: % cat help.common help.i38 | ./mergehelp.awk >version.awk % perl ./merge_help.pl help.common help.i386 >version.perl % diff version.awk version.perl 59c59 < --- > 112c112 < The read command reads a line of input from the terminal. If the --- > The read command reads a line of input from the terminal. If the 114c114 < received after seconds. (Any keypress will cancel the --- > received after seconds. (Any keypress will cancel the 117c117 < If -p is specified, is printed before reading input. No --- > If -p is specified, is printed before reading input. No 198c198 < It may be overridden by setting the bootfile variable to a --- > It may be overridden by setting the bootfile variable to a 240c240 < Variable substitution is performed on the prompt. The default --- > Variable substitution is performed on the prompt. The default 293c293 < is removed. --- > is removed. % Revised script below, and at http://www.patho.gen.nz/~jabley/mergehelp.awk if that's more convenient. Joe #!/usr/bin/awk -f # # $Id: mergehelp.awk,v 1.3 1999/01/13 20:06:52 jabley Exp $ # # Merge two boot loader help files for FreeBSD 3.0 # Joe Abley BEGIN \ { state = 0; first = 0; ind = 0; } # beginning of first command /^###/ && (state == 0) \ { state = 1; next; } # entry header /^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \ { match($0, " T[[:graph:]]+"); T = substr($0, RSTART + 2, RLENGTH - 2); match($0, " S[[:graph:]]+"); S = (RLENGTH == -1) ? "" : substr($0, RSTART + 2, RLENGTH - 2); match($0, " D[[:graph:]][[:print:]]*$"); D = substr($0, RSTART + 2); # find a suitable place to store this one... ind++; if (ind == 1) { first = ind; help[ind, "T"] = T; help[ind, "S"] = S; help[ind, "link"] = -1; } else { i = first; j = -1; while (help[i, "T"] help[i, "S"] < T S) { j = i; i = help[i, "link"]; if (i == -1) break; } if (i == -1) { help[j, "link"] = ind; help[ind, "link"] = -1; } else { help[ind, "link"] = i; if (j == -1) first = ind; else help[j, "link"] = ind; } } help[ind, "T"] = T; help[ind, "S"] = S; help[ind, "D"] = D; # set our state state = 2; help[ind, "text"] = 0; next; } # end of last command, beginning of next one /^###/ && (state == 2) \ { state = 1; } (state == 2) \ { sub("[[:blank:]]+$", ""); if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next; help[ind, "text", help[ind, "text"]] = $0; help[ind, "text"]++; next; } # show them what we have (it's already sorted in help[]) END \ { node = first; while (node != -1) { printf "################################################################################\n"; printf "# T%s ", help[node, "T"]; if (help[node, "S"] != "") printf "S%s ", help[node, "S"]; printf "D%s\n\n", help[node, "D"]; for (i = 0; i < help[node, "text"]; i++) printf "%s\n", help[node, "text", i]; node = help[node, "link"]; } printf "################################################################################\n"; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message