~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to doc/texi2pod.pl

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-10-19 00:00:09 UTC
  • mfrom: (2.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20111019000009-8p33w3wz4b1rdri0
Tags: 1.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
  - Depend on libssl-dev 0.9.8k-7ubuntu4 (LP: #503339)
* Dropped changes, superseded in Debian:
  - Keep build dependencies in main:
    + debian/control: remove info2man build-dep
    + debian/patches/series: disable wget-infopod_generated_manpage
  - Mark wget Multi-Arch: foreign, so packages that aren't of the same arch
    can depend on it.
* Pass --with-ssl=openssl; we don't want to use gnutls, there's no udeb for
  it.
* Add a second build pass for the udeb, so we can build without libidn.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env perl
 
1
#! /usr/bin/perl -w
2
2
 
3
 
#   Copyright (C) 1999, 2000, 2001, 2003, 2007, 2009 Free Software
4
 
#   Foundation, Inc.
 
3
#   Copyright (C) 1999, 2000, 2001, 2003, 2010 Free Software Foundation, Inc.
5
4
 
6
5
# This file is part of GCC.
7
6
 
16
15
# GNU General Public License for more details.
17
16
 
18
17
# You should have received a copy of the GNU General Public License
19
 
# along with GCC.  If not, see <http://www.gnu.org/licenses/>.
 
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.
20
21
 
21
22
# This does trivial (and I mean _trivial_) conversion of Texinfo
22
23
# markup to Perl POD format.  It's intended to be used to extract
23
24
# something suitable for a manpage from a Texinfo document.
24
25
 
25
 
use warnings;
26
 
 
27
26
$output = 0;
28
27
$skipping = 0;
29
28
%sects = ();
37
36
$fnno = 1;
38
37
$inf = "";
39
38
$ibase = "";
 
39
@ipath = ();
40
40
 
41
41
while ($_ = shift) {
42
42
    if (/^-D(.*)$/) {
52
52
        die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
53
53
            unless $flag =~ /^[a-zA-Z0-9_-]+$/;
54
54
        $defs{$flag} = $value;
 
55
    } elsif (/^-I(.*)$/) {
 
56
        if ($1 ne "") {
 
57
            $flag = $1;
 
58
        } else {
 
59
            $flag = shift;
 
60
        }
 
61
        push (@ipath, $flag);
55
62
    } elsif (/^-/) {
56
63
        usage();
57
64
    } else {
155
162
        } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
156
163
            $_ = "\n=back\n";
157
164
            $ic = pop @icstack;
 
165
        } elsif ($ended eq "multitable") {
 
166
            $_ = "\n=back\n";
158
167
        } else {
159
168
            die "unknown command \@end $ended at line $.\n";
160
169
        }
204
213
 
205
214
    # Now the ones that have to be replaced by special escapes
206
215
    # (which will be turned back into text by unmunge())
 
216
    # Replace @@ before @{ and @} in order to parse @samp{@@} correctly.
207
217
    s/&/&amp;/g;
208
218
    s/\@\@/&at;/g;
209
219
    s/\@\{/&lbrace;/g;
210
220
    s/\@\}/&rbrace;/g;
 
221
    s/\@`\{(.)\}/&$1grave;/g;
211
222
 
212
 
    # Inside a verbatim block, handle @var specially.
 
223
    # Inside a verbatim block, handle @var, @samp and @url specially.
213
224
    if ($shift ne "") {
214
225
        s/\@var\{([^\}]*)\}/<$1>/g;
 
226
        s/\@samp\{([^\}]*)\}/"$1"/g;
 
227
        s/\@url\{([^\}]*)\}/<$1>/g;
215
228
    }
216
229
 
217
230
    # POD doesn't interpret E<> inside a verbatim block.
230
243
        $inf = gensym();
231
244
        $file = postprocess($1);
232
245
 
233
 
        # Try cwd and $ibase.
234
 
        open($inf, "<" . $file)
235
 
            or open($inf, "<" . $ibase . "/" . $file)
236
 
                or die "cannot open $file or $ibase/$file: $!\n";
 
246
        # Try cwd and $ibase, then explicit -I paths.
 
247
        $done = 0;
 
248
        foreach $path ("", $ibase, @ipath) {
 
249
            $mypath = $file;
 
250
            $mypath = $path . "/" . $mypath if ($path ne "");
 
251
            open($inf, "<" . $mypath) and ($done = 1, last);
 
252
        }
 
253
        die "cannot find $file" if !$done;
237
254
        next;
238
255
    };
239
256
 
240
 
    /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/
 
257
    /^\@(?:section|unnumbered|unnumberedsec|center|heading)\s+(.+)$/
241
258
        and $_ = "\n=head2 $1\n";
242
259
    /^\@subsection\s+(.+)$/
243
260
        and $_ = "\n=head3 $1\n";
 
261
    /^\@subsubsection\s+(.+)$/
 
262
        and $_ = "\n=head4 $1\n";
244
263
 
245
264
    # Block command handlers:
246
265
    /^\@itemize(?:\s+(\@[a-z]+|\*|-))?/ and do {
249
268
        if (defined $1) {
250
269
            $ic = $1;
251
270
        } else {
252
 
            $ic = '@bullet';
 
271
            $ic = '*';
253
272
        }
254
273
        $_ = "\n=over 4\n";
255
274
        $endw = "itemize";
267
286
        $endw = "enumerate";
268
287
    };
269
288
 
 
289
    /^\@multitable\s.*/ and do {
 
290
        push @endwstack, $endw;
 
291
        $endw = "multitable";
 
292
        $_ = "\n=over 4\n";
 
293
    };
 
294
 
270
295
    /^\@([fv]?table)\s+(\@[a-z]+)/ and do {
271
296
        push @endwstack, $endw;
272
297
        push @icstack, $ic;
276
301
        $ic =~ s/\@(?:code|kbd)/C/;
277
302
        $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
278
303
        $ic =~ s/\@(?:file)/F/;
 
304
        $ic =~ s/\@(?:asis)//;
279
305
        $_ = "\n=over 4\n";
280
306
    };
281
307
 
286
312
        $_ = "";        # need a paragraph break
287
313
    };
288
314
 
 
315
    /^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
 
316
        @columns = ();
 
317
        for $column (split (/\s*\@tab\s*/, $1)) {
 
318
            # @strong{...} is used a @headitem work-alike
 
319
            $column =~ s/^\@strong{(.*)}$/$1/;
 
320
            push @columns, $column;
 
321
        }
 
322
        $_ = "\n=item ".join (" : ", @columns)."\n";
 
323
    };
 
324
 
289
325
    /^\@itemx?\s*(.+)?$/ and do {
290
326
        if (defined $1) {
291
 
            my $thing = $1;
292
 
            if ($ic =~ /\@asis/) {
293
 
                $_ = "\n=item $thing\n";
 
327
            if ($ic) {
 
328
                if ($endw eq "enumerate") {
 
329
                    $_ = "\n=item $ic $1\n";
 
330
                    $ic =~ s/(\d+)/$1 + 1/eg;
 
331
                } else {
 
332
                    # Entity escapes prevent munging by the <>
 
333
                    # processing below.
 
334
                    $_ = "\n=item $ic\&LT;$1\&GT;\n";
 
335
                }
294
336
            } else {
295
 
                # Entity escapes prevent munging by the <> processing below.
296
 
                $_ = "\n=item $ic\&LT;$thing\&GT;\n";
 
337
                $_ = "\n=item $1\n";
297
338
            }
298
339
        } else {
299
340
            $_ = "\n=item $ic\n";
314
355
$sects{NAME} = "$fn \- $tl\n";
315
356
$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES};
316
357
 
317
 
for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT EXITSTATUS
318
 
           FILES BUGS NOTES FOOTNOTES SEEALSO AUTHOR COPYRIGHT)) {
 
358
for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT FILES
 
359
              BUGS NOTES FOOTNOTES SEEALSO AUTHOR COPYRIGHT)) {
319
360
    if(exists $sects{$sect}) {
320
361
        $head = $sect;
321
362
        $head =~ s/SEEALSO/SEE ALSO/;
322
 
        $head =~ s/EXITSTATUS/EXIT STATUS/;
323
363
        print "=head1 $head\n\n";
324
364
        print scalar unmunge ($sects{$sect});
325
365
        print "\n";
351
391
    s/\@r\{([^\}]*)\}/R<$1>/g;
352
392
    s/\@(?:dfn|var|emph|cite|i)\{([^\}]*)\}/I<$1>/g;
353
393
    s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g;
354
 
    s/\@(?:gccoptlist|samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g;
 
394
    s/\@(?:samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g;
355
395
    s/\@sc\{([^\}]*)\}/\U$1/g;
 
396
    s/\@acronym\{([^\}]*)\}/\U$1/g;
356
397
    s/\@file\{([^\}]*)\}/F<$1>/g;
357
398
    s/\@w\{([^\}]*)\}/S<$1>/g;
358
399
    s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
 
400
    s/\@\///g;
359
401
 
360
402
    # keep references of the form @ref{...}, print them bold
361
403
    s/\@(?:ref)\{([^\}]*)\}/B<$1>/g;
377
419
    s/\@gol//g;
378
420
    s/\@\*\s*\n?//g;
379
421
 
 
422
    # Anchors are thrown away
 
423
    s/\@anchor\{(?:[^\}]*)\}//g;
 
424
 
380
425
    # @uref can take one, two, or three arguments, with different
381
426
    # semantics each time.  @url and @email are just like @uref with
382
427
    # one argument, for our purposes.
384
429
    s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
385
430
    s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
386
431
 
 
432
    # Handle gccoptlist here, so it can contain the above formatting
 
433
    # commands.
 
434
    s/\@gccoptlist\{([^\}]*)\}/B<$1>/g;
 
435
 
387
436
    # Un-escape <> at this point.
388
437
    s/&LT;/</g;
389
438
    s/&GT;/>/g;
417
466
    # Replace escaped symbols with their equivalents.
418
467
    local $_ = $_[0];
419
468
 
 
469
    s/&(.)grave;/E<$1grave>/g;
420
470
    s/&lt;/E<lt>/g;
421
471
    s/&gt;/E<gt>/g;
422
472
    s/&lbrace;/\{/g;