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
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
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
# GCC is distributed in the hope that it will be useful,
12
# GNU CC 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 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.
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.
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
146
138
# Ignore @end foo, where foo is not an operation which may
147
139
# cause us to skip, if we are presently skipping.
149
next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/;
141
next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
151
143
die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
152
144
die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
237
227
/^\@include\s+(.+)$/ and do {
238
228
push @instack, $inf;
240
$file = postprocess($1);
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;
231
# Try cwd and $ibase.
233
or open($inf, "<" . $ibase . "/" . $1)
234
or die "cannot open $1 or $ibase/$1: $!\n";
254
239
and $_ = "\n=head2 $1\n";
255
240
/^\@subsection\s+(.+)$/
256
241
and $_ = "\n=head3 $1\n";
257
/^\@subsubsection\s+(.+)$/
258
and $_ = "\n=head4 $1\n";
260
243
# Block command handlers:
261
/^\@itemize(?:\s+(\@[a-z]+|\*|-))?/ and do {
244
/^\@itemize\s+(\@[a-z]+|\*|-)/ and do {
262
245
push @endwstack, $endw;
263
246
push @icstack, $ic;
269
248
$_ = "\n=over 4\n";
270
249
$endw = "itemize";
307
280
$_ = ""; # 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";
320
283
/^\@itemx?\s*(.+)?$/ and do {
321
284
if (defined $1) {
322
285
# Entity escapes prevent munging by the <> processing below.
323
287
$_ = "\n=item $ic\<$1\>\n";
325
289
$_ = "\n=item $ic\n";
382
346
s/\@w\{([^\}]*)\}/S<$1>/g;
383
347
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.
392
349
# Cross references are thrown away, as are @noindent and @refill.
393
350
# (@noindent is impossible in .pod, and @refill is unnecessary.)
394
351
# @* is also impossible in .pod; we discard it and any newline that
405
# Anchors are thrown away
406
s/\@anchor\{(?:[^\}]*)\}//g;
408
362
# @uref can take one, two, or three arguments, with different
409
363
# semantics each time. @url and @email are just like @uref with
410
364
# one argument, for our purposes.
412
366
s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
413
367
s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
415
# Un-escape <> at this point.
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
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
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);
428
378
s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g;
429
379
s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g;