blob: 7f721e9767c8220303f75ac49c3d5e9e2b63f962 [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001# 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
24BEGIN { header = 0;
25nameword["@defun"]=1
26nameword["@defunx"]=1
27nameword["@defmac"]=1
28nameword["@defmacx"]=1
29nameword["@defspec"]=1
30nameword["@defspecx"]=1
31nameword["@defvar"]=1
32nameword["@defvarx"]=1
33nameword["@defopt"]=1
34nameword["@defoptx"]=1
35nameword["@deffn"]=2
36nameword["@deffnx"]=2
37nameword["@defvr"]=2
38nameword["@defvrx"]=2
39nameword["@deftp"]=2
40nameword["@deftpx"]=2
41nameword["@deftypefun"]=2
42nameword["@deftypefunx"]=2
43nameword["@deftypevar"]=2
44nameword["@deftypevarx"]=2
45nameword["@deftypefn"]=3
46nameword["@deftypefnx"]=3
47nameword["@deftypevr"]=3
48nameword["@deftypevrx"]=3
49firstword["@defun"]=1
50firstword["@defunx"]=1
51firstword["@defmac"]=1
52firstword["@defmacx"]=1
53firstword["@defspec"]=1
54firstword["@defspecx"]=1
55firstword["@defvar"]=1
56firstword["@defvarx"]=1
57firstword["@defopt"]=1
58firstword["@defoptx"]=1
59firstword["@deffn"]=2
60firstword["@deffnx"]=2
61firstword["@defvr"]=2
62firstword["@defvrx"]=2
63firstword["@deftp"]=2
64firstword["@deftpx"]=2
65firstword["@deftypefun"]=1
66firstword["@deftypefunx"]=1
67firstword["@deftypevar"]=1
68firstword["@deftypevarx"]=1
69firstword["@deftypefn"]=2
70firstword["@deftypefnx"]=2
71firstword["@deftypevr"]=2
72firstword["@deftypevrx"]=2
73nameword["@item"]=1
74firstword["@item"]=1
75nameword["@itemx"]=1
76firstword["@itemx"]=1
77nameword["@vindex"]=1
78firstword["@vindex"]=1
79
80print "@c DO NOT EDIT THIS FILE!"
81print "@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
100header != 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 }