xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | # awk script to create summary.texinfo from the library texinfo files. |
| 2 | # Copyright (C) 1992-2016 Free Software Foundation, Inc. |
| 3 | # This file is part of the GNU C Library. |
| 4 | |
| 5 | # The GNU C Library is free software; you can redistribute it and/or |
| 6 | # modify it under the terms of the GNU Lesser General Public |
| 7 | # License as published by the Free Software Foundation; either |
| 8 | # version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | # The GNU C Library is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | # Lesser General Public License for more details. |
| 14 | |
| 15 | # You should have received a copy of the GNU Lesser General Public |
| 16 | # License along with the GNU C Library; if not, see |
| 17 | # <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | # This script recognizes sequences that look like: |
| 20 | # @comment HEADER.h |
| 21 | # @comment STANDARD |
| 22 | # @def... ITEM | @item ITEM | @vindex ITEM |
| 23 | |
| 24 | BEGIN { header = 0; |
| 25 | nameword["@defun"]=1 |
| 26 | nameword["@defunx"]=1 |
| 27 | nameword["@defmac"]=1 |
| 28 | nameword["@defmacx"]=1 |
| 29 | nameword["@defspec"]=1 |
| 30 | nameword["@defspecx"]=1 |
| 31 | nameword["@defvar"]=1 |
| 32 | nameword["@defvarx"]=1 |
| 33 | nameword["@defopt"]=1 |
| 34 | nameword["@defoptx"]=1 |
| 35 | nameword["@deffn"]=2 |
| 36 | nameword["@deffnx"]=2 |
| 37 | nameword["@defvr"]=2 |
| 38 | nameword["@defvrx"]=2 |
| 39 | nameword["@deftp"]=2 |
| 40 | nameword["@deftpx"]=2 |
| 41 | nameword["@deftypefun"]=2 |
| 42 | nameword["@deftypefunx"]=2 |
| 43 | nameword["@deftypevar"]=2 |
| 44 | nameword["@deftypevarx"]=2 |
| 45 | nameword["@deftypefn"]=3 |
| 46 | nameword["@deftypefnx"]=3 |
| 47 | nameword["@deftypevr"]=3 |
| 48 | nameword["@deftypevrx"]=3 |
| 49 | firstword["@defun"]=1 |
| 50 | firstword["@defunx"]=1 |
| 51 | firstword["@defmac"]=1 |
| 52 | firstword["@defmacx"]=1 |
| 53 | firstword["@defspec"]=1 |
| 54 | firstword["@defspecx"]=1 |
| 55 | firstword["@defvar"]=1 |
| 56 | firstword["@defvarx"]=1 |
| 57 | firstword["@defopt"]=1 |
| 58 | firstword["@defoptx"]=1 |
| 59 | firstword["@deffn"]=2 |
| 60 | firstword["@deffnx"]=2 |
| 61 | firstword["@defvr"]=2 |
| 62 | firstword["@defvrx"]=2 |
| 63 | firstword["@deftp"]=2 |
| 64 | firstword["@deftpx"]=2 |
| 65 | firstword["@deftypefun"]=1 |
| 66 | firstword["@deftypefunx"]=1 |
| 67 | firstword["@deftypevar"]=1 |
| 68 | firstword["@deftypevarx"]=1 |
| 69 | firstword["@deftypefn"]=2 |
| 70 | firstword["@deftypefnx"]=2 |
| 71 | firstword["@deftypevr"]=2 |
| 72 | firstword["@deftypevrx"]=2 |
| 73 | nameword["@item"]=1 |
| 74 | firstword["@item"]=1 |
| 75 | nameword["@itemx"]=1 |
| 76 | firstword["@itemx"]=1 |
| 77 | nameword["@vindex"]=1 |
| 78 | firstword["@vindex"]=1 |
| 79 | |
| 80 | print "@c DO NOT EDIT THIS FILE!" |
| 81 | print "@c This file is generated by summary.awk from the Texinfo sources." |
| 82 | } |
| 83 | |
| 84 | $1 == "@node" { node=$2; |
| 85 | for (i = 3; i <= NF; ++i) |
| 86 | { node=node " " $i; if ( $i ~ /,/ ) break; } |
| 87 | sub (/,[, ]*$/, "", node); |
| 88 | } |
| 89 | |
| 90 | $1 == "@comment" && $2 ~ /\.h$/ { header="@file{" $2 "}"; |
| 91 | for (i = 3; i <= NF; ++i) |
| 92 | header=header ", @file{" $i "}" |
| 93 | } |
| 94 | |
| 95 | $1 == "@comment" && $2 == "(none)" { header = -1; } |
| 96 | |
| 97 | $1 == "@comment" && header != 0 { std=$2; |
| 98 | for (i=3;i<=NF;++i) std=std " " $i } |
| 99 | |
| 100 | header != 0 && $1 ~ /@def|@item|@vindex/ \ |
| 101 | { defn=""; name=""; curly=0; n=1; |
| 102 | for (i = 2; i <= NF; ++i) { |
| 103 | if ($i ~ /^{/ && $i !~ /}/) { |
| 104 | curly=1 |
| 105 | word=substr ($i, 2, length ($i)) |
| 106 | } |
| 107 | else { |
| 108 | if (curly) { |
| 109 | if ($i ~ /}$/) { |
| 110 | curly=0 |
| 111 | word=word " " substr ($i, 1, length ($i) - 1) |
| 112 | } else |
| 113 | word=word " " $i |
| 114 | } |
| 115 | # Handle a single word in braces. |
| 116 | else if ($i ~ /^{.*}$/) |
| 117 | word=substr ($i, 2, length ($i) - 2) |
| 118 | else |
| 119 | word=$i |
| 120 | if (!curly) { |
| 121 | if (n >= firstword[$1]) |
| 122 | defn=defn " " word |
| 123 | if (n == nameword[$1]) |
| 124 | name=word |
| 125 | ++n |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | printf "@comment %s%c", name, 12 # FF |
| 130 | printf "@item%s%c%c", defn, 12, 12 |
| 131 | if (header != -1) printf "%s ", header; |
| 132 | printf "(%s): @ref{%s}.%c\n", std, node, 12; |
| 133 | header = 0 } |