make-obstacks-texi.pl 1.2 KB

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