diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-05-19 09:14:33 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-05-19 09:14:33 +0000 |
commit | 9bfb3b4dcc6fbab44b2ff86564832e34543a2be8 (patch) | |
tree | fe119943babfb365f2b6376438b1fe9537ef14a8 /Master/texmf/scripts | |
parent | e9a2a190f6ce2e9e0027affddb6022f977bbf766 (diff) |
xindy-2.4 support files
git-svn-id: svn://tug.org/texlive/trunk@18351 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/scripts')
-rwxr-xr-x | Master/texmf/scripts/xindy/texindy.pl | 216 | ||||
-rwxr-xr-x | Master/texmf/scripts/xindy/xindy.pl | 301 |
2 files changed, 318 insertions, 199 deletions
diff --git a/Master/texmf/scripts/xindy/texindy.pl b/Master/texmf/scripts/xindy/texindy.pl index cb0664c7016..28a7e0a4dd7 100755 --- a/Master/texmf/scripts/xindy/texindy.pl +++ b/Master/texmf/scripts/xindy/texindy.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# $Id: texindy,v 1.8 2009/03/22 11:08:18 jschrod Exp $ +# $Id: texindy,v 1.11 2010/05/10 23:39:24 jschrod Exp $ #------------------------------------------------------------ # (history at end) @@ -255,6 +255,51 @@ specific effect. and ngerman options. +=head1 COMPATIBILITY TO MAKEINDEX + +B<xindy> does not claim to be completely compatible with MakeIndex, +that would prevent some of its enhancements. That said, we strive to +deliver as much compatibility as possible. The most important +incompatibilities are + +=over + +=item * + +For raw index entries in LaTeX syntax, C<\index{aaa|bbb}> is +interpreted differently. For MakeIndex C<bbb> is markup that is output +as a LaTeX tag for this page number. For B<xindy>, this is a location +attribute, an abstract identifier that will be later associated with +markup that should be output for that attribute. + +For straight-forward usage, when C<bbb> is C<textbf> or similar, we +supply location attribute definitions that mimic MakeIndex's +behaviour. + +For more complex usage, when C<bbb> is not an identifier, no such +compatibility definitions exist and may also not been created with +current B<xindy>. In particular, this means that by default the LaTeX +package C<hyperref> will create raw index files that cannot be +processed with B<xindy>. This is not a bug, this is the unfortunate +result of an intented incompatibility. It is currently not possible to +get both hyperref's index links and use B<xindy>. + +A similar situation is reported to exist for the C<memoir> LaTeX +class. + +Programmers who know Common Lisp and Lex and want to work on a remedy +should please contact the author. + +=item * + +The MakeIndex compatibility definitions support only the default raw +index syntax and markup definition. It is not possible to configure +raw index parsing or use a MakeIndex style file to describe output +markup. + +=back + + =head1 ENVIRONMENT @@ -291,36 +336,81 @@ GNU General Public License for more details. =cut -use 5.006; + use strict; +use English qw(-no_match_vars); -BEGIN { - use vars qw($Revision $VERSION); - q$Revision: 1.8 $ =~ /: (\d+)\.(\d+)/ ; # q wg. Emacs indent! - my ($major, $minor) = ($1, $2); - $VERSION = "$major." . ($minor<10 ? '0' : '') . $minor; -} +our $VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /: (\d+)\.(\d+)/ ; -# Some common variables. -# Determine environment. Where is our library directory, and our modules? +# Used modules. +use Cwd; use File::Basename; -our ($cmd_dir, $cmd); -BEGIN { - $cmd_dir = dirname($0); - $cmd = basename($0); -} +use Getopt::Long qw(:config bundling); -# Used modules. +# Determine environment. Where is our library directory, and our modules? -use Getopt::Long qw(:config bundling); +our $is_TL = ( 'yes' eq 'yes' ); +our $is_w32 = ( $OSNAME =~ /^MSWin/i ) ; +our $real_cmd = Cwd::realpath($0); +our $cmd_dir = dirname($real_cmd); +our $cmd = basename($0); +our $xindy; + +# In TeX-Live, user commands are symlinks in some bin directory, and +# the actual scripts are in the library directory and have a .pl +# extension. In standalone installations, user command xindy is +# expected to be in the same directory as our command. + +if ( $is_TL ) { # TeX Live + + if ( $is_w32 ) { + $xindy = "$cmd_dir/xindy.pl"; + } else { + die "$cmd: not a symlink as required for TeX Live" unless -l $0; + # FIXME: What this good for? Ain't xindy not also + # "$cmd_dir/xindy.pl" in a Unix TL installation? Why does + # Peter use the directory of the last symlink, where it just + # finds the symlink again that is then expanded by xindy.pl? + $real_cmd = $0; + $cmd_dir = dirname($real_cmd); + # Follow symlinks, but remember last one + my $lcmd_dir; + while ( -l $real_cmd ) { + $lcmd_dir = $cmd_dir; + $real_cmd = readlink($real_cmd); + $real_cmd = "$lcmd_dir/$real_cmd" unless $real_cmd =~ m,^[\\/],; # relative link + $cmd_dir = dirname($real_cmd); + } + $xindy = "$lcmd_dir/xindy"; + } + # FIXME: That's a very ugly kludge to achieve that the VERSION + # file is found in output_xindy_release(). The real solution is to + # copy the code from xindy.pl that determines $modules_dir and + # $lib_dir and use that code as well. + $cmd_dir = Cwd::realpath("$cmd_dir/../../xindy/modules"); + die "Cannot locate xindy modules directory" unless -f "$cmd_dir/../VERSION"; +} else { + if ( -f "$cmd_dir/xindy" && -x _ ) { + $xindy = "$cmd_dir/xindy"; + } elsif ( -f "$cmd_dir/xindy.pl" && -x _ ) { + $xindy = "$cmd_dir/xindy.pl"; + } else { + die "$cmd: cannot locate xindy\n"; + } +} +die "$cmd: cannot locate xindy\n" unless -f $xindy && ($is_w32 || -x $xindy); # Check arguments, store them in proper variables. -my $usage_msg = <<_EOT_ +sub usage ( ;$ ) +{ + my $exit_code = shift; + $exit_code += 0; # turn undef into 0 + print STDERR <<_EOT_ usage: $cmd [-V?h] [-qv] [-iglr] [-d magic] [-o outfile.ind] [-t log] \\ [-L lang] [-C codepage] [-M module] [-I input] [idx0 idx1 ...] @@ -345,44 +435,19 @@ GNU-STYLE LONG OPTIONS FOR SHORT OPTIONS: -I / --input-markup (supported: latex, omega) _EOT_ -; - -sub usage () -{ - print STDERR $usage_msg; - exit 1; + ; + exit ($exit_code); } -sub parse_options(); -sub output_version(); - our ($output_version, $quiet, $verbose, $stdin, @debug, $outfile, $logfile, $language, $codepage, @modules, $input_markup); $language = 'general'; $codepage = 'latin'; $input_markup = 'latex'; -our $xindy; -if ( -f "$cmd_dir/xindy" && -x _ ) { - $xindy = "$cmd_dir/xindy"; -} elsif ( -f "$cmd_dir/xindy.pl" && -x _ ) { - $xindy = "$cmd_dir/xindy.pl"; -} elsif ( exists $ENV{"TL_ROOT"} && -f "$ENV{TL_ROOT}\\bin\\win32\\xindy.exe") { - $xindy = "$ENV{TL_ROOT}\\bin\\win32\\xindy.exe"; - $cmd_dir = "$ENV{TL_ROOT}\\bin\\win32"; -} elsif ( -f "$ENV{SELFAUTOLOC}/xindy.bat" ) { # woe32 - $xindy = "$ENV{SELFAUTOLOC}/xindy.bat"; - $cmd_dir = $ENV{"SELFAUTOLOC"}; -} elsif ( -f "$ENV{SELFAUTOLOC}/xindy.exe" ) { - $xindy = "$ENV{SELFAUTOLOC}/xindy.exe"; - $cmd_dir = $ENV{"SELFAUTOLOC"}; -} else { - die "$cmd: cannot locate xindy\n"; -} - parse_options(); output_version() if $output_version; # will not return -usage() if ( ! $stdin && @ARGV == 0 ); # brain damaged, but like makeindex +usage(1) if ( ! $stdin && @ARGV == 0 ); # brain damaged, but like makeindex # Construct xindy options, and eventually switch to it. @@ -401,25 +466,37 @@ push (@opt, map { ('-M', $_) } ($ENV{TEXINDY_AUTO_MODULE} || 'texindy', push (@opt, '-I', $input_markup); print "Calling xindy as: $xindy @opt @ARGV\n" if (grep /^script$/, @debug); +exec_xindy(@opt, @ARGV); -if ($xindy =~ m,\.(bat|exe)$,) { - system($xindy, @opt, @ARGV); - exit $? if $? != -1; -} else { - exec $xindy, @opt, @ARGV; -} -die "$cmd: could not execute $xindy: $!\n"; +# NOT REACHED # ------------------------------------------------------------ +sub exec_xindy { + if ( $is_w32 ) { + system ($EXECUTABLE_NAME, $xindy, @_); + if ($? == -1) { + die "$cmd: could not execute xindy: $ERRNO\n"; + } elsif ($? & 127) { + die "xindy died with signal " . ($? & 127) ."\n"; + } else { + exit ($? >> 8); + } + } else { + exec ($xindy, @_); + die "$cmd: could not execute xindy: $!\n"; + } +} + + sub parse_options() { my ($german, $letter_ordering, $no_ranges); GetOptions( 'version|V' => \$output_version, - 'help|h|?' => sub { print $usage_msg; exit 0; }, + 'help|h|?' => \&usage, 'quiet|q' => \$quiet, 'verbose|v' => \$verbose, 'stdin|i' => \$stdin, @@ -434,7 +511,7 @@ sub parse_options() { 'module|M=s' => \@modules, 'input-markup|I=s' => \$input_markup, ) - or usage(); + or usage(1); if ( $german ) { unshift (@modules, 'german-sty'); @@ -454,8 +531,8 @@ sub parse_options() { # to undef to prevent loading of the inputenc module. Setting it # to utf8 for the sort encoding is done by the xindy script. if ( $input_markup ne 'latex' && $input_markup ne 'omega' ) { - print STDERR "Unsupported input markup $input_markup.\n\n"; - usage(); + print STDERR "Unsupported input markup $input_markup.\n"; + usage(1); } if ( $input_markup eq 'omega' ) { $codepage = undef; @@ -467,9 +544,9 @@ sub parse_options() { sub output_version () { output_xindy_release(); print "$cmd script version: $VERSION\n"; - my @xindy_cmd = ($xindy, '--internal-version'); + my @xindy_cmd = ('--internal-version'); push (@xindy_cmd, qw(-d script --foobar)) if grep(/^script$/, @debug); - exec @xindy_cmd; + exec_xindy(@xindy_cmd); } @@ -479,25 +556,17 @@ sub output_xindy_release () { if ( -f "$cmd_dir/../VERSION" ) { $version_file = "$cmd_dir/../VERSION"; } else { - my $xindy_run; - if ($^O eq "MSWin32" || $^O eq "cygwin") { - $xindy_run = "xindy-lisp.exe"; - } else { - $xindy_run = "xindy.run"; - } # Where is the library directory? my $lib_dir; if ( $ENV{XINDY_LIBDIR} ) { $lib_dir = $ENV{XINDY_LIBDIR}; - } elsif ( -f "$cmd_dir/$xindy_run" ) { # texlive style - $lib_dir = $cmd_dir; } elsif ( '@libdir@' ne '@libdir' . '@' ) { # GNU configure at work? if ( -d '@libdir@/xindy' ) { # /usr style $lib_dir = '@libdir@/xindy'; } else { $lib_dir = '@libdir@'; # /opt style } - } elsif ( -f "$cmd_dir/../lib/$xindy_run" ) { # /opt style + } elsif ( -f "$cmd_dir/../lib/xindy.run" ) { # /opt style $lib_dir = "$cmd_dir/../lib"; } elsif ( -d "$cmd_dir/../lib/xindy" ) { # /usr style $lib_dir = "$cmd_dir/../lib/xindy"; @@ -529,6 +598,17 @@ sub output_xindy_release () { #====================================================================== # # $Log: texindy,v $ +# Revision 1.11 2010/05/10 23:39:24 jschrod +# Incorporate TeX-Live patches from Vladimir Volovich and Peter +# Breitenlohner: Support for TL installation scheme, support for Mac OS +# X, support for Windows in TL. +# +# Revision 1.10 2010/04/20 00:15:23 jschrod +# Emphasize incompatibility with hyperref in man page. +# +# Revision 1.9 2009/12/03 00:28:22 jschrod +# Search perl via env. +# # Revision 1.8 2009/03/22 11:08:18 jschrod # man page: --v is --verbose, not --version. # diff --git a/Master/texmf/scripts/xindy/xindy.pl b/Master/texmf/scripts/xindy/xindy.pl index 87fa6eea893..1913b316a33 100755 --- a/Master/texmf/scripts/xindy/xindy.pl +++ b/Master/texmf/scripts/xindy/xindy.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# $Id: xindy.pl,v 1.13 2009/03/29 11:14:04 jschrod Exp $ +# $Id: xindy.pl,v 1.16 2010/05/10 23:39:24 jschrod Exp $ #------------------------------------------------------------ # (history at end) @@ -222,14 +222,59 @@ F<usr>-installations. =item C<XINDY_LIBDIR> -Library directory where F<xindy.run> and F<xindy.mem> are located. +Library directory where F<xindy.mem> is located. The modules directory may be a subdirectory, too. =back -=head1 KNOWN BUGS +=head1 COMPATIBILITY TO MAKEINDEX + +B<xindy> does not claim to be completely compatible with MakeIndex, +that would prevent some of its enhancements. That said, we strive to +deliver as much compatibility as possible. The most important +incompatibilities are + +=over + +=item * + +For raw index entries in LaTeX syntax, C<\index{aaa|bbb}> is +interpreted differently. For MakeIndex C<bbb> is markup that is output +as a LaTeX tag for this page number. For B<xindy>, this is a location +attribute, an abstract identifier that will be later associated with +markup that should be output for that attribute. + +For straight-forward usage, when C<bbb> is C<textbf> or similar, we +supply location attribute definitions that mimic MakeIndex's +behaviour. + +For more complex usage, when C<bbb> is not an identifier, no such +compatibility definitions exist and may also not been created with +current B<xindy>. In particular, this means that by default the LaTeX +package C<hyperref> will create raw index files that cannot be +processed with B<xindy>. This is not a bug, this is the unfortunate +result of an intented incompatibility. It is currently not possible to +get both hyperref's index links and use B<xindy>. + +A similar situation is reported to exist for the C<memoir> LaTeX +class. + +Programmers who know Common Lisp and Lex and want to work on a remedy +should please contact the author. + +=item * + +The MakeIndex compatibility definitions support only the default raw +index syntax and markup definition. It is not possible to configure +raw index parsing or use a MakeIndex style file to describe output +markup. + +=back + + +=head1 KNOWN ISSUES Option B<-q> also prevents output of error messages. Error messages should be output on stderr, progress messages on stdout. @@ -237,6 +282,8 @@ should be output on stderr, progress messages on stdout. There should be a way to output the final index to stdout. This would imply B<-q>, of course. +LaTeX raw index parsing should be configurable. + Codepage C<utf8> should be supported for all languages, and should be used as internal codepage for LaTeX inputenc re-encoding. @@ -254,7 +301,7 @@ Joachim Schrod =head1 LEGALESE -Copyright (c) 2004-2006 by Joachim Schrod. +Copyright (c) 2004-2010 by Joachim Schrod. B<xindy> is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -267,61 +314,95 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. =for Emacs -#' +# ' =cut -use 5.006; + use strict; +use English qw(-no_match_vars); -BEGIN { - use vars qw($Revision $VERSION); - q$Revision: 1.13 $ =~ /: (\d+)\.(\d+)/ ; # q wg. Emacs indent! - my ($major, $minor) = ($1, $2); - $VERSION = "$major." . ($minor<10 ? '0' : '') . $minor; -} +our $VERSION = sprintf "%d.%02d", q$Revision: 1.16 $ =~ /: (\d+)\.(\d+)/ ; -# Some common variables. -# Determine environment. Where is our library directory, and our modules? +# Used modules. -use File::Basename; use Cwd; -our ($cmd_dir, $cmd, $xindy_run, $lib_dir, $modules_dir, $path_sep); -BEGIN { - $cmd_dir = dirname($0); - $cmd = basename($0); - - if ($^O eq "MSWin32" || $^O eq "cygwin") { - $xindy_run = "xindy-lisp.exe"; - $path_sep = ";"; +use File::Basename; +use File::Spec; +use File::Temp qw(tempfile tmpnam); +use Getopt::Long qw(:config bundling); +use POSIX qw(uname); + + +# Determine environment. Where is our library directory, and our modules? + +our $is_TL = ( 'yes' eq 'yes' ); +our $is_w32 = ( $OSNAME =~ /^MSWin/i ) ; +our $is_windows = ( $is_w32 || $OSNAME eq 'cygwin' ) ; +our $clisp = ( $is_windows ? 'clisp.exe' : 'clisp' ) ; +our $real_cmd = Cwd::realpath($0); +our $cmd_dir = dirname($real_cmd); +our $cmd = basename($0); + +our ($lib_dir, $modules_dir); + +# We have different installation structures for TeX-Live and a +# standalone installation. In TeX-Live, the user command is a symlink +# in some bin directory, and the actual script is in the library +# directory where both memory image and modules live as well. +# Standalone installations come in /usr or /opt variants, memory +# images are located in a lib directory, modules are located in a +# share directory. +# +# FIXME: In standalone installations, modules are still placed in lib +# directory. This is not conformant to FHS. + +if ( $is_TL ) { # TeX Live + + $modules_dir = Cwd::realpath("$cmd_dir/../../xindy/modules"); + die "$cmd: Cannot locate xindy modules directory" unless -d $modules_dir; + + if ( $is_w32 ) { + $cmd_dir = "$cmd_dir/../../../bin/win32"; } else { - $xindy_run = "xindy.run"; - $path_sep = ":"; + die "$cmd: not a symlink as required for TeX Live" unless -l $0; + # Follow symlinks and determine $cmd_dir such that + # $cmd_dir/xindy -> $r0 = XINDY_SCRIPTDIR/xindy.pl + # + # FIXME: What's this code good for? Cwd::realpath() already + # resolves all symbolic links; this just recomputes that + # information manually! It's from Peter, check with him. + $real_cmd = $0; + while (-l $real_cmd) { + $cmd_dir = dirname($real_cmd); + $real_cmd = readlink($real_cmd); + $real_cmd = "$cmd_dir/$real_cmd" unless $real_cmd =~ m,^[\\/],; # relative link + } } # library directory + $lib_dir = $cmd_dir; + + # clisp runtime + my $xindy_run = ( $is_windows ? + "$lib_dir/xindy-lisp.exe" : "$lib_dir/xindy.run" ); + $clisp = $xindy_run if -e $xindy_run; + +} else { # standalone installation + + # library directory if ( $ENV{XINDY_LIBDIR} ) { $lib_dir = $ENV{XINDY_LIBDIR}; - die "$cmd: Invalid XINDY_LIBDIR setting: cannot find $lib_dir/$xindy_run" if ! -f "$lib_dir/$xindy_run"; - } elsif ( -f "$cmd_dir/$xindy_run" ) { # texlive unix - $lib_dir = $cmd_dir; - } elsif ( exists $ENV{"TL_ROOT"} && -f "$ENV{TL_ROOT}\\bin\\win32\\$xindy_run") { # TL2009 woe32 - $lib_dir = "$ENV{TL_ROOT}\\bin\\win32"; - $cmd_dir = "$ENV{TL_ROOT}\\bin\\win32"; - } elsif ( exists $ENV{"SELFAUTOLOC"} && -f "$ENV{SELFAUTOLOC}/$xindy_run" ) { # TL2008 woe32 - $lib_dir = $ENV{"SELFAUTOLOC"}; - $cmd_dir = $ENV{"SELFAUTOLOC"}; } elsif ( '@libdir@' ne '@libdir' . '@' ) { # GNU configure at work? if ( -d '@libdir@/xindy' ) { # /usr style $lib_dir = '@libdir@/xindy'; } else { $lib_dir = '@libdir@'; # /opt style } - die "$cmd: Cannot locate $lib_dir/$xindy_run" if ! -f "$lib_dir/$xindy_run"; - } elsif ( -f "$cmd_dir/../lib/$xindy_run" ) { # /opt style + } elsif ( -f "$cmd_dir/../lib/xindy.mem" ) { # /opt style $lib_dir = "$cmd_dir/../lib"; - } elsif ( -f "$cmd_dir/../lib/xindy/$xindy_run" ) { # /usr style + } elsif ( -d "$cmd_dir/../lib/xindy" ) { # /usr style $lib_dir = "$cmd_dir/../lib/xindy"; } else { die "$cmd: Cannot locate xindy library directory"; @@ -332,43 +413,20 @@ BEGIN { $modules_dir = "$cmd_dir/../modules"; } elsif ( -d "$lib_dir/modules" ) { # /usr style $modules_dir = "$lib_dir/modules"; - } elsif ( -d "$lib_dir/../../texmf/xindy" ) { # texlive multiplatform style - $modules_dir = "$lib_dir/../../texmf/xindy"; - } elsif ( -d "$lib_dir/../texmf/xindy" ) { # texlive non-multiplatform style - $modules_dir = "$lib_dir/../texmf/xindy"; - } elsif ( -d "/usr/share/xindy" ) { # FSH style - $modules_dir = "/usr/share/xindy"; - } elsif (-l $0) { # binaries may be symlinks e.g. in /usr/local/bin - my $try_dir = dirname(Cwd::realpath($0)); - if ($try_dir =~ m,/texmf/scripts/xindy$, && -d "$try_dir/../../xindy") { - $modules_dir = "$try_dir/../../xindy"; - } else { - die "$cmd: Cannot locate xindy modules directory"; - } } else { die "$cmd: Cannot locate xindy modules directory"; } - # if $cmd_dir or $lib_dir is a symlink, clisp may get confused - # because of relative paths above, so we resolve the path - $modules_dir = Cwd::realpath($modules_dir); -} +} # determine environment -# Used modules. - -use Getopt::Long qw(:config bundling); -use File::Temp qw(tempfile tmpnam); -use File::Spec; -use POSIX qw(uname); # Check arguments, store them in proper variables. -# -# Do also something for backward compatibility: Check if this is an -# old-style call. If it is, we have two arguments at the end, and the -# second-to-last has the extension ".xdy". Then, call the old driver -# script with the original arguments... -my $usage_msg = <<_EOT_ +sub usage ( ;$ ) +{ + my $exit_code = shift; + $exit_code += 0; # turn undef into 0 + print STDERR <<_EOT_ usage: $cmd [-V?h] [-qv] [-d magic] [-o outfile.ind] [-t log] \\ [-L lang] [-C codepage] [-M module] [-I input] \\ @@ -391,58 +449,37 @@ GNU-STYLE LONG OPTIONS FOR SHORT OPTIONS: -I / --input-markup (supported: latex, omega, xindy) _EOT_ -; - -sub usage () -{ - print STDERR $usage_msg; - exit 1; + ; + exit ($exit_code); } -sub parse_options(); -sub handle_signals(); -sub create_raw_index(); -sub filter_index($$); -sub xindy_expression(); -sub call_xindy($$); - our ($quiet, $verbose, %debug, $outfile, $logfile, $language, @codepages, @modules, $input_markup, $interactive, $mem_file); $input_markup = 'latex'; - $mem_file = "$lib_dir/xindy.mem"; -if ($^O eq 'darwin' && ! -e $mem_file) { - # support universal binary on mac - my @uname = POSIX::uname(); - if ($uname[4] eq 'Power Macintosh') { - $mem_file = "$lib_dir/xindy-ppc.mem"; - } else { - $mem_file = "$lib_dir/xindy-i386.mem"; - } -} -die "$cmd: Cannot locate $mem_file" if ! -e $mem_file; +my @orig_argv = @ARGV; parse_options(); -if ( @ARGV == 2 && $ARGV[0] =~ /\.xdy$/ ) { - print STDERR <<EOF; -$cmd: deprecated calling convention detected. -Please change your command to -$cmd -I xindy -M $ARGV[0] $ARGV[1] +# Support universal binary on Mac OS X. -Run "$cmd --help" for full list of options, or read the documentation. -EOF - exit 1; +if ( $OSNAME eq 'darwin' && ! -e $mem_file ) { + my @uname = POSIX::uname(); + if ( $uname[4] eq 'Power Macintosh' ) { + $mem_file = "$lib_dir/xindy-ppc.mem"; + } else { + $mem_file = "$lib_dir/xindy-i386.mem"; + } } +die "$cmd: Cannot locate $mem_file" unless -e $mem_file; # This script creates temporary files. Whenever a file is created, its # name is added to @temp_files. In an END handler, the temporary files # are deleted. Signal handlers are set up to get proper program -# termination on user-induced signals. During program calls with -# system, SIGINT and +# termination on user-induced signals. our @temp_files = (); handle_signals(); @@ -458,7 +495,9 @@ END { our $raw_index = File::Spec->devnull; unless ( $interactive ) { - for my $f (@ARGV) { die "$f does not exist" if ! -f $f } + for my $f ( @ARGV ) { + die "$cmd: input file $f does not exist" unless -f $f; + } $raw_index = create_raw_index(); # processes @ARGV my $filter_cmd = ''; if ( $input_markup eq 'latex' ) { @@ -471,8 +510,7 @@ unless ( $interactive ) { } -# Execution: Obey environment variables, create xindy start -# expression, and eventually call it. +# Execution: Create xindy start expression and call it. my $xindy_expression = xindy_expression(); # accesses global option vars my $exit_code = call_xindy ($mem_file, $xindy_expression); @@ -492,7 +530,7 @@ sub parse_options() { GetOptions( 'version|V' => sub { output_version(0); }, 'internal-version' => sub { output_version(1); }, - 'help|h|?' => sub { print $usage_msg; exit 0; }, + 'help|h|?' => \&usage, 'quiet|q' => \$quiet, 'verbose|v' => \$verbose, 'debug|d=s' => \@debug, @@ -505,7 +543,7 @@ sub parse_options() { 'interactive' => \$interactive, 'mem-file=s' => \$mem_file, ) - or usage(); + or usage(1); # Debug option values are easier to test in a hash. Clean up trace # level options, too. @@ -527,7 +565,7 @@ sub parse_options() { if ( %debug_check ) { my @magic = keys(%debug_check); print STDERR "Unsupported argument for --debug: @magic\n"; - usage(); + usage(1); } # Script debugging implies running it verbose and not quiet. @@ -541,13 +579,11 @@ sub parse_options() { unless ( $outfile || $interactive ) { if ( @ARGV == 0 ) { print STDERR -"You need to specify --out-file if the raw index is read from standard input.\n\n"; - usage(); +"You need to specify --out-file if the raw index is read from standard input.\n"; + usage(1); } my ($name, $path, $suffix) = fileparse ($ARGV[0], '\.[^\.]+'); $outfile = "$path$name.ind"; - # FIXME opening "nul" multiple times causes a problem on woe32 - $logfile = "$path$name.ilg" if $^O eq "MSWin32" && ! defined $logfile; } # FIXME: xindy wants a log file. Really? @@ -561,8 +597,8 @@ sub parse_options() { if ( $input_markup && $input_markup ne 'latex' && $input_markup ne 'omega' && $input_markup ne 'xindy' ) { - print STDERR "Unsupported input markup $input_markup.\n\n"; - usage(); + print STDERR "Unsupported input markup $input_markup.\n"; + usage(1); } if ( $input_markup eq 'omega' ) { @codepages = qw(utf8); @@ -640,7 +676,7 @@ sub filter_index ( $$ ) { # Construct final xindy expression, from options. sub xindy_expression () { - my ($logging, $tracing, $trace_level, $searchpath); + my ($logging, $tracing, $trace_level); # Determine language module of make-rules framework. Part of the # complexity below is from compatibility with the TLC2 @@ -707,20 +743,18 @@ sub xindy_expression () { } $style_file = quotify($style_file); - my $outfile_q = quotify($outfile); - $raw_index = quotify($raw_index); + $outfile = quotify($outfile); $logging = ':logfile ' . quotify($logfile) if $logfile; $tracing = ':markup-trace :on' if $debug{markup}; $trace_level = ":trace-level $debug{trace_level}" if $debug{trace_level}; - $searchpath = quotify(join($path_sep, ".", $modules_dir, "$modules_dir/base")); my $exp = <<_EOT_ (progn - (searchpath $searchpath) + (searchpath ".:$modules_dir:$modules_dir/base") (xindy:startup :idxstyle $style_file - :rawindex $raw_index - :output $outfile_q + :rawindex "$raw_index" + :output $outfile $logging $tracing $trace_level) @@ -737,18 +771,11 @@ _EOT_ sub call_xindy ( $$ ) { my ($mem_file, $xindy_exp) = @_; - my @command = ("$lib_dir/$xindy_run", '-q', - '-B', $lib_dir, '-M', $mem_file, '-E', 'iso-8859-1'); + my @command = ($clisp, '-M', $mem_file, '-E', 'iso-8859-1'); if ( $interactive ) { print "Proposed xindy expression:\n\n$xindy_exp\n" unless $quiet; } else { - #push (@command, '-x', $xindy_exp); - my ($output, $outfile) = tempfile(); - push (@temp_files, $outfile); - print $output $xindy_exp; - close ($output); - print "xindy startup file: $outfile\n" if $debug{script}; - push (@command, $outfile); + push (@command, '-x', $xindy_exp); } if ( $debug{script} ) { @@ -759,7 +786,6 @@ sub call_xindy ( $$ ) { if ( $quiet && ! $interactive ) { open (STDOUT, '>', File::Spec->devnull); } - unlink($outfile) if $^O eq "MSWin32" && -f $outfile; system @command; if ( $? == -1 ) { print STDERR "$cmd: Could not execute xindy kernel: $!\n"; @@ -782,7 +808,9 @@ sub output_version ( ;$ ) { # optional arg: internal-version flag sub output_xindy_release () { my $version = 'unknown'; my $version_file; - if ( -f "$cmd_dir/../VERSION" ) { + if ( -f "$modules_dir/../VERSION" ) { + $version_file = "$modules_dir/../VERSION"; + } elsif ( -f "$cmd_dir/../VERSION" ) { $version_file = "$cmd_dir/../VERSION"; } elsif ( -f "$lib_dir/VERSION" ) { $version_file = "$lib_dir/VERSION"; @@ -807,7 +835,7 @@ sub output_xindy_release () { sub quotify ( $ ) { my $s = shift; - $s =~ s:([\\\"]):\\$1:g ; # quote double-quote and backslash + $s =~ s:[\\\"]:\\&1:g ; # quote double-quote and backslash return "\"$s\""; } @@ -816,6 +844,17 @@ sub quotify ( $ ) { #====================================================================== # # $Log: xindy.pl,v $ +# Revision 1.16 2010/05/10 23:39:24 jschrod +# Incorporate TeX-Live patches from Vladimir Volovich and Peter +# Breitenlohner: Support for TL installation scheme, support for Mac OS +# X, support for Windows in TL. +# +# Revision 1.15 2010/04/20 00:15:23 jschrod +# Emphasize incompatibility with hyperref in man page. +# +# Revision 1.14 2009/12/03 00:28:22 jschrod +# Search perl via env. +# # Revision 1.13 2009/03/29 11:14:04 jschrod # xindy.run does not exist any more, call clisp directly. # |