~ubuntu-branches/ubuntu/hoary/docbook-dsssl/hoary

« back to all changes in this revision

Viewing changes to bin/collateindex.pl

  • Committer: Bazaar Package Importer
  • Author(s): Peter Eisentraut
  • Date: 2004-11-06 12:28:09 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20041106122809-jm39fcli9ndotthy
Tags: 1.79-1
* New upstream release
* Removed the debconf and site configuration stuff; use a customization
  layer.
* Removed freebsd.dsl; it's useless without an up-to-date FreeBSD
  source tree.
* Removed basic.dsl; there is better information in the documentation.
* Removed obsolete symlink in /var/www
* Added watch file
* Simplified debian/rules
* Install frames subdirectory normally, not as documentation
* Install only one combined changelog, not one per directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl -- # -*- Perl -*-
2
2
#
3
 
# $Id: collateindex.pl,v 1.8 2003/01/19 21:36:48 adicarlo Exp $
 
3
# $Id: collateindex.pl,v 1.10 2004/10/24 17:05:41 petere78 Exp $
4
4
 
5
5
=head1 NAME
6
6
 
8
8
 
9
9
=head1 SYNOPSIS
10
10
 
11
 
B<collateindex.pl> [B<-p>] [B<-g>] [B<-s> I<name>] [B<-t> I<name>] [B<-P> F<file>]
12
 
                [B<-i> I<id>] [B<-o> F<file>] [B<-S> I<scope>] [B<-I> I<scope>]
13
 
                [B<-x>] [B<-f>] [B<-N>] [B<-q>] [F<file>
 
11
B<collateindex.pl> [B<-f>] [B<-g>] [B<-i> I<id>] [B<-I> I<scope>] [B<-N>]
 
12
                [B<-o> F<file>] [B<-p>] [B<-P> F<file>] [B<-q>] [B<-s> I<name>]
 
13
                [B<-S> I<scope>] [B<-t> I<name>] [B<-x>] F<file>
14
14
 
15
15
=head1 DESCRIPTION
16
16
 
17
 
B<collateindex.pl> is a Perl script that creates index data for
18
 
DocBook XML or SGML files.
 
17
B<collateindex.pl> creates index data for DocBook XML or SGML files.
19
18
 
20
19
=cut
21
20
 
 
21
use File::Basename;
22
22
use Getopt::Std;
23
23
 
24
 
$usage = "usage: $0 [options] file
25
 
Do 'perldoc $0' for documentation.\n";
26
 
 
27
 
( $version = '$Revision: 1.8 $' ) =~ s/^\$[R]evision:\s*([^ ]*)\s*\$$/$1/;
 
24
$me = basename($0);
 
25
 
 
26
$usage = "Usage: $0 [options] file
 
27
Try \"perldoc $me\" for documentation.\n";
 
28
 
 
29
( $version = '$Revision: 1.10 $' ) =~ s/^\$[R]evision:\s*([^ ]*)\s*\$$/$1/;
28
30
 
29
31
=head1 OPTIONS
30
32
 
31
33
=over 5
32
34
 
33
 
=item B<-p>
 
35
=item B<-f>
34
36
 
35
 
Link to points in the document.  The default is to link to the closest
36
 
containing section.
 
37
Force the output file to be written, even if it appears to have been
 
38
edited by hand.
37
39
 
38
40
=item B<-g>
39
41
 
40
42
Group terms with IndexDiv based on the first letter of the term (or
41
 
its sortas attribute).  (This probably doesn't handle i10n
42
 
particularly well.)
43
 
 
44
 
=item B<-s>
45
 
 
46
 
Name the IndexDiv that contains symbols.  The default is 'Symbols'.
47
 
Meaningless if B<-g> is not used.
48
 
 
49
 
=item B<-t> I<name>
50
 
 
51
 
Title for the index.
52
 
 
53
 
=item B<-P> F<file>
54
 
 
55
 
Read a preamble from F<file>.  The contents of F<file> will be
56
 
inserted before the E<lt>indexE<gt> tag.
 
43
its SortAs attribute).  (This might not handle all language environments.)
57
44
 
58
45
=item B<-i> I<id>
59
46
 
60
47
The ID to use for the E<lt>indexE<gt> tag.
61
48
 
62
 
=item B<-o> F<file>
63
 
 
64
 
Output to F<file>. Defaults to F<stdout>.
65
 
 
66
 
=item B<-S> I<scope>
67
 
 
68
 
Scope of the index, must be C<all>, C<local>, or C<global>.  If
69
 
unspecified, C<all> is assumed.
70
 
 
71
49
=item B<-I> I<scope>
72
50
 
73
51
The implied scope, must be C<all>, C<local>, or C<global>.  IndexTerms
74
52
which do not specify a scope will have the implied scope.  If
75
53
unspecified, C<all> is assumed.
76
54
 
77
 
=item B<-x>
78
 
 
79
 
Make a SetIndex.
80
 
 
81
 
=item B<-f>
82
 
 
83
 
Force the output file to be written, even if it appears to have been
84
 
edited by hand.
85
 
 
86
55
=item B<-N>
87
56
 
