3
# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
5
# This file is part of GNU CC.
7
# GNU CC is free software; you can redistribute it and/or modify
3
# Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
5
# This file is part of GCC.
7
# GCC is free software; you can redistribute it and/or modify
8
8
# it under the terms of the GNU General Public License as published by
9
9
# the Free Software Foundation; either version 2, or (at your option)
10
10
# any later version.
12
# GNU CC is distributed in the hope that it will be useful,
12
# GCC is distributed in the hope that it will be useful,
13
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
15
# GNU General Public License for more details.
17
17
# You should have received a copy of the GNU General Public License
18
# along with GNU CC; see the file COPYING. If not, write to
19
# the Free Software Foundation, 59 Temple Place - Suite 330,
20
# Boston MA 02111-1307, USA.
18
# along with GCC; see the file COPYING. If not, write to
19
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20
# Boston MA 02110-1301, USA.
22
22
# This does trivial (and I mean _trivial_) conversion of Texinfo
23
23
# markup to Perl POD format. It's intended to be used to extract
138
146
# Ignore @end foo, where foo is not an operation which may
139
147
# cause us to skip, if we are presently skipping.
141
next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
149
next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/;
143
151
die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
144
152
die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
227
237
/^\@include\s+(.+)$/ and do {
228
238
push @instack, $inf;
240
$file = postprocess($1);
231
# Try cwd and $ibase.
233
or open($inf, "<" . $ibase . "/" . $1)
234
or die "cannot open $1 or $ibase/$1: $!\n";
242
# Try cwd and $ibase, then explicit -I paths.
244
foreach $path ("", $ibase, @ipath) {
246
$mypath = $path . "/" . $mypath if ($path ne "");
247
open($inf, "<" . $mypath) and ($done = 1, last);
249
die "cannot find $file" if !$done;
239
254
and $_ = "\n=head2 $1\n";
240
255
/^\@subsection\s+(.+)$/
241
256
and $_ = "\n=head3 $1\n";
257
/^\@subsubsection\s+(.+)$/
258
and $_ = "\n=head4 $1\n";
243
260
# Block command handlers:
244
/^\@itemize\s+(\@[a-z]+|\*|-)/ and do {
261
/^\@itemize(?:\s+(\@[a-z]+|\*|-))?/ and do {
245
262
push @endwstack, $endw;
246
263
push @icstack, $ic;
248
269
$_ = "\n=over 4\n";
249
270
$endw = "itemize";
280
307
$_ = ""; # need a paragraph break
310
/^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
312
for $column (split (/\s*\@tab\s*/, $1)) {
313
# @strong{...} is used a @headitem work-alike
314
$column =~ s/^\@strong{(.*)}$/$1/;
315
push @columns, $column;
317
$_ = "\n=item ".join (" : ", @columns)."\n";
283
320
/^\@itemx?\s*(.+)?$/ and do {
284
321
if (defined $1) {
285
322
# Entity escapes prevent munging by the <> processing below.
287
323
$_ = "\n=item $ic\<$1\>\n";
289
325
$_ = "\n=item $ic\n";
346
382
s/\@w\{([^\}]*)\}/S<$1>/g;
347
383
s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
385
# keep references of the form @ref{...}, print them bold
386
s/\@(?:ref)\{([^\}]*)\}/B<$1>/g;
388
# Change double single quotes to double quotes.
349
392
# Cross references are thrown away, as are @noindent and @refill.
350
393
# (@noindent is impossible in .pod, and @refill is unnecessary.)
351
394
# @* is also impossible in .pod; we discard it and any newline that
405
# Anchors are thrown away
406
s/\@anchor\{(?:[^\}]*)\}//g;
362
408
# @uref can take one, two, or three arguments, with different
363
409
# semantics each time. @url and @email are just like @uref with
364
410
# one argument, for our purposes.
366
412
s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
367
413
s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
369
# Turn B<blah I<blah> blah> into B<blah> I<blah> B<blah> to
370
# match Texinfo semantics of @emph inside @samp. Also handle @r
415
# Un-escape <> at this point.
374
1 while s/B<((?:[^<>]|I<[^<>]*>)*)R<([^>]*)>/B<$1>${2}B</g;
375
1 while (s/B<([^<>]*)I<([^>]+)>/B<$1>I<$2>B</g);
376
1 while (s/I<([^<>]*)B<([^>]+)>/I<$1>B<$2>I</g);
419
# Now un-nest all B<>, I<>, R<>. Theoretically we could have
420
# indefinitely deep nesting; in practice, one level suffices.
421
1 while s/([BIR])<([^<>]*)([BIR])<([^<>]*)>/$1<$2>$3<$4>$1</g;
423
# Replace R<...> with bare ...; eliminate empty markup, B<>;
424
# shift white space at the ends of [BI]<...> expressions outside
378
428
s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g;
379
429
s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g;