X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fpod2latex.PL;h=feed98e923d93db6717e125a93abb19b93c23818;hb=9072afa6a1cad5176fdec32dd3c05b3363fea520;hp=602364e2ec6bed8fc7f32d1371c6bacb92dcc669;hpb=18b0293d6bd44580fa162d92218c33f9d9672066;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/pod2latex.PL b/pod/pod2latex.PL index 602364e..feed98e 100644 --- a/pod/pod2latex.PL +++ b/pod/pod2latex.PL @@ -2,6 +2,7 @@ use Config; use File::Basename qw(&basename &dirname); +use Cwd; # List explicitly here the variables you want Configure to # generate. Metaconfig only looks for shell variables, so you @@ -12,10 +13,10 @@ use File::Basename qw(&basename &dirname); # This forces PL files to create target in same directory as PL file. # This is so that make depend always knows where to find PL derivatives. -chdir(dirname($0)); -($file = basename($0)) =~ s/\.PL$//; -$file =~ s/\.pl$// - if ($^O eq 'VMS' or $^O eq 'os2'); # "case-forgiving" +$origdir = cwd; +chdir dirname($0); +$file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; open OUT,">$file" or die "Can't create $file: $!"; @@ -25,9 +26,9 @@ print "Extracting $file (with variable substitutions)\n"; # You can use $Config{...} to use Configure variables. print OUT <<"!GROK!THIS!"; -$Config{'startperl'} - eval 'exec perl -S \$0 "\$@"' - if 0; +$Config{startperl} + eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; !GROK!THIS! # In the following, perl variables are not expanded during extraction. @@ -124,11 +125,21 @@ open(LATEX,">$pod.tex"); &do_hdr(); $cutting = 1; +$begun = ""; while () { if ($cutting) { next unless /^=/; $cutting = 0; } + if ($begun) { + if (/^=end\s+$begun/) { + $begun = ""; + } + elsif ($begun =~ /^(tex|latex)$/) { + print LATEX $_; + } + next; + } chop; length || (print LATEX "\n") && next; @@ -146,6 +157,22 @@ while () { next; } + if (/^=for\s+(\S+)\s*/s) { + if ($1 eq "tex" or $1 eq "latex") { + print LATEX $',"\n"; + } else { + # ignore unknown for + } + next; + } + elsif (/^=begin\s+(\S+)\s*/s) { + $begun = $1; + if ($1 eq "tex" or $1 eq "latex") { + print LATEX $'."\n"; + } + next; + } + # preserve '=item' line with pod quotes as they are. if (/^=item/) { ($bareitem = $_) =~ s/^=item\s*//; @@ -447,6 +474,12 @@ while () { noindex: ; } + elsif ($cmd eq 'pod') { + ; # recognise the pod directive, as no op (hs) + } + elsif ($cmd eq 'pod') { + ; # recognise the pod directive, as no op (hs) + } else { warn "Unrecognized directive: $cmd\n"; } @@ -651,7 +684,7 @@ BEGIN { "otilde" => "\\~{o}", # small o, tilde "Ouml" => '\\"{O}', # capital O, dieresis or umlaut mark "ouml" => '\\"{o}', # small o, dieresis or umlaut mark - "szlig" => '\\ss', # small sharp s, German (sz ligature) + "szlig" => '\\ss{}', # small sharp s, German (sz ligature) "THORN" => '\\L', # capital THORN, Icelandic "thorn" => '\\l',, # small thorn, Icelandic "Uacute" => "\\'{U}", # capital U, acute accent @@ -672,3 +705,4 @@ BEGIN { close OUT or die "Can't close $file: $!"; chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; +chdir $origdir;