88
57
New index (generates an empty index file).
89
58
 
 
59
=item B<-o> F<file>
 
60
 
 
61
Output to F<file>. Defaults to F<stdout>.
 
62
 
 
63
=item B<-p>
 
64
 
 
65
Link to points in the document.  The default is to link to the closest
 
66
containing section.
 
67
 
 
68
=item B<-P> F<file>
 
69
 
 
70
Read a preamble from F<file>.  The contents of F<file> will be
 
71
inserted before the E<lt>indexE<gt> tag.
 
72
 
90
73
=item B<-q>
91
74
 
92
75
Run quietly.
93
76
 
 
77
=item B<-s> I<name>
 
78
 
 
79
Name the IndexDiv that contains symbols.  The default is C<Symbols>.
 
80
Meaningless if B<-g> is not used.
 
81
 
 
82
=item B<-S> I<scope>
 
83
 
 
84
Scope of the index, must be C<all>, C<local>, or C<global>.  If
 
85
unspecified, C<all> is assumed.
 
86
 
 
87
=item B<-t> I<name>
 
88
 
 
89
Title for the index.
 
90
 
 
91
=item B<-x>
 
92
 
 
93
Make a SetIndex.
 
94
 
94
95
=item B<-V>
95
96
 
96
97
Print version number and exit.
97
98
 
98
99
=item F<file>
99
100
 
100
 
The file containing index data generated by B<Jade> with the DocBook
101
 
HTML Stylesheet.
 
101
The file containing index data generated with the DocBook DSSSL
 
102
HTML stylesheet (usually called F<HTML.index>).
102
103
 
103
104
=back
104
105
 
145
146
}
146
147
 
147
148
$dat = shift @ARGV || die $usage;
148
 
die "$0: cannot find $dat.\n" if ! -f $dat;
 
149
die "$me: file \"$dat\" does not exist\n" if ! -f $dat;
149
150
 
150
151
%legal_scopes = ('ALL' => 1, 'LOCAL' => 1, 'GLOBAL' => 1);
151
152
if ($scope && !$legal_scopes{$scope}) {
152
 
    die "Invalid scope.\n$usage\n";
 
153
    die "$me: invalid scope: $scope\n";
153
154
}
154
155
if ($impliedscope && !$legal_scopes{$impliedscope}) {
155
 
    die "Invalid implied scope.\n$usage\n";
 
156
    die "$me: invalid implied scope: $impliedscope\n";
156
157
}
157
158
 
158
159
@term = ();
269
270
        my($href) = $1;
270
271
        $_ = scalar(<F>);
271
272
        chop;
272
 
        die "Bad zone: $_\n" if !/^title (.*)$/i;
 
273
        die "$me: invalid zone: $_\n" if !/^title (.*)$/i;
273
274
        $idx->{'zone'}->{$href} = $1;
274
275
        next;
275
276
    }
276
277
 
277
 
    die "Unrecognized: $_\n";
 
278
    die "$me: unrecognized tag in input: $_\n";
278
279
}
279
280
close (F);
280
281
 
494
495
        if $linkpoints;
495
496
 
496
497
    if ($same) {
497
 
       warn "duplicated index entry found, $aP $aS $aT\n";
 
498
       warn "$me: duplicated index entry found: $aP $aS $aT\n";
498
499
    }
499
500
 
500
501
    $same;
675
676
        }
676
677
 
677
678
        if ($handedit) {
678
 
            print "\n$outfile appears to have been edited by hand; use -f or\n";
679
 
            print "      change the output file.\n";
 
679
            print STDERR "$me: file \"$outfile\" appears to have been edited by hand\n";
 
680
            print STDERR "Use the -f option or specify a different output file name.\n";
680
681
            exit 1;
681
682
        }
682
683
    }
683
684
 
684
 
    open (OUT, ">$outfile") || die "$usage\nCannot write to $outfile.\n";
 
685
    open (OUT, ">$outfile") || die "$me: could not open file \"$outfile\": $!\n";
685
686
 
686
687
    if ($preamble) {
687
688
        # Copy the preamble
691
692
            }
692
693
            close(F);
693
694
        } else {
694
 
            warn "$0: cannot open preamble $preamble.\n";
 
695
            warn "$me: could not open preamble file \"$preamble\": $!\n";
695
696
        }
696
697
    }
697
698
}
718
719
 
719
720
=item B<0>
720
721
 
721
 
Success.
 
722
Success
722
723
 
723
724
=item B<1>
724
725
 
725
 
Failure.
 
726
Failure
726
727
 
727
728
=back
728
729
 
729
730
=head1 AUTHOR
730
731
 
731
 
Norm Walsh E<lt>ndw@nwalsh.comE<gt>.
 
732
Norm Walsh E<lt>ndw@nwalsh.comE<gt>
732
733
 
733
 
Minor updates by Adam Di Carlo E<lt>adam@onshore.comE<gt>.
 
734
Minor updates by Adam Di Carlo E<lt>adam@onshore.comE<gt> and Peter Eisentraut E<lt>peter_e@gmx.netE<gt>
734
735
 
735
736
=cut
736
737