Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jan 1999 09:10:07 +1300
From:      Joe Abley <jabley@clear.co.nz>
To:        Andrzej Bialecki <abial@nask.pl>
Cc:        "Daniel C. Sobral" <dcs@newsguy.com>, Mike Smith <mike@smith.net.au>, freebsd-hackers@FreeBSD.ORG, jabley@clear.co.nz
Subject:   Re: FICL and setting BTX variables
Message-ID:  <19990114091007.D2686@clear.co.nz>
In-Reply-To: <Pine.BSF.4.02A.9901131127490.5148-100000@korin.warman.org.pl>; from Andrzej Bialecki on Wed, Jan 13, 1999 at 11:31:48AM %2B0100
References:  <19990113204253.D1312@clear.co.nz> <Pine.BSF.4.02A.9901131127490.5148-100000@korin.warman.org.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <value> seconds.  (Any keypress will cancel the
  ---
  >       received after <value> seconds.  (Any keypress will cancel the 
  117c117
  <       If -p is specified, <prompt> is printed before reading input. No
  ---
  >       If -p is specified, <prompt> 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 <jabley@clear.co.nz> 

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990114091007.D2686>