1 #!/usr/bin/perl -w 2 3 # (C) 2013 Free Software Foundation 4 # Contributed by Tobias Burnus 5 # 6 # This script is Free Software, and it can be copied, distributed and 7 # modified as defined in the GNU General Public License. A copy of 8 # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html 9 10 use strict; 11 use File::Basename; 12 13 14 if ($#ARGV != 0 or $ARGV[0] eq "") { 15 my $name = basename($0); 16 17 print "\nUSAGE: `$name` memory.texi\n\n"; 18 print "Reads GLIBC's manual/memory.texi and extracts the obstacks section\n" 19 ."Redirect the output to update GCC's libiberty/obstacks.texi\n\n"; 20 exit 1; 21 } 22 23 open (IN, "<$ARGV[0]") || die "Cannot open '$ARGV[0]': $!"; 24 my $data = join ("", <IN>); 25 close (IN); 26 27 $data =~ s/.*\@node Obstacks\n/\@node Obstacks\n/s; 28 $data =~ s/\n\@node [^\n]+\n\@subsection.*/\n/s; 29 30 # Add refs to GLIBC 31 $data =~ s/(\@p?xref{[^}]*)}/$1, , , libc, The GNU C Library Reference Manual}/gs; 32 33 34 # And undo the refs which are in this file 35 my @nodes = grep /^\@node /, (split /\n/, $data); 36 37 foreach my $node (@nodes) { 38 $node =~ s/\@node //; 39 $node =~ s/,.*//; 40 $node =~ s/ / *\n?/g; 41 chomp ($node); 42 43 $data =~ s/(\@p?xref{$node), , , libc, The GNU C Library Reference Manual}/$1}/gsi; 44 } 45 46 print $data; 47