~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to texi2pod.pl

  • Committer: blueswir1
  • Date: 2007-09-25 17:28:42 UTC
  • Revision ID: git-v1:c2efc95d45fd4c76d4650a34a2a2676b87a93ac4
 Fix monitor expressions


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3238 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/perl -w
2
2
 
3
 
#   Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
4
 
 
5
 
# This file is part of GCC.
6
 
 
7
 
# GCC is free software; you can redistribute it and/or modify
 
3
#   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
 
4
 
 
5
# This file is part of GNU CC.
 
6
 
 
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.
11
11
 
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.
16
16
 
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.
21
21
 
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
36
36
$fnno = 1;
37
37
$inf = "";
38
38
$ibase = "";
39
 
@ipath = ();
40
39
 
41
40
while ($_ = shift) {
42
41
    if (/^-D(.*)$/) {
52
51
        die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
53
52
            unless $flag =~ /^[a-zA-Z0-9_-]+$/;
54
53
        $defs{$flag} = $value;
55
 
    } elsif (/^-I(.*)$/) {
56
 
        if ($1 ne "") {
57
 
            $flag = $1;
58
 
        } else {
59
 
            $flag = shift;
60
 
        }
61
 
        push (@ipath, $flag);
62
54
    } elsif (/^-/) {
63
55
        usage();
64
56
    } else {
146
138
        # Ignore @end foo, where foo is not an operation which may
147
139
        # cause us to skip, if we are presently skipping.
148
140
        my $ended = $1;
149
 
        next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/;
 
141
        next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
150
142
 
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;
162
154
        } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
163
155
            $_ = "\n=back\n";
164
156
            $ic = pop @icstack;
165
 
        } elsif ($ended eq "multitable") {
166
 
            $_ = "\n=back\n";
167
157
        } else {
168
158
            die "unknown command \@end $ended at line $.\n";
169
159
        }
188
178
        next;
189
179
    };
190
180
 
191
 
    /^\@(ignore|menu|iftex|copying)\b/ and do {
 
181
    /^\@(ignore|menu|iftex)\b/ and do {
192
182
        push @endwstack, $endw;
193
183
        push @skstack, $skipping;
194
184
        $endw = $1;
237
227
    /^\@include\s+(.+)$/ and do {
238
228
        push @instack, $inf;
239
229
        $inf = gensym();
240
 
        $file = postprocess($1);
241
230
 
242
 
        # Try cwd and $ibase, then explicit -I paths.
243
 
        $done = 0;
244
 
        foreach $path ("", $ibase, @ipath) {
245
 
            $mypath = $file;
246
 
            $mypath = $path . "/" . $mypath if ($path ne "");
247
 
            open($inf, "<" . $mypath) and ($done = 1, last);
248
 
        }
249
 
        die "cannot find $file" if !$done;
 
231
        # Try cwd and $ibase.
 
232
        open($inf, "<" . $1)
 
233
            or open($inf, "<" . $ibase . "/" . $1)
 
234
                or die "cannot open $1 or $ibase/$1: $!\n";
250
235
        next;
251
236
    };
252
237
 
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";
259
242
 
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;
264
 
        if (defined $1) {
265
 
            $ic = $1;
266
 
        } else {
267
 
            $ic = '*';
268
 
        }
 
247
        $ic = $1;
269
248
        $_ = "\n=over 4\n";
270
249
        $endw = "itemize";
271
250
    };
282
261
        $endw = "enumerate";
283
262
    };
284
263
 
285
 
    /^\@multitable\s.*/ and do {
286
 
        push @endwstack, $endw;
287
 
        $endw = "multitable";
288
 
        $_ = "\n=over 4\n";
289
 
    };
290
 
 
291
264
    /^\@([fv]?table)\s+(\@[a-z]+)/ and do {
292
265
        push @endwstack, $endw;
293
266
        push @icstack, $ic;
307
280
        $_ = "";        # need a paragraph break
308
281
    };
309
282
 
310
 
    /^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
311
 
        @columns = ();
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;
316
 
        }
317
 
        $_ = "\n=item ".join (" : ", @columns)."\n";
318
 
    };
319
 
 
320
283
    /^\@itemx?\s*(.+)?$/ and do {
321
284
        if (defined $1) {
322
285
            # Entity escapes prevent munging by the <> processing below.
 
286
#            print "$ic\n";
323
287
            $_ = "\n=item $ic\&LT;$1\&GT;\n";
324
288
        } else {
325
289
            $_ = "\n=item $ic\n";
382
346
    s/\@w\{([^\}]*)\}/S<$1>/g;
383
347
    s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
384
348
 
385
 
    # keep references of the form @ref{...}, print them bold
386
 
    s/\@(?:ref)\{([^\}]*)\}/B<$1>/g;
387
 
 
388
 
    # Change double single quotes to double quotes.
389
 
    s/''/"/g;
390
 
    s/``/"/g;
391
 
 
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
402
359
    s/\@gol//g;
403
360
    s/\@\*\s*\n?//g;
404
361
 
405
 
    # Anchors are thrown away
406
 
    s/\@anchor\{(?:[^\}]*)\}//g;
407
 
 
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;
414
368
 
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
 
371
    # inside bold.
416
372
    s/&LT;/</g;
417
373
    s/&GT;/>/g;
418
 
 
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;
422
 
 
423
 
    # Replace R<...> with bare ...; eliminate empty markup, B<>;
424
 
    # shift white space at the ends of [BI]<...> expressions outside
425
 
    # the expression.
426
 
    s/R<([^<>]*)>/$1/g;
 
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);
427
377
    s/[BI]<>//g;
428
378
    s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g;
429
379
    s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g;