[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

New xdvi



I've just written a new xdvi wrapper to fix bugs 117528 and 127353.
Can someone else also test it, please?  It is attached.

   Julian

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

        Julian Gilbey, website: http://www.polya.uklinux.net/
   Debian GNU/Linux Developer, see: http://people.debian.org/~jdg/
     Visit http://www.thehungersite.com/ to help feed the hungry
#! /usr/bin/perl -w

# This is the xdvi wrapper script for Debian, based on Thomas Esser's
# teTeX version 0.2.
# Debian version: Copyright Julian Gilbey, 2002.
# Original version: Copyright Thomas Esser, 1998.
# Permission to distribute this software is given under the terms of
# the GNU general public license version 2 or later.

# Thomas writes:
# This script sets some environment variables to make sure that xdvi's
# resource file in $XDVIINPUTS/xdvi is read by xdvi.bin.
# Special care was taken to make this work for old R3, too. Therefore,
# we need to modify XAPPLRESDIR. If you are running R4 or later, you
# can set XUSERFILESEARCHPATH for user specific application default
# files. You cannot use XAPPLRESDIR for user specific application default
# files.

# Julian writes:
# While Debian runs X11R6, we keep the XAPPLRESDIR part of the code for
# consistency.  This has been rewritten in Perl so that we can mangle
# the arguments to handled gzipped dvi files, which not have errors if
# there are spaces in some arguments.

use strict;
use File::Basename;
use File::Temp qw(tempfile);

my @NAMEOPT;
if (@ARGV == 1 and ($ARGV[0] eq '-help' or $ARGV[0] eq '-version')) {
    @NAMEOPT=();
} else {
    @NAMEOPT=qw(-name xdvi);
}

$ENV{'XDVIINPUTS'} .= ":\$TEXMF/{xdvi,web2c}";

my ($xdviappfile, $xdviappdir, $xdviapppath);
$xdviappfile=`kpsewhich -progname=xdvi --format='other text files' XDvi`;
if ("$xdviappfile" ne '') {
    $xdviappdir=dirname($xdviappfile);
    $xdviapppath="$xdviappdir/%N";

    # For R3, we have to set XAPPLRESDIR.
    $ENV{'XAPPLRESDIR'}=$xdviappdir;

    # For R4 or later, we have to set XFILESEARCHPATH, since XAPPLRESDIR might
    # be ignored (if XUSERFILESEARCHPATH is set)
    if (exists $ENV{'XFILESEARCHPATH'}) {
	$ENV{'XFILESEARCHPATH'} = "$xdviapppath:$ENV{'XFILESEARCHPATH'}";
    } else {
	$ENV{'XFILESEARCHPATH'} = $xdviapppath;
    }
}

my $status;
if (@ARGV) {
    my $filename = pop @ARGV;
    my ($fh, $tempfile);

    if ($filename =~ /\.(gz|Z|bz2)$/) {
	($fh, $tempfile) = tempfile("tetexXXXXXX", SUFFIX => '.dvi');
	if ($filename =~ /\.(gz|Z)$/) {
	    system("gzip -d -c '$filename' > $tempfile");
	} else {
	    system("bzip2 -d -c '$filename' > $tempfile");
	}
	if ($? >> 8 != 0) {
	    $status = $? >> 8;
	    unlink $tempfile;
	    exit $status;
	}

	system('xdvi.bin', @NAMEOPT, @ARGV, $tempfile);
	$status = $?;
	unlink $tempfile;
    } else {
	system('xdvi.bin', @NAMEOPT, @ARGV, $filename);
	$status = $?;
    }
} else {
    system('xdvi.bin', @NAMEOPT);
    $status = $?;
}

exit $status;

Reply to: