The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/boot/common/merge_help.awk

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!/usr/bin/awk -f
    2 #
    3 # $FreeBSD: releng/8.2/sys/boot/common/merge_help.awk 162742 2006-09-28 19:06:20Z jhb $
    4 #
    5 # Merge two boot loader help files for FreeBSD 3.0
    6 # Joe Abley <jabley@patho.gen.nz>
    7 
    8 BEGIN \
    9 {
   10   state = 0;
   11   first = -1;
   12   ind = 0;
   13 }
   14 
   15 # beginning of first command
   16 /^###/ && (state == 0) \
   17 {
   18   state = 1;
   19   next;
   20 }
   21 
   22 # entry header
   23 /^# T[[:graph:]]+ (S[[:graph:]]+ )*D[[:graph:]][[:print:]]*$/ && (state == 1) \
   24 {
   25   match($0, " T[[:graph:]]+");
   26   T = substr($0, RSTART + 2, RLENGTH - 2);
   27   match($0, " S[[:graph:]]+");
   28   SSTART = RSTART
   29   S = (RLENGTH == -1) ? "" : substr($0, RSTART + 2, RLENGTH - 2);
   30   match($0, " D[[:graph:]][[:print:]]*$");
   31   D = substr($0, RSTART + 2);
   32   if (SSTART > RSTART)
   33     S = "";
   34 
   35   # find a suitable place to store this one...
   36   ind++;
   37   if (ind == 1)
   38   {
   39     first = ind;
   40     help[ind, "T"] = T;
   41     help[ind, "S"] = S;
   42     help[ind, "link"] = -1;
   43   } else {
   44     i = first; j = -1;
   45     while (help[i, "T"] help[i, "S"] < T S)
   46     {
   47       j = i;
   48       i = help[i, "link"];
   49       if (i == -1) break;
   50     }
   51 
   52     if (i == -1)
   53     {
   54       help[j, "link"] = ind;
   55       help[ind, "link"] = -1;
   56     } else {
   57       help[ind, "link"] = i;
   58       if (j == -1)
   59         first = ind;
   60       else
   61         help[j, "link"] = ind;
   62     }
   63   }
   64   help[ind, "T"] = T;
   65   help[ind, "S"] = S;
   66   help[ind, "D"] = D;
   67 
   68   # set our state
   69   state = 2;
   70   help[ind, "text"] = 0;
   71   next;
   72 }
   73 
   74 # end of last command, beginning of next one
   75 /^###/ && (state == 2) \
   76 {
   77   state = 1;
   78 }
   79 
   80 (state == 2) \
   81 {
   82   sub("[[:blank:]]+$", "");
   83   if (help[ind, "text"] == 0 && $0 ~ /^[[:blank:]]*$/) next;
   84   help[ind, "text", help[ind, "text"]] = $0;
   85   help[ind, "text"]++;
   86   next;
   87 }
   88 
   89 # show them what we have (it's already sorted in help[])
   90 END \
   91 {
   92   node = first;
   93   while (node != -1)
   94   {
   95     printf "################################################################################\n";
   96     printf "# T%s ", help[node, "T"];
   97     if (help[node, "S"] != "") printf "S%s ", help[node, "S"];
   98     printf "D%s\n\n", help[node, "D"];
   99     for (i = 0; i < help[node, "text"]; i++)
  100       printf "%s\n", help[node, "text", i];
  101     node = help[node, "link"];
  102   }
  103   printf "################################################################################\n";
  104 }

Cache object: 36094a7694dfae596e8e5a0ba5df3047


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.