OSDN Git Service

2007-12-26 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / contrib / texi2pod.pl
index ed0d102..3931e1c 100755 (executable)
@@ -6,7 +6,7 @@
 
 # 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,
@@ -162,6 +162,8 @@ while(<$inf>) {
        } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
            $_ = "\n=back\n";
            $ic = pop @icstack;
+       } elsif ($ended eq "multitable") {
+           $_ = "\n=back\n";
        } else {
            die "unknown command \@end $ended at line $.\n";
        }
@@ -252,6 +254,8 @@ while(<$inf>) {
        and $_ = "\n=head2 $1\n";
     /^\@subsection\s+(.+)$/
        and $_ = "\n=head3 $1\n";
+    /^\@subsubsection\s+(.+)$/
+       and $_ = "\n=head4 $1\n";
 
     # Block command handlers:
     /^\@itemize(?:\s+(\@[a-z]+|\*|-))?/ and do {
@@ -260,7 +264,7 @@ while(<$inf>) {
        if (defined $1) {
            $ic = $1;
        } else {
-           $ic = '@bullet';
+           $ic = '*';
        }
        $_ = "\n=over 4\n";
        $endw = "itemize";
@@ -278,6 +282,12 @@ while(<$inf>) {
        $endw = "enumerate";
     };
 
+    /^\@multitable\s.*/ and do {
+       push @endwstack, $endw;
+       $endw = "multitable";
+       $_ = "\n=over 4\n";
+    };
+
     /^\@([fv]?table)\s+(\@[a-z]+)/ and do {
        push @endwstack, $endw;
        push @icstack, $ic;
@@ -287,6 +297,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";
     };
 
@@ -297,10 +308,24 @@ while(<$inf>) {
        $_ = "";        # need a paragraph break
     };
 
+    /^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
+       @columns = ();
+       for $column (split (/\s*\@tab\s*/, $1)) {
+           # @strong{...} is used a @headitem work-alike
+           $column =~ s/^\@strong{(.*)}$/$1/;
+           push @columns, $column;
+       }
+       $_ = "\n=item ".join (" : ", @columns)."\n";
+    };
+
     /^\@itemx?\s*(.+)?$/ and do {
        if (defined $1) {
-           # Entity escapes prevent munging by the <> processing below.
-           $_ = "\n=item $ic\&LT;$1\&GT;\n";
+            if ($ic) {
+                # 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/;
@@ -356,7 +381,7 @@ 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/\@file\{([^\}]*)\}/F<$1>/g;
     s/\@w\{([^\}]*)\}/S<$1>/g;
@@ -382,6 +407,9 @@ sub postprocess
     s/\@gol//g;
     s/\@\*\s*\n?//g;
 
+    # Anchors are thrown away
+    s/\@anchor\{(?:[^\}]*)\}//g;
+
     # @uref can take one, two, or three arguments, with different
     # semantics each time.  @url and @email are just like @uref with
     # one argument, for our purposes.
@@ -389,6 +417,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;