5 # Free Software Foundation
7 # This file is part of the libiberty library.
8 # Libiberty is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # Libiberty is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
18 # You should have received a copy of the GNU Library General Public
19 # License along with libiberty; see the file COPYING.LIB. If not,
20 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
23 # Originally written by DJ Delorie <dj@redhat.com>
27 # This program looks for texinfo snippets in source files and other
28 # files, and builds per-category files with entries sorted in
31 # The syntax it looks for is lines starting with '@def' in *.c and
32 # other files (see TEXIFILES in Makefile.in). Entries are terminated
33 # at the next @def* (which begins a new entry) or, for C files, a line
34 # that begins with '*/' without leading spaces (this assumes that the
35 # texinfo snippet is within a C-style /* */ comment).
41 if ($ARGV[0] eq "-v") {
49 if ($outfile !~ /\S/ || ! -f
"$srcdir/Makefile.in" ) {
50 print STDERR
"Usage: gather-docs [-v] srcdir outfile.txi [files with snippets in them ...]\n";
58 if (!open(IN
, "$srcdir/$in")) {
59 print STDERR
"Cannot open $srcdir/$in for reading: $!\n";
70 $pertinent = 1 if /^\@def[a-z]*[a-wyz] /;
71 $pertinent = 0 if /^\*\//;
72 next unless $pertinent;
74 if (/^\@def[a-z]*[a-wyz] /) {
76 ($name) = m/[^\(]* ([^\( \t\r\n]+) *\(/;
80 $key =~ s/[^a-z0-9]+/ /g;
83 $src_file{$key} = $in;
84 $src_line{$key} = $line;
85 print "\nReading $in :" if $verbose && $first;
87 print " $name" if $verbose;
88 $node_lines{$key} .= $_;
91 $node_lines{$key} .= $_;
94 $pertinent = 0 if /^\@end def/;
100 print "\n" if $verbose;
101 exit $errors if $errors;
103 if (!open (OUT
, "> $outfile")) {
104 print STDERR
"Cannot open $outfile for writing: $!\n";
108 print "Writing $outfile\n" if $verbose;
110 print OUT
"\@c Automatically generated from *.c and others (the comments before\n";
111 print OUT
"\@c each entry tell you which file and where in that file). DO NOT EDIT!\n";
112 print OUT
"\@c Edit the *.c files, configure with --enable-maintainer-mode,\n";
113 print OUT
"\@c and let gather-docs build you a new copy.\n\n";
115 for $key (sort keys %name) {
116 print OUT
"\@c $src_file{$key}:$src_line{$key}\n";
117 print OUT
$node_lines{$key};
121 if (! print OUT
"\n") {
122 print STDERR
"Disk full writing $srcdir/$cat.texi\n";
This page took 0.033184 seconds and 4 git commands to generate.