OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / contrib / texi2pod.pl
index e7b983b..5a4bbac 100755 (executable)
@@ -1,12 +1,12 @@
 #! /usr/bin/perl -w
 
-#   Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+#   Copyright (C) 1999, 2000, 2001, 2003, 2010 Free Software Foundation, Inc.
 
 # This file is part of GCC.
 
 # GCC is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
+# the Free Software Foundation; either version 3, or (at your option)
 # any later version.
 
 # GCC is distributed in the hope that it will be useful,
@@ -213,14 +213,18 @@ while(<$inf>) {
 
     # Now the ones that have to be replaced by special escapes
     # (which will be turned back into text by unmunge())
+    # Replace @@ before @{ and @} in order to parse @samp{@@} correctly.
     s/&/&amp;/g;
+    s/\@\@/&at;/g;
     s/\@\{/&lbrace;/g;
     s/\@\}/&rbrace;/g;
-    s/\@\@/&at;/g;
+    s/\@`\{(.)\}/&$1grave;/g;
 
-    # Inside a verbatim block, handle @var specially.
+    # Inside a verbatim block, handle @var, @samp and @url specially.
     if ($shift ne "") {
        s/\@var\{([^\}]*)\}/<$1>/g;
+       s/\@samp\{([^\}]*)\}/"$1"/g;
+       s/\@url\{([^\}]*)\}/<$1>/g;
     }
 
     # POD doesn't interpret E<> inside a verbatim block.
@@ -250,7 +254,7 @@ while(<$inf>) {
        next;
     };
 
-    /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/
+    /^\@(?:section|unnumbered|unnumberedsec|center|heading)\s+(.+)$/
        and $_ = "\n=head2 $1\n";
     /^\@subsection\s+(.+)$/
        and $_ = "\n=head3 $1\n";
@@ -264,7 +268,7 @@ while(<$inf>) {
        if (defined $1) {
            $ic = $1;
        } else {
-           $ic = '@bullet';
+           $ic = '*';
        }
        $_ = "\n=over 4\n";
        $endw = "itemize";
@@ -297,6 +301,7 @@ while(<$inf>) {
        $ic =~ s/\@(?:code|kbd)/C/;
        $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
        $ic =~ s/\@(?:file)/F/;
+       $ic =~ s/\@(?:asis)//;
        $_ = "\n=over 4\n";
     };
 
@@ -319,8 +324,18 @@ while(<$inf>) {
 
     /^\@itemx?\s*(.+)?$/ and do {
        if (defined $1) {
-           # Entity escapes prevent munging by the <> processing below.
-           $_ = "\n=item $ic\&LT;$1\&GT;\n";
+            if ($ic) {
+               if ($endw eq "enumerate") {
+                   $_ = "\n=item $ic $1\n";
+                   $ic =~ s/(\d+)/$1 + 1/eg;
+               } else {
+                   # Entity escapes prevent munging by the <>
+                   # processing below.
+                   $_ = "\n=item $ic\&LT;$1\&GT;\n";
+               }
+            } else {
+                $_ = "\n=item $1\n";
+            }
        } else {
            $_ = "\n=item $ic\n";
            $ic =~ y/A-Ya-y/B-Zb-z/;
@@ -376,11 +391,13 @@ sub postprocess
     s/\@r\{([^\}]*)\}/R<$1>/g;
     s/\@(?:dfn|var|emph|cite|i)\{([^\}]*)\}/I<$1>/g;
     s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g;
-    s/\@(?:gccoptlist|samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g;
+    s/\@(?:samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g;
     s/\@sc\{([^\}]*)\}/\U$1/g;
+    s/\@acronym\{([^\}]*)\}/\U$1/g;
     s/\@file\{([^\}]*)\}/F<$1>/g;
     s/\@w\{([^\}]*)\}/S<$1>/g;
     s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
+    s/\@\///g;
 
     # keep references of the form @ref{...}, print them bold
     s/\@(?:ref)\{([^\}]*)\}/B<$1>/g;
@@ -412,6 +429,10 @@ sub postprocess
     s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
     s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
 
+    # Handle gccoptlist here, so it can contain the above formatting
+    # commands.
+    s/\@gccoptlist\{([^\}]*)\}/B<$1>/g;
+
     # Un-escape <> at this point.
     s/&LT;/</g;
     s/&GT;/>/g;
@@ -445,6 +466,7 @@ sub unmunge
     # Replace escaped symbols with their equivalents.
     local $_ = $_[0];
 
+    s/&(.)grave;/E<$1grave>/g;
     s/&lt;/E<lt>/g;
     s/&gt;/E<gt>/g;
     s/&lbrace;/\{/g;