No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / libiberty / gather-docs
blobbe4dbbfc1e2a3aab7f37a53742c06fc3bcec003c
1 #!/usr/bin/perl
2 # -*- perl -*-
4 # Copyright (C) 2001
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., 51 Franklin Street - Fifth Floor,
21 # Boston, MA 02110-1301, 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
29 # alphabetical order.
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") {
42 $verbose = 1;
43 shift;
46 $srcdir = shift;
47 $outfile = shift;
49 if ($outfile !~ /\S/ || ! -f "$srcdir/Makefile.in" ) {
50 print STDERR "Usage: gather-docs [-v] srcdir outfile.txi [files with snippets in them ...]\n";
51 exit 1;
54 $errors = 0;
56 for $in (@ARGV) {
58 if (!open(IN, "$srcdir/$in")) {
59 print STDERR "Cannot open $srcdir/$in for reading: $!\n";
60 $errors ++;
62 } else {
63 $first = 1;
64 $pertinent = 0;
65 $man_mode = 0;
66 $line = 0;
68 while (<IN>) {
69 $line ++;
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]+) *\(/;
77 $name =~ s/[ ]*$//;
78 $key = $name;
79 $key =~ tr/A-Z/a-z/;
80 $key =~ s/[^a-z0-9]+/ /g;
81 $name{$key} = $node;
82 $lines{$key} = '';
83 $src_file{$key} = $in;
84 $src_line{$key} = $line;
85 print "\nReading $in :" if $verbose && $first;
86 $first = 0;
87 print " $name" if $verbose;
88 $node_lines{$key} .= $_;
90 } else {
91 $node_lines{$key} .= $_;
94 $pertinent = 0 if /^\@end def/;
96 close (IN);
100 print "\n" if $verbose;
101 exit $errors if $errors;
103 if (!open (OUT, "> $outfile")) {
104 print STDERR "Cannot open $outfile for writing: $!\n";
105 $errors ++;
106 next;
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};
118 print OUT "\n";
121 if (! print OUT "\n") {
122 print STDERR "Disk full writing $srcdir/$cat.texi\n";
123 $errors ++;
126 close (OUT);
128 exit $errors;