frame, backtrace: allow targets to supply a frame unwinder
[deliverable/binutils-gdb.git] / libiberty / gather-docs
CommitLineData
39423523
DD
1#!/usr/bin/perl
2# -*- perl -*-
3
d4d868a2 4# Copyright (C) 2001, 2009, 2011
39423523
DD
5# Free Software Foundation
6#
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.
12#
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.
17#
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,
979c05d3
NC
20# write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
21# Boston, MA 02110-1301, USA.
39423523
DD
22#
23# Originally written by DJ Delorie <dj@redhat.com>
24
25
26
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.
30
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).
36
37#
38
39
40
41if ($ARGV[0] eq "-v") {
42 $verbose = 1;
43 shift;
44}
45
46$srcdir = shift;
47$outfile = shift;
48
49if ($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;
52}
53
54$errors = 0;
55
56for $in (@ARGV) {
57
58 if (!open(IN, "$srcdir/$in")) {
59 print STDERR "Cannot open $srcdir/$in for reading: $!\n";
60 $errors ++;
61
62 } else {
63 $first = 1;
64 $pertinent = 0;
65 $man_mode = 0;
66 $line = 0;
67
68 while (<IN>) {
69 $line ++;
70 $pertinent = 1 if /^\@def[a-z]*[a-wyz] /;
71 $pertinent = 0 if /^\*\//;
72 next unless $pertinent;
73
74 if (/^\@def[a-z]*[a-wyz] /) {
75
d4d868a2
RW
76 ($name) = m/[^\(]* ([^\( \t\r\n\@]+) *(\(|\@?$)/;
77 $name =~ s/[ ]*\@?$//;
39423523
DD
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} .= $_;
89
90 } else {
91 $node_lines{$key} .= $_;
92 }
93
94 $pertinent = 0 if /^\@end def/;
95 }
96 close (IN);
97 }
98}
99
100print "\n" if $verbose;
101exit $errors if $errors;
102
103if (!open (OUT, "> $outfile")) {
104 print STDERR "Cannot open $outfile for writing: $!\n";
105 $errors ++;
106 next;
107}
108print "Writing $outfile\n" if $verbose;
109
110print OUT "\@c Automatically generated from *.c and others (the comments before\n";
111print OUT "\@c each entry tell you which file and where in that file). DO NOT EDIT!\n";
112print OUT "\@c Edit the *.c files, configure with --enable-maintainer-mode,\n";
23d03362 113print OUT "\@c run 'make stamp-functions' and gather-docs will build a new copy.\n\n";
39423523
DD
114
115for $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";
119}
120
121if (! print OUT "\n") {
122 print STDERR "Disk full writing $srcdir/$cat.texi\n";
123 $errors ++;
124}
125
126close (OUT);
127
128exit $errors;
This page took 0.688441 seconds and 4 git commands to generate.