--- texlive-bin-2007.dfsg.2.orig/debian/patches/fix-thumbpdf-perlwarning
+++ texlive-bin-2007.dfsg.2/debian/patches/fix-thumbpdf-perlwarning
@@ -0,0 +1,19 @@
+fix-thumbpdf-perlwarning  <preining@logic.at>
+Fix stupid warning of perl, present also in upstream
+---
+ thumbpdf |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/thumbpdf
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/thumbpdf	2005-07-06 13:03:00.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/thumbpdf	2007-05-19 16:30:21.000000000 +0200
+@@ -813,7 +813,7 @@
+             "\"";
+   print "> $cmd\n" if $::opt_verbose;
+   my @capture = `$cmd`;
+-  if (!defined(@capture))
++  if (!@capture)
+   {
+     die "$Error Cannot execute pdfTeX!\n";
+   }
--- texlive-bin-2007.dfsg.2.orig/debian/patches/19_dvipdfm_config
+++ texlive-bin-2007.dfsg.2/debian/patches/19_dvipdfm_config
@@ -0,0 +1,33 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 19_dvipdfm_config.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Add a patch for dvipdfm's config file that allows proper inclusion of
+## DP: really large Postscript files, as reported by Thomas Esser and Laurent
+## DP: Siebenmann  on the TeXLive list.
+
+@DPATCH@
+ texmf/dvipdfm/config/config |   10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+Index: texlive-bin-2006.svn3816/texmf/dvipdfm/config/config
+===================================================================
+--- texlive-bin-2006.svn3816.orig/texmf/dvipdfm/config/config	2006-07-24 01:13:11.000000000 +0200
++++ texlive-bin-2006.svn3816/texmf/dvipdfm/config/config	2007-01-26 03:59:35.000000000 +0100
+@@ -4,7 +4,15 @@
+ 
+ % Distiller config. Uses ghostscript and works on compressed and
+ % uncompressed files.
+-D "zcat -f %i | gs -q -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dUseFlateCompression=true -dSAFER -sOutputFile=%o - -c quit"
++% D "zcat -f %i | gs -q -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=1.2 -dUseFlateCompression=true -dSAFER -sOutputFile=%o - -c quit"
++%%%%%%%%%%%%%% begin bug comment
++% Laurent S. & Heiko Oberdiek bugfix of May 2006 on comp.text.tex:
++% Any fixed papersize as in above line will cause unwanted clipping of very big objects, 
++% so -- following a (version 8.50)  gs log suggestion spotted by Heiko Oberdiek 
++% -- use  "-dEPSCrop" instead of  "-sPAPERSIZE=a0".  
++% The other gs suggestion "-dEPSFitPage" causes unwanted downscaling. Here is the revised line:
++%%%%%%%%%%%%%% end bug comment
++D "zcat -f %i | gs -q -sDEVICE=pdfwrite -dEPSCrop -dCompatibilityLevel=1.2 -dUseFlateCompression=true -dSAFER -sOutputFile=%o - -c quit"
+ 
+ % Set default paper size here
+ p a4
--- texlive-bin-2007.dfsg.2.orig/debian/patches/17_texdoc
+++ texlive-bin-2007.dfsg.2/debian/patches/17_texdoc
@@ -0,0 +1,221 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 17_texdoc.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: texdoc should follow symlinks, and man pages, and sec fixes, from tetex
+
+@DPATCH@
+ build/source/texk/tetex/texdoc     |   75 +++++++++++++++++++++++--------------
+ build/source/texk/tetex/texdoc.man |   32 ++++++++++++---
+ 2 files changed, 72 insertions(+), 35 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/texdoc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/texdoc	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2007/build/source/texk/tetex/texdoc	2007-08-11 13:43:46.000000000 +0200
+@@ -17,6 +17,15 @@
+ #
+ # Support for compressed documentation implemented by adopting changes
+ # made by debian. Thomas Esser, Dec. 2004.
++#
++# Debian specific changes:
++#    Denis Barbier <barbier@imacs.polytechnique.fr>, Feb 15 2000
++#  * accept gzipped files on input
++#  * temporary directory set according to TMPDIR
++#    
++#    Frank Küster <frank@debian.org>, 2004-11-23
++#  * do not uncompress dvi.gz, xdvi can handle this
++#  * go to background with uncompressed files
+ 
+ test -f /bin/sh5 && test -z "$RUNNING_SH5" \
+   && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+@@ -30,22 +39,22 @@
+ 
+ export PATH
+ 
+-needsCleanup=false
++# needsCleanup=false
+ progname=texdoc
+-tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$
++# tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$
+ 
+ ###############################################################################
+ # setupTmpDir()
+ #   set up a temp directory and a trap to remove it
+ ###############################################################################
+-setupTmpDir()
+-{
+-  $needsCleanup && return
++# setupTmpDir()
++# {
++#   $needsCleanup && return
+ 
+-  trap 'cleanup --force' 1 2 3 7 13 15
+-  needsCleanup=true
+-  mkdir "$tmpdir" || abort "could not create directory \`$tmpdir'"
+-}
++#   trap 'cleanup --force' 1 2 3 7 13 15
++#   needsCleanup=true
++#   mkdir "$tmpdir" || abort "could not create directory \`$tmpdir'"
++# }
+ 
+ ###############################################################################
+ # abort(errmsg) 
+@@ -65,15 +74,21 @@
+ ###############################################################################
+ cleanup()
+ {
+-  case $1 in
+-    --force)
+-        $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
+-          && { rm -f "$tmpdir"/*; cd /; rmdir "$tmpdir"; }
+-        ;;
+-    *)  # directory might not be empty if some other viewer is still
+-        # running, so be quiet about it
+-        rmdir $tmpdir >/dev/null 2>&1;;
+-  esac
++#   case $1 in
++#     --force)
++#         $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
++#           && { rm -f "$tmpdir"/*; cd /; rmdir "$tmpdir"; }
++#         ;;
++#     *)  # directory might not be empty if some other viewer is still
++#         # running, so be quiet about it
++#         rmdir $tmpdir >/dev/null 2>&1;;
++#   esac
++  # is the temporary directory empty? If not, texdoc was called with 
++  # two or more arguments, and one viewer is still running
++  if test "`echo $tmpdir/*`" = $tmpdir/'*'
++  then
++    rm -rf $tmpdir
++  fi
+ }
+ 
+ 
+@@ -91,13 +106,12 @@
+         extlist='.pdf .ps .txt .dvi .html'
+ 	;;
+   *)
+-	: ${TEXDOCVIEW_dvi='(xdvi %s) &'}
+-	: ${TEXDOCVIEW_pdf='(acroread %s) &'}
+-	: ${TEXDOCVIEW_ps='(gv %s) &'}
+-	: ${TEXDOCVIEW_html='mozilla -remote openURL'"'(%s)'"' 2>/dev/null || mozilla %s &'}
+-	: ${TEXDOCVIEW_txt="${PAGER-more} %s"}
+-	: ${TEXDOCVIEW_="${PAGER-more} %s"} # no extension, default to pager
+-        extlist='.dvi .dvi.gz .dvi.bz2 .pdf .pdf.gz .pdf.bz2 .ps .ps.gz .ps.bz2 .txt .txt.gz .txt.bz2 .html'
++	: ${TEXDOCVIEW_dvi='(see %s) &'}
++	: ${TEXDOCVIEW_pdf='(see %s) &'}
++	: ${TEXDOCVIEW_ps='(see %s) &'}
++	: ${TEXDOCVIEW_html='(see %s) &'}
++	: ${TEXDOCVIEW_txt='(see %s) &'}
++	: ${TEXDOCVIEW_='(see %s) &'} # no extension, default to pager
+ 
+         # Commands run to uncompress files, according to filename extension.
+         : ${TEXDOCUNZIP_gz='gzip -d -c'}
+@@ -105,6 +119,10 @@
+ 	;;
+ esac
+ 
++extlist=`kpsewhich --expand-brace='$TEXDOCEXT' | tr ':' ' '`
++test -z "$extlist" && \
++extlist='.dvi .dvi.gz .dvi.bz2 .pdf .pdf.gz .pdf.bz2 .ps .ps.gz .ps.bz2 .txt .txt.gz .txt.bz2 .html'
++
+ mode=viewer
+ help='Usage: texdoc [OPTION]... [NAME]...
+   Search for NAME in the TeX documentation and start a viewer.
+@@ -136,11 +154,14 @@
+     ;;
+ esac
+ 
++tmpdir=`mktemp -d -t texdoc.XXXXXXXX`
++trap 'rc=$?; cleanup; exit $rc' 1 2 6 13 15
++
+ for name
+ do
+   case $mode in
+     search)
+-      find `kpsewhich --expand-path='$TEXMF/doc' | tr : ' '` -type f -print |
++      find `kpsewhich --expand-path='$TEXMF/doc' | tr : ' '` -follow -type f -print |
+         egrep $name
+       continue
+       ;;
+@@ -153,7 +174,6 @@
+ 
+   found=false
+   for ext in "" $extlist; do
+-
+     filename=`kpsewhich -format='TeX system documentation' $name$ext 2>/dev/null`
+     test -z "$filename" && continue
+     found=true
+@@ -177,7 +197,6 @@
+         # than once
+         test -f "$tmpdir/$src" && break
+ 
+-        setupTmpDir
+         eval "$uncompress $filename > $tmpdir/$src"
+         filename=$tmpdir/$src
+         viewer=`eval echo $viewer | sed -e "s|%s|$filename; rm -f $filename; cleanup|"`
+Index: texlive-bin-2007/build/source/texk/tetex/texdoc.man
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/texdoc.man	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2007/build/source/texk/tetex/texdoc.man	2007-08-11 13:42:46.000000000 +0200
+@@ -28,12 +28,17 @@
+ .PP 
+ .SH "OPTIONS" 
+ .PP 
+-.IP "\fB--help\fP" 
++.IP "\fB\-\-help\fP" 
+ Display a brief summary of options\&.
+ .IP 
+-.IP "\fB-l\fP" 
++.IP "\fB\-l\fP" 
+ List matching files\&.  Does not start a viewer\&.
+-.IP "\fB-v\fP" 
++.PP
++.IP "\fB\-s\fP"
++Search the disk. From all documentation files found by texdoc, the
++ones whose names match the remaining arguments (as egrep pattern) will
++be displayed.
++.IP "\fB\-v\fP" 
+ Sets verbose mode\&.  Shows the command being used to
+ display the documentation\&.
+ .PP 
+@@ -42,14 +47,18 @@
+ .IP "\fB$TEXDOCVIEW_dvi\fP" 
+ DVI viewer\&.  Defaults to \fBxdvi\fP(1)\&.
+ .IP "\fB$TEXDOCVIEW_pdf\fP" 
+-PDF viewer\&.  Defaults to \fBacroread\fP(1)\&.
++PDF viewer\&. The default is to use the program defined in the
++\fImailcap\fP file, see \fBmailcap\fP(5)\&.
+ .IP "\fB$TEXDOCVIEW_ps\fP" 
+-PostScript viewer\&.  Defaults to
++PostScript viewer\&. The default is to use the program defined in the
++\fImailcap\fP file, see \fBmailcap\fP(5)\&.
+ \fBghostview\fP(1)\&.
+ .IP "\fB$TEXDOCVIEW_html\fP" 
+-HTML viewer\&.  Defaults to \fBnetscape\fP(1)\&.
++HTML viewer\&. The default is to use the program defined in the
++\fImailcap\fP file, see \fBmailcap\fP(5)\&.
+ .IP "\fB$TEXDOCVIEW_txt\fP" 
+-Text viewer\&.  Defaults to \fB$PAGER-more\fP\&.
++Text viewer\&.  Defaults is to use the program indicated by the
++\fB$PAGER\fP variable, or \fBmore\fP if this is unset\&.
+ .PP 
+ The environment variables should be set with a ``%s\&'\&' as a placeholder
+ for the name of the file\&.  For example,
+@@ -66,6 +75,15 @@
+ hostname$ export TEXDOCVIEW_html
+ .EE 
+ .PP 
++.SH "SPECIFIC TO DEBIAN"
++.PP
++The Debian teTeX packages texdoc use the mime-support package to determine
++the appropriate viewer for the respective file type except for
++\fIdvi\fP and \fItxt\fP. texdoc of Debian is able to handle gzip- and
++bzip2-compressed files. If texdoc finds more than on file for a string
++the first hit is displayed. The file extensions are regarded and the
++search order can be configured in \fItexmf.cnf\fP (\fI90TeXDoc.cnf\fP).
++.PP 
+ .SH "SEE ALSO" 
+ .PP 
+ \fBacroread\fP(1), \fBgv\fP(1), \fBkpsewhich\fP(1),
--- texlive-bin-2007.dfsg.2.orig/debian/patches/14_etex_takes_buildformat
+++ texlive-bin-2007.dfsg.2/debian/patches/14_etex_takes_buildformat
@@ -0,0 +1,30 @@
+# 14_etex_takes_buildformat
+#
+# Move the BuildFormat call of etex to Packag/etex instead of bin-etex
+# since bin-etex is in collection-basicbin, and etex in collection-basic
+
+@DPATCH@
+--- /data/TeX/texlive/./Master/texmf-dist/tpm/etex.tpm	2005-09-30 15:42:37.000000000 +0200
++++ ./texmf-dist/tpm/etex.tpm	2005-11-22 02:15:26.000000000 +0100
+@@ -38,6 +38,9 @@
+ texmf-dist/doc/etex/base/nts-group.html
+ texmf-dist/doc/etex/base/webmerge.tex
+     </TPM:DocFiles>
++    <TPM:Installation>
++      <TPM:Execute function="BuildFormat" parameter="etex"/>
++    </TPM:Installation>
+     <TPM:Provides>Package/etex</TPM:Provides>
+   </rdf:Description>
+ </rdf:RDF>
+--- /data/TeX/texlive/./Master/texmf/tpm/bin-etex.tpm	2005-11-02 00:53:10.000000000 +0100
++++ ./texmf/tpm/bin-etex.tpm	2005-11-22 02:15:10.000000000 +0100
+@@ -47,9 +47,6 @@
+       <TPM:TLCore name="bin-kpathsea"/>
+       <TPM:TLCore name="lib-texmfmp"/>
+     </TPM:Requires>
+-    <TPM:Installation>
+-      <TPM:Execute function="BuildFormat" parameter="etex"/>
+-    </TPM:Installation>
+     <TPM:Provides>TLCore/bin-etex</TPM:Provides>
+   </rdf:Description>
+ </rdf:RDF>
--- texlive-bin-2007.dfsg.2.orig/debian/patches/a2ping-upstream-fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/a2ping-upstream-fixes
@@ -0,0 +1,833 @@
+a2ping-upstream-fixes
+include fixes made by upstream:
+2007/03/07 (Péter Szabó and Frank Küster)
+
+* various improvements for tetex2 and tetex3 compatibility
+* various other improvements
+* POD documentation enhancements (font embedding tricks) by Frank Küster
+---
+ build/source/texk/tetex/a2ping |  446 ++++++++++++++++++++++++++++++++---------
+ 1 file changed, 358 insertions(+), 88 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/a2ping
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/a2ping	2007-06-29 08:05:33.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/a2ping	2007-06-29 08:06:09.000000000 +0200
+@@ -10,6 +10,29 @@
+ # This program is free software, licensed under the GNU GPL, >=2.0.
+ # This software comes with absolutely NO WARRANTY. Use at your own risk!
+ #
++# !! Imp: merge back to a2ping.pa
++# !! Ghostcript compute pipe too slow
++#      $ a2ping.pl -v debrecen-hyph.ps de                                                                                                                                   brecen-hyph.pdf
++#      a2ping.pl 2.77p, 2004-04-28 -- Written by <pts@fazekas.hu> from April 2003.
++#      This is free software, GNU GPL >=2.0. There is NO WARRANTY.
++#      (epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.)
++#      * Strongest BoundingBox comment: %%HiResBoundingBox:
++#      * Doing --PaperSize unchanged
++#      * Output filename: debrecen-hyph.pdf
++#      * Output FileFormat: PDF
++#      * Ghostscript ps2pdf command: gs -dSAFER  
++#      * Compression: zip
++#      * Input filename: debrecen-hyph.ps
++#      * Computing BBox info from non-EPS PS file
++#      * Ghostscript compute pipe: gs -dSAFER -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox                                                                                                                                    -sFN=debrecen-hyph.ps /tmp/a2ping_pl-16977-298938572-c.tgs 2>&1
++#      * Applying BoundingBox from Compute-GS T-: 71 81 539 769
++#      * Applying HiResBoundingBox from Compute-GS T-H: 71.837998 81.971997 538.235984                                                                                                                                    768.113977
++#      * Scanning header for BoundingBox
++#      * Applying BoundingBox from ADSC T-: 0 0 596 842
++#      * Final BoundingBox: 0 0 596 842
++#      * Ghostscript ps2pdf pipe: gs -dSAFER -q -dBATCH -sDEVICE=pdfwrite  -sOutputFile                                                                                                                                   =debrecen-hyph.pdf -
++#      * Done OK, created PDF file debrecen-hyph.pdf (338451 bytes)
++#
+ package just; BEGIN{$INC{'just.pm'}='just.pm'}
+ BEGIN{ $just::VERSION=2 }
+ sub end(){1}
+@@ -329,8 +352,9 @@
+ use strict;
+ use integer;
+ use Htex::papers;
+-BEGIN { $Htex::a2ping::VERSION="2.77p" }
++BEGIN { $Htex::a2ping::VERSION="2.78p" }
+ 
++# Imp: option to ignore `%%Orientation: Portrait', which gs respects and rotates by 90 degrees if necessary
+ # Imp: gs(704?!) sometimes finds too small bbox, see Univers.eps
+ # Imp: respect bbox in METAPOST %! (not EPS), don't use Compute-GS T-
+ # Imp: -sPDFPassword=...
+@@ -377,7 +401,7 @@
+ 
+ ### program identification
+ my $program = "a2ping.pl";
+-my $filedate="2004-04-28"; # my $filedate="2001/03/05";
++my $filedate="2007-03-07"; # my $filedate="2001/03/05";
+ my $copyright = "Written by <pts\@fazekas.hu> from April 2003.
+ This is free software, GNU GPL >=2.0. There is NO WARRANTY.
+ (epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.)\n";
+@@ -420,7 +444,7 @@
+ }
+ END { unlink keys %tmpfiles; }
+ sub temp_unlink($) {
+-  if (exists $tmpfiles{$_[0]}) {
++  if (defined $_[0] and exists $tmpfiles{$_[0]}) {
+     unlink $_[0] if $tmpunlink_p;
+     delete $tmpfiles{$_[0]};
+   }
+@@ -436,19 +460,18 @@
+ }
+ 
+ #** @return arg rounded down to int
+-sub floor($) {
++sub myfloor($) {
+   # Dat: Perl int() rounds towards zero
+   no integer;
+-  $_[0] < 0 ? -int(-$_[0]) : int($_[0])
++  $_[0]==int($_[0]) ? $_[0] : $_[0] < 0 ? -int(1-$_[0]) : int($_[0])
+ }
+ 
+ #** @return arg rounded up to int
+-sub ceil($) {
+-  no integer;
+-  $_[0]==int($_[0]) ? $_[0] : 1+ ($_[0] < 0 ? -int(-$_[0]) : int($_[0]))
++sub myceil($) {
++  no integer; #### BUGFIX at Wed Nov 15 17:23:29 CET 2006
++  $_[0]==int($_[0]) ? $_[0] : 1+ ($_[0] < 0 ? -int(-$_[0]) : int($_[0]));
+ }
+ 
+-
+ just::main;
+ 
+ # ---
+@@ -460,8 +483,8 @@
+ sub FL_SAMPLED(){16} # is it a sampled (raster, pixel-based)
+ sub FL_ANY_ORIGIN_OK(){32} # (llx,lly) may be anything, not just (0,0)
+ sub FL_HAS_ANTIALIAS(){64}
+-sub FL_VIA_SAM2P(){128} # sam2p(1) can convert PNM to such a format
+-sub FL_OK_SAM2P(){256}
++sub FL_VIA_SAM2P(){128} # sam2p(1) should convert PNM to such a format
++sub FL_OK_SAM2P(){256} # sam2p(1) can convert PNM to such a format
+ 
+ my %fmts=( # Name=>[flags]
+   'EPS'=>[FL_PAGE1_STOP],
+@@ -511,6 +534,8 @@
+ --(no)below     allow below+left_from baseline    (def: no)
+ --(no)tmpunlink unlink temporary files            (def: yes)
+ --(no)antialias render shades at outlines (def: scale3no) (=scale3yes =no =yes)
++--(no)lossy     allow lossy image filters (EPS->PDF) (def: yes)
++--(no)keepoldmediabox keep only old, [0 0]-based MediaBox in PDF (def: no)
+ --gs-cmd=       path to Ghostscript               (def: gs or gswin32c)
+ --gs-ccmd=      path to Ghostscript, 4 bbox calc  (def: gs or gswin32c)
+ --gsextra=      extra arg to gs
+@@ -547,6 +572,8 @@
+ # $::opt_filter=0; # deprecated
+ # $::opt_outputfile=undef; # deprecated
+ $::opt_below=undef;
++$::opt_keepoldmediabox=0;
++$::opt_lossy=1;
+ $::opt_antialias=undef; # render shades at path outlines for better readability
+ $::opt_gs_cmd=undef;
+ $::opt_extra="";
+@@ -634,7 +661,7 @@
+   my %argnone=qw(help 1 verbose 1 noverbose 1 nocompress 1 noantialias 1); # 0 arg
+   my %argmaybe=qw();  # 0 or 1 arg
+   my %argbool=qw(hires 1 exact 1 below 1 gs 1 filter 1 tmpunlink 1
+-    approx 1); # boolean arg
++    approx 1 lossy 1 keepoldmediabox 1); # boolean arg
+   # Dat: --noverbose --nocompress
+   my $opts_ok=1;
+   for ($I=0; $I<@ARGV; $I++) {
+@@ -693,6 +720,8 @@
+     elsif ($optname eq "hires")  { $::opt_hires =$optval }
+     elsif ($optname eq "exact")  { $::opt_exact =$optval }
+     elsif ($optname eq "below")  { $::opt_below =$optval }
++    elsif ($optname eq "keepoldmediabox")  { $::opt_keepoldmediabox=$optval }
++    elsif ($optname eq "lossy")  { $::opt_lossy =$optval }
+     elsif ($optname eq "approx") { $::opt_approx=$optval }
+     elsif ($optname eq "threshold")  { $::opt_threshold=$optval+0 } # Imp: accept only int 0..256
+     elsif ($optname eq "filter") {
+@@ -750,8 +779,9 @@
+ $GS=$::opt_gs_cmd if defined $::opt_gs_cmd;
+ my $CGS=$GS;
+ $CGS=$::opt_gs_ccmd if defined $::opt_gs_ccmd;
+-$GS.= " -dSAFER"; # -dWRITESYSTEMDICT
+-$CGS.=" -dSAFER"; # -dWRITESYSTEMDICT
++# vvv SUXX: (r) file doesn't work with gs 8.5x -DSAFER
++#$GS.= " -dSAFER"; # -dWRITESYSTEMDICT
++#$CGS.=" -dSAFER"; # -dWRITESYSTEMDICT
+ 
+ ### get input and output filename
+ if (!defined $InputFilename and defined $OutputFilename) { # --filter
+@@ -863,6 +893,7 @@
+ 
+ #**** pts ****
+ sub read_error() { error "read $InputFilename: $!" }
++my $in_mac_p=0; # 0: "\n" or "\r\n" is line terminator; 1: "\r" is line terminator
+ my $bytes_left=-1; # -1==unlimited
+ my $already_read=0;
+ sub dem1($){defined$_[0]?$_[0]:-1}
+@@ -875,7 +906,10 @@
+   if (defined $_[0]) { read_error if 0>dem1 read IN, $S, $_[0] }
+   else {
+     $!=0; # clean up error code
+-    $S=<IN>;
++    if ($in_mac_p) {
++      local $/="\r";
++      $S=~s@\r\Z(?!\n)@\n@ if defined($S=<IN>);
++    } else { $S=<IN> }
+     read_error if !defined($S) and $!;
+     $S="" if !defined $S; # EOF
+   }
+@@ -1005,6 +1039,81 @@
+ }
+ binmode IN;
+ 
++#** Dat: uses $FileFormat, $InputFileName, $OutputFileName
++#** @param $S prepend to pipe
++sub run_sam2p($$) {
++  my($approx_p,$S)=@_;
++  # Imp: why isn't sam2p(1) PNG -> PNG idempotent?
++  my $tfmt=$FileFormat eq'markedEPS' || $FileFormat eq 'EPS' ? 'EPS'
++         : $FileFormat eq'markedPS' || $FileFormat eq 'PS' ? 'PS' # Dat: emits no /PageSize
++         : $FileFormat eq'PDF1' || $FileFormat eq 'PDF' ? 'PDF'
++         : undef;
++  if (defined $tfmt) {}
++  elsif (is_via_sam2p() or is_ok_sam2p()) {$tfmt=$FileFormat; $::opt_approx=1}
++  else { error "sam2p doesn't support our FileFormat $FileFormat" }
++  fix_pipe_in ".img", $S, 0;
++  if ($approx_p) {
++    if ($tfmt eq 'GIF') {
++      # Dat: reduce palette to 8-bit if necessary
++      my @args=('sam2p',@extra,"$tfmt:",'--',$InputFilename,$OutputFilename);
++      debug "Running: @args";
++      my $cmd=join('  ',map{fnq$_}@args)." 2>&1";
++      my $res=readpipe($cmd);
++      if ($res=~/\binvalid combination, no applicable OutputRule\b/) {
++        # Dat: reduce palette to 8-bit
++        #die "NOR";
++        my $have_convert_p;
++        my $have_pnmquant_p=0;
++        for my $dir (split/:/,$ENV{PATH}) {
++          if ((-f"$dir/pnmquant")) { $have_pnmquant_p=1 }
++        }
++        if (!$have_pnmquant_p) {
++          $have_convert_p=0;
++          for my $dir (split/:/,$ENV{PATH}) {
++            if ((-f"$dir/convert")) { $have_convert_p=1 }
++          }
++        }
++        my $cmd;
++        if ($have_pnmquant_p) {
++          my @args1=('sam2p','PPM:','--',$InputFilename,'-');
++          my @args2=('sam2p',@extra,"$tfmt:",'--','-',$OutputFilename);
++          $cmd=join('  ',map{fnq$_}@args1)." | pnmquant 256 | ".
++                  join('  ',map{fnq$_}@args2);
++        } elsif ($have_convert_p) {
++          my @args1=('sam2p','PPM:','--',$InputFilename,'-');
++          my @args2=('sam2p',@extra,"$tfmt:",'--','-',$OutputFilename);
++          # vvv Dat: `convert - GIF:-' does quantize (and emits GIF)
++          $cmd=join('  ',map{fnq$_}@args1)." | convert - GIF:- | ".
++                  join('  ',map{fnq$_}@args2);
++        }
++        debug "Running pipe: $cmd";
++        exec($cmd);
++      } elsif ($? !=0) { die $res }
++      # die $cmd;
++      #debug "Running: $progname  @extra @_";
++      #error "prog $progname failed: $? $!"
++      #if 0!=system $progname, @extra, @_; # Dat: non-zero exit() or not found
++    }
++    do_exec('sam2p', ("$tfmt:", '--', $InputFilename, $OutputFilename));
++  } else {
++    warning "post-processing of sam2p PDF output increases file size" if $tfmt eq 'PDF';
++    $tfmt='EPS' if $tfmt eq 'PDF'; # Imp: PDF1<->PDF
++    close IN;
++    my $tpfn=temp_prefix()."Psimg";
++    error "Cannot open temp pipe dest: $tpfn" unless open TP, "> $tpfn";
++    $tmpfiles{$tpfn}=1;
++    die unless close TP;
++    do_system('sam2p', ("$tfmt:", '--', $InputFilename, $tpfn));
++    error "Cannot open temp pipe src: $tpfn" unless open IN, "< $tpfn";
++    $already_read=0; $bytes_left=-1;
++    $InputFilename=$tpfn; # '-'
++    goto SCAN_AGAIN
++  }
++}
++
++#** Force this value for %%HiResBoundingBox if a %BoundingBox is read
++my $force_hiresbbox_value;
++
+ ### scan first line, check for DOS EPSF (and remove DOS headers)
+ my $header;
+ { SCAN_AGAIN:
+@@ -1049,44 +1158,37 @@
+     $S.=readIN;
+     $S=substr($S,1);
+     error "$InputFilename: bad HP PJL UEL header: ".(~chomp($S)&&$S)
+-      if $S!~/\A%-12345X\@PJL ENTER LANGUAGE\s*=\s*POSTSCRIPT\s*\r?$/i;
++      if $S!~/\A\\e?%-12345X\@PJL ENTER LANGUAGE\s*=\s*POSTSCRIPT\s*\r?$/i;
+     1 while length($S=readIN())!=0 and substr($S,0,4)ne'%!PS';
+     die "$InputFilename: premature HP PJL UEL header" if length($S)==0;
+   } elsif ($iff eq "P") {
+     # no-op yet, see later
+   } elsif ($iff eq "?") {
+     error "unknown input image format: $InputFilename";
+-  } else { # some vector graphics format
+-    # Imp: why isn't sam2p(1) PNG -> PNG idempotent?
+-    my $sfmt=$FileFormat eq'markedEPS' || $FileFormat eq 'EPS' ? 'EPS'
+-           : $FileFormat eq'markedPS' || $FileFormat eq 'PS' ? 'PS' # Dat: emits no /PageSize
+-           : $FileFormat eq'PDF1' || $FileFormat eq 'PDF' ? 'PDF'
+-           : undef;
+-    if (defined $sfmt) {}
+-    elsif (is_via_sam2p() or is_ok_sam2p()) {$sfmt=$FileFormat; $::opt_approx=1}
+-    else { error "sam2p doesn't support our FileFormat $FileFormat" }
+-    fix_pipe_in ".img", $S, 0;
+-    if ($::opt_approx) {
+-      do_exec('sam2p', ("$sfmt:", '--', $InputFilename, $OutputFilename));
+-    } else {
+-      warning "post-processing of sam2p PDF output increases file size" if $sfmt eq 'PDF';
+-      $sfmt='EPS' if $sfmt eq 'PDF'; # Imp: PDF1<->PDF
+-      close IN;
+-      my $tpfn=temp_prefix()."Psimg";
+-      error "Cannot open temp pipe dest: $tpfn" unless open TP, "> $tpfn";
+-      $tmpfiles{$tpfn}=1;
+-      die unless close TP;
+-      do_system('sam2p', ("$sfmt:", '--', $InputFilename, $tpfn));
+-      error "Cannot open temp pipe src: $tpfn" unless open IN, "< $tpfn";
+-      $already_read=0; $bytes_left=-1;
+-      $InputFilename=$tpfn; # '-'
+-      goto SCAN_AGAIN
+-    }
++  } else { # source file is in some raster graphics format
++    run_sam2p($::opt_approx,$S);
++    goto SCAN_AGAIN
+   }
+ 
+   # now deal with PS, EPS and PDF
+   if (substr($S,0,1) eq '%') {
+-    $S.=readIN;
++    { my $max=128;
++      my $C;
++      while (length($S)<$max and defined($C=readIN(1)) and
++       $C ne "\n" and $C ne "\r") { $S.=$C }
++      error "couldn't find end of PS/PDF header line in $max bytes\n" if
++        length($S)>=$max or !defined($C);
++      $C=($C eq "\r") ? readIN(1) : "NONE";
++      if (!defined$C or ($C ne "\n" and $C ne "NONE")) {
++        use IO::Handle; # Dat: needed for ungetc
++	IN->ungetc(ord($C)) if defined $C;
++        debug "MAC \\r detected";
++        $in_mac_p=1;
++      } elsif ($C eq "\n") { # Dat: \r\n, DOS CRLF
++        $in_mac_p=0; $S.="\r";
++      } else { $in_mac_p=0 }
++      $S.="\n";
++    } # $S.=readIN;
+     if (substr($S,0,4)eq'%PDF') {
+       # error "$InputFilename: won't read a PDF file";
+       if ($FileFormat eq 'PDF') { # convert PDF to PDF
+@@ -1147,21 +1249,34 @@
+         error "closing PIPE: $?" unless close PIPE;
+         error "BoundingBox not found in pdftops output" if !@L;
+         debug "Got PaperSize: @L";
+-        $L[0]=ceil $L[0]; $L[1]=ceil $L[1]; # Dat: pdftops expects integer papersize :-( )
++
++	# vvv Dat: pdftops without -eps doesn't report HiResBoundingBox,
++	#     so we force it here
++	# at Wed Nov 15 17:19:23 CET 2006
++	$::opt_bboxfrom='adsc' if $::opt_bboxfrom eq 'guess';
++	$force_hiresbbox_value="0 0 @L";
++	
++        #die defined $L[1];
++        $L[0]=myceil $L[0]; $L[1]=myceil $L[1]; # Dat: pdftops expects integer papersize :-( )
+ 	if ($::opt_approx) {
+-          do_exec 'pdftops', '-paperw', $L[0], '-paperh', $L[1], $InputFilename, $OutputFilename;
++	  # vvv Dat: even pdftops 3.01 accepts only integer for -paperw and paperh
++          do_exec 'pdftops', '-paperw', myfloor($L[0]+0.5), '-paperh', myfloor($L[1]+0.5), $InputFilename, $OutputFilename;
+ 	} else {
+ 	  my $tpfn=temp_prefix()."Pps";
+ 	  error "Cannot open temp pipe dest: $tpfn" unless open TP, "> $tpfn";
+ 	  $tmpfiles{$tpfn}=1;
+ 	  die unless close TP;
+-          do_system 'pdftops', '-paperw', $L[0], '-paperh', $L[1], $InputFilename, $tpfn;
++          do_system 'pdftops', '-paperw', myfloor($L[0]+0.5), '-paperh', myfloor($L[1]+0.5), $InputFilename, $tpfn;
+ 	  error "Cannot open temp pipe src: $tpfn" unless open IN, "< $tpfn";
+ 	  $already_read=0; $bytes_left=-1;
+ 	  $InputFilename=$tpfn; # '-'
+ 	  goto SCAN_AGAIN
+ 	}
++      } elsif (is_ok_sam2p() or is_via_sam2p()) {
++        # Dat: PDF to GIF conversion
++        run_sam2p(1,$S);
+       }
++      
+       error "cannot create from PDF: FileFormat $FileFormat";
+      OK:
+     }
+@@ -1211,11 +1326,11 @@
+     ($px,$py)=($1+0,$2+0) if $after_correct=~m@/PageSize\s*\[(\S+)\s+(\S+)+\]@;
+     my @paper=Htex::papers::any("$px,$py");
+     $paper[0]=defined $paper[0] ? "%%DocumentPaperSizes: $paper[0]\n" : "";
+-    $bbx.="%%BoundingBox: ".floor($llx)." ".floor($lly)." ".
+-                             ceil($urx)." ". ceil($ury)."\n";
++    $bbx.="%%BoundingBox: ".myfloor($llx)." ".myfloor($lly)." ".
++                             myceil($urx)." ". myceil($ury)."\n";
+     $bbx.="%%HiResBoundingBox: $llx $lly $urx $ury\n".
+-          "%%ExactBoundingBox: $llx $lly $urx $ury\n" if floor($llx)!=$llx
+-      or floor($lly)!=$lly or ceil($urx)!=$urx or ceil($ury)!=$ury;
++          "%%ExactBoundingBox: $llx $lly $urx $ury\n" if myfloor($llx)!=$llx
++      or myfloor($lly)!=$lly or myceil($urx)!=$urx or myceil($ury)!=$ury;
+     $bbx.="%%DocumentMedia: plain $px $py 0 () ()\n". # like pdftops(1)
+           "$paper[0]";
+     # ^^^ Imp: can DocumentMedia be non-integer? As of us, it can.
+@@ -1250,10 +1365,10 @@
+     }
+     my $new_bbox="$llx $lly $urx $ury";
+     if ($old_bbox eq $new_bbox) {
+-      debug "Final BoundingBox: $new_bbox";
++      debug "Final (HiRes)BoundingBox: $new_bbox";
+     } else {
+-      debug "Old BoundingBox: $old_bbox";
+-      debug "Final corrected BoundingBox: $new_bbox";
++      debug "Old (HiRes)BoundingBox: $old_bbox";
++      debug "Final corrected (HiRes)BoundingBox: $new_bbox";
+     }
+     $pagedev_mark="/pdfmark where{pop}{/pdfmark/cleartomark load def}ifelse\n$pagedev_mark"
+       if length($pagedev_mark)!=0;
+@@ -1263,27 +1378,42 @@
+   #      recompress the images already compressed in the EPS file, but keep
+   #      them in their original, compressed form. So we rather instruct GS to
+   #      recompress
++  # !! Dat: /CompatibilityLevel 1.3 %PDF-1.2 -- Dat: 1.2 won't embed Courier
+   my $markpagedevices="";
++  my $imagesopts=($::opt_lossy ? "
++/AutoFilterMonoImages true
++/AutoFilterGrayImages true
++/AutoFilterColorImages true
++/MonoImageFilter /CCITTFaxEncode                                              
++/GrayImageFilter /DCTEncode
++/ColorImageFilter /DCTEncode
++" : "
++/AutoFilterMonoImages false
++/AutoFilterGrayImages false
++/AutoFilterColorImages false
++/MonoImageFilter /LZWEncode
++/GrayImageFilter /LZWEncode
++/ColorImageFilter /LZWEncode
++"); # Dat: assumes new, patent-free LZW
+   if (is_pdfmark()) {
++    # Dat: CompatibilityLevel 1.3 is required for font embedding & all /FlateDecode
+     $markpagedevices="
+-/CompatibilityLevel 1.2 %PDF-1.2
++/CompatibilityLevel 1.3 %PDF-1.3
+ /EmbedAllFonts true
+ /Optimize true % ignored by gs-6.70
+ /AutoRotatePages /None
+ /UseFlateCompression ".($::opt_compression ne 'none'?"true":"false")."
+ /AutoPositionEPSFiles false
+-/AutoFilterGrayImages false
+ /ConvertImagesToIndexed false
+ /DownsampleMonoImages false
+ /DownsampleGrayImages false
+ /DownsampleColorImages false
+-/AutoFilterColorImages false
+ /EncodeMonoImages true
+ /EncodeGrayImages true
+ /EncodeColorImages true
+ /AntiAliasMonoImages false
+ /AntiAliasGrayImages false
+-/AntiAliasColorImages false\n";
++/AntiAliasColorImages false\n$imagesopts";
+     $markpagedevices=(length($markpagedevices)!=0 ? "<< $markpagedevices >> setpagedevice\n" : "");
+     $markpagedevices.="1 dict dup /ImagingBBox null put setpagedevice\n";
+     $markpagedevices.="1 dict dup /Policies 1 dict dup /PageSize 3 put put setpagedevice\n"; # ripped from pdftops(1)
+@@ -1298,7 +1428,7 @@
+     # Dat: true for FileFormat PGM
+     # Dat: emit /PageSize even for PDF1
+     # Dat: Ghostscript 6.70 rounds /PageSize down, but we need up when creating /MediaBox for PDF
+-    $setpagesize="2 dict dup /PageSize [".ceil($urx)." ".ceil($ury)."] put setpagedevice\n";
++    $setpagesize="2 dict dup /PageSize [".myceil($urx)." ".myceil($ury)."] put setpagedevice\n";
+     # ^^^ Dat: PLRM.pdf doesn't forbid a non-integer /PageSize
+   }
+   my $bsetup=is_page1_stop()?"":"%%BeginSetup\n%%EndSetup\n";
+@@ -1310,7 +1440,20 @@
+   #     %%BeginSetup..%%EndSetup pair just before our code doing
+   #     `setpagedevice'.
+   # !! ?? run pstops first, and then a2ping.pl
+-  my $save=$is_restored?"save\n":"";
++  # !! why does a PDF -> PS conversion need $is_restored?
++  # vvv Dat: `mark' is necessary, because pstops 1.17 from xpdf(1) emits lines
++  #     lines leaving `false' on the stack:
++  #     %%BeginResource: font SKPOPP+LMRoman12-Regular
++  #     %!PS-AdobeFont-1.0: LMRoman12-Regular 0.86
++  #     %%CreationDate: 4th August (Monday) 2003
++  #     % Generated by MetaType1 (a MetaPost-based engine)
++  #     % CM sources: copyright (C) 1997 AMS, all rights reserved; METATYPE1/Type 1 ver
++  #     % ADL: 694 194 112
++  #     %%EndComments
++  #     FontDirectory/LMRoman12-Regular known{/LMRoman12-Regular findfont dup/UniqueID
++  #     /UniqueID get 0 eq exch/FontType get 1 eq and}{pop false}ifelse
++  #     {save true}{false}ifelse}{false}ifelse
++  my $save=$is_restored?"save mark\n":"";
+   $bbx.$fontsdefs."%%EndComments\n".$bsetup.$setpagesize.$markpagedevices.$pagedev_mark.$after_correct.$save.$translate
+ }
+ 
+@@ -1532,9 +1675,9 @@
+       ## die $res;
+       temp_unlink $tfn;
+       ## print STDERR $res;
+-      error "not a GS output from $GS"
++      error $?==11 ? "segmentation fault in $GS" : "not a GS output from $GS ($?)"
+         if !defined $res # BUGFIX at Sun Mar  7 18:51:34 CET 2004
+-        or $res!~s/\A\w+ Ghostscript \d.*\n// # AFPL Ghostscript 6.50 (2000-12-02)
++        or $res!~s/\A(?:\w+ Ghostscript \d|Copyright .* artofcode ).*\n// # AFPL Ghostscript 6.50 (2000-12-02)
+         or $res!~s/.*?^bbox-begin\n//m;
+       if ($res!~s/\nbbox-success\n\Z(?!\n)/\n/) {
+         warning # not `error', mpost(1) `prologues:=0; ... btex fonts' output won't compile 
+@@ -1587,6 +1730,7 @@
+         elsif ($line=~/^sides-dumplex==false$/) { $duplexi=2 }
+         elsif ($line=~/^sides-tumble==true$/) { $tumblei=1 }
+         elsif ($line=~/^sides-tumble==false$/) { $tumblei=2 }
++        elsif ($line=~/^add-showpage==\d+$/) { } # !!
+         elsif (length($line)==0 or $line=~/^(?:Copyright |This software )/) {}
+         elsif ($line=~/^Loading (\S+) font from.*[.][.][.]/) { debug "GS builtin font used: $1" }
+         else { debug "unknown line ($line)" }
+@@ -1619,7 +1763,7 @@
+         die if is_page1_stop();
+         # vvv ($llx,$lly,$urx,$ury)=(0,0,$papersize_x,$papersize_y);
+         # $do_bb_line->("set 0 0 $papersize_x $papersize_y"," from /PageSize");
+-        $after_correct.="1 dict dup /PageSize [".ceil($papersize_x)." ".ceil($papersize_y)."] put setpagedevice\n";
++        $after_correct.="1 dict dup /PageSize [".myceil($papersize_x)." ".myceil($papersize_y)."] put setpagedevice\n";
+         # ^^^ Dat: both PS and markedPS would benefit from /PaperSize
+         # ^^^ Dat: will be put after CorrectBoundingBox
+         # Dat: unneeded: $allow_adsc_bb=0 if $FileFormat eq 'PDF'; # force this into /CropBox (otherwise only /MediaBox)
+@@ -1655,8 +1799,11 @@
+         }
+       }
+       # vvv Dat: save...restore is _always_ necessary to undo the changes made
+-      #     in the file itself
+-      $is_restored=1; # $after_comments.="save\n"; 
++      #     by the file itself (??)
++      # vvv BUGFIX (only EPS) at Tue Feb  8 21:40:11 CET 2005
++      # vvv Dat: now with PS output it is possible that garbage is left on
++      #     the stack (see the `LMRoman' example above)
++      $is_restored=1 if $FileFormat eq'EPS' or $FileFormat eq'markedEPS';
+       $after_comments.=$undefs; # after our precious setpagedevice calls
+       # debug "pop_count=$pop_count;";
+       # debug "end_count=$end_count;";
+@@ -1696,7 +1843,7 @@
+   my %fontsnames;
+   my @creator;
+   read_again: while (length($_=readIN)) {
+-    ##print STDERR "(($_))\n";
++    #print STDERR "(($_))\n";
+     ### end of header
+     next unless /\S/;
+     y@\r@@d; chomp;
+@@ -1715,8 +1862,9 @@
+         $creator_adobeps_p=1;
+       } elsif (/^%%Creator:\s*MetaPost\b/i) {
+         $creator_metapost_p=1;
+-      } elsif ((substr($_,0,2)ne'%%' and substr($_,0,7)ne'%*Font:')
+-       and substr($_,0,5)ne'%EPS ' # epsincl.mp
++      } elsif ((substr($_,0,2)ne'%%' and substr($_,0,7)ne'%*Font:' and
++       substr($_,0,5)ne'%ADO_' and !/^%AI\d_/ # Dat: %ADO_DSC_..., %AI7_Thumbnail
++       and substr($_,0,5)ne'%EPS ') # epsincl.mp
+        or !$creator_metapost_p and substr($_,0,5)eq'%%End'
+        or /^%%Begin(?:Prolog|Setup)\b/i
+          ) { $after_comments.="$_\n"; last }
+@@ -1741,7 +1889,12 @@
+     } elsif (/^$BBregex$BBValues/oi) { ### BoundingBox with values
+       s@($BBregex)\s*1\s+1\s+@$1 0 0 @ if $creator_adobeps_p;
+       # vvv $bbtype may be possibly already set by compute-gs
+-      $do_bb_line->($_," from ADSC") if $allow_adsc_bb;
++      if ($allow_adsc_bb) {
++        $do_bb_line->($_," from ADSC");
++	if ($force_hiresbbox_value) {
++	  $do_bb_line->("%%HiResBoundingBox: $force_hiresbbox_value"," from ADSC");
++	}
++      }
+     } elsif (/^$BBregex\s*\(atend\)/oi) {
+       ### BoundingBox with (atend)
+       debug "At end $1BoundingBox";
+@@ -1750,6 +1903,8 @@
+       $do_atend=1
+     } elsif (/^%%Page:/i and !$creator_metapost_p) { # at Thu Sep 25 15:59:52 CEST 2003
+       $after_comments.="$_\n"; last
++    } elsif (/^%(?:ADO_DSC_|AI\d_)/) { # Dat: example: %ADO_DSC_Encoding: MacOS Roman
++      $to_OUT.="%$_\n";
+     } elsif (/^%\*Font:\s+(\S+)\s+/) { # mpost(1) output
+       ## debug $_;
+       $fontsdefs.="$_\n"; # put in front (before `gsave ... translate')
+@@ -1884,7 +2039,7 @@
+ # vvv Dat: $after_code is pop+end
+ print OUT "\n$extra_trailer$after_code",
+   ("grestore\n"x$need_grestore),
+-  ("restore\n"x$is_restored),
++  ("cleartomark restore\n"x$is_restored),
+   "%%EOF\n";
+ error "closing gs filter: $? $!" unless close OUT;
+ 
+@@ -1939,6 +2094,7 @@
+   my $tfn=temp_prefix()."p.tgs";
+   error "temp open $tfn: $!" unless open F, "> $tfn";
+   $tmpfiles{$tfn}=1;
++  # vvv Dat: doesn't work with gs 8.53: Error: /undefined in readxrefentry
+   die unless print F "% this is temporary gs command file created by $program".'
+   GS_PDF_ProcSet begin
+   pdfdict begin
+@@ -1949,7 +2105,10 @@
+   % vvv Dat: modifies Objects[0]
+   1 pdffindpageref 0 get
+   Objects 0 OFT put
+-  readxrefentry ===
++  %===
++  %print_xref
++  { readxrefentry } stopped { Objects exch lget } if
++  ===
+   currentdict pdfclose end end end
+   ';
+   die unless close F;
+@@ -1957,6 +2116,7 @@
+   my $gs2="$GS -dNODISPLAY -dBATCH -sFN=".fnq(fix_pipe_out(undef))." -q ".fnq($tfn);
+   debug "Ghostscript dup pipe: $gs2";
+   my $offset=`$gs2`;
++  #die $offset;
+   chomp $offset;
+   temp_unlink $tfn;
+   if ($offset=~/\A\d+\Z(?!\n)/) {
+@@ -1966,14 +2126,26 @@
+     die unless seek F, $offset+=0, 0;
+     my $pageobj;
+     die unless 32<read F, $pageobj, 4096;
+-    if ($pageobj=~m@\A(.*?/Type\s*/Page\b.*?)(/MediaBox\s*\[0 0 [^\]]*\]).*?/MediaBox\b@s) {
+-      substr($pageobj, length($1), length($2))=" "x length($2);
+-      # ^^^ overwrite first buggy /MediaBox definition with spaces
+-      die unless seek F, $offset, 0;
+-      die unless print F $pageobj;
+-      debug "old /MediaBox destroyed.";
++    if ($::opt_keepoldmediabox) {
++      if ($pageobj=~m@\A(.*?/Type\s*/Page\b.*?/MediaBox\s*\[0 0 [^\]]*\].*?)((?:/CropBox\s*\[[^\]]+\]\s*)?/MediaBox\s*\[[^\]]+\])@s) {
++	substr($pageobj, length($1), length($2))=" "x length($2);
++	# ^^^ overwrite first buggy /MediaBox definition with spaces
++	die unless seek F, $offset, 0;
++	die unless print F $pageobj;
++	debug "new /MediaBox destroyed.";
++      } else {
++	debug "warning: double /MediaBox not found at $offset";
++      }
+     } else {
+-      debug "warning: double /MediaBox not found at $offset";
++      if ($pageobj=~m@\A(.*?/Type\s*/Page\b.*?)(/MediaBox\s*\[0 0 [^\]]*\]).*?/MediaBox\b@s) {
++	substr($pageobj, length($1), length($2))=" "x length($2);
++	# ^^^ overwrite first buggy /MediaBox definition with spaces
++	die unless seek F, $offset, 0;
++	die unless print F $pageobj;
++	debug "old /MediaBox destroyed.";
++      } else {
++	debug "warning: double /MediaBox not found at $offset";
++      }
+     }
+     die unless close F;
+   } else {
+@@ -2091,8 +2263,9 @@
+ if (@pnm2sampled_cmd) { # $scale3_pnm_fn -> $OutputFilename
+   do_system @pnm2sampled_cmd; # Dat: uses @extra -- really share that?
+   temp_unlink $scale3_pnm_fn;
++} else { # BUGFIX for `a2ping.pl -v --antialias=no negyzet.eps negyzet.png' at Wed Jul 20 21:34:29 CEST 2005
++  fix_close_out();
+ }
+-fix_close_out();
+ undef $unlink_OutputFilename;
+ if ($OutputFilename eq '-') {
+   debug "Done OK, stdout is $FileFormat"
+@@ -2187,14 +2360,97 @@
+ PNM output formats are PGM, PGM and PPM. To write PNM output formats, GS
+ is used.
+ 
++=head1 OPTIONS
+ 
+-=head1 TIPS AND TRICKS
++=head2 General Options
+ 
+ =over 2
+ 
+-=item *
++=item B<-h>, B<--help>
++
++Show a summary of the usage
++
++=item B<--doc>
++
++Show the man page
++
++=item B<-v>, B<--(no)verbose>
++
++Show progress and debug messages (default: no)
++
++=head2 Options for the Bounding box
++
++=item B<--(no)hires>
++
++Use HiResBoundingBox in the input file, if present (default: yes)
++
++=item B<--(no)exact>
++
++Use ExactBoundingBox in the input file, if present (default: no)
+ 
+-Call with the B<-v> option to see progress and debug messages.
++=item B<--(no)keepoldmediabox>
++
++keep only old, [0 0]-based MediaBox in PDF (default: no)
++
++=item B<--bboxfrom=>I<adsc|compute-gs|guess|pagesize>
++
++Method for determining the BoundingBox  (default: guess)
++
++=item B<--(no)below>
++
++Allow page content below and left of the origin (default: no)
++
++
++=head2 Options for graphics and fonts
++
++=item B<--(no)compress>
++
++use compression                   (default: best)
++
++=item B<--(no)antialias>
++
++render shades at outlines.  Possible values: (=I<scale3yes> =I<no> =I<yes>)  (default: scale3no)
++
++=item B<--(no)lossy>
++
++allow lossy image filters (EPS->PDF) (default: yes)
++
++=item B<--papersize=>I<unchanged|force-unknown|600bpx5cm>
++
++(default: default) (bp)
++
++=item B<--threshold=>
++
++min color for 1 in 8->1 bit conv  (default: 128)
++
++
++=head2 Options for debugging and changing internals
++
++=item B<--(no)tmpunlink>
++
++Unlink temporary files (default: yes).  Use B<--notmpunklink> if you
++want to inspect intermediate files.
++
++=item B<--gs-cmd=>I<path>
++
++path to Ghostscript program (default: gs or gswin32c)
++
++=item B<--gs-ccmd=>I<path>
++
++path to Ghostscript for BoundingBox calculation (default: gs or gswin32c)
++
++=item B<--gsextra=>I<GS_ARGS>
++
++Pass extra arguments to gs
++
++=item B<--extra=>
++
++Pass extra arguments to external program (i.e pdftops)
++
++
++=head1 TIPS AND TRICKS
++
++=over 2
+ 
+ =item *
+ 
+@@ -2260,6 +2516,11 @@
+ is going to be really big, you should specify B<--AntiAlias=yes> instead of
+ the default B<--AntiAlias=scale3no> to speed up conversion.
+ 
++=item * 
++
++To make sure fonts are included in a PDF file generated from eps, use
++B<--gsextra='-dEmbedAllFonts=true -dPDFSETTINGS=/printer'>.
++
+ =back
+ 
+ 
+@@ -2297,7 +2558,7 @@
+ 
+ =head1 AUTHORS
+ 
+-The author of B<a2ping> is Szabó Péter <F<pts@fazekas.hu>>.
++The author of B<a2ping> is Péter Szabó <F<pts@fazekas.hu>>.
+ 
+ B<a2ping> is inspired by and historically based on the B<epstopdf> Perl
+ script modified by Thomas Esser, Sept. 1998, but his modifications have
+@@ -2306,6 +2567,9 @@
+ for Elsevier Science. B<epstopdf> contained extra tricks from Hans Hagen's
+ texutil.
+ 
++B<a2ping> contains contributions from several people, see the HISTORY for
++details. Thank you all for contributing!
++
+ =head1 HISTORY
+ 
+ =head2 1999/05/06 v2.5 (Heiko Oberdiek)
+@@ -2334,7 +2598,7 @@
+  * Newline before grestore for the case that there is no
+    whitespace at the end of the eps file.
+ 
+-=head2 2003/02/02 (Szabó Péter)
++=head2 2003/02/02 (Péter Szabó)
+ 
+  * option --below
+  * removes DOS EPSF binary junk correctly
+@@ -2347,7 +2611,7 @@
+  * can convert PDF to EPS (by calling pdftops(1)) and PDF to PDF
+  * emulates work for PDF input
+ 
+-=head2 2003/04/16 (Szabó Péter)
++=head2 2003/04/16 (Péter Szabó)
+ 
+  * added PS and sam2p support, renamed to a2ping
+  * sam2p and pdftops if $InputFilename eq '-';
+@@ -2357,7 +2621,7 @@
+  * removes ^L (form feed) from end of EPS file
+  * -x=-c:rle to add sam2p options
+ 
+-=head2 2003/04/26 (Szabó Péter)
++=head2 2003/04/26 (Péter Szabó)
+ 
+  * omit the unnecessary setpagedevice calls when creating normal eps
+  * --noverbose --nocompress supported differently
+@@ -2374,7 +2638,7 @@
+    setpagedevice. Precedence for other inputs: --PageSize, setpagedevice,
+    %%*BoundingBox
+ 
+-=head2 2003/09/25 (Szabó Péter)
++=head2 2003/09/25 (Péter Szabó)
+ 
+  * --bboxfrom=adsc: %%BoundingBox overrides -sDEVICE=bbox
+  * improved bbox discovery
+@@ -2384,11 +2648,11 @@
+  * consistent bbox, --PageSize, /PageSize handling
+  * consistent --Resolution and --Duplex handling
+ 
+-=head2 2003/12/02 (Szabó Péter)
++=head2 2003/12/02 (Péter Szabó)
+ 
+  * --bboxfrom=compute-gs option to fix PS -> EPS bbox (gs -sDEVICE=bbox), tuzv.eps
+ 
+-=head2 2004/02/10 v2.77 (Szabó Péter)
++=head2 2004/02/10 v2.77p fixed (Péter Szabó)
+ 
+  * the compute-pipe routine is now run unless --bboxfrom=guess with EPS
+  * added --gsextra=
+@@ -2397,3 +2661,9 @@
+  * separated FileFormat features to FL_* constants
+  * added --doc
+  * there is no default FileFormat (PDF) anymore
++
++=head2 2007/03/07 (Péter Szabó and Frank Küster)
++
++ * various improvements for tetex2 and tetex3 compatibility
++ * various other improvements
++ * POD documentation enhancements (font embedding tricks) by Frank Küster
--- texlive-bin-2007.dfsg.2.orig/debian/patches/tl2007.2-xdvipdfmx-fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/tl2007.2-xdvipdfmx-fixes
@@ -0,0 +1,8165 @@
+---
+ build/source/texk/xdvipdfmx/configure        |    2 
+ build/source/texk/xdvipdfmx/configure.in     |    2 
+ build/source/texk/xdvipdfmx/src/bmpimage.c   |    4 
+ build/source/texk/xdvipdfmx/src/cff_dict.c   |  107 +--
+ build/source/texk/xdvipdfmx/src/cff_dict.h   |    3 
+ build/source/texk/xdvipdfmx/src/cidtype0.c   |   27 
+ build/source/texk/xdvipdfmx/src/cidtype2.c   |    4 
+ build/source/texk/xdvipdfmx/src/dpxfile.c    |    6 
+ build/source/texk/xdvipdfmx/src/dvi.c        |  163 ++++-
+ build/source/texk/xdvipdfmx/src/dvi.h        |    5 
+ build/source/texk/xdvipdfmx/src/dvipdfmx.c   |  143 ++--
+ build/source/texk/xdvipdfmx/src/epdf.c       |  780 ++++++++++++++++++++-------
+ build/source/texk/xdvipdfmx/src/epdf.h       |    4 
+ build/source/texk/xdvipdfmx/src/fontmap.c    |   37 -
+ build/source/texk/xdvipdfmx/src/fontmap.h    |    2 
+ build/source/texk/xdvipdfmx/src/jpegimage.c  |  170 +++++
+ build/source/texk/xdvipdfmx/src/mpost.c      |   24 
+ build/source/texk/xdvipdfmx/src/pdfcolor.c   |  210 +------
+ build/source/texk/xdvipdfmx/src/pdfcolor.h   |   16 
+ build/source/texk/xdvipdfmx/src/pdfdev.c     |  214 ++++++-
+ build/source/texk/xdvipdfmx/src/pdfdev.h     |    9 
+ build/source/texk/xdvipdfmx/src/pdfdoc.c     |   39 -
+ build/source/texk/xdvipdfmx/src/pdfdoc.h     |    5 
+ build/source/texk/xdvipdfmx/src/pdfdraw.c    |  435 ++++++++-------
+ build/source/texk/xdvipdfmx/src/pdfdraw.h    |    7 
+ build/source/texk/xdvipdfmx/src/pdfencrypt.c |   32 -
+ build/source/texk/xdvipdfmx/src/pdfencrypt.h |    9 
+ build/source/texk/xdvipdfmx/src/pdfobj.c     |  537 ++++++++++++------
+ build/source/texk/xdvipdfmx/src/pdfobj.h     |   14 
+ build/source/texk/xdvipdfmx/src/pdfparse.c   |    7 
+ build/source/texk/xdvipdfmx/src/pdfximage.c  |  279 ++++++---
+ build/source/texk/xdvipdfmx/src/pdfximage.h  |   16 
+ build/source/texk/xdvipdfmx/src/pngimage.c   |   15 
+ build/source/texk/xdvipdfmx/src/pst_obj.c    |    6 
+ build/source/texk/xdvipdfmx/src/spc_color.c  |   28 
+ build/source/texk/xdvipdfmx/src/spc_dvips.c  |  578 +++++++++++++++++++-
+ build/source/texk/xdvipdfmx/src/spc_html.c   |    4 
+ build/source/texk/xdvipdfmx/src/spc_misc.c   |    2 
+ build/source/texk/xdvipdfmx/src/spc_pdfm.c   |   83 +-
+ build/source/texk/xdvipdfmx/src/spc_util.c   |   77 +-
+ build/source/texk/xdvipdfmx/src/spc_util.h   |    4 
+ build/source/texk/xdvipdfmx/src/spc_xtx.c    |  148 ++++-
+ build/source/texk/xdvipdfmx/src/spc_xtx.h    |    1 
+ build/source/texk/xdvipdfmx/src/specials.h   |    2 
+ build/source/texk/xdvipdfmx/src/truetype.c   |   44 -
+ build/source/texk/xdvipdfmx/src/tt_aux.c     |   27 
+ build/source/texk/xdvipdfmx/src/tt_aux.h     |    4 
+ build/source/texk/xdvipdfmx/src/tt_cmap.c    |   47 -
+ build/source/texk/xdvipdfmx/src/tt_glyf.c    |   22 
+ build/source/texk/xdvipdfmx/src/tt_post.c    |    9 
+ build/source/texk/xdvipdfmx/src/tt_table.c   |   92 +--
+ build/source/texk/xdvipdfmx/src/tt_table.h   |   20 
+ build/source/texk/xdvipdfmx/src/type1.c      |   18 
+ build/source/texk/xdvipdfmx/src/type1c.c     |    2 
+ build/source/texk/xdvipdfmx/src/vf.c         |    5 
+ 55 files changed, 3191 insertions(+), 1359 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/configure
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/configure	2007-01-07 13:43:13.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/configure	2008-05-28 18:46:46.000000000 +0200
+@@ -1828,7 +1828,7 @@
+ 
+ # Define the identity of the package.
+  PACKAGE=xdvipdfmx
+- VERSION=0.4
++ VERSION=0.6
+ 
+ 
+ cat >>confdefs.h <<_ACEOF
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/configure.in
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/configure.in	2007-01-07 13:43:13.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/configure.in	2008-05-28 18:46:46.000000000 +0200
+@@ -1,6 +1,6 @@
+ dnl Process this file with autoconf to produce a configure script.
+ AC_INIT(src/dvipdfmx.c)
+-AM_INIT_AUTOMAKE(xdvipdfmx, 0.4)
++AM_INIT_AUTOMAKE(xdvipdfmx, 0.6)
+ AM_CONFIG_HEADER(config.h)
+ AM_MAINTAINER_MODE
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/bmpimage.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/bmpimage.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/bmpimage.c	2008-05-28 18:46:46.000000000 +0200
+@@ -145,8 +145,8 @@
+     /* ignore biSizeImage */ p += 4;
+     biXPelsPerMeter = ULONG_LE(p); p += 4;
+     biYPelsPerMeter = ULONG_LE(p); p += 4;
+-    info.xdpi = biXPelsPerMeter * 0.0254; /* convert pixels per meter to DPI */
+-    info.ydpi = biYPelsPerMeter * 0.0254;
++    info.xdensity = 72.0 / (biXPelsPerMeter * 0.0254);
++    info.ydensity = 72.0 / (biYPelsPerMeter * 0.0254);
+     if (info.height < 0) {
+       info.height = -info.height;
+       flip = 0;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cff_dict.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/cff_dict.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cff_dict.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,5 +1,5 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/cff_dict.c,v 1.13 2004/08/26 16:02:26 hirata Exp $
+-    
++/*  $Header: /home/cvsroot/dvipdfmx/src/cff_dict.c,v 1.15 2007/07/05 05:45:06 chofchof Exp $
++
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+     Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
+@@ -301,9 +301,6 @@
+   if (dict_operator[id].opname == NULL || argtype < 0) {
+     *status = CFF_ERROR_PARSE_ERROR;
+     return;
+-  } else if (stack_top < 1) {
+-    *status = CFF_ERROR_STACK_UNDERFLOW;
+-    return;
+   }
+ 
+   if (dict->count >= dict->max) {
+@@ -317,20 +314,30 @@
+       argtype == CFF_TYPE_BOOLEAN ||
+       argtype == CFF_TYPE_SID ||
+       argtype == CFF_TYPE_OFFSET) {
++    /* check for underflow here, as exactly one operand is expected */
++    if (stack_top < 1) {
++      *status = CFF_ERROR_STACK_UNDERFLOW;
++      return;
++    }
+     stack_top--;
+     (dict->entries)[dict->count].count  = 1;
+     (dict->entries)[dict->count].values = NEW(1, double);
+     (dict->entries)[dict->count].values[0] = arg_stack[stack_top];
++    dict->count += 1;
+   } else {
+-    (dict->entries)[dict->count].count  = stack_top;
+-    (dict->entries)[dict->count].values = NEW(stack_top, double);
+-    while (stack_top > 0) {
+-      stack_top--;
+-      (dict->entries)[dict->count].values[stack_top] = arg_stack[stack_top];
++    /* just ignore operator if there were no operands provided;
++       don't treat this as underflow (e.g. StemSnapV in TemporaLGCUni-Italic.otf) */
++    if (stack_top > 0) {
++      (dict->entries)[dict->count].count  = stack_top;
++      (dict->entries)[dict->count].values = NEW(stack_top, double);
++      while (stack_top > 0) {
++        stack_top--;
++        (dict->entries)[dict->count].values[stack_top] = arg_stack[stack_top];
++      }
++      dict->count += 1;
+     }
+   }
+ 
+-  dict->count += 1;
+   *data += 1;
+ 
+   return;
+@@ -430,7 +437,7 @@
+ {
+   long e;
+   int i = 0, pos = 2;
+-#define CFF_REAL_MAX_LEN 17
++  char buffer[32];
+ 
+   if (destlen < 2)
+     ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
+@@ -448,28 +455,19 @@
+     pos++;
+   }
+ 
+-  e = 0;
+-  if (value >= 10.0) {
+-    while (value >= 10.0) {
+-      value /= 10.0;
+-      e++;
+-    }
+-  } else if (value < 1.0) {
+-    while (value < 1.0) {
+-      value *= 10.0;
+-      e--;
+-    }
+-  }
++  /* To avoid the problem with Mac OS X 10.4 Quartz,
++   * change the presion of the real numbers
++   * on June 27, 2007 for musix20.pfb */
++  sprintf(buffer, "%.13g", value);
+ 
+-  sprintf(work_buffer, "%1.14g", value);
+-  for (i=0;i<CFF_REAL_MAX_LEN;i++) {
++  for (i = 0; buffer[i] != '\0'; i++) {
+     unsigned char ch = 0;
+-    if (work_buffer[i] == '\0') {
+-      break;
+-    } else if (work_buffer[i] == '.') {
++    if (buffer[i] == '.') {
+       ch = 0x0a;
+-    } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') {
+-      ch = work_buffer[i] - '0';
++    } else if (buffer[i] >= '0' && buffer[i] <= '9') {
++      ch = buffer[i] - '0';
++    } else if (buffer[i] == 'e') {
++      ch = (buffer[++i] == '-' ? 0x0c : 0x0b);
+     } else {
+       ERROR("%s: Invalid character.", CFF_DEBUG_STR);
+     }
+@@ -485,53 +483,6 @@
+     pos++;
+   }
+ 
+-  if (e > 0) {
+-    if (pos % 2) {
+-      dest[pos/2] += 0x0b;
+-    } else {
+-      if (destlen < pos/2 + 1)
+-	ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
+-      dest[pos/2] = 0xb0;
+-    }
+-    pos++;
+-  } else if (e < 0) {
+-    if (pos % 2) {
+-      dest[pos/2] += 0x0c;
+-    } else {
+-      if (destlen < pos/2 + 1)
+-	ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
+-      dest[pos/2] = 0xc0;
+-    }
+-    e *= -1;
+-    pos++;
+-  }
+-
+-  if (e != 0) {
+-    sprintf(work_buffer, "%ld", e);
+-    for (i=0;i<CFF_REAL_MAX_LEN;i++) {
+-      unsigned char ch = 0;
+-      if (work_buffer[i] == '\0') {
+-	break;
+-      } else if (work_buffer[i] == '.') {
+-	ch = 0x0a;
+-      } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') {
+-	ch = work_buffer[i] - '0';
+-      } else {
+-	ERROR("%s: Invalid character.", CFF_DEBUG_STR);
+-      }
+-
+-      if (destlen < pos/2 + 1)
+-	ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
+-
+-      if (pos % 2) {
+-	dest[pos/2] += ch;
+-      } else {
+-	dest[pos/2] = (ch << 4);
+-      }
+-      pos++;
+-    }
+-  }
+-
+   if (pos % 2) {
+     dest[pos/2] += 0x0f;
+     pos++;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cff_dict.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/cff_dict.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cff_dict.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/cff_dict.h,v 1.6 2004/02/15 12:59:42 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/cff_dict.h,v 1.7 2007/06/30 01:18:13 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -26,7 +26,6 @@
+ #include "cff_types.h"
+ #include "cff.h"
+ 
+-#define CFF_CIDCOUNT_DEFAULT      8720
+ #define CFF_NOMINALWIDTHX_DEFAULT 0.0
+ #define CFF_DEFAULTWIDTHX_DEFAULT 0.0
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cidtype0.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/cidtype0.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cidtype0.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/cidtype0.c,v 1.34 2005/07/17 09:53:37 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/cidtype0.c,v 1.36 2007/06/30 01:18:13 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -182,7 +182,7 @@
+     vhea = tt_read_vhea_table(sfont);
+   if (vhea && sfnt_find_table_pos(sfont, "vmtx") > 0) {
+     sfnt_locate_table(sfont, "vmtx");
+-    vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics);
++    vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings);
+   }
+   /*
+    * OpenType font must have OS/2 table.
+@@ -312,7 +312,7 @@
+   hhea = tt_read_hhea_table(sfont);
+ 
+   sfnt_locate_table(sfont, "hmtx");
+-  hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics);
++  hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings);
+ 
+   add_CIDHMetrics(sfont, fontdict, CIDToGIDMap, last_cid, maxp, head, hmtx);
+   if (need_vmetrics)
+@@ -472,8 +472,8 @@
+   long   size, offset = 0;
+   card8 *data;
+   card16 num_glyphs, gid;
+-  long   cid;
+-  card16 cid_count, cs_count, last_cid;
++  long   cid, cid_count;
++  card16 cs_count, last_cid;
+   int    fd, prev_fd, parent_id;
+   char  *used_chars;
+   unsigned char *CIDToGIDMap = NULL;
+@@ -530,9 +530,9 @@
+     ERROR("Not a CIDFont.");
+ 
+   if (cff_dict_known(cffont->topdict, "CIDCount")) {
+-    cid_count = (card16) cff_dict_get(cffont->topdict, "CIDCount", 0);
++    cid_count = (long) cff_dict_get(cffont->topdict, "CIDCount", 0);
+   } else {
+-    cid_count = CFF_CIDCOUNT_DEFAULT;
++    cid_count = CID_MAX + 1;
+   }
+ 
+   cff_read_charsets(cffont);
+@@ -542,11 +542,6 @@
+   cid = 0; last_cid = 0; num_glyphs = 0;
+   for (cid = 0; cid <= CID_MAX; cid++) {
+     if (is_used_char2(used_chars, cid)) {
+-      if (cid >= cid_count) {
+-	WARN("Glyph for CID %u missing in font \"%s\".", (CID) cid, font->ident);
+-	used_chars[cid/8] &= ~(1 << (7 - (cid % 8)));
+-	continue;
+-      }
+       gid = cff_charsets_lookup(cffont, cid);
+       if (cid != 0 && gid == 0) {
+ 	WARN("Glyph for CID %u missing in font \"%s\".", (CID) cid, font->ident);
+@@ -832,8 +827,8 @@
+ 
+   /* getting font info. from TrueType tables */
+   if ((font->descriptor
+-       = tt_get_fontdesc(sfont, &(opt->embed), 0)) == NULL)
+-    ERROR("Could not obtain neccesary font info.");
++       = tt_get_fontdesc(sfont, &(opt->embed), 0, name)) == NULL)
++    ERROR("Could not obtain necessary font info.");
+ 
+   if (opt->embed) {
+     memmove(fontname + 7, fontname, strlen(fontname) + 1);
+@@ -1244,8 +1239,8 @@
+ 
+   /* getting font info. from TrueType tables */
+   if ((font->descriptor
+-       = tt_get_fontdesc(sfont, &(opt->embed), 0)) == NULL)
+-    ERROR("Could not obtain neccesary font info.");
++       = tt_get_fontdesc(sfont, &(opt->embed), 0, name)) == NULL)
++    ERROR("Could not obtain necessary font info.");
+ 
+   if (opt->embed) {
+     memmove(fontname + 7, fontname, strlen(fontname) + 1);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cidtype2.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/cidtype2.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/cidtype2.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1049,9 +1049,9 @@
+ 	       pdf_new_name("Subtype"),
+ 	       pdf_new_name("CIDFontType2"));
+ 
+-  font->descriptor = tt_get_fontdesc(sfont, &(opt->embed), 0);
++  font->descriptor = tt_get_fontdesc(sfont, &(opt->embed), 0, name);
+   if (!font->descriptor) {
+-    ERROR("Could not obtain neccesary font info.");
++    ERROR("Could not obtain necessary font info.");
+   }
+ 
+   if (opt->embed) {
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dpxfile.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/dpxfile.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dpxfile.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.14 2005/12/18 14:56:47 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.15 2007/03/17 04:48:41 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -520,9 +520,9 @@
+   }
+ #else
+ # if defined(__TDS_VERSION__) && __TDS_VERSION__ >= 0x200406L
+-  fqpn = kpse_find_file(filename, kpse_enc_format, 0);
++  fqpn = kpse_find_file(q, kpse_enc_format, 0);
+ # else
+-  fqpn = kpse_find_file(filename, kpse_tex_ps_header_format, 0);
++  fqpn = kpse_find_file(q, kpse_tex_ps_header_format, 0);
+ # endif
+ #endif /* MIKTEX */
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dvi.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/dvi.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dvi.c	2008-05-28 18:46:46.000000000 +0200
+@@ -61,6 +61,7 @@
+ #ifdef XETEX
+ #include "pdfcolor.h"
+ #include "pdfximage.h"
++#include "pdfdev.h"
+ #include "ft2build.h"
+ #include FT_FREETYPE_H
+ #include FT_TRUETYPE_TABLES_H
+@@ -98,6 +99,11 @@
+ 
+ static double dev_origin_x = 72.0, dev_origin_y = 770.0;
+ 
++double get_origin (int x)
++{
++  return x ? dev_origin_x : dev_origin_y;
++}
++
+ #define PHYSICAL 1
+ #define VIRTUAL  2
+ #define SUBFONT  3
+@@ -122,6 +128,9 @@
+   FT_Face ft_face;
+   unsigned short *glyph_widths;
+   int   layout_dir;
++  float extend;
++  float slant;
++  float embolden;
+ #endif
+ } *loaded_fonts = NULL;
+ static int num_loaded_fonts = 0, max_loaded_fonts = 0;
+@@ -147,6 +156,9 @@
+   char  *fam_name, *sty_name; /* only used for native fonts in XeTeX */
+   unsigned long rgba_color;   /* only used for native fonts in XeTeX */
+   int    layout_dir; /* 1 = vertical, 0 = horizontal */
++  int    extend;
++  int    slant;
++  int    embolden;
+ #endif
+ } *def_fonts = NULL;
+ 
+@@ -157,6 +169,9 @@
+ #define XDV_FLAG_COLORED        0x0200
+ #define XDV_FLAG_FEATURES       0x0400
+ #define XDV_FLAG_VARIATIONS     0x0800
++#define XDV_FLAG_EXTEND			0x1000
++#define XDV_FLAG_SLANT			0x2000
++#define XDV_FLAG_EMBOLDEN		0x4000
+ #endif
+ 
+ static int num_def_fonts = 0, max_def_fonts = 0;
+@@ -600,6 +615,9 @@
+   def_fonts[num_def_fonts].sty_name    = NULL;
+   def_fonts[num_def_fonts].rgba_color  = 0xffffffff;
+   def_fonts[num_def_fonts].layout_dir  = 0;
++  def_fonts[num_def_fonts].extend      = 0x00010000; /* 1.0 */
++  def_fonts[num_def_fonts].slant       = 0;
++  def_fonts[num_def_fonts].embolden    = 0;
+ #endif
+   num_def_fonts++;
+ 
+@@ -663,6 +681,18 @@
+         (void)get_unsigned_quad(dvi_file); /* skip axis and value for each variation setting */
+       WARN("Variation axes are not supported; ignoring variation settings for font %s.\n", font_name);
+     }
++    if (flags & XDV_FLAG_EXTEND)
++      def_fonts[num_def_fonts].extend = get_signed_quad(dvi_file);
++    else
++      def_fonts[num_def_fonts].extend = 0x00010000;
++    if (flags & XDV_FLAG_SLANT)
++      def_fonts[num_def_fonts].slant = get_signed_quad(dvi_file);
++    else
++      def_fonts[num_def_fonts].slant = 0;
++    if (flags & XDV_FLAG_EMBOLDEN)
++      def_fonts[num_def_fonts].embolden = get_signed_quad(dvi_file);
++    else
++      def_fonts[num_def_fonts].embolden = 0;
+     num_def_fonts++;
+   } else {
+     ERROR("Unknown native_font flags.");
+@@ -828,6 +858,12 @@
+   link_annot = flag;
+ }
+ 
++int
++dvi_is_tracking_boxes(void)
++{
++  return (compute_boxes && link_annot && marked_depth >= tagged_depth);
++}
++
+ void
+ dvi_do_special (const void *buffer, UNSIGNED_QUAD size)
+ {
+@@ -1003,12 +1039,12 @@
+ #ifdef XETEX
+ static int
+ dvi_locate_native_font (const char *ps_name, const char *fam_name,
+-                        const char *sty_name, spt_t ptsize, int layout_dir)
++                        const char *sty_name, spt_t ptsize, int layout_dir, int extend, int slant, int embolden)
+ {
+   int           cur_id = -1;
+   fontmap_rec  *mrec;
+   int           i;
+-  char         *fontmap_key = malloc(strlen(ps_name) + 3);
++  char         *fontmap_key = malloc(strlen(ps_name) + 40); // CHECK this is enough
+ 
+   if (verbose)
+     MESG("<%s(%s:%s)@%.2fpt", ps_name, fam_name, sty_name, ptsize * dvi2pts);
+@@ -1017,10 +1053,10 @@
+ 
+   cur_id = num_loaded_fonts++;
+ 
+-  sprintf(fontmap_key, "%s/%c", ps_name, layout_dir == 0 ? 'H' : 'V');
++  sprintf(fontmap_key, "%s/%c/%d/%d/%d", ps_name, layout_dir == 0 ? 'H' : 'V', extend, slant, embolden);
+   mrec = pdf_lookup_fontmap_record(fontmap_key);
+   if (mrec == NULL) {
+-    if (pdf_load_native_font(ps_name, fam_name, sty_name, layout_dir) == -1) {
++    if (pdf_load_native_font(ps_name, fam_name, sty_name, layout_dir, extend, slant, embolden) == -1) {
+     ERROR("Cannot proceed without the \"native\" font: %s (%s %s)...",
+           ps_name, fam_name, sty_name);
+     }
+@@ -1043,6 +1079,9 @@
+   }
+   loaded_fonts[cur_id].glyph_widths = mrec->opt.glyph_widths;
+   loaded_fonts[cur_id].layout_dir = layout_dir;
++  loaded_fonts[cur_id].extend = mrec->opt.extend;
++  loaded_fonts[cur_id].slant = mrec->opt.slant;
++  loaded_fonts[cur_id].embolden = mrec->opt.bold;
+ 
+   if (verbose)
+     MESG(">");
+@@ -1678,7 +1717,10 @@
+                                        def_fonts[i].fam_name,
+                                        def_fonts[i].sty_name,
+                                        def_fonts[i].point_size,
+-                                       def_fonts[i].layout_dir);
++                                       def_fonts[i].layout_dir,
++                                       def_fonts[i].extend,
++                                       def_fonts[i].slant,
++                                       def_fonts[i].embolden);
+     } else {
+       font_id = dvi_locate_font(def_fonts[i].font_name,
+ 	                        def_fonts[i].point_size);
+@@ -1734,6 +1776,7 @@
+ do_xxx (UNSIGNED_QUAD size) 
+ {
+   UNSIGNED_QUAD i;
++#if 0  
+   Ubyte  *buffer;	/* FIXME - no need for new buffer here */
+ 
+   buffer = NEW(size+1, Ubyte);
+@@ -1742,6 +1785,10 @@
+   }
+   dvi_do_special(buffer, size);
+   RELEASE(buffer);
++#else
++  dvi_do_special(dvi_page_buffer + dvi_page_buf_index, size);
++  dvi_page_buf_index += size;
++#endif
+ }
+ 
+ static void
+@@ -1864,6 +1911,9 @@
+   }
+ }
+ 
++/* globals initialized by fontmap.c when it opens freetype */
++extern FT_Int ft_major, ft_minor, ft_patch;
++
+ static void
+ do_glyph_array (int yLocsPresent)
+ {
+@@ -1889,20 +1939,23 @@
+ 
+   if (font->rgba_color != 0xffffffff) {
+     pdf_color color;
+-    pdf_color_push();
++//    pdf_color_push();
+     pdf_color_rgbcolor(&color,
+       (double)((unsigned char)(font->rgba_color >> 24) & 0xff) / 255,
+       (double)((unsigned char)(font->rgba_color >> 16) & 0xff) / 255,
+       (double)((unsigned char)(font->rgba_color >>  8) & 0xff) / 255);
+-    pdf_dev_setcolor(&color, 0); /* stroke color */
+-    pdf_dev_setcolor(&color, 1); /* fill color */
++    pdf_color_push(&color, &color);
++//    pdf_dev_setcolor(&color, 0); /* stroke color */
++//    pdf_dev_setcolor(&color, 1); /* fill color */
+   }
+   for (i = 0; i < slen; i++) {
+     glyph_id = get_buffered_unsigned_pair(); /* freetype glyph index */
+     if (glyph_id < font->ft_face->num_glyphs) {
+       if (font->glyph_widths[glyph_id] == 0xffff) {
+-        if (FT_IS_SFNT(font->ft_face)) {
+-          /* CFF driver of freetype does not set vertical metrics correctly,
++        if (FT_IS_SFNT(font->ft_face)
++          && ((ft_major < 2) || ((ft_major == 2) && (ft_minor < 2)))) {
++          /* prior to version 2.2.0,
++             CFF driver of freetype does not set vertical metrics correctly,
+              so we'll read the metrics directly */
+           TT_HoriHeader  *dir_hea; /* vhea structure is identical */
+           dir_hea = FT_Get_Sfnt_Table(font->ft_face, (font->layout_dir == 0)
+@@ -1919,13 +1972,14 @@
+             font->glyph_widths[glyph_id] = 0;
+         }
+         else {
+-          FT_Load_Glyph(font->ft_face, glyph_id, FT_LOAD_NO_SCALE);
++          FT_Load_Glyph(font->ft_face, glyph_id, FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
+           font->glyph_widths[glyph_id] = (font->layout_dir == 0)
+                                           ? font->ft_face->glyph->metrics.horiAdvance
+                                           : font->ft_face->glyph->metrics.vertAdvance;
+         }
+       }
+       glyph_width = (double)font->size * (double)font->glyph_widths[glyph_id] / (double)font->ft_face->units_per_EM;
++      glyph_width = glyph_width * font->extend;
+       if (compute_boxes && link_annot && marked_depth >= tagged_depth) {
+         pdf_rect rect;
+         height = (double)font->size * (double)font->ft_face->ascender / (double)font->ft_face->units_per_EM;
+@@ -1994,9 +2048,7 @@
+     transform is a 3x2 affine transform matrix expressed in fixed-point values
+   */
+   
+-  if (page_no > 0)
+-    --page_no; /* convert 1-based page number to 0-based index */
+-  xobj_id = pdf_ximage_findresource(path, page_no, pdf_box);
++  xobj_id = pdf_ximage_findresource(path, page_no/*, pdf_box*/);
+   if (xobj_id >= 0) {
+       /* FIXME: this seems to work for 72dpi JPEGs, but isn't right for others;
+          need to take the actual image resolution into account in pdf_dev_put_image,
+@@ -2393,26 +2445,39 @@
+   v = atof(q);
+   RELEASE(q);
+ 
++  skip_white(&p, endptr);
+   q = parse_c_ident(&p, endptr);
+   if (q) {
+-    if (strlen(q) > strlen("true") &&
++    char *qq = q; /* remember this for RELEASE, because q may be advanced */
++    if (strlen(q) >= strlen("true") &&
+         !memcmp(q, "true", strlen("true"))) {
+       u /= mag != 0.0 ? mag : 1.0; /* inverse magnify */
+       q += strlen("true");
+     }
+-    for (k = 0; _ukeys[k] && strcmp(_ukeys[k], q); k++);
+-    switch (k) {
+-    case K_UNIT__PT: u *= 72.0 / 72.27; break;
+-    case K_UNIT__IN: u *= 72.0; break;
+-    case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
+-    case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
+-    case K_UNIT__BP: u *= 1.0 ; break;
+-    default:
+-      WARN("Unknown unit of measure: %s", q);
++    if (strlen(q) == 0) { /* "true" was a separate word from the units */
++      RELEASE(qq);
++      skip_white(&p, endptr);
++      qq = q = parse_c_ident(&p, endptr);
++    }
++    if (q) {
++      for (k = 0; _ukeys[k] && strcmp(_ukeys[k], q); k++);
++      switch (k) {
++      case K_UNIT__PT: u *= 72.0 / 72.27; break;
++      case K_UNIT__IN: u *= 72.0; break;
++      case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
++      case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
++      case K_UNIT__BP: u *= 1.0 ; break;
++      default:
++        WARN("Unknown unit of measure: %s", q);
++        error = -1;
++        break;
++      }
++      RELEASE(qq);
++    }
++    else {
++      WARN("Missing unit of measure after \"true\"");
+       error = -1;
+-      break;
+     }
+-    RELEASE(q);
+   }
+ 
+   *vp = v * u; *pp = p;
+@@ -2425,7 +2490,10 @@
+ {
+   char  *q, *p = (char *) buf;
+   char  *endptr;
+-  int    ns_pdf = 0, error = 0;
++  int    ns_pdf = 0, ns_xtx = 0, error = 0;
++  double tmp;
++  extern double paper_width, paper_height;
++  extern char   landscape_mode;
+ 
+   endptr = p + size;
+ 
+@@ -2441,6 +2509,15 @@
+       q = parse_c_ident(&p, endptr); ns_pdf = 1;
+     }
+   }
++  else if (q && !strcmp(q, "x")) {
++    skip_white(&p, endptr);
++    if (p < endptr && *p == ':') {
++      p++;
++      skip_white(&p, endptr);
++      RELEASE(q);
++      q = parse_c_ident(&p, endptr); ns_xtx = 1;
++    }
++  }
+   skip_white(&p, endptr);
+ 
+   if (q) {
+@@ -2454,21 +2531,26 @@
+         else {
+           skip_white(&p, endptr);
+           if (!strcmp(kp, "width")) {
+-            error = read_length(wd, dvi_tell_mag(), &p, endptr);
++            error = read_length(&tmp, dvi_tell_mag(), &p, endptr);
+             if (!error)
+-              *wd *= dvi_tell_mag();
++              *wd = tmp * dvi_tell_mag();
+           } else if (!strcmp(kp, "height")) {
+-            error = read_length(ht, dvi_tell_mag(), &p, endptr);
++            error = read_length(&tmp, dvi_tell_mag(), &p, endptr);
+             if (!error)
+-              *ht *= dvi_tell_mag();
++              *ht = tmp * dvi_tell_mag();
+           } else if (!strcmp(kp, "xoffset")) {
+-            error = read_length(xo, dvi_tell_mag(), &p, endptr);
++            error = read_length(&tmp, dvi_tell_mag(), &p, endptr);
+             if (!error)
+-              *xo *= dvi_tell_mag();
++              *xo = tmp * dvi_tell_mag();
+           } else if (!strcmp(kp, "yoffset")) {
+-            error = read_length(yo, dvi_tell_mag(), &p, endptr);
++            error = read_length(&tmp, dvi_tell_mag(), &p, endptr);
+             if (!error)
+-              *yo *= dvi_tell_mag();
++              *yo = tmp * dvi_tell_mag();
++          } else if (!strcmp(kp, "default")) {
++            *wd = paper_width;
++            *ht = paper_height;
++            *lm = landscape_mode;
++            *xo = *yo = 72.0;
+           }
+           RELEASE(kp);
+         }
+@@ -2482,19 +2564,26 @@
+         qchr = *p; p++;
+         skip_white(&p, endptr);
+       }
+-      error = read_length(wd, 1.0, &p, endptr);
++      error = read_length(&tmp, dvi_tell_mag(), &p, endptr);
+       if (!error) {
++        *wd = tmp * dvi_tell_mag();
+         skip_white(&p, endptr);
+         if (p < endptr && *p == ',') {
+           p++; skip_white(&p, endptr);
+         }
+-        error = read_length(ht, 1.0, &p, endptr);
++        error = read_length(&tmp, dvi_tell_mag(), &p, endptr);
++        if (!error)
++          *ht = tmp * dvi_tell_mag();
+         skip_white(&p, endptr);
+       }
+       if (!error && qchr) { /* Check if properly quoted */
+         if (p >= endptr || *p != qchr)
+           error = -1;
+       }
++      if (error == 0) {
++        paper_width  = *wd;
++        paper_height = *ht;
++      }
+     }
+     RELEASE(q);
+   }
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dvi.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/dvi.h	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dvi.h	2008-05-28 18:46:46.000000000 +0200
+@@ -30,6 +30,8 @@
+ /* spt_t */
+ #include "pdfdev.h"
+ 
++extern double get_origin (int x);
++
+ extern void  dvi_set_verbose (void);
+ 
+ /* returns scale (dvi2pts) */
+@@ -90,4 +92,7 @@
+ 
+ extern void  dvi_do_special    (const void *buffer, UNSIGNED_QUAD size);
+ 
++/* allow other modules (pdfdev) to ask whether we're collecting box areas */
++int dvi_is_tracking_boxes(void);
++
+ #endif /* _DVI_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dvipdfmx.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/dvipdfmx.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/dvipdfmx.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.47 2006/12/11 13:23:26 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.52 2007/05/18 05:19:00 chofchof Exp $
+     
+ 	This is xdvipdfmx, an extended version of...
+ 
+@@ -70,6 +70,9 @@
+ #define OPT_TPIC_TRANSPARENT_FILL (1 << 1)
+ #define OPT_CIDFONT_FIXEDPITCH    (1 << 2)
+ #define OPT_FONTMAP_FIRST_MATCH   (1 << 3)
++#define OPT_NO_OBJSTM             (1 << 4)
++
++static int    do_objstm;
+ 
+ static char   ignore_colors = 0;
+ static double annot_grow    = 0.0;
+@@ -89,11 +92,12 @@
+ static unsigned permission  = 0x003C;
+ 
+ /* Page device */
+-static double paper_width  = 595.0;
+-static double paper_height = 842.0;
++double paper_width  = 595.0;	/* not static, we allow dvi.c to access them */
++double paper_height = 842.0;
++char   landscape_mode    = 0;
++
+ static double x_offset = 72.0;
+ static double y_offset = 72.0;
+-static char   landscape_mode    = 0;
+ 
+ int always_embed = 0; /* always embed fonts, regardless of licensing flags */
+ 
+@@ -130,12 +134,12 @@
+ }
+ 
+ static void
+-usage (void)
++usage (int exit_code)
+ {
+   fprintf (stdout, "\nThis is %s-%s by Jonathan Kew and Jin-Hwan Cho,\n", PACKAGE, VERSION);
+   fprintf (stdout, "an extended version of DVIPDFMx, which in turn was\n");
+   fprintf (stdout, "an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.\n");
+-  fprintf (stdout, "\nCopyright (c) 2006 SIL International and Jin-Hwan Cho.\n");
++  fprintf (stdout, "\nCopyright (c) 2006-2008 SIL International and Jin-Hwan Cho.\n");
+   fprintf (stdout, "\nThis is free software; you can redistribute it and/or modify\n");
+   fprintf (stdout, "it under the terms of the GNU General Public License as published by\n");
+   fprintf (stdout, "the Free Software Foundation; either version 2 of the License, or\n");
+@@ -143,44 +147,54 @@
+   fprintf (stdout, "\nUsage: xdvipdfmx [options] xdvfile\n");
+   fprintf (stdout, "-c \t\tIgnore color specials (for B&W printing)\n");
+   fprintf (stdout, "-d number\tSet PDF decimal digits (0-5) [2]\n");
+-  fprintf (stdout, "-l \t\tLandscape mode\n");
+ #if 0
+   /* Not supported */
+   fprintf (stdout, "-e \t\tDisable partial font embedding [default is enabled]\n");
+ #endif
+   fprintf (stdout, "-f filename\tSet font map file name [t1fonts.map]\n");
++  fprintf (stdout, "-g dimension\tAnnotation \"grow\" amount [0.0in]\n");
++  fprintf (stdout, "-h \t\tShow this help message\n");
++  fprintf (stdout, "-l \t\tLandscape mode\n");
+   fprintf (stdout, "-m number\tSet additional magnification\n");
+   fprintf (stdout, "-o filename\tSet output file name [dvifile.pdf]\n");
+   fprintf (stdout, "-p papersize\tSet papersize [a4]\n");
++  fprintf (stdout, "-q \t\tBe quiet\n");
+   fprintf (stdout, "-r resolution\tSet resolution (in DPI) for raster fonts [600]\n");
+   fprintf (stdout, "-s pages\tSelect page ranges (-)\n");
++#ifndef NO_THUMBNAIL
+   fprintf (stdout, "-t \t\tEmbed thumbnail images\n");
++#endif /* !NO_THUMBNAIL */
+   fprintf (stdout, "-x dimension\tSet horizontal offset [1.0in]\n");
+   fprintf (stdout, "-y dimension\tSet vertical offset [1.0in]\n");
+   fprintf (stdout, "-z number  \tSet zlib compression level (0-9) [9]\n");
+ 
+-  fprintf (stdout, "-v         \tBe verbose\n");
+-  fprintf (stdout, "-vv        \tBe more verbose\n");
++  fprintf (stdout, "-v \t\tBe verbose\n");
++  fprintf (stdout, "-vv\t\tBe more verbose\n");
+   fprintf (stdout, "-C number\tSpecify miscellaneous option flags [0]:\n");
+   fprintf (stdout, "\t\t  0x0001 reserved\n");
+   fprintf (stdout, "\t\t  0x0002 Use semi-transparent filling for tpic shading command,\n");
+-  fprintf (stdout, "\t\t         instead of opaque gray color. (requires PDF 1.4)\n");
++  fprintf (stdout, "\t\t\t instead of opaque gray color. (requires PDF 1.4)\n");
+   fprintf (stdout, "\t\t  0x0004 Treat all CIDFont as fixed-pitch font.\n");
+   fprintf (stdout, "\t\t  0x0008 Do not replace duplicate fontmap entries.\n");
++  fprintf (stdout, "\t\t  0x0010 Do not create object streams.\n");
+   fprintf (stdout, "\t\tPositive values are always ORed with previously given flags.\n");
+   fprintf (stdout, "\t\tAnd negative values replace old values.\n");
+-  fprintf (stdout, "-E         \tAlways try to embed fonts, regardless of licensing flags.\n");
++  fprintf (stdout, "-D template\tPS->PDF conversion command line template [none]\n");
++  fprintf (stdout, "-E \t\tAlways try to embed fonts, regardless of licensing flags.\n");
++  fprintf (stdout, "-K number\tEncryption key bits [40]\n");
++  fprintf (stdout, "-M \t\tExperimental mps-to-pdf mode\n");
+   fprintf (stdout, "-O number\tSet maximum depth of open bookmark items [0]\n");
+   fprintf (stdout, "-P number\tSet permission flags for PDF encryption [0x003C]\n");
+-  fprintf (stdout, "-S         \tEnable PDF encryption\n");
+-  fprintf (stdout, "-T         \tEmbed thumbnail images. Remove images files when finished.\n");
+-  fprintf (stdout, "-M         \tExperimental mps-to-pdf mode\n");
+-  fprintf (stdout, "-V number\tSet PDF minor version [3]\n");
++  fprintf (stdout, "-S \t\tEnable PDF encryption\n");
++#ifndef NO_THUMBNAIL
++  fprintf (stdout, "-T \t\tEmbed thumbnail images. Remove images files when finished.\n");
++#endif /* !NO_THUMBNAIL */
++  fprintf (stdout, "-V number\tSet PDF minor version [4]\n");
+   fprintf (stdout, "\nAll dimensions entered on the command line are \"true\" TeX dimensions.\n");
+   fprintf (stdout, "Argument of \"-s\" lists physical page ranges separated by commas, e.g., \"-s 1-3,5-6\"\n");
+   fprintf (stdout, "Papersize is specified by paper format (e.g., \"a4\") or by w<unit>,h<unit> (e.g., \"20cm,30cm\").\n");
+ 
+-  exit(1);
++  exit(exit_code);
+ }
+ 
+ 
+@@ -209,25 +223,38 @@
+   v = atof(q);
+   RELEASE(q);
+ 
++  skip_white(&p, endptr);
+   q = parse_c_ident(&p, endptr);
+   if (q) {
+-    if (strlen(q) > strlen("true") &&
++    char *qq = q;
++    if (strlen(q) >= strlen("true") &&
+         !memcmp(q, "true", strlen("true"))) {
+       q += strlen("true"); /* just skip "true" */
+     }
+-    for (k = 0; _ukeys[k] && strcmp(_ukeys[k], q); k++);
+-    switch (k) {
+-    case K_UNIT__PT: u *= 72.0 / 72.27; break;
+-    case K_UNIT__IN: u *= 72.0; break;
+-    case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
+-    case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
+-    case K_UNIT__BP: u *= 1.0 ; break;
+-    default:
+-      WARN("Unknown unit of measure: %s", q);
++    if (strlen(q) == 0) {
++      RELEASE(qq);
++      skip_white(&p, endptr);
++      qq = q = parse_c_ident(&p, endptr);
++    }
++    if (q) {
++      for (k = 0; _ukeys[k] && strcmp(_ukeys[k], q); k++);
++      switch (k) {
++      case K_UNIT__PT: u *= 72.0 / 72.27; break;
++      case K_UNIT__IN: u *= 72.0; break;
++      case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
++      case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
++      case K_UNIT__BP: u *= 1.0 ; break;
++      default:
++        WARN("Unknown unit of measure: %s", q);
++        error = -1;
++        break;
++      }
++      RELEASE(qq);
++    }
++    else {
++      WARN("Missing unit of measure after \"true\"");
+       error = -1;
+-      break;
+     }
+-    RELEASE(q);
+   }
+ 
+   *vp = v * u; *pp = p;
+@@ -322,7 +349,7 @@
+ /* It doesn't work as expected (due to dvi filename). */
+ #define CHECK_ARG(n,m) if (argc < (n) + 1) {\
+   fprintf (stderr, "\nMissing %s after \"-%c\".\n", (m), *flag);\
+-  usage();\
++  usage(1);\
+ }
+ 
+ static void
+@@ -429,9 +456,9 @@
+           ver_minor = atoi(argv[1]);
+           POP_ARG();
+         }
+-        if (ver_minor < 3 || ver_minor > 5) {
+-          WARN("PDF version 1.%d not supported. (1.3 used instead)", ver_minor);
+-          ver_minor = 3;
++        if (ver_minor < 3 || ver_minor > 6) {
++          WARN("PDF version 1.%d not supported. (1.4 used instead)", ver_minor);
++          ver_minor = 4;
+         }
+         pdf_set_version((unsigned) ver_minor);
+       }
+@@ -505,9 +532,12 @@
+       case 'E':
+         always_embed = 1;
+         break;
++      case 'h':
++        usage(0);
++        break;
+       default:
+         fprintf (stderr, "Unknown option in \"%s\"", flag);
+-        usage();
++        usage(1);
+         break;
+       }
+     }
+@@ -525,12 +555,13 @@
+       pdf_enc_set_verbose();
+       pdf_obj_set_verbose();
+       dpx_file_set_verbose();
++      tt_aux_set_verbose();
+     }
+   }
+ 
+   if (argc > 1) {
+     fprintf(stderr, "Multiple dvi filenames?");
+-    usage();
++    usage(1);
+   } else if (argc > 0) {
+     /*
+      * The only legitimate way to have argc == 0 here is
+@@ -572,8 +603,10 @@
+ 
+   if (!(fp = MFOPEN (fullname, FOPEN_R_MODE))) {
+     WARN("Could not open config file \"%s\".", fullname);
++    RELEASE(fullname);
+     return;
+   }
++  RELEASE(fullname);
+   while ((start = mfgets (work_buffer, WORK_BUFFER_SIZE, fp)) != NULL) {
+     char *argv[2];
+     int   argc;
+@@ -641,6 +674,7 @@
+ {
+   long     page_no, page_count, i, step;
+   double   page_width, page_height;
++  double   init_paper_width, init_paper_height;
+   pdf_rect mediabox;
+ 
+   spc_exec_at_begin_document();
+@@ -655,8 +689,8 @@
+     num_page_ranges = 1;
+   }
+ 
+-  page_width  = paper_width;
+-  page_height = paper_height;
++  init_paper_width  = page_width  = paper_width;
++  init_paper_height = page_height = paper_height;
+   page_count  = 0;
+ 
+   mediabox.llx = 0.0;
+@@ -664,7 +698,6 @@
+   mediabox.urx = paper_width;
+   mediabox.ury = paper_height;
+ 
+-  pdf_doc_set_creator (dvi_comment());
+   pdf_doc_set_mediabox(0, &mediabox); /* Root node */
+ 
+   for (i = 0; i < num_page_ranges && dvi_npages() > 0; i++) {
+@@ -679,6 +712,7 @@
+         char   lm;
+ 
+         /* Users want to change page size even after page is started! */
++        page_width = paper_width; page_height = paper_height;
+         w = page_width; h = page_height; lm = landscape_mode;
+         xo = x_offset; yo = y_offset;
+         dvi_scan_paper_size(page_no, &w, &h, &xo, &yo, &lm);
+@@ -694,8 +728,8 @@
+           x_offset = xo;
+           y_offset = yo;
+         }
+-        if (page_width  != paper_width ||
+-            page_height != paper_height) {
++        if (page_width  != init_paper_width ||
++            page_height != init_paper_height) {
+           mediabox.llx = 0.0;
+           mediabox.lly = 0.0;
+           mediabox.urx = page_width;
+@@ -781,12 +815,6 @@
+ {
+   double dvi2pts;
+ 
+-  if (argc < 2) {
+-    fprintf(stderr, "No dvi filename specified.");
+-    usage();
+-    return 1;
+-  }
+-
+ #ifdef MIKTEX
+   miktex_initialize();
+ #else
+@@ -818,26 +846,24 @@
+   pdf_font_set_dpi(font_dpi);
+ 
+   if (dvi_filename == NULL) {
+-    if (pdf_filename == NULL) {
+-      WARN("No dvi or pdf filename specified.");
+-      usage();
+-      return 1;
+-    }
+-    else {
++    if (verbose)
++      MESG("No dvi filename specified, reading standard input.\n");
++    if (pdf_filename == NULL)
+       if (verbose)
+-        MESG("No dvi filename specified, reading standard input.");
+-    }
++        MESG("No pdf filename specified, writing to standard output.\n");
+   }
+ 
+-  if (pdf_filename == NULL)
++  if (pdf_filename == NULL && dvi_filename != NULL)
+     set_default_pdf_filename();
+ 
+   if (do_encryption) {
+     pdf_enc_set_passwd(key_bits, permission, dvi_filename, pdf_filename);
+-    if (key_bits > 40)
++    if (key_bits > 40 && pdf_get_version() < 4)
+       pdf_set_version(4);
+   }
+ 
++  do_objstm = !(opt_flags & OPT_NO_OBJSTM);
++
+   if (mp_mode) {
+     x_offset = 0.0;
+     y_offset = 0.0;
+@@ -848,19 +874,22 @@
+     if (dvi2pts == 0.0)
+       ERROR("dvi_init() failed!");
+ 
++    pdf_doc_set_creator(dvi_comment());
++
+     dvi_scan_paper_size(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode);
+     if (landscape_mode) {
+       SWAP(paper_width, paper_height);
+     }
+   }
+ 
+-  MESG("%s -> %s\n", dvi_filename == NULL ? "stdin" : dvi_filename, pdf_filename);
++  MESG("%s -> %s\n", dvi_filename == NULL ? "stdin" : dvi_filename,
++		     pdf_filename == NULL ? "stdout" : pdf_filename);
+ 
+   /* Set default paper size here so that all page's can inherite it.
+    * annot_grow:    Margin of annotation.
+    * bookmark_open: Miximal depth of open bookmarks.
+    */
+-  pdf_open_document(pdf_filename,
++  pdf_open_document(pdf_filename, do_encryption, do_objstm,
+                     paper_width, paper_height, annot_grow, bookmark_open);
+ 
+   /* Ignore_colors placed here since
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/epdf.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/epdf.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/epdf.c	2008-05-28 18:47:42.000000000 +0200
+@@ -1,28 +1,27 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.14 2004/09/12 11:57:49 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.18 2008/02/13 20:22:21 matthias Exp $
+ 
+-    This is dvipdfm, a DVI to PDF translator.
+-    Copyright (C) 1998, 1999 by Mark A. Wicks
++    This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
++
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
++    the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
++    
++    Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+ 
+     This program is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published by
+     the Free Software Foundation; either version 2 of the License, or
+     (at your option) any later version.
+-
++    
+     This program is distributed in the hope that it will be useful,
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     GNU General Public License for more details.
+-
++    
+     You should have received a copy of the GNU General Public License
+     along with this program; if not, write to the Free Software
+-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+-    
+-    The author may be contacted via the e-mail address
+-
+-	mwicks@kettering.edu
++    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+ 
+-
+ /*
+  * Concatinating content streams are only supported for streams that only uses
+  * single FlateDecode filter, i.e.,
+@@ -49,6 +48,8 @@
+ #include "pdfdev.h"
+ 
+ #include "pdfximage.h"
++#include "pdfdraw.h"
++#include "pdfparse.h"
+ 
+ #include "epdf.h"
+ 
+@@ -60,44 +61,55 @@
+ static int  rect_equal       (pdf_obj *rect1, pdf_obj *rect2);
+ 
+ /*
+- * From PDF Reference 4th ed.
+- *
+- *  MediaBox rectangle (Required; inheritable)
+- *
+- *   A rectangle, expressed in default user space units, defining the boundaries of the
+- *   physical medium on which the page is intended to be displayed or printed.
+- *
+- *  CropBox rectangle (Optional; inheritable)
++ * From PDFReference15_v6.pdf (p.119 and p.834)
+  *
+- *    A rectangle, expressed in default user space units, defining the visible region of
+- *    default user space. When the page is displayed or printed, its contents are to be
+- *    clipped (cropped) to this rectangle and then imposed on the output medium in some
+- *    implementation-defined manner.
+- *    Default value: the value of MediaBox.
++ * MediaBox rectangle (Required; inheritable)
+  *
+- *  BleedBox rectangle (Optional; PDF 1.3)
++ * The media box defines the boundaries of the physical medium on which the
++ * page is to be printed. It may include any extended area surrounding the
++ * finished page for bleed, printing marks, or other such purposes. It may
++ * also include areas close to the edges of the medium that cannot be marked
++ * because of physical limitations of the output device. Content falling
++ * outside this boundary can safely be discarded without affecting the
++ * meaning of the PDF file.
++ *
++ * CropBox rectangle (Optional; inheritable)
++ *
++ * The crop box defines the region to which the contents of the page are to be
++ * clipped (cropped) when displayed or printed. Unlike the other boxes, the
++ * crop box has no defined meaning in terms of physical page geometry or
++ * intended use; it merely imposes clipping on the page contents. However,
++ * in the absence of additional information (such as imposition instructions
++ * specified in a JDF or PJTF job ticket), the crop box will determine how
++ * the pageâ€™s contents are to be positioned on the output medium. The default
++ * value is the pageâ€™s media box. 
++ *
++ * BleedBox rectangle (Optional; PDF 1.3)
++ *
++ * The bleed box (PDF 1.3) defines the region to which the contents of the
++ * page should be clipped when output in a production environment. This may
++ * include any extra â€śbleed areaâ€ť needed to accommodate the physical
++ * limitations of cutting, folding, and trimming equipment. The actual printed
++ * page may include printing marks that fall outside the bleed box.
++ * The default value is the pageâ€™s crop box. 
++ *
++ * TrimBox rectangle (Optional; PDF 1.3)
++ *
++ * The trim box (PDF 1.3) defines the intended dimensions of the finished page
++ * after trimming. It may be smaller than the media box, to allow for
++ * production-related content such as printing instructions, cut marks, or
++ * color bars. The default value is the pageâ€™s crop box. 
++ *
++ * ArtBox rectangle (Optional; PDF 1.3)
++ *
++ * The art box (PDF 1.3) defines the extent of the pageâ€™s meaningful content
++ * (including potential white space) as intended by the pageâ€™s creator.
++ * The default value is the pageâ€™s crop box.
+  *
+- *    A rectangle, expressed in default user space units, defining the region to which the
+- *    contents of the page should be clipped when output in a production environment.
+- *    Default value: the value of CropBox.
++ * Rotate integer (Optional; inheritable)
+  *
+- *  TrimBox rectangle (Optional; PDF 1.3)
+- *
+- *    A rectangle, expressed in default user space units, defining the intended dimensions
+- *    of the finished page after trimming.
+- *    Default value: the value of CropBox.
+- *
+- *  ArtBox rectangle (Optional; PDF 1.3)
+- *
+- *    A rectangle, expressed in default user space units, defining the extent of the page's
+- *    meaningful content (including potential white space) as intended by the page's creator
+- *    Default value: the value of CropBox.
+- *
+- *  Rotate integer (Optional; inheritable)
+- *
+- *    The number of degrees by which the page should be rotated clockwise when displayed or
+- *    printed. The value must be a multiple of 90.
+- *    Default value: 0.
++ * The number of degrees by which the page should be rotated clockwise when
++ * displayed or printed. The value must be a multiple of 90. Default value: 0.
+  */
+ 
+ static int
+@@ -132,16 +144,12 @@
+        pdf_number_value(pdf_get_array(crop_box, 3)));
+ }
+ 
+-int
+-pdf_include_page (pdf_ximage *ximage, FILE *image_file, int page_index, int pdf_box)
++static pdf_obj*
++pdf_get_page_obj (FILE *image_file, long page_no, pdf_obj **ret_bbox, pdf_obj **ret_resources)
+ {
+-  xform_info info;
+-  pdf_obj *contents,  *contents_ref, *contents_dict;
+-  pdf_obj *page_tree;
+-  pdf_obj *bbox, *resources, *rotate, *matrix;
+-  int page_count;
++  pdf_obj *page_tree, *resources = NULL, *rotate = NULL, *bbox = NULL;
++  long page_count, page_idx;
+ 
+-  pdf_ximage_init_form_info(&info);
+   /*
+    * Get Page Tree.
+    */
+@@ -153,22 +161,22 @@
+     trailer = pdf_open(image_file);
+     if (!trailer) {
+       WARN("Trailer not found! Corrupt PDF file?");
+-      pdf_close();
+-      return -1;
++      return NULL;
+     }
+ 
+     if (pdf_lookup_dict(trailer, "Encrypt")) {
+       WARN("This PDF document is encrypted.");
+       pdf_release_obj(trailer);
+-      pdf_close();
+-      return -1;
++      return NULL;
+     }
+ 
+     catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root"));
+-    if (!catalog) {
+-      WARN("Catalog isn't where I expect it.");
+-      pdf_close();
+-      return -1;
++    if (!PDF_OBJ_DICTTYPE(catalog)) {
++      WARN("Can't read document catalog.");
++      pdf_release_obj(trailer);
++      if (catalog)
++	pdf_release_obj(catalog);
++      return NULL;
+     }
+     pdf_release_obj(trailer);
+ 
+@@ -176,11 +184,8 @@
+     if (markinfo) {
+       tmp = pdf_lookup_dict(markinfo, "Marked");
+       pdf_release_obj(markinfo);
+-      if (tmp && pdf_boolean_value(tmp)) {
+-	WARN("Tagged PDF not supported.");
+-	pdf_release_obj(catalog);
+-	pdf_close();
+-	return -1;
++      if (PDF_OBJ_BOOLEANTYPE(tmp) && pdf_boolean_value(tmp)) {
++	WARN("File contains tagged PDF. Ignoring tags.");
+       }
+     }
+ 
+@@ -189,70 +194,63 @@
+   }
+   if (!page_tree) {
+     WARN("Page tree not found.");
+-    pdf_close();
+-    return -1;
++    return NULL;
+   }
+ 
+-  page_count = (int)pdf_number_value(pdf_lookup_dict(page_tree, "Count"));
+-  if (page_index >= page_count)
+-    page_index = page_count - 1;
+-  else if (page_index < 0) {
+-    page_index = page_count + page_index;
+-    if (page_index < 0)
+-      page_index = 0;
++  /*
++   * Negative page numbers are counted from the back.
++   */
++  {
++    long count = pdf_number_value(pdf_lookup_dict(page_tree, "Count"));
++    page_idx = page_no + (page_no >= 0 ? -1 : count);
++    if (page_idx < 0 || page_idx >= count) {
++      WARN("Page %ld does not exist.", page_no);
++      page_idx = page_idx < 0 ? 0 : count - 1;
++    }
++    page_no = page_idx + 1;
+   }
+   
+   /*
+-   * Seek required page. Get Media/Crop Box.
++   * Seek correct page. Get Media/Crop Box.
+    * Media box and resources can be inherited.
+    */
+   {
+     pdf_obj *kids_ref, *kids;
+-    pdf_obj *crop_box;
++    pdf_obj *crop_box = NULL;
+     pdf_obj *tmp;
+ 
+-    tmp  = pdf_lookup_dict(page_tree, "MediaBox");
+-    bbox = tmp ? pdf_deref_obj(tmp) : NULL;
+-    tmp  = pdf_lookup_dict(page_tree, "CropBox");
+-    crop_box = tmp ? pdf_deref_obj(tmp) : NULL;
+-    tmp  = pdf_lookup_dict(page_tree, "Rotate");
+-    rotate   = tmp ? pdf_deref_obj(tmp) : NULL;
+-
+     tmp = pdf_lookup_dict(page_tree, "Resources");
+     resources = tmp ? pdf_deref_obj(tmp) : pdf_new_dict();
+ 
+-    while ((kids_ref = pdf_lookup_dict(page_tree, "Kids")) != NULL) {
+-      /* page_tree is a Pages object: figure out which of its Kids we need */
+-      int kid_index;
+-      kids = pdf_deref_obj(kids_ref);
+-      for (kid_index = 0; ; ++kid_index) {
+-        pdf_release_obj(page_tree);
+-        page_tree = pdf_deref_obj(pdf_get_array(kids, kid_index));
+-        /* page_tree might be a Page or another Pages node */
+-        tmp = pdf_lookup_dict(page_tree, "Count");
+-        if (tmp) {
+-          /* it's a subtree: check if the required page is within this tree */
+-          page_count = (int)pdf_number_value(tmp);
+-          if (page_index < page_count)
+-            break;
+-          else
+-            page_index -= page_count;
+-        }
+-        else {
+-          /* it's a page: break if it's the one we want */
+-          if (page_index == 0)
+-            break;
+-          else
+-            --page_index;
+-        }
+-      }
+-      pdf_release_obj(kids);
+-
++    while (1) {
++      long kids_length, i;
++ 
+       if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) {
+ 	if (bbox)
+ 	  pdf_release_obj(bbox);
+ 	bbox = tmp;
+       }
++      if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) {
++        if (!rect_equal(tmp, bbox)) {
++	  if (bbox)
++	    pdf_release_obj(bbox);
++	  bbox = tmp;
++        }
++      }
++      if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) {
++        if (!rect_equal(tmp, bbox)) {
++	  if (bbox)
++	    pdf_release_obj(bbox);
++	  bbox = tmp;
++        }
++      }
++      if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) {
++        if (!rect_equal(tmp, bbox)) {
++	  if (bbox)
++	    pdf_release_obj(bbox);
++	  bbox = tmp;
++        }
++      }
+       if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) {
+ 	if (crop_box)
+ 	  pdf_release_obj(crop_box);
+@@ -271,116 +269,192 @@
+ 	  pdf_release_obj(resources);
+ 	resources = tmp;
+       }
++
++      kids_ref = pdf_lookup_dict(page_tree, "Kids");
++      if (!kids_ref)
++	break;
++      kids = pdf_deref_obj(kids_ref);
++      kids_length = pdf_array_length(kids);
++
++      for (i = 0; i < kids_length; i++) {
++	long count;
++
++	pdf_release_obj(page_tree);
++	page_tree = pdf_deref_obj(pdf_get_array(kids, i));
++
++	tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count"));
++	if (tmp) {
++	  /* Pages object */
++	  count = pdf_number_value(tmp);
++	  pdf_release_obj(tmp);
++	} else
++	  /* Page object */
++	  count = 1;
++
++	if (page_idx < count)
++	  break;
++
++	page_idx -= count;
++      }
++      
++      pdf_release_obj(kids);
++
++      if (i == kids_length) {
++	WARN("Page %ld not found! Broken PDF file?", page_no);
++	if (bbox)
++	  pdf_release_obj(bbox);
++	if (crop_box)
++	  pdf_release_obj(crop_box);
++	if (rotate)
++	  pdf_release_obj(rotate);
++	pdf_release_obj(resources);
++	pdf_release_obj(page_tree);
++	return NULL;
++      }
+     }
+     if (crop_box) {
+       pdf_release_obj(bbox);
+       bbox = crop_box;
+     }
+   }
++
+   if (!bbox) {
+     WARN("No BoundingBox information available.");
+     pdf_release_obj(page_tree);
+     pdf_release_obj(resources);
+     if (rotate)
+       pdf_release_obj(rotate);
+-    pdf_close();
+-    return -1;
++    return NULL;
++  }
++  
++  if (rotate) {
++    if (pdf_number_value(rotate) != 0.0)
++      WARN("<< /Rotate %d >> found. (Not supported yet)",  (int)pdf_number_value(rotate));
++    pdf_release_obj(rotate);
++    rotate = NULL;
+   }
+ 
+-  /*
+-   * BleedBox, TrimBox, and ArtBox are not inheritable.
+-   */
+-  {
+-    pdf_obj *tmp;
++  if (ret_bbox != NULL)
++    *ret_bbox = bbox;
++  if (ret_resources != NULL)
++    *ret_resources = resources;
+ 
+-    if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) {
+-      if (!rect_equal(tmp, bbox)) {
+-	print_bbox_info(tmp, "TrimBox", bbox);
+-	if (bbox)
+-	  pdf_release_obj(bbox);
+-	bbox = tmp;
+-      }
+-    }
+-    if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) {
+-      if (!rect_equal(tmp, bbox)) {
+-	print_bbox_info(tmp, "BleedBox", bbox);
+-	if (bbox)
+-	  pdf_release_obj(bbox);
+-	bbox = tmp;
++  return page_tree;  
++}
++
++static pdf_obj*
++pdf_get_page_content (pdf_obj* page)
++{
++  pdf_obj *contents, *content_new;
++
++  contents = pdf_deref_obj(pdf_lookup_dict(page, "Contents"));
++  if (!contents)
++    return NULL;
++
++  if (pdf_obj_typeof(contents) == PDF_NULL) {
++    /* empty page */
++    pdf_release_obj(contents);
++    /* TODO: better don't include anything if the page is empty */
++    contents = pdf_new_stream(0);
++  } else if (PDF_OBJ_ARRAYTYPE(contents)) {
++    /*
++     * Concatenate all content streams.
++     */
++    pdf_obj *content_seg, *content_new;
++    int      idx = 0;
++    content_new = pdf_new_stream(STREAM_COMPRESS);
++    for (;;) {
++      content_seg = pdf_deref_obj(pdf_get_array(contents, idx));
++      if (!content_seg)
++	break;
++      else if (PDF_OBJ_NULLTYPE(content_seg)) {
++	/* Silently ignore. */
++      }  else if (!PDF_OBJ_STREAMTYPE(content_seg)) {
++	WARN("Page content not a stream object. Broken PDF file?");
++        pdf_release_obj(content_seg);
++	pdf_release_obj(content_new);
++        pdf_release_obj(contents);
++	return NULL;
++      } else if (concat_stream(content_new, content_seg) < 0) {
++	WARN("Could not handle content stream with multiple segments.");
++        pdf_release_obj(content_seg);
++	pdf_release_obj(content_new);
++        pdf_release_obj(contents);
++	return NULL;
+       }
++      pdf_release_obj(content_seg);
++      idx++;
+     }
+-    if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) {
+-      if (!rect_equal(tmp, bbox)) {
+-	print_bbox_info(tmp, "ArtBox", bbox);
+-	if (bbox)
+-	  pdf_release_obj(bbox);
+-	bbox = tmp;
+-      }
++    pdf_release_obj(contents);
++    contents = content_new;
++  } else {
++    if (!PDF_OBJ_STREAMTYPE(contents)) {
++      WARN("Page content not a stream object. Broken PDF file?");
++      pdf_release_obj(contents);
++      return NULL;
+     }
+-    if (rotate) {
+-      if (pdf_number_value(rotate) != 0.0)
+-	WARN("<< /Rotate %d >> found. (Not supported yet)",  (int)pdf_number_value(rotate));
+-      pdf_release_obj(rotate);
+-      rotate = NULL;
++    /* Flate the contents if necessary. */
++    content_new = pdf_new_stream(STREAM_COMPRESS);
++    if (concat_stream(content_new, contents) < 0) {
++      WARN("Could not handle a content stream.");
++      pdf_release_obj(contents);
++      pdf_release_obj(content_new);
++      return NULL;
+     }
+-
+-    info.bbox.llx = pdf_number_value(pdf_get_array(bbox, 0));
+-    info.bbox.lly = pdf_number_value(pdf_get_array(bbox, 1));
+-    info.bbox.urx = pdf_number_value(pdf_get_array(bbox, 2));
+-    info.bbox.ury = pdf_number_value(pdf_get_array(bbox, 3));
++    pdf_release_obj(contents);
++    contents = content_new;
+   }
+ 
++  return contents;
++}
++
++int
++pdf_include_page (pdf_ximage *ximage, FILE *image_file)
++{
++  xform_info info;
++  pdf_obj *contents,  *contents_dict;
++  pdf_obj *page_tree;
++  pdf_obj *matrix;
++  pdf_obj *bbox = NULL, *resources = NULL;
++  long page_no, page_idx;
++
++  pdf_ximage_init_form_info(&info);
++
+   /*
+-   * Handle page content stream.
+-   * page_tree is now set to the first page.
++   * Get Page Tree.
+    */
+-  contents_ref = contents = NULL;
+-  {
+-    contents = pdf_deref_obj(pdf_lookup_dict(page_tree, "Contents"));
+-    pdf_release_obj(page_tree);
+-    if (!contents) {
+-      pdf_release_obj(bbox);
+-      pdf_close();
+-      return -1;
+-    }
++  page_no = pdf_ximage_get_page(ximage);
++  if (page_no == 0)
++    page_no = 1;
+ 
+-    /*
+-     * Concatinate all content streams.
+-     */
+-    if (PDF_OBJ_ARRAYTYPE(contents)) {
+-      pdf_obj *content_seg, *content_new;
+-      int      idx = 0;
+-      content_new = pdf_new_stream(STREAM_COMPRESS);
+-      for (;;) {
+-	content_seg = pdf_deref_obj(pdf_get_array(contents, idx));
+-	if (!content_seg)
+-	  break;
+-	else if (PDF_OBJ_NULLTYPE(content_seg)) {
+-	  /* Silently ignore. */
+-	}  else if (!PDF_OBJ_STREAMTYPE(content_seg)) {
+-	  WARN("Page content not a stream object. Broken PDF file?");
+-	  pdf_release_obj(content_new);
+-	  pdf_release_obj(bbox);
+-	  pdf_close();
+-	  return -1;
+-	} else if (concat_stream(content_new, content_seg) < 0) {
+-	  WARN("Could not handle content stream with multiple segment.");
+-	  pdf_release_obj(content_new);
+-	  pdf_release_obj(bbox);
+-	  pdf_close();
+-	  return -1;
+-	}
+-	pdf_release_obj(content_seg);
+-	idx++;
+-      }
+-      pdf_release_obj(contents);
+-      contents = content_new;
+-    }
+-    if (!contents) {
+-      pdf_release_obj(bbox);
+-      pdf_close();
+-      return -1;
+-    }
++  page_tree = pdf_get_page_obj(image_file, page_no, &bbox, &resources);
++  if (page_tree == NULL) {
++    pdf_close();
++    return -1;
++  }
++
++  if (bbox != NULL) {
++    pdf_obj *tmp;
++
++    tmp = pdf_deref_obj(pdf_get_array(bbox, 0));
++    info.bbox.llx = pdf_number_value(tmp);
++    pdf_release_obj(tmp);
++    tmp = pdf_deref_obj(pdf_get_array(bbox, 1));
++    info.bbox.lly = pdf_number_value(tmp);
++    pdf_release_obj(tmp);
++    tmp = pdf_deref_obj(pdf_get_array(bbox, 2));
++    info.bbox.urx = pdf_number_value(tmp);
++    pdf_release_obj(tmp);
++    tmp = pdf_deref_obj(pdf_get_array(bbox, 3));
++    info.bbox.ury = pdf_number_value(tmp);
++    pdf_release_obj(tmp);
++  }
++
++  contents = pdf_get_page_content(page_tree);
++  pdf_release_obj(page_tree);
++  if (contents == NULL) {
++    pdf_close();
++    return -1;
+   }
+ 
+   {
+@@ -389,6 +463,9 @@
+     tmp = pdf_import_object(resources);
+     pdf_release_obj(resources);
+     resources = tmp;
++    tmp = pdf_import_object(bbox);
++    pdf_release_obj(bbox);
++    bbox = tmp;
+   }
+ 
+   pdf_close();
+@@ -423,6 +500,315 @@
+   return 0;
+ }
+ 
++typedef enum {
++  OP_SETCOLOR		= 1,
++  OP_CLOSEandCLIP	= 2,
++  OP_CLIP		= 3,
++  OP_CONCATMATRIX	= 4,
++  OP_SETCOLORSPACE	= 5,
++  OP_RECTANGLE		= 6,
++  OP_CURVETO		= 7,
++  OP_CLOSEPATH		= 8,
++  OP_LINETO		= 9,
++  OP_MOVETO		= 10,
++  OP_NOOP		= 11,
++  OP_GSAVE		= 12,
++  OP_GRESTORE		= 13,
++  OP_CURVETO1		= 14,
++  OP_CURVETO2		= 15,
++  OP_UNKNOWN		= 16
++} pdf_opcode;
++
++static struct operator
++{
++  const char *token;
++  int         opcode;
++} pdf_operators[] = {
++  {"SCN",	OP_SETCOLOR},
++  {"b*",	OP_CLOSEandCLIP},
++  {"B*",	OP_CLIP},
++  {"cm",	OP_CONCATMATRIX},
++  {"CS",	OP_SETCOLORSPACE},
++  {"f*",	0},
++  {"gs",	-1},
++  {"re",	OP_RECTANGLE},
++  {"rg",	-3},
++  {"RG",	-3},
++  {"sc",	OP_SETCOLOR},
++  {"SC",	OP_SETCOLOR},
++  {"W*",	OP_CLIP},
++  {"b",		OP_CLOSEandCLIP},
++  {"B",		OP_CLIP},
++  {"c",		OP_CURVETO},
++  {"d",		-2},
++  {"f",		0},
++  {"F",		0},
++  {"g",		-1},
++  {"G",		-1},
++  {"h",		OP_CLOSEPATH},
++  {"i",		-1},
++  {"j",		-1},
++  {"J",		-1},
++  {"k",		-4},
++  {"K",		-4},
++  {"l",		OP_LINETO},
++  {"m",		OP_MOVETO},
++  {"M",		-1},
++  {"n",		OP_NOOP},
++  {"q",		OP_GSAVE},
++  {"Q",		OP_GRESTORE},
++  {"s",		OP_CLOSEandCLIP},
++  {"S",		OP_CLIP},
++  {"v",		OP_CURVETO1},
++  {"w",		-1},
++  {"W",		OP_CLIP},
++  {"y",		OP_CURVETO2}
++};
++
++
++int
++pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user)
++{
++  pdf_obj *page_tree, *contents;
++  int depth = 0, top = -1;
++  char *clip_path, *temp, *end_path;
++  pdf_tmatrix M;
++  double stack[6];
++  pdf_coord   p0, p1, p2;
++  pdf_rect    bbox;
++
++  pdf_dev_currentmatrix(&M);
++  pdf_invertmatrix(&M);
++  M.e += x_user; M.f += y_user;
++  page_tree = pdf_get_page_obj (image_file, pageNo, NULL, NULL);
++  if (!page_tree) {
++    pdf_close();
++    return -1;
++  }
++
++  contents = pdf_get_page_content(page_tree);
++  pdf_release_obj(page_tree);
++  if (!contents) {
++    pdf_close();
++    return -1;
++  }
++
++  pdf_doc_add_page_content(" ", 1);
++
++  clip_path = malloc(pdf_stream_length(contents) + 1);
++  strncpy(clip_path, (char*)pdf_stream_dataptr(contents),  pdf_stream_length(contents));
++  end_path = clip_path + pdf_stream_length(contents);
++  depth = 0;
++
++  for (; clip_path < end_path; clip_path++) {
++    int color_dimen;
++    char *token;
++    skip_white(&clip_path, end_path);
++    if (clip_path == end_path)
++      break;
++    if (depth > 1) {
++      if (*clip_path == 'q')
++        depth++;
++      if (*clip_path == 'Q')
++	depth--;
++      parse_ident(&clip_path, end_path);
++      continue;
++    } else if (*clip_path == '-'
++	    || *clip_path == '+'
++	    || *clip_path == '.'
++	    || isdigit(*clip_path)) {
++      stack[++top] = strtod(clip_path, &temp);
++      clip_path = temp;
++    } else if (*clip_path == '[') {
++      /* Ignore, but put a dummy value on the stack (in case of d operator) */
++      parse_pdf_array(&clip_path, end_path);
++      stack[++top] = 0;
++    } else if (*clip_path == '/') {
++      if  (strncmp("/DeviceGray",	clip_path, 11) == 0
++	|| strncmp("/Indexed",		clip_path, 8)  == 0
++	|| strncmp("/CalGray",		clip_path, 8)  == 0) {
++	color_dimen = 1;
++	continue;
++      }
++      else if  (strncmp("/DeviceRGB",	clip_path, 10) == 0
++	|| strncmp("/CalRGB",		clip_path, 7)  == 0
++	|| strncmp("/Lab",		clip_path, 4)  == 0) {
++	color_dimen = 3;
++	continue;
++      }
++      else if  (strncmp("/DeviceCMYK",	clip_path, 11) == 0) {
++	color_dimen = 4;
++	continue;
++      }
++      else {
++        clip_path++;
++        parse_ident(&clip_path, end_path);
++	skip_white(&clip_path, end_path);
++	token = parse_ident(&clip_path, end_path);
++        if (strcmp(token, "gs") == 0) {
++	  continue;
++	}
++        return -1;
++      }
++    } else {
++      int j;
++      pdf_tmatrix T;
++      pdf_coord  p0, p1, p2, p3;
++
++      token = parse_ident(&clip_path, end_path);
++      for (j = 0; j < sizeof(pdf_operators) / sizeof(pdf_operators[0]); j++)
++        if (strcmp(token, pdf_operators[j].token) == 0)
++	  break;
++      if (j == sizeof(pdf_operators) / sizeof(pdf_operators[0])) {
++        return -1;
++      }
++      switch (pdf_operators[j].opcode) {
++	case  0:
++	case -1:
++	case -2:
++	case -3:
++	case -4:
++	  /* Just pop the stack and do nothing. */
++	  top += pdf_operators[j].opcode;
++	  if (top < -1)
++	    return -1;
++	  break;
++	case OP_SETCOLOR:
++	  top -= color_dimen;
++	  if (top < -1)
++	    return -1;
++	  break;
++	case OP_CLOSEandCLIP:
++	  pdf_dev_closepath();
++	case OP_CLIP:
++#if 0
++	  pdf_dev_clip();
++#else
++	  pdf_dev_flushpath('W', PDF_FILL_RULE_NONZERO);
++#endif
++	  break;
++	case OP_CONCATMATRIX:
++	  if (top < 5)
++	    return -1;
++	  T.f = stack[top--];
++	  T.e = stack[top--];
++	  T.d = stack[top--];
++	  T.c = stack[top--];
++	  T.b = stack[top--];
++	  T.a = stack[top--];
++	  pdf_concatmatrix(&M, &T);
++	  break;
++	case OP_SETCOLORSPACE:
++	  /* Do nothing. */
++	  break;
++	case OP_RECTANGLE:
++	  if (top < 3)
++	    return -1;
++	  p1.y = stack[top--];
++	  p1.x = stack[top--];
++	  p0.y = stack[top--];
++	  p0.x = stack[top--];
++	  if (M.b == 0 && M.c == 0) {
++	    pdf_tmatrix M0;
++	    M0.a = M.a; M0.b = M.b; M0.c = M.c; M0.d = M.d;
++	    M0.e = 0; M0.f = 0;
++	    pdf_dev_transform(&p0, &M);
++	    pdf_dev_transform(&p1, &M0);
++	    pdf_dev_rectadd(p0.x, p0.y, p1.x, p1.y);
++	  } else {
++	    p2.x = p0.x + p1.x; p2.y = p0.y + p1.y;
++	    p3.x = p0.x; p3.y = p0.y + p1.y;
++	    p1.x += p0.x; p1.y = p0.y;
++	    pdf_dev_transform(&p0, &M);
++	    pdf_dev_transform(&p1, &M);
++	    pdf_dev_transform(&p2, &M);
++	    pdf_dev_transform(&p3, &M);
++	    pdf_dev_moveto(p0.x, p0.y);
++	    pdf_dev_lineto(p1.x, p1.y);
++	    pdf_dev_lineto(p2.x, p2.y);
++	    pdf_dev_lineto(p3.x, p3.y);
++	    pdf_dev_closepath();
++	  }
++	  break;
++	case OP_CURVETO:
++	  if (top < 5)
++	    return -1;
++	  p0.y = stack[top--];
++	  p0.x = stack[top--];
++	  pdf_dev_transform(&p0, &M);
++	  p1.y = stack[top--];
++	  p1.x = stack[top--];
++	  pdf_dev_transform(&p1, &M);
++	  p2.y = stack[top--];
++	  p2.x = stack[top--];
++	  pdf_dev_transform(&p2, &M);
++	  pdf_dev_curveto(p2.x, p2.y, p1.x, p1.y, p0.x, p0.y);
++	  break;
++	case OP_CLOSEPATH:
++	  pdf_dev_closepath();
++	  break;
++	case OP_LINETO:
++	  if (top < 1)
++	    return -1;
++	  p0.y = stack[top--];
++	  p0.x = stack[top--];
++	  pdf_dev_transform(&p0, &M);
++	  pdf_dev_lineto(p0.x, p0.y);
++	  break;
++	case OP_MOVETO:
++	  if (top < 1)
++	    return -1;
++	  p0.y = stack[top--];
++	  p0.x = stack[top--];
++	  pdf_dev_transform(&p0, &M);
++	  pdf_dev_moveto(p0.x, p0.y);
++	  break;
++	case OP_NOOP:
++	  pdf_doc_add_page_content(" n", 2);
++	  break;
++	case OP_GSAVE:
++	  depth++;
++	  break;
++	case OP_GRESTORE:
++	  depth--;
++	  break;
++	case OP_CURVETO1:
++	  if (top < 3)
++	    return -1;
++	  p0.y = stack[top--];
++	  p0.x = stack[top--];
++	  pdf_dev_transform(&p0, &M);
++	  p1.y = stack[top--];
++	  p1.x = stack[top--];
++	  pdf_dev_transform(&p1, &M);
++	  pdf_dev_vcurveto(p1.x, p1.y, p0.x, p0.y);
++	  break;
++	case OP_CURVETO2:
++	  if (top < 3)
++	    return -1;
++	  p0.y = stack[top--];
++	  p0.x = stack[top--];
++	  pdf_dev_transform(&p0, &M);
++	  p1.y = stack[top--];
++	  p1.x = stack[top--];
++	  pdf_dev_transform(&p1, &M);
++	  pdf_dev_ycurveto(p1.x, p1.y, p0.x, p0.y);
++	  break;
++	default:
++	  return -1;
++      }
++    }
++  }
++  clip_path = end_path;
++  clip_path -= pdf_stream_length(contents);
++  free(clip_path);
++
++  pdf_release_obj(contents);
++  pdf_close();
++
++  return 0;
++}
++
+ #define WBUF_SIZE 4096
+ #if HAVE_ZLIB
+ static int
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/epdf.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/epdf.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/epdf.h	2008-05-28 18:46:46.000000000 +0200
+@@ -34,6 +34,8 @@
+ #define pdfbox_trim  4
+ #define pdfbox_art   5
+ 
+-extern int pdf_include_page (pdf_ximage *ximage, FILE *file, int page_index, int pdf_box);
++extern int pdf_copy_clip (FILE *image_file, int page_index, double x_user, double y_user);
++//extern int pdf_include_page (pdf_ximage *ximage, FILE *file, int page_index, int pdf_box);
++extern int pdf_include_page (pdf_ximage *ximage, FILE *file);
+ 
+ #endif /* _EPDF_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/fontmap.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/fontmap.c	2007-01-21 13:14:26.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/fontmap.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.33 2005/07/30 11:44:18 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.35 2007/01/21 15:17:53 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -980,7 +980,8 @@
+ #ifdef XETEX
+ 
+ static int
+-pdf_insert_native_fontmap_record (const char *name, const char *path, int index, FT_Face face, int layout_dir)
++pdf_insert_native_fontmap_record (const char *name, const char *path, int index, FT_Face face,
++                                  int layout_dir, int extend, int slant, int embolden)
+ {
+   char        *fontmap_key;
+   fontmap_rec *mrec;
+@@ -988,8 +989,8 @@
+   ASSERT(name);
+   ASSERT(path || face);
+ 
+-  fontmap_key = malloc(strlen(name) + 3);
+-  sprintf(fontmap_key, "%s/%c", name, layout_dir == 0 ? 'H' : 'V');
++  fontmap_key = malloc(strlen(name) + 40);	// CHECK
++  sprintf(fontmap_key, "%s/%c/%d/%d/%d", name, layout_dir == 0 ? 'H' : 'V', extend, slant, embolden);
+ 
+   if (verbose)
+     MESG("<NATIVE-FONTMAP:%s", fontmap_key);
+@@ -1007,6 +1008,11 @@
+     mrec->opt.flags |= FONTMAP_OPT_VERT;
+ 
+   fill_in_defaults(mrec, fontmap_key);
++  
++  mrec->opt.extend = extend   / 65536.0;
++  mrec->opt.slant  = slant    / 65536.0;
++  mrec->opt.bold   = embolden / 65536.0;
++  
+   pdf_insert_fontmap_record(mrec->map_name, mrec);
+   pdf_clear_fontmap_record(mrec);
+   RELEASE(mrec);
+@@ -1020,7 +1026,7 @@
+ static FT_Library ftLib;
+ 
+ static int
+-pdf_load_native_font_from_path(const char *ps_name, int layout_dir)
++pdf_load_native_font_from_path(const char *ps_name, int layout_dir, int extend, int slant, int embolden)
+ {
+   const char *p;
+   char *filename = NEW(strlen(ps_name), char);
+@@ -1059,15 +1065,20 @@
+   }
+ 
+   if (error == 0)
+-    return pdf_insert_native_fontmap_record(ps_name, filename, index, face, layout_dir);
++    return pdf_insert_native_fontmap_record(ps_name, filename, index, face,
++                                           layout_dir, extend, slant, embolden);
+   else
+     return error;
+ }
+ 
++FT_Int ft_major; /* global so that dvi.c can check the version */
++FT_Int ft_minor;
++FT_Int ft_patch;
++
+ int
+ pdf_load_native_font (const char *ps_name,
+                       const char *fam_name, const char *sty_name,
+-                      int layout_dir)
++                      int layout_dir, int extend, int slant, int embolden)
+ {
+   static int        sInitialized = 0;
+   int error = -1;
+@@ -1079,11 +1090,12 @@
+       WARN("FreeType initialization failed.");
+       return error;
+     }
++    FT_Library_Version(ftLib, &ft_major, &ft_minor, &ft_patch);
+     sInitialized = 1;
+   }
+   
+   if (ps_name[0] == '[') {
+-    error = pdf_load_native_font_from_path(ps_name, layout_dir);
++    error = pdf_load_native_font_from_path(ps_name, layout_dir, extend, slant, embolden);
+   }
+   else {
+     ATSFontRef  fontRef;
+@@ -1105,7 +1117,8 @@
+             FT_Face face;
+             ftErr = FT_New_Face_From_FSSpec(ftLib, &pathSpec, index, &face);
+             if (ftErr == 0) {
+-              error = pdf_insert_native_fontmap_record(ps_name, NULL, 0, face, layout_dir);
++              error = pdf_insert_native_fontmap_record(ps_name, NULL, 0, face,
++                                                       layout_dir, extend, slant, embolden);
+             }
+           }
+         }
+@@ -1132,11 +1145,12 @@
+       WARN("FreeType initialization failed.");
+       return error;
+     }
++    FT_Library_Version(ftLib, &ft_major, &ft_minor, &ft_patch);
+     sInitialized = 1;
+   }
+ 
+   if (ps_name[0] == '[') {
+-    error = pdf_load_native_font_from_path(ps_name, layout_dir);
++    error = pdf_load_native_font_from_path(ps_name, layout_dir, extend, slant, embolden);
+   }
+   else {
+     os = FcObjectSetBuild(FC_FILE, FC_INDEX, FC_FAMILY, FC_STYLE, NULL);
+@@ -1159,7 +1173,8 @@
+         FT_New_Face(ftLib, (char*)path, index, &face);
+         name = (char *)FT_Get_Postscript_Name(face);
+         if (!strcmp(name, ps_name)) {
+-          error = pdf_insert_native_fontmap_record(ps_name, (char*)path, index, face, layout_dir);
++          error = pdf_insert_native_fontmap_record(ps_name, (char*)path, index, face,
++                                                   layout_dir, extend, slant, embolden);
+           /* don't dispose of the FT_Face, as we'll be using it to retrieve font data */
+           break;
+         }
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/fontmap.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/fontmap.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/fontmap.h	2008-05-28 18:46:46.000000000 +0200
+@@ -101,7 +101,7 @@
+ #ifdef XETEX
+ extern int          pdf_load_native_font      (const char *ps_name,
+                                                const char *fam_name, const char *sty_name,
+-                                               int layout_dir);
++                                               int layout_dir, int extend, int slant, int embolden);
+ #endif
+ 
+ #endif /* _FONTMAP_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/jpegimage.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/jpegimage.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/jpegimage.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/jpegimage.c,v 1.8 2004/09/05 13:30:05 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/jpegimage.c,v 1.9 2007/05/18 05:19:01 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -113,6 +113,7 @@
+   JM_EXP   = 0xdf,
+ 
+   JM_APP0  = 0xe0,
++  JM_APP1  = 0xe1,
+   JM_APP2  = 0xe2,
+   JM_APP14 = 0xee,
+   JM_APP15 = 0xef,
+@@ -334,8 +335,33 @@
+   info.bits_per_component = j_info.bits_per_component;
+   info.num_components     = j_info.num_components;
+ 
+-  info.xdpi = j_info.xdpi;
+-  info.ydpi = j_info.ydpi;
++#define IS_JFIF(j) ((j).flags & HAVE_APPn_JFIF)
++  if (IS_JFIF(j_info)) {
++    int i;
++    for (i = 0; i < j_info.num_appn; i++) {
++      if (j_info.appn[i].marker == JM_APP0 && j_info.appn[i].app_sig == JS_APPn_JFIF)
++        break;
++    }
++    if (i < j_info.num_appn) {
++      struct JPEG_APPn_JFIF *app_data = (struct JPEG_APPn_JFIF *)j_info.appn[i].app_data;
++      switch (app_data->units) {
++      case 1: /* pixels per inch */
++        info.xdensity = 72.0 / app_data->Xdensity;
++        info.ydensity = 72.0 / app_data->Ydensity;
++        break;
++      case 2: /* pixels per centimeter */
++        info.xdensity = 72.0 / 2.54 / app_data->Xdensity;
++        info.ydensity = 72.0 / 2.54 / app_data->Ydensity;
++        break;
++      default:
++        break;
++      }
++    }
++  }
++  else { /* resolution data from EXIF is handled here */
++    info.xdensity = 72.0 / j_info.xdpi;
++    info.ydensity = 72.0 / j_info.ydpi;
++  }
+ 
+   pdf_ximage_set_image(ximage, &info, stream);
+   JPEG_info_clear(&j_info);
+@@ -504,6 +530,133 @@
+   return 7;
+ }
+ 
++static unsigned long
++read_exif_bytes(unsigned char **p, int n, int b)
++{
++  unsigned long rval = 0;
++  unsigned char *pp = *p;
++  if (b) {
++    switch (n) {
++      case 4:
++        rval += *pp++; rval <<= 8;
++        rval += *pp++; rval <<= 8;
++      case 2:
++        rval += *pp++; rval <<= 8;
++        rval += *pp;
++        break;
++    }
++  }
++  else {
++    pp += n;
++    switch (n) {
++      case 4:
++        rval += *--pp; rval <<= 8;
++        rval += *--pp; rval <<= 8;
++      case 2:
++        rval += *--pp; rval <<= 8;
++        rval += *--pp;
++        break;
++    }
++  }
++  *p += n;
++  return rval;
++}
++
++static unsigned short
++read_APP1_Exif (struct JPEG_info *j_info, FILE *fp, unsigned short length)
++{
++  /* this doesn't save the data, just reads the tags we need */
++  /* based on info from http://www.exif.org/Exif2-2.PDF */
++  unsigned char *buffer = NEW(length, unsigned char);
++  unsigned char *p, *rp;
++  unsigned char *tiff_header;
++  char bigendian;
++  int i;
++  double rational_value;
++  int num_fields, tag, type, count, value, num, den;
++  double xres = 72.0;
++  double yres = 72.0;
++  double res_unit = 1.0;
++  fread(buffer, length, 1, fp);
++  p = buffer;
++  while ((p < buffer + length) && (*p == 0))
++    ++p;
++  tiff_header = p;
++  if ((*p == 'M') && (*(p+1) == 'M'))
++    bigendian = 1;
++  else if ((*p == 'I') && (*(p+1) == 'I'))
++    bigendian = 0;
++  else
++    goto err;
++  p += 2;
++  i = read_exif_bytes(&p, 2, bigendian);
++  if (i != 42)
++    goto err;
++  i = read_exif_bytes(&p, 4, bigendian);
++  p = tiff_header + i;
++  num_fields = read_exif_bytes(&p, 2, bigendian);
++  while (num_fields-- > 0) {
++    tag = read_exif_bytes(&p, 2, bigendian);
++    type = read_exif_bytes(&p, 2, bigendian);
++    count = read_exif_bytes(&p, 4, bigendian);
++    switch (type) {
++      case 1: /* byte */
++        value = *p++;
++        p += 3;
++        break;
++      case 3: /* short */
++        value = read_exif_bytes(&p, 2, bigendian);
++        p += 2;
++        break;
++      case 4: /* long */
++      case 9: /* slong */
++        value = read_exif_bytes(&p, 4, bigendian);
++        break;
++      case 5: /* rational */
++      case 10: /* srational */
++        value = read_exif_bytes(&p, 4, bigendian);
++        rp = tiff_header + value;
++        num = read_exif_bytes(&rp, 4, bigendian);
++        den = read_exif_bytes(&rp, 4, bigendian);
++        break;
++      case 7: /* undefined */
++        value = *p++;
++        p += 3;
++        break;
++      case 2: /* ascii */
++      default:
++        p += 4;
++        break;
++    }
++    switch (tag) {
++      case 282: /* x res */
++        if (den != 0)
++          xres = num / den;
++        break;
++      case 283: /* y res */
++        if (den != 0)
++          yres = num / den;
++        break;
++      case 296: /* res unit */
++        switch (value) {
++          case 2:
++            res_unit = 1.0;
++            break;
++          case 3:
++            res_unit = 2.54;
++            break;
++        }
++    }
++  }
++  
++  j_info->xdpi = xres * res_unit;
++  j_info->ydpi = yres * res_unit;
++
++err:
++  RELEASE(buffer);
++  return length;
++}
++
+ static unsigned short
+ read_APP0_JFIF (struct JPEG_info *j_info, FILE *fp, unsigned short length)
+ {
+@@ -701,6 +854,17 @@
+       }
+       seek_relative(fp, length);
+       break;
++    case JM_APP1:
++      if (length > 5) {
++	if (fread(app_sig, sizeof(char), 5, fp) != 5)
++	  return -1;
++	length -= 5;
++	if (!memcmp(app_sig, "Exif\000", 5)) {
++	  length -= read_APP1_Exif(j_info, fp, length);
++	}
++      }
++      seek_relative(fp, length);
++      break;
+     case JM_APP2:
+       if (length >= 14) {
+ 	if (fread(app_sig, sizeof(char), 12, fp) != 12)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/mpost.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/mpost.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/mpost.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.36 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.38 2007/11/22 16:57:08 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+ 
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -260,7 +260,8 @@
+ 
+   save = *start;
+   while (*start < end) {
+-    skip_white(start, end);
++    if (**start != '%')
++      skip_white(start, end);
+     if (*start >= end)
+       break;
+     if (!strncmp(*start, "%%EndProlog", 11)) {
+@@ -1189,8 +1190,7 @@
+       pdf_color_cmykcolor(&color,
+ 			  values[0], values[1],
+ 			  values[2], values[3]);
+-      pdf_dev_setcolor(&color, 0);
+-      pdf_dev_setcolor(&color, 1);
++      pdf_dev_set_color(&color);
+     }
+     break;
+   case SETGRAY:
+@@ -1198,8 +1198,7 @@
+     error = pop_get_numbers(values, 1);
+     if (!error) {
+       pdf_color_graycolor(&color, values[0]);
+-      pdf_dev_setcolor(&color, 0);
+-      pdf_dev_setcolor(&color, 1);
++      pdf_dev_set_color(&color);
+     }
+     break;
+   case SETRGBCOLOR:
+@@ -1207,8 +1206,7 @@
+     if (!error) {
+       pdf_color_rgbcolor(&color,
+ 			 values[0], values[1], values[2]);
+-      pdf_dev_setcolor(&color, 0);
+-      pdf_dev_setcolor(&color, 1);
++      pdf_dev_set_color(&color);
+     }
+     break;
+ 
+@@ -1462,7 +1460,7 @@
+ 
+   autorotate = pdf_dev_get_param(PDF_DEV_PARAM_AUTOROTATE);
+   pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, 0);
+-  pdf_color_push(); /* ... */
++  //pdf_color_push(); /* ... */
+ 
+   /* Comment in dvipdfm:
+    * Remember that x_user and y_user are off by 0.02 %
+@@ -1470,7 +1468,7 @@
+   pdf_dev_moveto(x_user, y_user);
+   error = mp_parse_body(p, endptr, x_user, y_user);
+ 
+-  pdf_color_pop(); /* ... */
++  //pdf_color_pop(); /* ... */
+   pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, autorotate);
+   pdf_dev_set_dirmode(dirmode);
+ 
+@@ -1535,7 +1533,7 @@
+   dirmode    = pdf_dev_get_dirmode();
+   autorotate = pdf_dev_get_param(PDF_DEV_PARAM_AUTOROTATE);
+   pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, 0);
+-  pdf_color_push();
++  //pdf_color_push();
+ 
+   form_id  = pdf_doc_begin_grabbing(ident, 0.0, 0.0, &(info.bbox));
+ 
+@@ -1562,7 +1560,7 @@
+ 
+   pdf_doc_end_grabbing();
+ 
+-  pdf_color_pop();
++  //pdf_color_pop();
+   pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, autorotate);
+   pdf_dev_set_dirmode(dirmode);
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfcolor.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfcolor.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfcolor.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.c,v 1.13 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.c,v 1.14 2007/11/22 11:45:39 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -212,115 +212,28 @@
+ }
+ #endif
+ 
+-static int
+-valid_color_values (pdf_color *validated, const pdf_color *color)
++int
++pdf_color_is_valid (pdf_color *color)
+ {
+-  int  i, num_components = 0;
++  int  i, num_components;
+ 
+   num_components = color->num_components;
+   if (num_components != 1 &&
+       num_components != 3 &&
+       num_components != 4) {
+     ERROR("Only RGB/CMYK/Gray currently supported.");
+-    return -1;
++    return 0;
+   }
+ 
+   for (i = 0; i < num_components; i++) {
+     if (color->values[i] < 0.0 || color->values[i] > 1.0) {
+       WARN("Invalid color value: %g", color->values[i]);
+-      return -1;
+-    } else {
+-      validated->values[i] = color->values[i];
+-    }
+-  }
+-  validated->num_components = color->num_components;
+-
+-  return 0;
+-}
+-
+-int
+-pdf_dev_currentcolor (pdf_color *color, int is_fill)
+-{
+-  ASSERT(color);
+-
+-  if (is_fill) {
+-    memcpy(color, &current_fill, sizeof(pdf_color));
+-  } else {
+-    memcpy(color, &current_stroke, sizeof(pdf_color));
+-  }
+-
+-  return 0;
+-}
+-
+-int
+-pdf_dev_setcolor (const pdf_color *color, int is_fill)
+-{
+-  int       len = 0, colormode;
+-  int       i;
+-  char      format_buffer[128];
+-  pdf_color validated;
+-
+-  if (!color) {
+-    WARN("No color specified.");
+-    return -1;
+-  }
+-
+-  colormode = pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE);
+-  if (!colormode) {
+-    WARN("setcolor ignored. (Ignore color option set)");
+-    return  0;
+-  }
+-
+-  if (valid_color_values(&validated, color) < 0) {
+-    return -1;
+-  }
+-
+-#if  0
+-  /* There are much problems in this :( */
+-  if (is_fill) {
+-    if (!compare_color(&validated, &current_fill)) {
+-      return 0;
+-    }
+-  } else {
+-    if (!compare_color(&validated, &current_stroke)) {
+       return 0;
+     }
+   }
+-#endif
+-
+-  graphics_mode();
+-
+-  for (i = 0; i < validated.num_components; i++) {
+-    len = sprintf(format_buffer, " %g", ROUND(validated.values[i], 0.01));
+-    pdf_doc_add_page_content(format_buffer, len);
+-  }
+-
+-  switch (validated.num_components) {
+-  case  3:
+-    pdf_doc_add_page_content((is_fill ? " rg" : " RG"), 3);
+-    break;
+-  case  4:
+-    pdf_doc_add_page_content((is_fill ? " k"  : " K" ), 2);
+-    break;
+-  case  1:
+-    pdf_doc_add_page_content((is_fill ? " g"  : " G" ), 2);
+-    break;
+-  default:
+-    ERROR("Only RGB/CMYK/Gray currently supported.");
+-    return -1;
+-    break;
+-  }
+-
+-  if (is_fill) {
+-    memcpy(&current_fill,   &validated, sizeof(pdf_color));
+-  } else {
+-    memcpy(&current_stroke, &validated, sizeof(pdf_color));
+-  }
+-
+-  return  0;
++  return 1;
+ }
+ 
+-
+ /* Dvipdfm special */
+ pdf_color default_color = {
+   1,
+@@ -330,116 +243,77 @@
+ void
+ pdf_color_set_default (const pdf_color *color)
+ {
+-  ASSERT(color);
+-
+-  memcpy(&default_color, color, sizeof(pdf_color));
++  pdf_color_copycolor(&default_color, color);
+ }
+ 
+-
+-/*
+- * Having color stack here is wrong.
+- * dvi.c or XXX_special should treat this.
+- */
+ #define DEV_COLOR_STACK_MAX 128
+ 
+ static struct {
+-  int       next;
++  int       current;
+   pdf_color stroke[DEV_COLOR_STACK_MAX];
+   pdf_color fill[DEV_COLOR_STACK_MAX];
+ } color_stack = {
+   0,
+ };
+ 
+-/* BUG (20060330): color change does not effect on the next page.
+- *   The problem is due to the part of grestore because it restores
+- *   the color values in the state of gsave which are not correct
+- *   if the color values are changed inside of a page.
+- */
+ void
+-pdf_dev_preserve_color (void)
++pdf_color_clear_stack (void)
+ {
+-  if (color_stack.next > 0) {
+-    current_stroke = color_stack.stroke[color_stack.next];
+-    current_fill   = color_stack.fill[color_stack.next];
++  if (color_stack.current > 0) {
++    WARN("You've mistakenly made a global color change within nested colors.");
+   }
++  color_stack.current = 0;
++  pdf_color_copycolor(&color_stack.stroke[color_stack.current], &default_color);
++  pdf_color_copycolor(&color_stack.fill[color_stack.current], &default_color);
++  return;
+ }
+ 
+ void
+-pdf_dev_reset_color (void)
++pdf_color_push (pdf_color *sc, pdf_color *fc)
+ {
+-  int  colormode;
+-  pdf_color fillcolor, strokecolor;
+-
+-  /* Shouldn't give a warning */
+-  colormode = pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE);
+-  if (!colormode) {
+-    return;
+-  }
+-
+-  if (color_stack.next > 0) {
+-    strokecolor = current_stroke;
+-    fillcolor   = current_fill;
++  if (color_stack.current >= DEV_COLOR_STACK_MAX-1) {
++    WARN("Color stack overflow. Just ignore.");
+   } else {
+-    strokecolor = default_color;
+-    fillcolor   = default_color;
++    color_stack.current++;
++    pdf_color_copycolor(&color_stack.stroke[color_stack.current], sc);
++    pdf_color_copycolor(&color_stack.fill[color_stack.current], fc);
++    pdf_dev_reset_color();
+   }
+-
+-  pdf_dev_setcolor(&strokecolor, 0);
+-  pdf_dev_setcolor(&fillcolor, 1);
+- 
+   return;
+ }
+ 
+-
+ void
+-pdf_color_clear (void)
++pdf_color_pop (void)
+ {
+-  color_stack.next = 0;
++  if (color_stack.current <= 0) {
++    WARN("Color stack underflow. Just ignore.");
++  } else {
++    color_stack.current--;
++    pdf_dev_reset_color();
++  }
++  return;
+ }
+ 
+ void
+-pdf_color_push (void)
++pdf_color_get_current (pdf_color **sc, pdf_color **fc)
+ {
+-  int  current;
+-
+-  current = color_stack.next;
+-  if (current >= DEV_COLOR_STACK_MAX) {
+-    WARN("Exceeded depth of color stack.");
+-    return;
+-  }
+-
+-  memcpy(&color_stack.stroke[current],
+-	 &current_stroke, sizeof(pdf_color));
+-  memcpy(&color_stack.fill[current],
+-	 &current_fill  , sizeof(pdf_color));
+-
+-  color_stack.next++;
+-
++  *sc = &color_stack.stroke[color_stack.current];
++  *fc = &color_stack.fill[color_stack.current];
+   return;
+ }
+ 
++/* BUG (20060330): color change does not effect on the next page.
++ *   The problem is due to the part of grestore because it restores
++ *   the color values in the state of gsave which are not correct
++ *   if the color values are changed inside of a page.
++ */
+ void
+-pdf_color_pop (void)
++pdf_dev_preserve_color (void)
+ {
+-  int  current;
+-
+-  current = --(color_stack.next);
+-
+-  if (current <  0) {
+-    WARN("End color with no corresponding begin color.");
+-    /*
+-     * In the case of mismatched push and pop, color_stack.next must set
+-     * to be the default value, 0. Otherwise causes segmentation fault
+-     * in the next push command.
+-     */
+-    pdf_color_clear();
+-    return;
++  if (color_stack.current > 0) {
++    current_stroke = color_stack.stroke[color_stack.current];
++    current_fill   = color_stack.fill[color_stack.current];
+   }
+-
+-  pdf_dev_setcolor(&color_stack.stroke[current], 0);
+-  pdf_dev_setcolor(&color_stack.fill[current]  , 1);
+-
+-  return;
+ }
+ 
+ /***************************** COLOR SPACE *****************************/
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfcolor.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfcolor.h	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfcolor.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.h,v 1.7 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.h,v 1.8 2007/11/22 11:45:39 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -51,10 +51,6 @@
+ 
+ extern void       pdf_color_set_verbose   (void);
+ 
+-extern int        pdf_dev_setcolor        (const pdf_color *color, int is_fill);
+-
+-extern int        pdf_dev_currentcolor    (pdf_color *color, int is_fill);
+-
+ extern int        pdf_color_rgbcolor      (pdf_color *color,
+                                            double r, double g, double b);
+ extern int        pdf_color_cmykcolor     (pdf_color *color,
+@@ -63,6 +59,7 @@
+ extern void       pdf_color_copycolor     (pdf_color *color1, const pdf_color *color2);
+ 
+ extern int        pdf_color_is_white      (pdf_color *color);
++extern int        pdf_color_is_valid      (pdf_color *color);
+ 
+ /* Not check size */
+ extern pdf_obj *iccp_get_rendering_intent (const void *profile, long proflen);
+@@ -88,12 +85,15 @@
+  * See remark in spc_color.c.
+  */
+ extern void     pdf_color_set_default (const pdf_color *color);
+-extern void     pdf_color_push  (void);
++extern void     pdf_color_push  (pdf_color *sc, pdf_color *fc);
+ extern void     pdf_color_pop   (void);
+-extern void     pdf_color_clear (void);
++
++/* Color stack
++ */
++extern void     pdf_color_clear_stack (void);
++extern void     pdf_color_get_current (pdf_color **sc, pdf_color **fc);
+ 
+ /* Reinstall color */
+ extern void     pdf_dev_preserve_color(void);
+-extern void     pdf_dev_reset_color   (void);
+ 
+ #endif /* _PDF_COLOR_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdev.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfdev.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdev.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.61 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.64 2007/11/27 02:44:29 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -824,7 +824,7 @@
+     if (font->bold <= 0.0)
+       len = sprintf(format_buffer, " 0 Tr");
+     else
+-      len = sprintf(format_buffer, " 2 Tr %.2f w", font->bold); /* _FIXME_ */
++      len = sprintf(format_buffer, " 2 Tr %.6f w", font->bold); /* _FIXME_ */
+     pdf_doc_add_page_content(format_buffer, len);
+   }
+   text_state.bold_param = font->bold;
+@@ -1131,11 +1131,8 @@
+      * Same issues as earlier. Use floating point for simplicity.
+      * This routine needs to be fast, so we don't call sprintf() or strcpy().
+      */
+-#if 0
+-    text_state.offset -=
++    text_state.offset -= 
+       (spt_t) (kern * font->extend * (font->sptsize / 1000.0));
+-#endif
+-    text_state.offset   -= delh;
+     format_buffer[len++] = text_state.is_mb ? '>' : ')';
+     if (font->wmode)
+       len += p_itoa(-kern, format_buffer + len);
+@@ -1191,7 +1188,7 @@
+   dev_param.colormode = (black_and_white ? 0 : 1);
+ 
+   graphics_mode();
+-  pdf_color_clear();
++  pdf_color_clear_stack();
+   pdf_dev_init_gstates();
+ 
+   num_dev_fonts = 0;
+@@ -1219,7 +1216,7 @@
+   num_dev_fonts = 0;
+   max_dev_fonts = 0;
+ 
+-  pdf_dev_clean_gstates();
++  pdf_dev_clear_gstates();
+ }
+ 
+ /*
+@@ -1247,6 +1244,148 @@
+   text_state.is_mb         = 0;
+ }
+ 
++void
++pdf_dev_reset_color(void)
++{
++  pdf_color *sc, *fc;
++
++  if (pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
++    pdf_color_get_current(&sc, &fc);
++    pdf_dev_set_strokingcolor(sc);
++    pdf_dev_set_nonstrokingcolor(fc);
++  }
++  return;
++}
++
++static int
++color_to_string (pdf_color *color, char *buffer)
++{
++  int i, len = 0;
++
++  for (i = 0; i < color->num_components; i++) {
++    len += sprintf(format_buffer+len, " %g", ROUND(color->values[i], 0.001));
++  }
++  return len;
++}
++
++void
++pdf_dev_set_color (pdf_color *color)
++{
++  int len;
++
++  if (!pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
++    WARN("Ignore color option was set. Just ignore.");
++    return;
++  } else if (!(color && pdf_color_is_valid(color))) {
++    WARN("No valid color is specified. Just ignore.");
++    return;
++  }
++
++  graphics_mode();
++  len = color_to_string(color, format_buffer);
++  format_buffer[len++] = ' ';
++  switch (color->num_components) {
++  case  3:
++    format_buffer[len++] = 'R';
++    format_buffer[len++] = 'G';
++    break;
++  case  4:
++    format_buffer[len++] = 'K';
++    break;
++  case  1:
++    format_buffer[len++] = 'G';
++    break;
++  default: /* already verified the given color */
++    break;
++  }
++  strncpy(format_buffer+len, format_buffer, len);
++  len = len << 1;
++  switch (color->num_components) {
++  case  3:
++    format_buffer[len-2] = 'r';
++    format_buffer[len-1] = 'g';
++    break;
++  case  4:
++    format_buffer[len-1] = 'k';
++    break;
++  case  1:
++    format_buffer[len-1] = 'g';
++  break;
++  default: /* already verified the given color */
++    break;
++  }
++  pdf_doc_add_page_content(format_buffer, len);
++  return;
++}
++
++void
++pdf_dev_set_strokingcolor (pdf_color *color)
++{
++  int len;
++
++  if (!pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
++    WARN("Ignore color option was set. Just ignore.");
++    return;
++  } else if (!(color && pdf_color_is_valid(color))) {
++    WARN("No valid color is specified. Just ignore.");
++    return;
++  }
++
++  graphics_mode();
++  len = color_to_string(color, format_buffer);
++  format_buffer[len++] = ' ';
++  switch (color->num_components) {
++  case  3:
++    format_buffer[len++] = 'R';
++    format_buffer[len++] = 'G';
++    break;
++  case  4:
++    format_buffer[len++] = 'K';
++    break;
++  case  1:
++    format_buffer[len++] = 'G';
++    break;
++  default: /* already verified the given color */
++    break;
++  }
++  pdf_doc_add_page_content(format_buffer, len);
++  return;
++}
++
++void
++pdf_dev_set_nonstrokingcolor (pdf_color *color)
++{
++  int len;
++
++  if (!pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
++    WARN("Ignore color option was set. Just ignore.");
++    return;
++  } else if (!(color && pdf_color_is_valid(color))) {
++    WARN("No valid color is specified. Just ignore.");
++    return;
++  }
++
++  graphics_mode();
++  len = color_to_string(color, format_buffer);
++  format_buffer[len++] = ' ';
++  switch (color->num_components) {
++  case  3:
++    format_buffer[len++] = 'r';
++    format_buffer[len++] = 'g';
++    break;
++  case  4:
++    format_buffer[len++] = 'k';
++    break;
++  case  1:
++    format_buffer[len++] = 'g';
++    break;
++  default: /* already verified the given color */
++    break;
++  }
++  pdf_doc_add_page_content(format_buffer, len);
++  return;
++}
++
+ /* Not working */
+ void
+ pdf_dev_set_origin (double phys_x, double phys_y)
+@@ -1262,9 +1401,6 @@
+   pdf_dev_concat(&M1);
+ }
+ 
+-static pdf_color saved_sc, saved_fc;
+-static int have_saved_color = 0;
+-
+ void
+ pdf_dev_bop (const pdf_tmatrix *M)
+ {
+@@ -1276,28 +1412,15 @@
+   pdf_dev_concat(M);
+ 
+   pdf_dev_reset_fonts();
+-  pdf_dev_preserve_color(); /* preserve the last color in the previous page */
+   pdf_dev_reset_color();
+-
+-  if (have_saved_color) {
+-    pdf_dev_setcolor(&saved_sc, 0);
+-    pdf_dev_setcolor(&saved_fc, 1);
+-  }
+ }
+ 
+ void
+ pdf_dev_eop (void)
+ {
+   int  depth;
+-  
+-  graphics_mode();
+ 
+-  /* preserve the current color for start of next page, so \special{color...}
+-     doesn't cease to have any effect at a page break;
+-     note that printing pages out of order will break the assumptions here */
+-  pdf_dev_currentcolor(&saved_sc, 0);
+-  pdf_dev_currentcolor(&saved_fc, 1);
+-  have_saved_color = 1;
++  graphics_mode();
+ 
+   depth = pdf_dev_current_depth();
+   if (depth != 1) {
+@@ -1782,6 +1905,47 @@
+                             res_name,
+                             pdf_ximage_get_reference(id));
+ 
++  if (dvi_is_tracking_boxes()) {
++    pdf_tmatrix P;
++    int i;
++    pdf_rect rect;
++    pdf_coord corner[4];
++
++    pdf_dev_set_rect(&rect, 65536 * ref_x, 65536 * ref_y,
++	65536 * (r.urx - r.llx), 65536 * (r.ury - r.lly), 0);
++
++    corner[0].x = rect.llx; corner[0].y = rect.lly;
++    corner[1].x = rect.llx; corner[1].y = rect.ury;
++    corner[2].x = rect.urx; corner[2].y = rect.ury;
++    corner[3].x = rect.urx; corner[3].y = rect.lly;
++
++    pdf_copymatrix(&P, &(p->matrix));
++    for (i = 0; i < 4; ++i) {
++      corner[i].x -= rect.llx;
++      corner[i].y -= rect.lly;
++      pdf_dev_transform(&(corner[i]), &P);
++      corner[i].x += rect.llx;
++      corner[i].y += rect.lly;
++    }
++
++    rect.llx = corner[0].x;
++    rect.lly = corner[0].y;
++    rect.urx = corner[0].x;
++    rect.ury = corner[0].y;
++    for (i = 0; i < 4; ++i) {
++      if (corner[i].x < rect.llx)
++	rect.llx = corner[i].x;
++      if (corner[i].x > rect.urx)
++	rect.urx = corner[i].x;
++      if (corner[i].y < rect.lly)
++	rect.lly = corner[i].y;
++      if (corner[i].y > rect.ury)
++	rect.ury = corner[i].y;
++    }
++
++    pdf_doc_expand_box(&rect);
++  }
++
+   return 0;
+ }
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdev.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfdev.h	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdev.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.19 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.20 2007/11/22 11:45:39 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -27,6 +27,7 @@
+ 
+ #include "numbers.h"
+ #include "pdfobj.h"
++#include "pdfcolor.h"
+ 
+ typedef signed long spt_t;
+ 
+@@ -202,7 +203,11 @@
+  * XFrom (content grabbing) and Metapost support want them.
+  */
+ extern void   pdf_dev_reset_fonts (void);
+-extern void   pdf_dev_reset_color (void); /* defined in pdfcolor.c */
++extern void   pdf_dev_reset_color (void);
++
++extern void   pdf_dev_set_color            (pdf_color *color);
++extern void   pdf_dev_set_strokingcolor    (pdf_color *color);
++extern void   pdf_dev_set_nonstrokingcolor (pdf_color *color);
+ 
+ /* Initialization of transformation matrix with M and others.
+  * They are called within pdf_doc_begin_page() and pdf_doc_end_page().
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdoc.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfdoc.c	2006-12-21 13:35:39.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdoc.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.44 2006/12/20 08:10:13 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.50 2008/02/13 20:22:21 matthias Exp $
+  
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -144,9 +144,9 @@
+   MFCLOSE(fp);
+ 
+   if (found_in_cwd) {
+-    xobj_id = pdf_ximage_findresource(thumb_filename, 0, 0);
++    xobj_id = pdf_ximage_findresource(thumb_filename, 0/*, 0*/);
+   } else {
+-    xobj_id = pdf_ximage_findresource(guess_filename, 0, 0);
++    xobj_id = pdf_ximage_findresource(guess_filename, 0/*, 0*/);
+   }
+ 
+   if (xobj_id < 0) {
+@@ -511,7 +511,7 @@
+ # ifdef HAVE_TM_GMTOFF
+ #  define timezone (-bd_time->tm_gmtoff)
+ # else
+-#  define timezone  (-compute_timezone_offset())
++#  define timezone (-compute_timezone_offset())
+ # endif /* not HAVE_TM_GMTOFF */
+ #endif  /* not HAVE_TIMEZONE */
+   time_t      current_time;
+@@ -1037,6 +1037,7 @@
+                pdf_new_name("Last"),
+                pdf_link_obj(prev_ref));
+ 
++  pdf_release_obj(prev_ref);
+   pdf_release_obj(node->dict);
+   node->dict = NULL;
+ 
+@@ -1334,10 +1335,10 @@
+ #endif
+ 
+   rect_array = pdf_new_array();
+-  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->llx - annot_grow, 0.01)));
+-  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->lly - annot_grow, 0.01)));
+-  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->urx + annot_grow, 0.01)));
+-  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->ury + annot_grow, 0.01)));
++  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->llx - annot_grow, 0.001)));
++  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->lly - annot_grow, 0.001)));
++  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->urx + annot_grow, 0.001)));
++  pdf_add_array(rect_array, pdf_new_number(ROUND(rect->ury + annot_grow, 0.001)));
+   pdf_add_dict (annot_dict, pdf_new_name("Rect"), rect_array);
+ 
+   pdf_add_array(page->annots, pdf_ref_obj(annot_dict));
+@@ -1961,10 +1962,10 @@
+   currentpage->contents = currentpage->background;
+ 
+   pdf_dev_gsave();
+-  pdf_color_push();
+-  pdf_dev_setcolor(&bgcolor, 1); /* is_fill */
++  //pdf_color_push();
++  pdf_dev_set_nonstrokingcolor(&bgcolor);
+   pdf_dev_rectfill(r.llx, r.lly, r.urx - r.llx, r.ury - r.lly);
+-  pdf_color_pop();
++  //pdf_color_pop();
+   pdf_dev_grestore();
+ 
+   currentpage->contents = saved_content;
+@@ -2023,12 +2024,13 @@
+ 
+ void
+ pdf_open_document (const char *filename,
++		   int do_encryption, int do_objstm,
+                    double media_width, double media_height,
+                    double annot_grow_amount, int bookmark_open_depth)
+ {
+   pdf_doc *p = &pdoc;
+ 
+-  pdf_out_init(filename);
++  pdf_out_init(filename, do_encryption);
+ 
+   pdf_doc_init_catalog(p);
+ 
+@@ -2054,7 +2056,14 @@
+   pdf_doc_init_names    (p);
+   pdf_doc_init_page_tree(p, media_width, media_height);
+ 
+-  create_encrypt();
++  if (do_encryption) {
++    pdf_obj *encrypt = pdf_encrypt_obj();
++    pdf_set_encrypt(encrypt, pdf_enc_id_array());
++    pdf_release_obj(encrypt);
++  }
++
++  if (do_objstm)
++    pdf_objstm_init();
+ 
+ #ifndef NO_THUMBNAIL
+   /* Create a default name for thumbnail image files */
+@@ -2118,6 +2127,8 @@
+   }
+ #endif /* !NO_THUMBNAIL */
+ 
++  pdf_objstm_close();
++
+   return;
+ }
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdoc.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfdoc.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdoc.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.19 2005/07/30 11:44:18 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.21 2007/11/14 03:36:01 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -33,6 +33,7 @@
+ extern void     pdf_doc_set_verbose (void);
+ 
+ extern void     pdf_open_document  (const char *filename,
++				    int do_encryption, int do_objstm,
+ 				    double media_width, double media_height,
+ 				    double annot_grow_amount, int bookmark_open_depth);
+ extern void     pdf_close_document (void);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdraw.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfdraw.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdraw.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.13 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.14 2007/11/22 17:10:12 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -207,6 +207,7 @@
+     W.c = -(M->c) / det;  W.d =  (M->a) / det;
+     W.e =  (M->c) * (M->f) - (M->d) * (M->e);
+     W.f =  (M->b) * (M->e) - (M->a) * (M->f);
++    W.e /= det; W.f /= det;
+   }
+ 
+   pdf_copymatrix(M, &W);
+@@ -267,7 +268,7 @@
+ #define FORMAT_BUFF_LEN(p) 1024
+ 
+ static void
+-pdf_path__initpath (pdf_path *p)
++init_a_path (pdf_path *p)
+ {
+   ASSERT(p);
+ 
+@@ -301,7 +302,7 @@
+ }
+     
+ static void
+-pdf_path__cleanpath (pdf_path *p)
++clear_a_path (pdf_path *p)
+ {
+   ASSERT(p);
+ 
+@@ -710,7 +711,7 @@
+  (c) == 'f' || (c) == 'F' || \
+  (c) == 's' || (c) == 'S' || \
+  (c) == 'b' || (c) == 'B' || \
+- (c) == 'W' \
++ (c) == 'W' || (c) == ' ' \
+ )
+ 
+ static /* __inline__ */ int
+@@ -752,7 +753,7 @@
+ 
+   ASSERT(r && PT_OP_VALID(opchr));
+ 
+-  isclip = (opchr == 'W') ? 1 : 0;
++  isclip = (opchr == 'W' || opchr == ' ') ? 1 : 0;
+ 
+   /* disallow matrix for clipping.
+    * q ... clip Q does nothing and
+@@ -789,17 +790,21 @@
+   buf[len++] = ' ';
+   buf[len++] = 'r'; buf[len++] = 'e';
+ 
+-  buf[len++] = ' ';
+-  buf[len++] = opchr;
++  if (opchr != ' ') {
++    buf[len++] = ' ';
++    buf[len++] = opchr;
+ 
+-  buf[len++] = ' ';
+-  buf[len++] = isclip ? 'n' : 'Q';
++    buf[len++] = ' ';
++    buf[len++] = isclip ? 'n' : 'Q';
++  }
+ 
+   pdf_doc_add_page_content(buf, len); len = 0;
+ 
+   return 0;
+ }
+ 
++static int path_added = 0;
++
+ /* FIXME */
+ static int
+ pdf_dev__flushpath (pdf_dev   *P,
+@@ -815,13 +820,17 @@
+   pdf_coord *pt;
+   int        n_pts, n_seg;
+   int        len = 0;
++  int        isclip = 0;
+   int        isrect, i, j;
+ 
+   ASSERT(pa && PT_OP_VALID(opchr));
+ 
+-  if (PA_LENGTH(pa) <= 0)
++  isclip = (opchr == 'W') ? 1 : 0;
++
++  if (PA_LENGTH(pa) <= 0 && path_added == 0)
+     return 0;
+ 
++  path_added = 0;
+   graphics_mode();
+   isrect = pdf_path__isarect(pa, ignore_rule); 
+   if (isrect) {
+@@ -864,6 +873,9 @@
+   b[len++] = opchr;
+   if (rule == PDF_FILL_RULE_EVENODD)
+     b[len++] = '*';
++  if (isclip) {
++    b[len++] = ' '; b[len++] = 'n';
++  }
+ 
+   pdf_doc_add_page_content(b, len);
+ 
+@@ -899,6 +911,8 @@
+   /* internal */
+   pdf_path  path;
+   long      flags;
++  /* bookkeeping the origin of the last transform applied */
++  pdf_coord pt_fixee;
+ } pdf_gstate;
+ 
+ 
+@@ -987,25 +1001,18 @@
+ 
+ #define m_stack_depth(s)    ((s) ? (s)->size : 0)
+ 
+-
+-static m_stack _gsstck; /* FIXME */
+-
++static m_stack gs_stack;
+ 
+ static void
+-pdf_dev__init_gstate (pdf_gstate *gs)
++init_a_gstate (pdf_gstate *gs)
+ {
+-  pdf_path    *pa = &gs->path;
+-  pdf_color   *cf = &gs->fillcolor;
+-  pdf_color   *cs = &gs->strokecolor;
+-  pdf_tmatrix *M  = &gs->matrix;
+-
+   gs->cp.x = 0.0;
+   gs->cp.y = 0.0;
+ 
+-  pdf_setmatrix(M, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
++  pdf_setmatrix(&gs->matrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
+ 
+-  pdf_color_graycolor(cs, 0.0);
+-  pdf_color_graycolor(cf, 0.0);
++  pdf_color_graycolor(&gs->strokecolor, 0.0);
++  pdf_color_graycolor(&gs->fillcolor, 0.0);
+ 
+   gs->linedash.num_dash = 0;
+   gs->linedash.offset   = 0;
+@@ -1018,22 +1025,24 @@
+ 
+   /* Internal variables */
+   gs->flags = 0;
+-  pdf_path__initpath(pa);
++  init_a_path(&gs->path);
++  gs->pt_fixee.x = 0;
++  gs->pt_fixee.y = 0;
+ 
+   return;
+ }
+ 
+ static void
+-pdf_dev__clean_gstate (pdf_gstate *gs)
++clear_a_gstate (pdf_gstate *gs)
+ {
+-  pdf_path__cleanpath(&gs->path);
++  clear_a_path(&gs->path);
+   memset(gs, 0, sizeof(pdf_gstate));
+ 
+   return;
+ }
+ 
+ static void
+-pdf_dev__copy_gstate (pdf_gstate *gs1, pdf_gstate *gs2)
++copy_a_gstate (pdf_gstate *gs1, pdf_gstate *gs2)
+ {
+   int   i;
+ 
+@@ -1065,6 +1074,8 @@
+ 
+   pdf_color_copycolor(&gs1->fillcolor  , &gs2->fillcolor);
+   pdf_color_copycolor(&gs1->strokecolor, &gs2->strokecolor);
++  gs1->pt_fixee.x = gs2->pt_fixee.x;
++  gs1->pt_fixee.y = gs2->pt_fixee.y;
+ 
+   return;
+ }
+@@ -1072,156 +1083,89 @@
+ void
+ pdf_dev_init_gstates (void)
+ {
+-  m_stack    *gss = &_gsstck;
+   pdf_gstate *gs;
+ 
+-  m_stack_init(gss);
++  m_stack_init(&gs_stack);
+ 
+   gs = NEW(1, pdf_gstate);
+-  pdf_dev__init_gstate(gs);
++  init_a_gstate(gs);
+ 
+-  m_stack_push(gss, gs); /* Initial state */
++  m_stack_push(&gs_stack, gs); /* Initial state */
+ 
+   return;
+ }
+ 
+ void
+-pdf_dev_clean_gstates (void)
++pdf_dev_clear_gstates (void)
+ {
+-  m_stack    *gss = &_gsstck;
+   pdf_gstate *gs;
+ 
+-  if (m_stack_depth(gss) > 1) /* at least 1 elem. */
+-    WARN("GS stack depth not 0 at end of document.");
++  if (m_stack_depth(&gs_stack) > 1) /* at least 1 elem. */
++    WARN("GS stack depth is not zero at the end of the document.");
+ 
+-  while ((gs = m_stack_pop(gss)) != NULL) {
+-    pdf_dev__clean_gstate(gs);
++  while ((gs = m_stack_pop(&gs_stack)) != NULL) {
++    clear_a_gstate(gs);
+     RELEASE(gs);
+   }
+-
+   return;
+ }
+ 
+-
+ int
+-pdf_dev_currentpoint (pdf_coord *p)
+-{
+-  m_stack    *gss = &_gsstck;
+-  pdf_gstate *gs  = m_stack_top(gss);
+-  pdf_coord  *cpt = &gs->cp;
+-
+-  ASSERT(p);
+-
+-  p->x = cpt->x; p->y = cpt->y;
+-
+-  return 0;
+-}
+-
+-int
+-pdf_dev_currentmatrix (pdf_tmatrix *M)
+-{
+-  m_stack     *gss = &_gsstck;
+-  pdf_gstate  *gs  = m_stack_top(gss);
+-  pdf_tmatrix *CTM = &gs->matrix;
+-
+-  ASSERT(M);
+-
+-  pdf_copymatrix(M, CTM);
+-
+-  return 0;
+-}
+-
+-#if  0
+-int
+-pdf_dev_currentcolor (pdf_color *color, int is_fill)
++pdf_dev_gsave (void)
+ {
+-  m_stack    *gss = &_gsstck;
+-  pdf_gstate *gs  = m_stack_top(gss);
+-  pdf_color  *fcl = &gs->fillcolor;
+-  pdf_color  *scl = &gs->strokecolor;
++  pdf_gstate *gs0, *gs1;
++  pdf_color  *sc, *fc;
+ 
+-  ASSERT(color);
++  gs0 = m_stack_top(&gs_stack);
++  gs1 = NEW(1, pdf_gstate);
++  init_a_gstate(gs1);
++  copy_a_gstate(gs1, gs0);
++  pdf_color_get_current(&sc, &fc);
++  pdf_color_copycolor(&gs1->strokecolor, sc);
++  pdf_color_copycolor(&gs1->fillcolor, fc);
++  m_stack_push(&gs_stack, gs1);
+ 
+-  pdf_color_copycolor(color, is_fill ? fcl : scl);
++  pdf_doc_add_page_content(" q", 2);
+ 
+   return 0;
+ }
+-#endif /* 0 */
+ 
+ int
+-pdf_dev_concat (const pdf_tmatrix *M)
++pdf_dev_grestore (void)
+ {
+-  m_stack     *gss = &_gsstck;
+-  pdf_gstate  *gs  = m_stack_top(gss);
+-  pdf_path    *cpa = &gs->path;
+-  pdf_coord   *cpt = &gs->cp;
+-  pdf_tmatrix *CTM = &gs->matrix;
+-  pdf_tmatrix  W;
+-  char        *buf = FORMAT_BUFF_PTR(NULL);
+-  int          len = 0;
+-
+-  ASSERT(M);
++  pdf_gstate *gs;
++  pdf_color   sc, fc;
+ 
+-  /* Adobe Reader erases page content if there are
+-   * non invertible transformation.
+-   */
+-  if (fabs(detP(M)) < 1.0e-8) {
+-    WARN("Transformation matrix not invertible.");
+-    WARN("--- M = [%g %g %g %g %g %g]",
+-         M->a, M->b, M->c, M->d, M->e, M->f);
+-    return -1;
++  if (m_stack_depth(&gs_stack) <= 1) { /* Initial state at bottom */
++    WARN("Too many grestores.");
++    return  -1;
+   }
+ 
+-  buf[len++] = ' ';
+-  len += pdf_sprint_matrix(buf + len, M);
+-  buf[len++] = ' ';
+-  buf[len++] = 'c';
+-  buf[len++] = 'm';
+-  pdf_doc_add_page_content(buf, len);
+-
+-  pdf_concatmatrix(CTM, M);
+-
+-  inversematrix(&W, M);
+-
+-  pdf_path__transform (cpa, &W);
+-  pdf_coord__transform(cpt, &W);
+-
+-  return 0;
+-}
+-
+-
+-int
+-pdf_dev_gsave (void)
+-{
+-  m_stack    *gss = &_gsstck;
+-  pdf_gstate *gs0, *gs1;
+-
+-  gs0 = m_stack_top(gss);
+-  gs1 = NEW(1, pdf_gstate);
+-
+-  pdf_dev__init_gstate(gs1);
+-  pdf_dev__copy_gstate(gs1, gs0);
+-
+-  pdf_dev_currentcolor(&gs1->strokecolor, 0);
+-  pdf_dev_currentcolor(&gs1->fillcolor, 1);
++  gs = m_stack_pop(&gs_stack);
++//  pdf_color_copycolor(&sc, &gs->strokecolor);
++//  pdf_color_copycolor(&fc, &gs->fillcolor);
++  clear_a_gstate(gs);
++  RELEASE(gs);
+ 
+-  m_stack_push(gss, gs1);
++  pdf_doc_add_page_content(" Q", 2);
+ 
+-  pdf_doc_add_page_content(" q", 2);
++  pdf_dev_reset_fonts();
++//  pdf_dev_set_strokingcolor(&sc);
++//  pdf_dev_set_nonstrokingcolor(&fc);
+ 
+-  return 0;
++  return  0;
+ }
+ 
+ 
+ int
+ pdf_dev_push_gstate (void)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs0;
+ 
+   gs0 = NEW(1, pdf_gstate);
+ 
+-  pdf_dev__init_gstate(gs0);
++  init_a_gstate(gs0);
+ 
+   m_stack_push(gss, gs0);
+ 
+@@ -1232,7 +1176,7 @@
+ int
+ pdf_dev_pop_gstate (void)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs;
+ 
+   if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */
+@@ -1241,7 +1185,7 @@
+   }
+ 
+   gs = m_stack_pop(gss);
+-  pdf_dev__clean_gstate(gs);
++  clear_a_gstate(gs);
+   RELEASE(gs);
+ 
+   return  0;
+@@ -1251,16 +1195,15 @@
+ int
+ pdf_dev_current_depth (void)
+ {
+-  m_stack  *gss = &_gsstck;
+-
+-  return (m_stack_depth(gss) - 1); /* 0 means initial state */
++  return (m_stack_depth(&gs_stack) - 1); /* 0 means initial state */
+ }
+ 
+ void
+ pdf_dev_grestore_to (int depth)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs;
++  pdf_color   sc, fc;
+ 
+   ASSERT(depth >= 0);
+ 
+@@ -1271,44 +1214,105 @@
+   while (m_stack_depth(gss) > depth + 1) {
+     pdf_doc_add_page_content(" Q", 2);
+     gs = m_stack_pop(gss);
+-    pdf_dev__clean_gstate(gs);
++//    pdf_color_copycolor(&sc, &gs->strokecolor);
++//    pdf_color_copycolor(&fc, &gs->fillcolor);
++    clear_a_gstate(gs);
+     RELEASE(gs);
+   }
+   pdf_dev_reset_fonts();
+-  pdf_dev_reset_color();
++//  pdf_dev_set_strokingcolor(&sc);
++//  pdf_dev_set_nonstrokingcolor(&fc);
+ 
+   return;
+ }
+ 
+ int
+-pdf_dev_grestore (void)
++pdf_dev_currentpoint (pdf_coord *p)
+ {
+-  m_stack    *gss = &_gsstck;
+-  pdf_gstate *gs;
+-  pdf_color   sc, fc;
++  m_stack    *gss = &gs_stack;
++  pdf_gstate *gs  = m_stack_top(gss);
++  pdf_coord  *cpt = &gs->cp;
+ 
+-  if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */
+-    WARN("Too many grestores.");
+-    return  -1;
+-  }
++  ASSERT(p);
+ 
+-  gs = m_stack_pop(gss);
++  p->x = cpt->x; p->y = cpt->y;
+ 
+-  pdf_color_copycolor(&sc, &gs->strokecolor);
+-  pdf_color_copycolor(&fc, &gs->fillcolor);
++  return 0;
++}
+ 
+-  pdf_dev__clean_gstate(gs);
+-  RELEASE(gs);
++int
++pdf_dev_currentmatrix (pdf_tmatrix *M)
++{
++  m_stack     *gss = &gs_stack;
++  pdf_gstate  *gs  = m_stack_top(gss);
++  pdf_tmatrix *CTM = &gs->matrix;
+ 
+-  pdf_doc_add_page_content(" Q", 2);
++  ASSERT(M);
+ 
+-  pdf_dev_reset_fonts();
+-  pdf_dev_reset_color();
++  pdf_copymatrix(M, CTM);
+ 
+-  pdf_dev_setcolor(&sc, 0);
+-  pdf_dev_setcolor(&fc, 1);
++  return 0;
++}
+ 
+-  return  0;
++#if  0
++int
++pdf_dev_currentcolor (pdf_color *color, int is_fill)
++{
++  m_stack    *gss = &gs_stack;
++  pdf_gstate *gs  = m_stack_top(gss);
++  pdf_color  *fcl = &gs->fillcolor;
++  pdf_color  *scl = &gs->strokecolor;
++
++  ASSERT(color);
++
++  pdf_color_copycolor(color, is_fill ? fcl : scl);
++
++  return 0;
++}
++#endif /* 0 */
++
++int
++pdf_dev_concat (const pdf_tmatrix *M)
++{
++  m_stack     *gss = &gs_stack;
++  pdf_gstate  *gs  = m_stack_top(gss);
++  pdf_path    *cpa = &gs->path;
++  pdf_coord   *cpt = &gs->cp;
++  pdf_tmatrix *CTM = &gs->matrix;
++  pdf_tmatrix  W;
++  char        *buf = FORMAT_BUFF_PTR(NULL);
++  int          len = 0;
++
++  ASSERT(M);
++
++  /* Adobe Reader erases page content if there are
++   * non invertible transformation.
++   */
++  if (fabs(detP(M)) < 1.0e-8) {
++    WARN("Transformation matrix not invertible.");
++    WARN("--- M = [%g %g %g %g %g %g]",
++         M->a, M->b, M->c, M->d, M->e, M->f);
++    return -1;
++  }
++
++  if (fabs(M->a - 1.0) > 1.e-8 || fabs(M->b) > 1.e-8
++   || fabs(M->c) > 1.e-8 || fabs(M->d - 1.0) > 1.e-8
++   || fabs(M->e) > 1.e-8 || fabs(M->f) > 1.e-8) {
++    buf[len++] = ' ';
++    len += pdf_sprint_matrix(buf + len, M);
++    buf[len++] = ' ';
++    buf[len++] = 'c';
++    buf[len++] = 'm';
++    pdf_doc_add_page_content(buf, len);
++
++    pdf_concatmatrix(CTM, M);
++  }
++  inversematrix(&W, M);
++
++  pdf_path__transform (cpa, &W);
++  pdf_coord__transform(cpt, &W);
++
++  return 0;
+ }
+ 
+ /*
+@@ -1324,7 +1328,7 @@
+ int
+ pdf_dev_setmiterlimit (double mlimit)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   int         len = 0;
+   char       *buf = FORMAT_BUFF_PTR(NULL);
+@@ -1344,7 +1348,7 @@
+ int
+ pdf_dev_setlinecap (int capstyle)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   int         len = 0;
+   char       *buf = FORMAT_BUFF_PTR(NULL);
+@@ -1361,7 +1365,7 @@
+ int
+ pdf_dev_setlinejoin (int joinstyle)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   int         len = 0;
+   char       *buf = FORMAT_BUFF_PTR(NULL);
+@@ -1378,7 +1382,7 @@
+ int
+ pdf_dev_setlinewidth (double width)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);  
+   int         len = 0;
+   char       *buf = FORMAT_BUFF_PTR(NULL);
+@@ -1398,7 +1402,7 @@
+ int
+ pdf_dev_setdash (int count, double *pattern, double offset)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   int         len = 0;
+   char       *buf = FORMAT_BUFF_PTR(NULL);
+@@ -1424,7 +1428,7 @@
+ int
+ pdf_dev_setflat (int flatness)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   int         len = 0;
+   char       *buf = FORMAT_BUFF_PTR(NULL);
+@@ -1445,7 +1449,7 @@
+ int
+ pdf_dev_clip (void)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+ 
+@@ -1455,7 +1459,7 @@
+ int
+ pdf_dev_eoclip (void)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+ 
+@@ -1465,7 +1469,7 @@
+ int
+ pdf_dev_flushpath (char p_op, int fill_rule)
+ {
+-  m_stack    *gss   = &_gsstck;
++  m_stack    *gss   = &gs_stack;
+   pdf_gstate *gs    = m_stack_top(gss);
+   pdf_path   *cpa   = &gs->path;
+   int         error = 0;
+@@ -1485,7 +1489,7 @@
+ int
+ pdf_dev_newpath (void)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *p   = &gs->path;
+ 
+@@ -1501,7 +1505,7 @@
+ int
+ pdf_dev_moveto (double x, double y)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1514,7 +1518,7 @@
+ int
+ pdf_dev_rmoveto (double x, double y)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1528,7 +1532,7 @@
+ int
+ pdf_dev_lineto (double x, double y)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1542,7 +1546,7 @@
+ int
+ pdf_dev_rlineto (double x, double y)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1558,7 +1562,7 @@
+                   double x1, double y1,
+                   double x2, double y2)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1572,11 +1576,43 @@
+ }
+ 
+ int
++pdf_dev_vcurveto  (double x0, double y0,
++                  double x1, double y1)
++{
++  m_stack    *gss = &gs_stack;
++  pdf_gstate *gs  = m_stack_top(gss);
++  pdf_path   *cpa = &gs->path;
++  pdf_coord  *cpt = &gs->cp;
++  pdf_coord   p0, p1;
++
++  p0.x = x0; p0.y = y0;
++  p1.x = x1; p1.y = y1;
++
++  return pdf_path__curveto(cpa, cpt, cpt, &p0, &p1);
++}
++
++int
++pdf_dev_ycurveto  (double x0, double y0,
++                  double x1, double y1)
++{
++  m_stack    *gss = &gs_stack;
++  pdf_gstate *gs  = m_stack_top(gss);
++  pdf_path   *cpa = &gs->path;
++  pdf_coord  *cpt = &gs->cp;
++  pdf_coord   p0, p1;
++
++  p0.x = x0; p0.y = y0;
++  p1.x = x1; p1.y = y1;
++
++  return pdf_path__curveto(cpa, cpt, &p0, &p1, &p1);
++}
++
++int
+ pdf_dev_rcurveto (double x0, double y0,
+                   double x1, double y1,
+                   double x2, double y2)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1593,7 +1629,7 @@
+ int
+ pdf_dev_closepath (void)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_coord  *cpt = &gs->cp;
+   pdf_path   *cpa = &gs->path;
+@@ -1605,7 +1641,7 @@
+ void
+ pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M)
+ {
+-  m_stack     *gss = &_gsstck;
++  m_stack     *gss = &gs_stack;
+   pdf_gstate  *gs  = m_stack_top(gss);
+   pdf_tmatrix *CTM = &gs->matrix;
+ 
+@@ -1619,7 +1655,7 @@
+ void
+ pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M)
+ {
+-  m_stack     *gss = &_gsstck;
++  m_stack     *gss = &gs_stack;
+   pdf_gstate  *gs  = m_stack_top(gss);
+   pdf_tmatrix *CTM = &gs->matrix;
+ 
+@@ -1633,7 +1669,7 @@
+ void
+ pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M)
+ {
+-  m_stack     *gss = &_gsstck;
++  m_stack     *gss = &gs_stack;
+   pdf_gstate  *gs  = m_stack_top(gss);
+   pdf_tmatrix *CTM = &gs->matrix;
+ 
+@@ -1647,7 +1683,7 @@
+ void
+ pdf_dev_itransform (pdf_coord *p, const pdf_tmatrix *M)
+ {
+-  m_stack     *gss = &_gsstck;
++  m_stack     *gss = &gs_stack;
+   pdf_gstate  *gs  = m_stack_top(gss);
+   pdf_tmatrix *CTM = &gs->matrix;
+ 
+@@ -1662,7 +1698,7 @@
+ pdf_dev_arc  (double c_x , double c_y, double r,
+               double a_0 , double a_1)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1678,7 +1714,7 @@
+ pdf_dev_arcn (double c_x , double c_y, double r,
+               double a_0 , double a_1)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1696,7 +1732,7 @@
+               int    a_d ,
+               double xar)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;
+@@ -1712,7 +1748,7 @@
+ pdf_dev_bspline (double x0, double y0,
+                  double x1, double y1, double x2, double y2)
+ {
+-  m_stack    *gss = &_gsstck;
++  m_stack    *gss = &gs_stack;
+   pdf_gstate *gs  = m_stack_top(gss);
+   pdf_path   *cpa = &gs->path;
+   pdf_coord  *cpt = &gs->cp;  
+@@ -1772,3 +1808,36 @@
+   
+   return  pdf_dev__rectshape(NULL, &r, NULL, 'W');
+ }
++
++int
++pdf_dev_rectadd (double x, double y,
++                  double w, double h)
++{
++  pdf_rect r;
++
++  r.llx = x;
++  r.lly = y;
++  r.urx = x + w;
++  r.ury = y + h;
++  path_added = 1;
++
++  return  pdf_dev__rectshape(NULL, &r, NULL, ' ');
++}
++
++void
++pdf_dev_set_fixed_point (double x, double y)
++{
++  m_stack    *gss = &gs_stack;
++  pdf_gstate *gs  = m_stack_top(gss);
++  gs->pt_fixee.x = x;
++  gs->pt_fixee.y = y;
++}
++
++void
++pdf_dev_get_fixed_point (pdf_coord *p)
++{
++  m_stack    *gss = &gs_stack;
++  pdf_gstate *gs  = m_stack_top(gss);
++  p->x = gs->pt_fixee.x;
++  p->y = gs->pt_fixee.y;
++}
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdraw.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfdraw.h	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfdraw.h	2008-05-28 18:46:46.000000000 +0200
+@@ -83,6 +83,10 @@
+ extern int    pdf_dev_curveto       (double x0 , double y0,
+                                      double x1 , double y1,
+                                      double x2 , double y2);
++extern int    pdf_dev_vcurveto      (double x0 , double y0,
++                                     double x1 , double y1);
++extern int    pdf_dev_ycurveto      (double x0 , double y0,
++                                     double x1 , double y1);
+ extern int    pdf_dev_rcurveto      (double x0 , double y0,
+                                      double x1 , double y1,
+                                      double x2 , double y2);
+@@ -107,6 +111,7 @@
+                                     );
+ extern int    pdf_dev_rectfill      (double x, double y, double w, double h);
+ extern int    pdf_dev_rectclip      (double x, double y, double w, double h);
++extern int    pdf_dev_rectadd       (double x, double y, double w, double h);
+  
+ extern int    pdf_dev_flushpath     (char p_op, int fill_rule);
+ 
+@@ -156,4 +161,6 @@
+ extern int    pdf_dev_currentcolor  (pdf_color *color, int is_fill);
+ extern int    pdf_dev_setcolor      (const pdf_color *color, int is_fill);
+ 
++extern void pdf_dev_set_fixed_point (double x, double y);
++extern void pdf_dev_get_fixed_point (pdf_coord *p);
+ #endif /* _PDF_DRAW_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfencrypt.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfencrypt.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfencrypt.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.8 2005/07/20 08:49:55 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.9 2007/04/03 05:25:50 chofchof Exp $
+  
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -71,7 +71,6 @@
+ 
+ static char owner_passwd[MAX_PWD_LEN], user_passwd[MAX_PWD_LEN];
+ 
+-static unsigned char do_encryption = 0;
+ static unsigned char verbose = 0;
+ 
+ void pdf_enc_set_verbose (void)
+@@ -379,7 +378,6 @@
+     fflush(stderr);
+   }
+ 
+-  do_encryption = 1;
+   key_size = (unsigned char)(bits / 8);
+   algorithm = (key_size == 5 ? 1 : 2);
+   permission = (unsigned long)perm | 0x000000C0;
+@@ -396,8 +394,6 @@
+ {
+   unsigned char *result;
+ 
+-  if (!do_encryption) return;
+-
+   memcpy(in_buf, key_data, key_size);
+   in_buf[key_size]   = (unsigned char)(current_label) & 0xFF;
+   in_buf[key_size+1] = (unsigned char)(current_label >> 8) & 0xFF;
+@@ -416,20 +412,15 @@
+   RELEASE (result);
+ }
+ 
+-void create_encrypt (void)
++pdf_obj *pdf_encrypt_obj (void)
+ {
+   pdf_obj *doc_encrypt;
+ 
+-  if (!do_encryption) return;
+-
+ #ifdef DEBUG
+-  fprintf (stderr, "(create_encrypt)");
++  fprintf (stderr, "(pdf_encrypt_obj)");
+ #endif
+ 
+-  /* Create an empty Encryption entry and make it
+-     be the root object */
+   doc_encrypt = pdf_new_dict ();
+-  pdf_set_encrypt (doc_encrypt);
+ 
+   /* KEY  : Filter
+    * TYPE : name
+@@ -509,20 +500,15 @@
+ 		pdf_new_name ("P"),
+ 		pdf_new_number (permission));
+ 
+-  do_encryption = 0;
+-  pdf_release_obj (doc_encrypt);
+-  do_encryption = 1;
++  return doc_encrypt;
+ }
+ 
+-unsigned char *pdf_enc_id_string (void)
++pdf_obj *pdf_enc_id_array (void)
+ {
+-  register int i;
+-  static unsigned char result[MAX_STR_LEN+1];
+-
+-  for (i = 0; i < MAX_KEY_LEN; i++)
+-    sprintf((char *)(result+2*i), "%02x", id_string[i]);
+-
+-  return result;
++  pdf_obj *id = pdf_new_array();
++  pdf_add_array(id, pdf_new_string(id_string, MAX_KEY_LEN));
++  pdf_add_array(id, pdf_new_string(id_string, MAX_KEY_LEN));
++  return id;
+ }
+ 
+ void pdf_enc_set_label (unsigned long label)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfencrypt.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfencrypt.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfencrypt.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.h,v 1.2 2002/10/30 02:27:13 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.h,v 1.3 2007/04/03 05:25:50 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -23,13 +23,14 @@
+ #ifndef _PDFENCRYPT_H_
+ #define _PDFENCRYPT_H_
+ 
++#include "pdfobj.h"
++
+ extern void pdf_enc_set_verbose (void);
+-extern unsigned char *pdf_enc_id_string (void);
+-extern void pdf_enc_set_encryption (void);
++extern pdf_obj *pdf_enc_id_array (void);
+ extern void pdf_enc_set_label (unsigned long label);
+ extern void pdf_enc_set_generation (unsigned generation);
+ extern void pdf_enc_set_passwd (unsigned size, unsigned perm, char *dviname, char *pdfname);
+ extern void pdf_encrypt_data (unsigned char *data, unsigned long len);
+-extern void create_encrypt (void);
++extern pdf_obj *pdf_encrypt_obj (void);
+ 
+ #endif /* _PDFENCRYPT_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfobj.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfobj.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfobj.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.40 2006/12/06 13:14:54 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.49 2008/02/08 19:02:38 matthias Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -42,11 +42,19 @@
+ #endif /* HAVE_ZLIB */
+ 
+ #include "pdfobj.h"
++#include "pdfdev.h"
+ 
+ #define STREAM_ALLOC_SIZE      4096u
+ #define ARRAY_ALLOC_SIZE       256
+ #define IND_OBJECTS_ALLOC_SIZE 512
+ 
++#define OBJ_NO_OBJSTM   (1 << 0)
++/* Objects with this flag will not be put into an object stream.
++   For instance, all stream objects have this flag set.          */
++#define OBJ_NO_ENCRYPT  (1 << 1)
++/* Objects with this flag will not be encrypted.
++   This implies OBJ_NO_OBJSTM if encryption is turned on.        */
++
+ /* Any of these types can be represented as follows */
+ struct pdf_obj 
+ {
+@@ -56,6 +64,7 @@
+ 			    all other "label" to zero */
+   unsigned short generation;  /* Only used if "label" is used */
+   unsigned refcount;  /* Number of links to this object */
++  int      flags;
+   void    *data;
+ };
+ 
+@@ -105,8 +114,8 @@
+ 
+ struct pdf_indirect
+ {
+-  unsigned label;
+-  unsigned generation;
++  unsigned long label;
++  unsigned short generation;
+   int dirty;  /* Dirty objects came from an input file and were not
+ 		 generated by this program.  They have a label in a
+ 		 different numbering sequence.  These are translated
+@@ -136,19 +145,35 @@
+ 
+ static struct xref_entry 
+ {
+-  long     file_position;
+-  pdf_obj *object;
+-  int      used; /* Used by PDF import */
+-} *output_xref = NULL;
++  unsigned char  type;
++  unsigned long  field2;
++  unsigned short field3;  
++  int            used; /* Used by PDF import */
++} *output_xref;
+ 
+-static unsigned long pdf_max_ind_objects = 0;
+-static unsigned long next_label          = 1;
++static unsigned long pdf_max_ind_objects;
++static unsigned long next_label;
+ 
+ static unsigned long startxref;
+ 
+-static unsigned pdf_root_obj    = 0;
+-static unsigned pdf_info_obj    = 0;
+-static unsigned pdf_encrypt_obj = 0;
++static pdf_obj *output_stream;
++
++#define OBJSTM_MAX_OBJS  200
++/* the limit is only 100 for linearized PDF */
++
++typedef struct pdf_objstm
++{
++  pdf_obj *stream;
++  unsigned long obj_label[OBJSTM_MAX_OBJS];
++  unsigned long obj_pos  [OBJSTM_MAX_OBJS];
++  unsigned char pos;
++} pdf_objstm;
++
++static int enc_mode;
++static int doc_enc_mode;
++
++static pdf_obj *trailer_dict;
++static pdf_obj *xref_stream;
+ 
+ /* Internal static routines */
+ 
+@@ -156,6 +181,8 @@
+ static void pdf_label_obj (pdf_obj *object);
+ static void pdf_write_obj (pdf_obj *object, FILE *file);
+ 
++static void pdf_flush_objstm (pdf_objstm *objstm);
++
+ static void pdf_out_char (FILE *file, char c);
+ static void pdf_out      (FILE *file, const void *buffer, long length);
+ 
+@@ -186,8 +213,8 @@
+ static void write_stream   (pdf_stream *stream, FILE *file);
+ static void release_stream (pdf_stream *stream);
+ 
+-static pdf_obj *pdf_ref_file_obj (unsigned long obj_num, unsigned obj_gen);
+-static pdf_obj *pdf_read_object  (unsigned long obj_num, unsigned obj_gen);
++static pdf_obj *pdf_ref_file_obj (unsigned long obj_num, unsigned short obj_gen);
++static pdf_obj *pdf_read_object  (unsigned long obj_num, unsigned short obj_gen);
+ 
+ static int  verbose = 0;
+ static char compression_level = 9;
+@@ -212,7 +239,7 @@
+   return;
+ }
+ 
+-static unsigned pdf_version = 3;
++static unsigned pdf_version = 4;
+ 
+ void
+ pdf_set_version (unsigned version)
+@@ -235,13 +262,69 @@
+   verbose++;
+ }
+ 
++static pdf_objstm *current_objstm = NULL;
++
++void
++pdf_objstm_init ()
++{
++  if (pdf_version >= 5) {
++    current_objstm = NEW(1, pdf_objstm);
++    current_objstm->pos = 0;
++  }
++}
++
++void
++pdf_objstm_close ()
++{
++  if (current_objstm) {
++    RELEASE(current_objstm);
++    current_objstm = NULL;
++  }
++}
++
++static void
++add_xref_entry (unsigned long label, unsigned char type, unsigned long field2, unsigned short field3)
++{
++  if (label >= pdf_max_ind_objects) {
++    pdf_max_ind_objects = (label/IND_OBJECTS_ALLOC_SIZE+1)*IND_OBJECTS_ALLOC_SIZE;
++    output_xref = RENEW(output_xref, pdf_max_ind_objects, struct xref_entry);
++  }
++
++  output_xref[label].type   = type;
++  output_xref[label].field2 = field2;
++  output_xref[label].field3 = field3;
++}
++
+ #define BINARY_MARKER "%\344\360\355\370\n"
+ void
+-pdf_out_init (const char *filename)
++pdf_out_init (const char *filename, int do_encryption)
+ {
+   char v;
+ 
+-  pdf_output_file = MFOPEN(filename, FOPEN_WBIN_MODE);
++  output_xref = NULL;
++  pdf_max_ind_objects = 0;
++  add_xref_entry(0, 0, 0, 0xffff);
++  next_label = 1;
++
++  if (pdf_version >= 5) {
++    xref_stream = pdf_new_stream(STREAM_COMPRESS);
++    xref_stream->flags |= OBJ_NO_ENCRYPT;
++    trailer_dict = pdf_stream_dict(xref_stream);
++    pdf_add_dict(trailer_dict, pdf_new_name("Type"), pdf_new_name("XRef"));
++  } else
++    trailer_dict = pdf_new_dict();
++
++  output_stream = NULL;
++
++  if (filename == NULL) { /* no filename: writing to stdout */
++#ifdef WIN32
++	setmode(fileno(stdout), _O_BINARY);
++#endif
++    pdf_output_file = stdout;
++  }
++  else
++    pdf_output_file = MFOPEN(filename, FOPEN_WBIN_MODE);
++
+   if (!pdf_output_file) {
+     if (strlen(filename) < 128)
+       ERROR("Unable to open \"%s\".", filename);
+@@ -253,94 +336,134 @@
+   pdf_out(pdf_output_file, &v, 1);
+   pdf_out(pdf_output_file, "\n", 1);
+   pdf_out(pdf_output_file, BINARY_MARKER, strlen(BINARY_MARKER));
++
++  enc_mode = 0;
++  doc_enc_mode = do_encryption;
+ }
+ 
+ static void
+-dump_xref (void)
++dump_xref_table (void)
+ {
+   long length;
+   unsigned long i;
+ 
+-  /* Record where this xref is for trailer */
+-  startxref = pdf_output_file_position;
+-
+   pdf_out(pdf_output_file, "xref\n", 5);
+ 
+   length = sprintf(format_buffer, "%d %lu\n", 0, next_label);
+   pdf_out(pdf_output_file, format_buffer, length);
+ 
+-  length = sprintf(format_buffer, "%010ld %05ld f \n", 0L, 65535L);
+   /*
+    * Every space counts.  The space after the 'f' and 'n' is * *essential*.
+    * The PDF spec says the lines must be 20 characters long including the
+    * end of line character.
+    */
+-  pdf_out(pdf_output_file, format_buffer, length);
+-  for (i = 1; i < next_label; i++){
+-    length = sprintf(format_buffer, "%010ld %05ld n \n",
+-		     output_xref[i-1].file_position, 0L);
++  for (i = 0; i < next_label; i++) {
++    unsigned char type = output_xref[i].type;
++    if (type > 1)
++      ERROR("object type %hu not allowed in xref table", type);
++    length = sprintf(format_buffer, "%010lu %05hu %c \n",
++		     output_xref[i].field2, output_xref[i].field3,
++		     type ? 'n' : 'f');
+     pdf_out(pdf_output_file, format_buffer, length);
+   }
+-  /* Done with xref table */
+-  RELEASE(output_xref);
+-  output_xref = NULL;
+ }
+ 
+ static void
+-dump_trailer (void)
++dump_trailer_dict (void)
+ {
+-  long length;
+-  unsigned long starttrailer;
+-
+-  starttrailer = pdf_output_file_position;
+-
+   pdf_out(pdf_output_file, "trailer\n", 8);
+-  pdf_out(pdf_output_file, "<<\n", 3);
+-
+-  length = sprintf(format_buffer, "/Size %lu\n", next_label);
+-  pdf_out(pdf_output_file, format_buffer, length);
+-
+-  if (pdf_root_obj == 0) 
+-    ERROR ("dump_trailer:  Invalid root object");
+-  length = sprintf(format_buffer, "/Root %u %u R\n", pdf_root_obj, 0);
+-  pdf_out(pdf_output_file, format_buffer, length);
++  enc_mode = 0;
++  write_dict(trailer_dict->data, pdf_output_file);
++  pdf_release_obj(trailer_dict);
++  pdf_out_char(pdf_output_file, '\n');
++}
+ 
+-  if (pdf_encrypt_obj != 0) {
+-    length = sprintf(format_buffer, "/Encrypt %u %u R\n", pdf_encrypt_obj, 0);
+-    pdf_out(pdf_output_file, format_buffer, length);
+-  }
+-  if (pdf_info_obj != 0) {
+-    length = sprintf(format_buffer, "/Info %u %u R\n", pdf_info_obj, 0);
+-    pdf_out(pdf_output_file, format_buffer, length);
+-  }
+-  if (pdf_encrypt_obj != 0) {
+-    unsigned char *id;
+-    id = pdf_enc_id_string();
+-    length = sprintf(format_buffer, "/ID [<%s> <%s>]\n", id, id);
+-    pdf_out(pdf_output_file, format_buffer, length);
++/*
++ * output a PDF 1.5 cross-reference stream;
++ * contributed by Matthias Franz (March 21, 2007)
++ */
++static void
++dump_xref_stream (void)
++{
++  unsigned long pos, i;
++  unsigned poslen;
++  unsigned char buf[7] = {0, 0, 0, 0, 0};
++
++  pdf_obj *w;
++
++  pdf_label_obj(xref_stream);
++
++  /* determine the necessary size of the offset field */
++  pos = startxref; /* maximal offset value */
++  poslen = 1;
++  while (pos >>= 8)
++    poslen++;
++
++  w = pdf_new_array();
++  pdf_add_array(w, pdf_new_number(1));      /* type                */
++  pdf_add_array(w, pdf_new_number(poslen)); /* offset (big-endian) */
++  pdf_add_array(w, pdf_new_number(2));      /* generation          */
++  pdf_add_dict(trailer_dict, pdf_new_name("W"), w);
++
++  /* We need the xref entry for the xref stream right now */
++  add_xref_entry(next_label-1, 1, startxref, 0);
++
++  for (i = 0; i < next_label; i++) {
++    unsigned j;
++    buf[0] = output_xref[i].type;
++    pos = output_xref[i].field2;
++    for (j = poslen; j--; ) {
++      buf[1+j] = (unsigned char) pos;
++      pos >>= 8;
++    }
++    unsigned short f3 = output_xref[i].field3;
++    buf[poslen+1] = (unsigned char) (f3 >> 8);
++    buf[poslen+2] = (unsigned char) (f3);
++    pdf_add_stream(xref_stream, &buf, poslen+3);
+   }
+-  pdf_out(pdf_output_file, ">>\n", 3);
+-  pdf_out(pdf_output_file, "startxref\n", 10);
+ 
+-  length = sprintf(format_buffer, "%lu\n", startxref);
+-  pdf_out(pdf_output_file, format_buffer, length);
+-
+-  pdf_out(pdf_output_file, "%%EOF\n", 6);
++  pdf_release_obj(xref_stream);
+ }
+ 
+ void
+ pdf_out_flush (void)
+ {
+   if (pdf_output_file) {
+-    dump_xref();
+-    dump_trailer();
++    long length;
++
++    /* Flush current object stream */
++    if (current_objstm && current_objstm->pos)
++      pdf_flush_objstm(current_objstm);
++
++    /* Record where this xref is for trailer */
++    startxref = pdf_output_file_position;
++
++    pdf_add_dict(trailer_dict, pdf_new_name("Size"),
++		 pdf_new_number(next_label));
++
++    if (pdf_version >= 5)
++      dump_xref_stream();
++    else {
++      dump_xref_table();
++      dump_trailer_dict();
++    }
++
++    /* Done with xref table */
++    RELEASE(output_xref);
++
++    pdf_out(pdf_output_file, "startxref\n", 10);
++    length = sprintf(format_buffer, "%lu\n", startxref);
++    pdf_out(pdf_output_file, format_buffer, length);
++    pdf_out(pdf_output_file, "%%EOF\n", 6);
++
+     MESG("\n");
+     if (verbose) {
+       if (compression_level > 0) {
+-	MESG("Compression eliminated approximately %lu bytes\n", compression_saved);
++	MESG("Compression saved %ld bytes%s\n", compression_saved,
++	     pdf_version < 5 ? ". Try \"-V 5\" for better compression" : "");
+       }
+     }
+-    MESG("%lu bytes written", pdf_output_file_position);
++    MESG("%ld bytes written", pdf_output_file_position);
+ 
+     MFCLOSE(pdf_output_file);
+   }
+@@ -361,50 +484,52 @@
+ void
+ pdf_set_root (pdf_obj *object)
+ {
+-  if (pdf_root_obj != 0) {
++  if (pdf_add_dict(trailer_dict, pdf_new_name("Root"), pdf_ref_obj(object))) {
+     ERROR("Root object already set!");
+   }
+-  if (object->label == 0) {  /* Make sure this object has a label */
+-    pdf_label_obj(object);
+-  }
+-  pdf_root_obj = object->label;
++  /* Adobe Readers don't like a document catalog inside an encrypted
++   * object stream, although the PDF v1.5 spec seems to allow this.
++   * Note that we don't set OBJ_NO_ENCRYPT since the name dictionary in
++   * a document catalog may contain strings, which should be encrypted.
++   */
++  if (doc_enc_mode)
++    object->flags |= OBJ_NO_OBJSTM;
+ }
+ 
+ void
+ pdf_set_info (pdf_obj *object)
+ {
+-  if (pdf_info_obj != 0) {
++  if (pdf_add_dict(trailer_dict, pdf_new_name("Info"), pdf_ref_obj(object))) {
+     ERROR ("Info object already set!");
+   }
+-  if (object->label == 0) {  /* Make sure this object has a label */
+-    pdf_label_obj(object);
+-  }
+-  pdf_info_obj = object->label;
+ }
+ 
+ void
+-pdf_set_encrypt (pdf_obj *object)
++pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id)
+ {
+-  if (pdf_encrypt_obj != 0) {
++  if (pdf_add_dict(trailer_dict, pdf_new_name("Encrypt"), pdf_ref_obj(encrypt))) {
+     ERROR("Encrypt object already set!");
+   }
+-  if (object->label == 0) {  /* Make sure this object has a label */
+-    pdf_label_obj(object);
+-  }
+-  pdf_encrypt_obj = object->label;
++  encrypt->flags |= OBJ_NO_ENCRYPT;
++
++  pdf_add_dict(trailer_dict, pdf_new_name("ID"), id);
+ }
+ 
+ static
+ void pdf_out_char (FILE *file, char c)
+ {
+-  fputc(c, file);
+-  /* Keep tallys for xref table *only* if writing a pdf file. */
+-  if (file == pdf_output_file) {
+-    pdf_output_file_position += 1;
+-    if (c == '\n')
+-      pdf_output_line_position  = 0;
+-    else
+-      pdf_output_line_position += 1;
++  if (output_stream && file ==  pdf_output_file)
++    pdf_add_stream(output_stream, &c, 1);
++  else {
++    fputc(c, file);
++    /* Keep tallys for xref table *only* if writing a pdf file. */
++    if (file == pdf_output_file) {
++      pdf_output_file_position += 1;
++      if (c == '\n')
++        pdf_output_line_position  = 0;
++      else
++        pdf_output_line_position += 1;
++    }
+   }
+ }
+ 
+@@ -419,18 +544,32 @@
+ static
+ void pdf_out (FILE *file, const void *buffer, long length)
+ {
+-  fwrite(buffer, 1, length, file);
+-  /* Keep tallys for xref table *only* if writing a pdf file */
+-  if (file == pdf_output_file) {
+-    pdf_output_file_position += length;
+-    pdf_output_line_position += length;
+-    /* "foo\nbar\n "... */
+-    if (length > 0 &&
++  if (output_stream && file ==  pdf_output_file)
++    pdf_add_stream(output_stream, buffer, length);
++  else {
++    fwrite(buffer, 1, length, file);
++    /* Keep tallys for xref table *only* if writing a pdf file */
++    if (file == pdf_output_file) {
++      pdf_output_file_position += length;
++      pdf_output_line_position += length;
++      /* "foo\nbar\n "... */
++      if (length > 0 &&
+ 	((char *)buffer)[length-1] == '\n')
+-      pdf_output_line_position = 0;
++        pdf_output_line_position = 0;
++    }
+   }
+ }
+ 
++/*  returns 1 if a white-space character is necessary to separate
++    an object of type1 followed by an object of type2              */
++static
++int pdf_need_white (int type1, int type2)
++{
++  return !(type1 == PDF_STRING || type1 == PDF_ARRAY || type1 == PDF_DICT ||
++	   type2 == PDF_STRING || type2 == PDF_NAME ||
++	   type2 == PDF_ARRAY || type2 == PDF_DICT);
++}
++
+ static
+ void pdf_out_white (FILE *file)
+ {
+@@ -461,6 +600,7 @@
+   result->label      = 0;
+   result->generation = 0;
+   result->refcount   = 1;
++  result->flags      = 0;
+ 
+   return result;
+ }
+@@ -480,20 +620,12 @@
+   if (INVALIDOBJ(object))
+     ERROR("pdf_label_obj(): passed invalid object.");
+ 
+-  if (next_label > pdf_max_ind_objects) {
+-    pdf_max_ind_objects += IND_OBJECTS_ALLOC_SIZE;
+-    output_xref = RENEW(output_xref, pdf_max_ind_objects, struct xref_entry);
+-  }
+   /*
+    * Don't change label on an already labeled object. Ignore such calls.
+    */
+   if (object->label == 0) {
+-    /* Save so we can lookup this object by its number */
+-    output_xref[next_label-1].object = object;
+-    output_xref[next_label-1].file_position = 0L;
+-    object->label      = next_label;
++    object->label      = next_label++;
+     object->generation = 0;
+-    next_label++;
+   }
+ }
+ 
+@@ -563,13 +695,13 @@
+   if (indirect->dirty) {
+     if (file == stderr) {
+       pdf_out(file, "{d}", 3);
+-      length = sprintf(format_buffer, "%d %d R", indirect->label, indirect->generation);
++      length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation);
+       pdf_out(stderr, format_buffer, length);
+     } else {
+       pdf_obj *clean;
+ 
+       if (indirect->dirty_file != pdf_input_file) {
+-        ERROR("Input PDF file doesn't match object: label=%d, from_file=%p, current_file=%p",
++        ERROR("Input PDF file doesn't match object: label=%lu, from_file=%p, current_file=%p",
+               indirect->label, indirect->dirty_file, pdf_input_file);
+       }
+       clean = pdf_ref_file_obj(indirect->label, indirect->generation);
+@@ -577,7 +709,7 @@
+       pdf_release_obj(clean);
+     }
+   } else {
+-    length = sprintf(format_buffer, "%d %d R", indirect->label, indirect->generation);
++    length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation);
+     pdf_out(file, format_buffer, length);
+   }
+ }
+@@ -821,7 +953,10 @@
+   int  nescc = 0, i, count;
+ 
+   s = str->string;
+-  pdf_encrypt_data(s, str->length);
++
++  if (enc_mode)
++    pdf_encrypt_data(s, str->length);
++
+   /*
+    * Count all ASCII non-printable characters.
+    */
+@@ -1022,13 +1157,17 @@
+   pdf_out_char(file, '[');
+   if (array->size > 0) {
+     unsigned long i;
+-
++    int type1 = PDF_UNDEFINED, type2;
++    
+     for (i = 0; i < array->size; i++) {
+-      if (i > 0)
+-	pdf_out_white(file);
+-      if (!array->values[i])
++      if (array->values[i]) {
++	type2 = array->values[i]->type;
++	if (type1 != PDF_UNDEFINED && pdf_need_white(type1, type2))
++	  pdf_out_white(file);
++	type1 = type2;
++	pdf_write_obj(array->values[i], file);
++      } else
+ 	WARN("PDF array element #ld undefined.", i);
+-      pdf_write_obj(array->values[i], file);
+     }
+   }
+   pdf_out_char(file, ']');
+@@ -1201,10 +1340,7 @@
+   pdf_out (file, "<<\n", 3); /* dropping \n saves few kb. */
+   while (dict->key != NULL) {
+     pdf_write_obj(dict->key, file);
+-    if (((dict -> value)->type) == PDF_BOOLEAN  ||
+-	((dict -> value)->type) == PDF_NUMBER   ||
+-	((dict -> value)->type) == PDF_INDIRECT ||
+-	((dict -> value)->type) == PDF_NULL) {
++    if (pdf_need_white(PDF_NAME, (dict->value)->type)) {
+       pdf_out_white(file);
+     }
+     pdf_write_obj(dict->value, file);
+@@ -1248,10 +1384,11 @@
+ }
+ 
+ /* Array is ended by a node with NULL this pointer */
+-void
++/* pdf_add_dict returns 0 if the key is new and non-zero otherwise */
++int
+ pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value)
+ {
+-  pdf_dict *data;
++  pdf_dict *data, *new_node;
+ 
+   TYPECHECK(dict, PDF_DICT);
+   TYPECHECK(key,  PDF_NAME);
+@@ -1260,34 +1397,29 @@
+   if (value != NULL && INVALIDOBJ(value))
+     ERROR("pdf_add_dict(): Passed invalid value");
+ 
+-  data = dict->data;
+   /* If this key already exists, simply replace the value */
+-  while (data->key != NULL) {
++  for (data = dict->data; data->key != NULL; data = data->next) {
+     if (!strcmp(pdf_name_value(key), pdf_name_value(data->key))) {
+       /* Release the old value */
+       pdf_release_obj(data->value);
+       /* Release the new key (we don't need it) */
+       pdf_release_obj(key);
+       data->value = value;
+-      break;
++      return 1;
+     }
+-    data = data->next;
+   }
+   /*
+-   * If we didn't find the key, build a new "end" node and add
++   * We didn't find the key. We build a new "end" node and add
+    * the new key just before the end
+    */
+-  if (data->key == NULL) {
+-    pdf_dict *new_node;
+-
+-    new_node = NEW (1, pdf_dict);
+-    new_node->key = NULL;
+-    new_node->value = NULL;
+-    new_node->next = NULL;
+-    data->next  = new_node;
+-    data->key   = key;
+-    data->value = value;
+-  }
++  new_node = NEW (1, pdf_dict);
++  new_node->key = NULL;
++  new_node->value = NULL;
++  new_node->next = NULL;
++  data->next  = new_node;
++  data->key   = key;
++  data->value = value;
++  return 0;
+ }
+ 
+ void
+@@ -1456,6 +1588,7 @@
+   data->max_length    = 0;
+ 
+   result->data = data;
++  result->flags |= OBJ_NO_OBJSTM;
+ 
+   return result;
+ }
+@@ -1490,19 +1623,25 @@
+       (stream->_flags & STREAM_COMPRESS) &&
+       compression_level > 0) {
+ 
++    pdf_obj *filters = pdf_lookup_dict(stream->dict, "Filter");
++
+     buffer_length = filtered_length + filtered_length/1000 + 14;
+     buffer = NEW(buffer_length, unsigned char);
+     {
+-      pdf_obj *filters;
++      pdf_obj *filter_name = pdf_new_name("FlateDecode");
+ 
+-      filters = pdf_lookup_dict(stream->dict, "Filter");
+-      if (!filters)
+-	filters = pdf_new_array();
+-      /*
+-       * FlateDecode is the first filter to be applied to the stream.
+-       */
+-      pdf_unshift_array(filters, pdf_new_name("FlateDecode"));
+-      pdf_add_dict(stream->dict, pdf_new_name("Filter"), filters);
++      if (filters)
++        /*
++         * FlateDecode is the first filter to be applied to the stream.
++         */
++        pdf_unshift_array(filters, filter_name);
++      else
++        /*
++         * Adding the filter as a name instead of a one-element array
++         * is crucial because otherwise Adobe Reader cannot read the
++         * cross-reference stream any more, cf. the PDF v1.5 Errata.
++         */
++        pdf_add_dict(stream->dict, pdf_new_name("Filter"), filter_name);
+     }
+ #ifdef HAVE_ZLIB_COMPRESS2    
+     if (compress2(buffer, &buffer_length, filtered,
+@@ -1516,7 +1655,8 @@
+     }
+ #endif /* HAVE_ZLIB_COMPRESS2 */
+     RELEASE(filtered);
+-    compression_saved += filtered_length - buffer_length - strlen("/Filter [/FlateDecode]\n");
++    compression_saved += filtered_length - buffer_length
++      - (filters ? strlen("/FlateDecode "): strlen("/Filter/FlateDecode\n"));
+ 
+     filtered        = buffer;
+     filtered_length = buffer_length;
+@@ -1541,7 +1681,10 @@
+   pdf_write_obj(stream->dict, file);
+ 
+   pdf_out(file, "\nstream\n", 8);
+-  pdf_encrypt_data(filtered, filtered_length);
++
++  if (enc_mode)
++    pdf_encrypt_data(filtered, filtered_length);
++
+   if (filtered_length > 0) {
+     pdf_out(file, filtered, filtered_length);
+   }
+@@ -1700,11 +1843,12 @@
+   long length;
+ 
+   /*
+-   * Record file position.  No object is numbered 0, so subtract 1
+-   * when using as an array index
++   * Record file position
+    */
+-  output_xref[object->label-1].file_position = pdf_output_file_position;
+-  length = sprintf(format_buffer, "%lu %d obj\n", object->label, object->generation);
++  add_xref_entry(object->label, 1,
++		 pdf_output_file_position, object->generation);
++  length = sprintf(format_buffer, "%lu %hu obj\n", object->label, object->generation);
++  enc_mode = doc_enc_mode && !(object->flags & OBJ_NO_ENCRYPT);
+   pdf_enc_set_label(object->label);
+   pdf_enc_set_generation(object->generation);
+   pdf_out(file, format_buffer, length);
+@@ -1712,6 +1856,64 @@
+   pdf_out(file, "\nendobj\n", 8);
+ }
+ 
++static void
++pdf_add_objstm (pdf_objstm *objstm, pdf_obj *object)
++{
++  unsigned char pos = objstm->pos++;
++
++  if (!pos) {
++    pdf_obj *stream = pdf_new_stream(STREAM_COMPRESS);
++    pdf_label_obj(stream);
++    objstm->stream = stream;
++  }
++  objstm->obj_label[pos] = object->label;
++  objstm->obj_pos[pos] = pdf_stream_length(objstm->stream);
++  
++  add_xref_entry(object->label, 2, objstm->stream->label, pos);
++  
++  output_stream = objstm->stream;
++  enc_mode = 0;
++  pdf_write_obj(object, pdf_output_file);
++  pdf_out_char(pdf_output_file, '\n');
++  output_stream = NULL;
++  
++  if (pos == OBJSTM_MAX_OBJS-1)
++    pdf_flush_objstm(objstm);
++}
++
++static void
++pdf_flush_objstm (pdf_objstm *objstm)
++{
++  unsigned char pos = objstm->pos;
++  pdf_obj *stream_obj = objstm->stream;
++  TYPECHECK(stream_obj, PDF_STREAM);
++  pdf_stream *stream = (pdf_stream *) stream_obj->data;
++
++  /* Precede stream data by offset table */
++  unsigned char *old_buf = stream->stream;
++  unsigned long old_length = stream->stream_length;
++  /* Reserve 22 bytes for each entry (two 10 digit numbers plus two spaces) */
++  stream->stream = NEW(old_length + 22*pos, unsigned char);
++  stream->stream_length = 0;
++  
++  unsigned char i;
++  for (i = 0; i < pos; i++) {
++    long length = sprintf(format_buffer, "%lu %lu ",
++			  objstm->obj_label[i], objstm->obj_pos[i]);
++    pdf_add_stream(stream_obj, format_buffer, length);
++  }
++
++  pdf_obj *dict = pdf_stream_dict(stream_obj);
++  pdf_add_dict(dict, pdf_new_name("Type"), pdf_new_name("ObjStm"));
++  pdf_add_dict(dict, pdf_new_name("N"), pdf_new_number(pos));
++  pdf_add_dict(dict, pdf_new_name("First"), pdf_new_number(stream->stream_length));
++  
++  pdf_add_stream(stream_obj, old_buf, old_length);
++  RELEASE(old_buf);
++  pdf_release_obj(stream_obj);
++  objstm->pos = 0;
++}
++
+ void
+ pdf_release_obj (pdf_obj *object)
+ {
+@@ -1729,8 +1931,13 @@
+      * Nothing is using this object so it's okay to remove it.
+      * Nonzero "label" means object needs to be written before it's destroyed.
+      */
+-    if (object->label && pdf_output_file != NULL) { 
+-      pdf_flush_obj(object, pdf_output_file);
++    if (object->label && pdf_output_file != NULL) {
++      if (!current_objstm || object->flags & OBJ_NO_OBJSTM
++	  || (doc_enc_mode && object->flags & OBJ_NO_ENCRYPT)
++	  || object->generation)
++	pdf_flush_obj(object, pdf_output_file);
++      else
++	pdf_add_objstm(current_objstm, object);
+     }
+     switch (object->type) {
+     case PDF_BOOLEAN:
+@@ -2020,14 +2227,14 @@
+  * returns the retained existing reference to that object
+  */
+ static pdf_obj *
+-pdf_ref_file_obj (unsigned long obj_num, unsigned obj_gen)
++pdf_ref_file_obj (unsigned long obj_num, unsigned short obj_gen)
+ {
+   pdf_obj *obj, *ref;
+ 
+   if (!checklabel(obj_num, obj_gen)) {
+     WARN("Can't resolve object: %lu %u",
+          obj_num, obj_gen);
+-    return NULL;
++    return pdf_new_null();
+   }
+   ref = xref_table[obj_num].indirect;
+   if (ref != NULL)
+@@ -2050,15 +2257,11 @@
+ 
+ 
+ pdf_obj *
+-pdf_new_ref (unsigned long obj_num, int obj_gen) 
++pdf_new_ref (unsigned long obj_num, unsigned short obj_gen)
+ {
+   pdf_obj      *result;
+   pdf_indirect *indirect;
+ 
+-  if (!checklabel(obj_num, obj_gen)) {
+-    WARN("Invalid object label: %lu %d", obj_num, obj_gen);
+-    return NULL;
+-  }
+   result   = pdf_new_obj(PDF_INDIRECT);
+   indirect = NEW(1, pdf_indirect);
+   result->data = indirect;
+@@ -2075,7 +2278,7 @@
+  * be replaced with "null". But we won't do that.
+  */ 
+ static pdf_obj *
+-pdf_read_object (unsigned long obj_num, unsigned obj_gen) 
++pdf_read_object (unsigned long obj_num, unsigned short obj_gen)
+ {
+   pdf_obj *result;
+   long     offset, limit, length;
+@@ -2084,7 +2287,7 @@
+   if (!checklabel(obj_num, obj_gen)) {
+     WARN("Trying to read nonexistent object: %lu %u",
+          obj_num, obj_gen);
+-    return NULL;
++    return pdf_new_null();
+   }
+   if (labelfreed(obj_num, obj_gen)) {
+     WARN("Trying to read deleted object: %lu %u",
+@@ -2361,7 +2564,7 @@
+   }
+   pdf_input_file = file;
+   if (!check_for_pdf(pdf_input_file)) {
+-    WARN("pdf_open: Not a PDF 1.[1-3] file.");
++    WARN("pdf_open: Not a PDF 1.[1-5] file.");
+     return NULL;
+   }
+   if ((trailer = read_xref()) == NULL) {
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfobj.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfobj.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfobj.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.21 2005/05/04 16:10:06 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.23 2007/11/14 03:36:01 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -51,10 +51,12 @@
+ extern void     pdf_obj_set_verbose (void);
+ extern void     pdf_error_cleanup   (void);
+ 
+-extern void     pdf_out_init      (const char *filename);
++extern void     pdf_out_init      (const char *filename, int do_encryption);
+ extern void     pdf_out_flush     (void);
+ extern void     pdf_set_version   (unsigned version);
+ extern unsigned pdf_get_version   (void);
++extern void     pdf_objstm_init   (void);
++extern void     pdf_objstm_close  (void);
+ 
+ extern pdf_obj *pdf_new_obj     (int type);
+ extern void     pdf_release_obj (pdf_obj *object);
+@@ -124,7 +126,7 @@
+  * pdf_link_obj() it rather than allocate/free-ing them each time. But I
+  * already removed that.
+  */
+-extern void     pdf_add_dict     (pdf_obj *dict, pdf_obj *key,    pdf_obj *value); 
++extern int      pdf_add_dict     (pdf_obj *dict, pdf_obj *key,    pdf_obj *value); 
+ extern void     pdf_put_dict     (pdf_obj *dict, const char *key, pdf_obj *value); 
+ 
+ /* Apply proc(key, value, pdata) for each key-value pairs in dict, stop if proc()
+@@ -160,7 +162,7 @@
+ 
+ extern void      pdf_set_info     (pdf_obj *obj);
+ extern void      pdf_set_root     (pdf_obj *obj);
+-extern void      pdf_set_encrypt  (pdf_obj *obj);
++extern void      pdf_set_encrypt  (pdf_obj *encrypt, pdf_obj *id);
+ 
+ extern int      check_for_pdf     (FILE *file);
+ extern pdf_obj *pdf_open          (FILE *file);
+@@ -171,7 +173,7 @@
+ 
+ extern int      pdfobj_escape_str (char *buffer, int size, const unsigned char *s, int len);
+ 
+-extern pdf_obj *pdf_new_ref       (unsigned long label, int generation);
++extern pdf_obj *pdf_new_ref       (unsigned long label, unsigned short generation);
+ extern void     pdf_copy_object   (pdf_obj *dst, pdf_obj *src);
+ 
+ #endif  /* _PDFOBJ_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfparse.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfparse.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfparse.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.39 2005/07/21 05:05:14 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.40 2007/04/03 05:11:39 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -952,7 +952,8 @@
+ static pdf_obj *
+ try_pdf_reference (char *start, char *end, char **endptr)
+ {
+-  unsigned long id = 0, gen = 0;
++  unsigned long id = 0;
++  unsigned short gen = 0;
+ 
+   if (endptr)
+     *endptr = start;
+@@ -989,7 +990,7 @@
+   if (endptr)
+     *endptr = start;
+ 
+-  return pdf_new_ref(id, (int) gen);
++  return pdf_new_ref(id, gen);
+ }
+ 
+ pdf_obj *
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfximage.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfximage.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfximage.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.14 2005/07/30 11:44:18 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.17 2008/02/13 20:22:21 matthias Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -63,14 +63,15 @@
+ struct attr_
+ {
+   long     width, height;
++  double   xdensity, ydensity;
+   pdf_rect bbox;
+-  double   xdpi, ydpi;
+ };
+ 
+ struct pdf_ximage_
+ {
+   char        *ident;
+   char         res_name[16];
++  long         page_no, page_count;
+ 
+   int          subtype;
+ 
+@@ -79,7 +80,6 @@
+   char        *filename;
+   pdf_obj     *reference;
+   pdf_obj     *resource;
+-  int          page_index;
+   int          pdf_box;
+ };
+ 
+@@ -112,18 +112,18 @@
+ pdf_init_ximage_struct (pdf_ximage *I)
+ {
+   I->ident    = NULL;
++  I->page_no  = I->page_count = 0;
+   I->filename = NULL;
+   I->subtype  = -1;
+   memset(I->res_name, 0, 16);
+   I->reference = NULL;
+   I->resource  = NULL;
+-  I->page_index = 0;
+   I->pdf_box    = 0;
+ 
+   I->attr.width = I->attr.height = 0;
++  I->attr.xdensity = I->attr.ydensity = 1.0;
+   I->attr.bbox.llx = I->attr.bbox.lly = 0;
+   I->attr.bbox.urx = I->attr.bbox.ury = 0;
+-  I->attr.xdpi = I->attr.ydpi = 72.0;
+ }
+ 
+ static void
+@@ -256,8 +256,8 @@
+ 
+ 
+ static int
+-load_image (const char *ident, int page_index, int pdf_box,
+-            const char *fullname, int format, FILE  *fp)
++load_image (const char *ident,
++            const char *fullname, int format, FILE  *fp, long page_no)
+ {
+   struct ic_ *ic = &_ic;
+   int         id = -1; /* ret */
+@@ -271,6 +271,7 @@
+ 
+   I  = &ic->ximages[id];
+   pdf_init_ximage_struct(I);
++  pdf_ximage_set_page(I, page_no, 0);
+ 
+   switch (format) {
+   case  IMAGE_TYPE_JPEG:
+@@ -299,11 +300,12 @@
+   case  IMAGE_TYPE_PDF:
+     if (_opts.verbose)
+       MESG("[PDF]");
+-    if (pdf_include_page(I, fp, page_index, pdf_box) < 0)
++//    if (pdf_include_page(I, fp, page_index, pdf_box) < 0)
++    if (pdf_include_page(I, fp) < 0)
+       return  -1;
+     I->subtype  = PDF_XOBJECT_TYPE_FORM;
+-    I->page_index = page_index;
+-    I->pdf_box = pdf_box;
++//    I->page_index = page_index;
++//    I->pdf_box = pdf_box;
+     break;
+   case  IMAGE_TYPE_EPS:
+     if (_opts.verbose)
+@@ -348,7 +350,7 @@
+ #define dpx_fclose(f)  (MFCLOSE((f)))
+ 
+ int
+-pdf_ximage_findresource (const char *ident, int page_index, int pdf_box)
++pdf_ximage_findresource (const char *ident, long page_no)
+ {
+   struct ic_ *ic = &_ic;
+   int         id = -1;
+@@ -359,9 +361,8 @@
+ 
+   for (id = 0; id < ic->count; id++) {
+     I = &ic->ximages[id];
+-    if (I->ident && !strcmp(ident, I->ident)
+-      && page_index == I->page_index
+-      && pdf_box == I->pdf_box) {
++    if (I->ident && !strcmp(ident, I->ident) &&
++	I->page_no == page_no + (page_no < 0 ? I->page_count+1 : 0)) {
+       return  id;
+     }
+   }
+@@ -393,7 +394,7 @@
+     id = mps_include_page(ident, fp);
+     break;
+   default:
+-    id = load_image(ident, page_index, pdf_box, fullname, format, fp);
++    id = load_image(ident, fullname, format, fp, page_no);
+     break;
+   }
+   dpx_fclose(fp);
+@@ -409,6 +410,20 @@
+   return  id;
+ }
+ 
++/* Reference: PDF Reference 1.5 v6, pp.321--322
++ *
++ * TABLE 4.42 Additional entries specific to a type 1 form dictionary
++ *
++ * BBox rectangle (Required) An array of four numbers in the form coordinate
++ *                system, giving the coordinates of the left, bottom, right,
++ *                and top edges, respectively, of the form XObject's bounding
++ *                box. These boundaries are used to clip the form XObject and
++ *                to determine its size for caching.
++ *
++ * Matrix array   (Optional) An array of six numbers specifying the form
++ *                matrix, which maps form space into user space.
++ *                Default value: the identity matrix [1 0 0 1 0 0].
++ */
+ void
+ pdf_ximage_init_form_info (xform_info *info)
+ {
+@@ -425,6 +440,36 @@
+   info->matrix.f = 0.0;
+ }
+ 
++/* Reference: PDF Reference 1.5 v6, pp.303--306
++ *
++ * TABLE 4.42 Additional entries specific to an image dictionary
++ *
++ * Width integer  (Required) The width of the image, in samples.
++ *
++ * Height integer (Required) The height of the image, in samples.
++ *
++ * ColorSpace name or array
++ *                (Required for images, except those that use the JPXDecode
++ *                filter; not allowed for image masks) The color space in
++ *                which image samples are specified. This may be any type
++ *                of color space except Patter.
++ *
++ *                If the image uses the JPXDecode filter, this entry is
++ *                optional.
++ *
++ * BitsPerComponent integer
++ *                (Required except for image masks and images that use the
++ *                JPXDecode filter) The number of bits used to represent
++ *                each color component. Only a single value may be specified;
++ *                the number of bits is the same for all color components.
++ *                Valid values are 1,2,4,8, and (in PDF1.5) 16. If ImageMask
++ *                is true, this entry is optional, and if speficified, its
++ *                value must be 1.
++ *
++ *                If the image stream uses the JPXDecode filter, this entry
++ *                is optional and ignored if present. The bit depth is
++ *                determined in the process of decoding the JPEG2000 image.
++ */
+ void
+ pdf_ximage_init_image_info (ximage_info *info)
+ {
+@@ -434,7 +479,7 @@
+   info->bits_per_component = 0;
+   info->num_components = 0;
+   info->min_dpi = 0;
+-  info->xdpi = info->ydpi = 72.0;
++  info->xdensity = info->ydensity = 1.0;
+ }
+ 
+ void
+@@ -444,15 +489,14 @@
+   ximage_info *info = image_info;
+ 
+   if (!PDF_OBJ_STREAMTYPE(resource))
+-    ERROR("Image XObject must be stream type.");
++    ERROR("Image XObject must be of stream type.");
+ 
+   I->subtype = PDF_XOBJECT_TYPE_IMAGE;
+ 
+-  I->attr.width  = info->width;
+-  I->attr.height = info->height;
+-
+-  I->attr.xdpi = info->xdpi;
+-  I->attr.ydpi = info->ydpi;
++  I->attr.width  = info->width;  /* The width of the image, in samples */
++  I->attr.height = info->height; /* The height of the image, in samples */
++  I->attr.xdensity = info->xdensity;
++  I->attr.ydensity = info->ydensity;
+ 
+   I->reference = pdf_ref_obj(resource);
+ 
+@@ -469,21 +513,36 @@
+ }
+ 
+ void
+-pdf_ximage_set_form (pdf_ximage *I,  void *form_info, pdf_obj *resource)
++pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource)
+ {
+-  xform_info  *info = form_info;
++  xform_info *info = form_info;
+ 
+   I->subtype   = PDF_XOBJECT_TYPE_FORM;
++
+   I->attr.bbox.llx = info->bbox.llx;
+   I->attr.bbox.lly = info->bbox.lly;
+   I->attr.bbox.urx = info->bbox.urx;
+   I->attr.bbox.ury = info->bbox.ury;
+ 
+   I->reference = pdf_ref_obj(resource);
++
+   pdf_release_obj(resource); /* Caller don't know we are using reference. */
+   I->resource  = NULL;
+ }
+ 
++long
++pdf_ximage_get_page (pdf_ximage *I)
++{
++  return I->page_no;
++}
++
++void
++pdf_ximage_set_page (pdf_ximage *I, long page_no, long page_count)
++{
++  I->page_no    = page_no;
++  I->page_count = page_count;
++}
++
+ 
+ #define CHECK_ID(c,n) do {\
+   if ((n) < 0 || (n) >= (c)->count) {\
+@@ -495,8 +554,8 @@
+ pdf_obj *
+ pdf_ximage_get_reference (int id)
+ {
+-  struct ic_  *ic = &_ic;
+-  pdf_ximage  *I;
++  struct ic_ *ic = &_ic;
++  pdf_ximage *I;
+ 
+   CHECK_ID(ic, id);
+ 
+@@ -504,16 +563,17 @@
+   if (!I->reference)
+     I->reference = pdf_ref_obj(I->resource);
+ 
+-  return  pdf_link_obj(I->reference);
++  return pdf_link_obj(I->reference);
+ }
+ 
++/* called from pdfdoc.c only for late binding */
+ int
+ pdf_ximage_defineresource (const char *ident,
+ 			   int subtype, void *info, pdf_obj *resource)
+ {
+-  struct ic_  *ic = &_ic;
+-  int          id;
+-  pdf_ximage  *I;
++  struct ic_ *ic = &_ic;
++  int         id;
++  pdf_ximage *I;
+ 
+   id = ic->count;
+   if (ic->count >= ic->capacity) {
+@@ -532,12 +592,10 @@
+   switch (subtype) {
+   case PDF_XOBJECT_TYPE_IMAGE:
+     pdf_ximage_set_image(I, info, resource);
+-    I->subtype = PDF_XOBJECT_TYPE_IMAGE;
+     sprintf(I->res_name, "Im%d", id);
+     break;
+   case PDF_XOBJECT_TYPE_FORM:
+     pdf_ximage_set_form (I, info, resource);
+-    I->subtype = PDF_XOBJECT_TYPE_FORM;
+     sprintf(I->res_name, "Fm%d", id);
+     break;
+   default:
+@@ -552,71 +610,77 @@
+ char *
+ pdf_ximage_get_resname (int id)
+ {
+-  struct ic_  *ic = &_ic;
+-  pdf_ximage  *I;
++  struct ic_ *ic = &_ic;
++  pdf_ximage *I;
+ 
+   CHECK_ID(ic, id);
+ 
+   I = GET_IMAGE(ic, id);
+ 
+-  return  I->res_name;
++  return I->res_name;
+ }
+ 
++
+ /* depth...
+  * Dvipdfm treat "depth" as "yoffset" for pdf:image and pdf:uxobj
+  * not as vertical dimension of scaled image. (And there are bugs.)
+  * This part contains incompatibile behaviour than dvipdfm!
+  */
+-#define EBB_DPI 72	/* was 100 in dvipdfmx; changed to 72 to match xetex's ideas
+-                       about graphics resolution/scaling */
++#define EBB_DPI 72
++
+ static void
+ scale_to_fit_I (pdf_tmatrix    *T,
+                 transform_info *p,
+                 pdf_ximage     *I)
+ {
+-  double  s_x, s_y;
+-  long    wdx = I->attr.width;
+-  long    htx = I->attr.height;
+-  double  ar, dp;
+-  double  xdpi = I->attr.xdpi;
+-  double  ydpi = I->attr.ydpi;
+-
+-  /* if image didn't have DPI info, then treat it as EBB_DPI */
+-  if (xdpi == 0.0)
+-    xdpi = EBB_DPI;
+-  if (ydpi == 0.0)
+-    ydpi = EBB_DPI;
+-
+-  if (htx == 0) {
+-    WARN("Image height=0!");
+-    htx = 1;
+-  }
+-
+-  ar = (double) wdx / htx;
+-
+-  /* only width/height --> uniform (keep aspect ratio)
+-   * no width-height   --> uniform with 72dpi implied (?)
+-   * both width-height --> non-uniform
+-   */
++  double  s_x, s_y, d_x, d_y;
++  double  wd0, ht0, dp, xscale, yscale;
++
++  if (p->flags & INFO_HAS_USER_BBOX) {
++    wd0 =  p->bbox.urx - p->bbox.llx;
++    ht0 =  p->bbox.ury - p->bbox.lly;
++    xscale = I->attr.width * I->attr.xdensity / wd0;
++    yscale = I->attr.height * I->attr.ydensity / ht0;
++    d_x = -p->bbox.llx / wd0;
++    d_y = -p->bbox.lly / ht0;
++  } else {
++    wd0 = I->attr.width * I->attr.xdensity;
++    ht0 = I->attr.height * I->attr.ydensity;
++    xscale = yscale = 1.0;
++    d_x = 0.0;
++    d_y = 0.0; 
++  }
++
++  if (wd0 == 0.0) {
++    WARN("Image width=0.0!");
++    wd0 = 1.0;
++  }
++  if (ht0 == 0.0) {
++    WARN("Image height=0.0!");
++    ht0 = 1.0;
++  }
++
+   if ( (p->flags & INFO_HAS_WIDTH ) &&
+        (p->flags & INFO_HAS_HEIGHT) ) {
+-    s_x = p->width; s_y = p->height + p->depth;
+-    dp  = p->depth;
+-  } else if ( p->flags & INFO_HAS_WIDTH  ) {
+-    s_x = p->width; s_y = s_x / ar;
++    s_x = p->width * xscale;
++    s_y = (p->height + p->depth) * yscale;
++    dp  = p->depth * yscale;
++  } else if ( p->flags & INFO_HAS_WIDTH ) {
++    s_x = p->width * xscale;
++    s_y = s_x * ((double)I->attr.height / I->attr.width);
+     dp  = 0.0;
+-  } else if ( p->flags & INFO_HAS_HEIGHT ) {
+-    s_y = p->height + p->depth; s_x = s_y * ar;
+-    dp  = p->depth;
++  } else if ( p->flags & INFO_HAS_HEIGHT) {
++    s_y = (p->height + p->depth) * yscale;
++    s_x = s_y * ((double)I->attr.width / I->attr.height);
++    dp  = p->depth * yscale;
+   } else {
+-    s_x = wdx * 72.0 / xdpi;
+-    s_y = htx * 72.0 / ydpi;
++    s_x = wd0;
++    s_y = ht0;
+     dp  = 0.0;
+   }
+-
+-  T->a   = s_x;  T->c  = 0.0;
+-  T->b   = 0.0;  T->d  = s_y;
+-  T->e   = 0.0;  T->f  = -dp;
++  T->a = s_x; T->c = 0.0;
++  T->b = 0.0; T->d = s_y;
++  T->e = d_x * s_x / xscale; T->f = d_y * s_y / yscale - dp;
+ 
+   return;
+ }
+@@ -677,15 +741,16 @@
+ }
+ 
+ 
++/* called from pdfdev.c and spc_html.c */
+ int
+ pdf_ximage_scale_image (int            id,
+-                        pdf_tmatrix    *M, /* ret */
+-                        pdf_rect       *r, /* ret */
+-                        transform_info *p  /* arg */
++                        pdf_tmatrix    *M, /* return value for trans matrix */
++                        pdf_rect       *r, /* return value for clipping */
++                        transform_info *p  /* argument from specials */
+                        )
+ {
+-  struct ic_  *ic = &_ic;
+-  pdf_ximage  *I;
++  struct ic_ *ic = &_ic;
++  pdf_ximage *I;
+ 
+   CHECK_ID(ic, id);
+ 
+@@ -694,13 +759,47 @@
+   pdf_setmatrix(M, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
+ 
+   switch (I->subtype) {
++  /* Reference: PDF Reference 1.5 v6, p.302
++   *
++   * An image can be placed on the output page in any desired position,
++   * orientation, and size by using the cm operator to modify the current
++   * transformation matrix (CTM) so as to map the unit square of user space
++   * to the rectangle or parallelogram in which the image is to be painted.
++   *
++   * There is neither BBox nor Matrix key in the image XObject.
++   * Everything must be controlled by the cm operator.
++   *
++   * The argument [p] contains the user-defined bounding box, the scailing
++   * factor of which is bp as EPS and PDF. On the other hand, I->attr
++   * contains the (sampling) width and the (sampling) height of the image.
++   *
++   * There is no problem if a bitmap image has density information.
++   * Otherwise, DVIPDFM's ebb generates bounding box as 100px = 72bp = 1in.
++   * In this case, screen captured images look bad. Moreover, DVIPDFM's ebb
++   * ignores all density information and use just 100px = 72bp = 1in.
++   *
++   * On the other hand, pdfTeX uses 100px = 100bp to get a better quality
++   * for screen captured images.
++   *
++   * DVIPDFMx's xbb generates bounding box as 100px = 100bp in the same
++   * way as pdfTeX. Furthermore, it takes care of density information too.
++   */
+   case PDF_XOBJECT_TYPE_IMAGE:
+     scale_to_fit_I(M, p, I);
+-    r->llx = 0.0;
+-    r->lly = 0.0;
+-    r->urx = M->a;
+-    r->ury = M->d;
++    if (p->flags & INFO_HAS_USER_BBOX) {
++      r->llx = p->bbox.llx / (I->attr.width * I->attr.xdensity);
++      r->lly = p->bbox.lly / (I->attr.height * I->attr.ydensity);
++      r->urx = p->bbox.urx / (I->attr.width * I->attr.xdensity);
++      r->ury = p->bbox.ury / (I->attr.height * I->attr.ydensity);
++    } else {
++      r->llx = 0.0;
++      r->lly = 0.0;
++      r->urx = 1.0;
++      r->ury = 1.0;
++    }
+     break;
++  /* User-defined transformation and clipping are controlled by
++   * the cm operator and W operator, explicitly */
+   case PDF_XOBJECT_TYPE_FORM:
+     scale_to_fit_F(M, p, I);
+     if (p->flags & INFO_HAS_USER_BBOX) {
+@@ -708,7 +807,7 @@
+       r->lly = p->bbox.lly;
+       r->urx = p->bbox.urx;
+       r->ury = p->bbox.ury;
+-    } else {
++    } else { /* I->attr.bbox from the image bounding box */
+       r->llx = I->attr.bbox.llx;
+       r->lly = I->attr.bbox.lly;
+       r->urx = I->attr.bbox.urx;
+@@ -736,6 +835,11 @@
+   return;
+ }
+ 
++char *get_distiller_template (void)
++{
++  return _opts.cmdtmpl;
++}
++
+ static int
+ ps_include_page (pdf_ximage *ximage, const char *filename)
+ {
+@@ -776,7 +880,8 @@
+     dpx_delete_temp_file(temp);
+     return  -1;
+   }
+-  error = pdf_include_page(ximage, fp, 0, pdfbox_crop);
++//  error = pdf_include_page(ximage, fp, 0, pdfbox_crop);
++  error = pdf_include_page(ximage, fp);
+   MFCLOSE(fp);
+ 
+   if (_opts.verbose > 1) {
+@@ -803,5 +908,3 @@
+     return 1;
+   return 0;
+ }
+-
+-
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfximage.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pdfximage.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pdfximage.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.8 2005/07/30 11:44:18 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.11 2008/02/13 20:22:21 matthias Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -39,10 +39,9 @@
+   int  bits_per_component;
+   int  num_components;
+ 
+-  double  xdpi;
+-  double  ydpi;
+-
+   long min_dpi; /* NOT USED YET */
++
++  double xdensity, ydensity; /* scale factor for bp */
+ } ximage_info;
+ 
+ typedef struct {
+@@ -63,7 +62,7 @@
+ extern pdf_obj *pdf_ximage_get_reference  (int xobj_id);
+ 
+ 
+-extern int      pdf_ximage_findresource   (const char *ident, int page_index, int pdf_box);
++extern int      pdf_ximage_findresource   (const char *ident, long page_no/*, int pdf_box*/);
+ extern int      pdf_ximage_defineresource (const char *ident,
+ 					   int subtype, void *cdata, pdf_obj *resource);
+ 
+@@ -72,9 +71,12 @@
+ extern void pdf_ximage_init_form_info  (xform_info  *info);
+ extern void pdf_ximage_set_image (pdf_ximage *ximage, void *info, pdf_obj *resource);
+ extern void pdf_ximage_set_form  (pdf_ximage *ximage, void *info, pdf_obj *resource);
++extern void pdf_ximage_set_page  (pdf_ximage *ximage, long page_no, long page_count);
++extern long pdf_ximage_get_page  (pdf_ximage *I);
+ 
+ /* from psimage.h */
+ extern void set_distiller_template (char *s);
++extern char *get_distiller_template (void);
+ 
+ extern int
+ pdf_ximage_scale_image (int            id,
+@@ -83,4 +85,6 @@
+                         transform_info *p  /* arg */
+                        );
+ 
++/* from dvipdfmx.c */
++extern void pdf_ximage_disable_ebb (void);
+ #endif /* _PDFXIMAGE_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pngimage.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pngimage.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pngimage.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.24 2004/09/11 14:50:29 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.25 2007/05/18 05:19:01 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -165,8 +165,8 @@
+   png_structp png_ptr;
+   png_infop   png_info_ptr;
+   png_byte    bpc, color_type;
+-  png_uint_32 width, height, rowbytes;
+-  
++  png_uint_32 width, height, rowbytes, xppm, yppm;
++
+   pdf_ximage_init_image_info(&info);
+ 
+   stream      = NULL;
+@@ -192,9 +192,8 @@
+   width      = png_get_image_width (png_ptr, png_info_ptr);
+   height     = png_get_image_height(png_ptr, png_info_ptr);
+   bpc        = png_get_bit_depth   (png_ptr, png_info_ptr);
+-
+-  info.xdpi  = png_get_x_pixels_per_meter(png_ptr, png_info_ptr) * 0.0254;
+-  info.ydpi  = png_get_y_pixels_per_meter(png_ptr, png_info_ptr) * 0.0254;
++  xppm       = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
++  yppm       = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
+ 
+   /* We do not need 16-bpc color. Ask libpng to convert down to 8-bpc. */
+   if (bpc > 8) {
+@@ -214,6 +213,10 @@
+   info.width  = width;
+   info.height = height;
+   info.bits_per_component = bpc;
++  if (xppm > 0)
++    info.xdensity = 72.0 / 0.0254 / xppm;
++  if (yppm > 0)
++    info.ydensity = 72.0 / 0.0254 / yppm;
+ 
+   stream_data_ptr = (png_bytep) NEW(rowbytes*height, png_byte);
+   read_image_data(png_ptr, png_info_ptr, stream_data_ptr, height, rowbytes);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pst_obj.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/pst_obj.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/pst_obj.c	2008-05-28 18:46:46.000000000 +0200
+@@ -555,9 +555,11 @@
+     } else {
+       break;
+     }
+-    val = val * base + c;
++    if (val < (LONG_MAX - c) / base) {
++      val = val * base + c;
++      count++;
++    }
+     cur++;
+-    count++;
+   }
+ 
+   if (ndigits != NULL)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_color.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_color.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_color.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/spc_color.c,v 1.5 2005/07/30 11:44:18 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/spc_color.c,v 1.6 2007/11/22 11:45:39 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -74,18 +74,14 @@
+ static int
+ spc_handler_color_push (struct spc_env *spe, struct spc_arg *args)
+ {
+-  int        error = 0;
++  int        error;
+   pdf_color  colorspec;
+ 
+-  pdf_color_push(); /* save currentcolor */
+-  if (args->curptr < args->endptr) {
+-    error = spc_util_read_colorspec(spe, &colorspec, args, 1);
+-    if (!error) {
+-      pdf_dev_setcolor(&colorspec, 0);
+-      pdf_dev_setcolor(&colorspec, 1);
+-    }
++  error = spc_util_read_colorspec(spe, &colorspec, args, 1);
++  if (!error) {
++    pdf_color_push(&colorspec, &colorspec);
+   }
+-  
++
+   return  error;
+ }
+ 
+@@ -97,9 +93,8 @@
+   return  0;
+ }
+ 
+-/* _FIXME_ ... I don't understand this well.
+- * Dvips's implementation is to clear color stack and then
+- * push color?
++/* Invoked by the special command "color rgb .625 0 0".
++ * DVIPS clears the color stack, and then saves and sets the given color.
+  */
+ static int
+ spc_handler_color_default (struct spc_env *spe, struct spc_arg *args)
+@@ -109,10 +104,9 @@
+ 
+   error = spc_util_read_colorspec(spe, &colorspec, args, 1);
+   if (!error) {
+-    pdf_color_clear();
+-    pdf_dev_setcolor(&colorspec, 0);
+-    pdf_dev_setcolor(&colorspec, 1);
+-    pdf_color_push(); /* save currentcolor */
++    pdf_color_set_default(&colorspec);
++    pdf_color_clear_stack(); /* the default color is saved on color_stack */
++    pdf_color_push(&colorspec, &colorspec);
+   }
+ 
+   return  error;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_dvips.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_dvips.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_dvips.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.9 2005/08/19 12:06:24 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.10 2008/02/13 20:22:21 matthias Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -32,6 +32,9 @@
+ 
+ #include "dpxfile.h"
+ 
++#include "dvi.h"
++#include "dvicodes.h"
++
+ #include "pdfparse.h"
+ 
+ #include "pdfdoc.h"
+@@ -45,8 +48,10 @@
+ 
+ #include "specials.h"
+ #include "spc_util.h"
++#include "mfileio.h"
+ 
+ #include "spc_dvips.h"
++#include "spc_xtx.h"
+ 
+ 
+ static int    block_pending = 0;
+@@ -54,6 +59,39 @@
+ static double pending_y     = 0.0;
+ static int    position_set  = 0;
+ 
++static char** ps_headers = 0;
++static int num_ps_headers = 0;
++
++static int
++spc_handler_ps_header (struct spc_env *spe, struct spc_arg *args)
++{
++  char *ps_header, *pro;
++
++  skip_white(&args->curptr, args->endptr);
++  if (args->curptr + 1 >= args->endptr ||
++      args->curptr[0] != '=') {
++    spc_warn(spe, "No filename specified for PSfile special.");
++    return  -1;
++  }
++  args->curptr++;
++
++  pro = malloc(args->endptr - args->curptr + 1);
++  strncpy(pro, args->curptr, args->endptr - args->curptr);
++  pro[args->endptr - args->curptr] = 0;
++  ps_header = kpse_find_file(pro, kpse_tex_ps_header_format, 0);
++  if (!ps_header) {
++    spc_warn(spe, "PS header %s not found.", pro);
++    return -1;
++  }
++  free(pro);
++
++  if (!(num_ps_headers & 0x0f))
++    ps_headers = realloc(ps_headers, sizeof(char*) * (num_ps_headers + 16));
++  ps_headers[num_ps_headers++] = ps_header;
++  args->curptr = args->endptr;
++  return 0;
++}
++
+ static char *
+ parse_filename (char **pp, char *endptr)
+ {
+@@ -119,12 +157,12 @@
+   }
+ 
+   transform_info_clear(&ti);
+-  if (spc_util_read_dimtrns(spe, &ti, args, 1) < 0) {
++  if (spc_util_read_dimtrns(spe, &ti, args, NULL, 1) < 0) {
+     RELEASE(filename);
+     return  -1;
+   }
+ 
+-  form_id = pdf_ximage_findresource(filename, 0, 0);
++  form_id = pdf_ximage_findresource(filename, 1);
+   if (form_id < 0) {
+     spc_warn(spe, "Failed to read image file: %s", filename);
+     RELEASE(filename);
+@@ -157,7 +195,7 @@
+     return -1;
+   }
+ 
+-  form_id = pdf_ximage_findresource(filename, 0, 0);
++  form_id = pdf_ximage_findresource(filename, 1);
+   if (form_id < 0) {
+     spc_warn(spe, "Could not open PS file: %s", filename);
+     error = -1;
+@@ -243,6 +281,462 @@
+   return  error;
+ }
+ 
++static char *global_defs = 0;
++static char *page_defs = 0;
++static char *temporary_defs = 0;
++static char *distiller_template = 0;
++static pdf_coord *put_stack;
++static int put_stack_depth = -1;
++static char *gs_in = 0;
++
++static int
++spc_handler_ps_tricks_gdef (struct spc_env *spe, struct spc_arg *args)
++{
++  FILE* fp;
++
++  fp = fopen(global_defs, "a");
++  fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++  fprintf(fp, "\n");
++  fclose(fp);
++
++  return 0;
++}
++
++static int
++spc_handler_ps_tricks_pdef (struct spc_env *spe, struct spc_arg *args)
++{
++  FILE* fp;
++  pdf_tmatrix M, T = { 1, 0, 0, 1, 0, 0 };
++  pdf_coord pt;
++
++  pdf_dev_currentmatrix(&M);
++  pdf_dev_get_fixed_point(&pt);
++  T.e = pt.x;
++  T.f = pt.y;
++  pdf_concatmatrix(&M, &T);
++  if (page_defs == 0)
++    page_defs = dpx_create_temp_file();
++  fp = fopen(page_defs, "a");
++  fprintf(fp, "gsave initmatrix [%f %f %f %f %f %f] concat %f %f moveto\n", M.a, M.b, M.c, M.d, M.e, M.f, spe->x_user - pt.x, spe->y_user - pt.y);
++  fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++  fprintf(fp, "\ngrestore\n");
++  fclose(fp);
++
++  return 0;
++}
++
++static int
++spc_handler_ps_tricks_tdef (struct spc_env *spe, struct spc_arg *args)
++{
++  FILE* fp;
++  if (!temporary_defs)
++    temporary_defs = dpx_create_temp_file();
++  fp = fopen(temporary_defs, "w");
++  fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++  fprintf(fp, "\n");
++  fclose(fp);
++
++  return 0;
++}
++
++static int calculate_PS (char *string, int length, double *res1, double *res2);
++
++static int
++spc_handler_ps_tricks_bput (struct spc_env *spe, struct spc_arg *args, int must_def, int pre_def)
++{
++  char *PutBegin, *formula, *ncLabel;
++  int label = 0;
++  pdf_coord tr;
++  pdf_tmatrix M, T = { 1, 0, 0, 1, 0, 0 };
++
++  if (must_def != 0) {
++    ncLabel = strstr(args->curptr, "LPut");
++    if (ncLabel != 0 && ncLabel < args->endptr - 3)
++      label = 1;
++    ncLabel = strstr(args->curptr, "HPutPos");
++    if (ncLabel != 0 && ncLabel < args->endptr - 6)
++      label = 1;
++  }
++
++  if (pre_def == 0) {
++    dpx_delete_temp_file(temporary_defs);
++    temporary_defs = 0;
++  }
++
++  pdf_dev_currentmatrix(&M);
++  formula = malloc(args->endptr - args->curptr + 120);
++  if (label != 0) {
++    sprintf(formula, "[%f %f %f %f %f %f] concat %f %f moveto\n", M.a, M.b, M.c, M.d, M.e, M.f, spe->x_user + get_origin(1), spe->y_user + get_origin(0));
++  } else
++    sprintf(formula, "[%f %f %f %f %f %f] concat %f %f moveto\n", M.a, M.b, M.c, M.d, M.e, M.f, spe->x_user, spe->y_user);
++  strncat(formula, args->curptr, args->endptr - args->curptr);
++  PutBegin = strstr(formula, "PutBegin");
++  strcpy(PutBegin, "exch = =");
++  *(PutBegin + 8) = 0;
++  if (calculate_PS(formula, strlen(formula), &tr.x, &tr.y) == 0) {
++    if (!(++put_stack_depth & 0x0f))
++      put_stack = realloc(put_stack, (put_stack_depth + 16) * sizeof(pdf_coord));
++    put_stack[put_stack_depth] = tr;
++  }
++  T.e = tr.x; T.f = tr.y;
++
++  pdf_dev_concat(&T);
++
++  if (must_def != 0) {
++    FILE* fp;
++    if (!temporary_defs)
++      temporary_defs = dpx_create_temp_file();
++    fp  = fopen(temporary_defs, "a");
++    fprintf(fp, "gsave\n");
++    if (label == 0)
++      fprintf(fp, "[%f %f %f %f %f %f] concat %f %f moveto\n", M.a, M.b, M.c, M.d, M.e, M.f, spe->x_user, spe->y_user);
++    fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++    fprintf(fp, "\ngrestore\n");
++    fclose(fp);
++  }
++
++  free(formula);
++  return 0;
++}
++
++static int
++spc_handler_ps_tricks_eput (struct spc_env *spe, struct spc_arg *args)
++{
++  pdf_coord tr = put_stack[put_stack_depth--];
++  pdf_tmatrix M = { 1, 0, 0, 1, -tr.x, -tr.y };
++
++  pdf_dev_concat(&M);
++
++  return 0;
++}
++
++/* Rotation without gsave/grestore. */
++static double* RAngles = 0;
++static int RAngleCount = -1;
++
++static int
++spc_handler_ps_tricks_brotate (struct spc_env *spe, struct spc_arg *args)
++{
++  double value, RAngle = 0;
++  char *cmd, *RotBegin;
++  int i, l = args->endptr - args->curptr;
++
++  static char *pre = "tx@Dict begin /RAngle { %f } def\n";
++  static char *post = "= end";
++
++  if (!(++RAngleCount & 0x0f))
++    RAngles = realloc(RAngles, (RAngleCount + 16) * sizeof(double));
++  for (i = 0; i < RAngleCount; i++)
++    RAngle += RAngles[i];
++  cmd = calloc(l + strlen(pre) + strlen(post) + 12, 1);
++  sprintf(cmd, pre, RAngle);
++  strncat(cmd, args->curptr, l);
++  RotBegin = strstr(cmd, "RotBegin");
++  strcpy(RotBegin, post);
++  if (calculate_PS(cmd, strlen(cmd), &value, 0) != 0)
++    return -1;
++  RAngles[RAngleCount] = value;
++
++  return  spc_handler_xtx_do_rotate (spe->x_user, spe->y_user, value);
++}
++
++static int
++spc_handler_ps_tricks_erotate (struct spc_env *spe, struct spc_arg *args)
++{
++  double value = RAngles[RAngleCount--];
++
++  return  spc_handler_xtx_do_rotate (spe->x_user, spe->y_user, (-1.0) * value);
++}
++
++static int
++check_next_obj(unsigned char * buffer)
++{
++  switch (buffer[0]) {
++    case XXX1:
++      if (buffer[1] < 5)
++        return 0;
++      buffer += 2;
++      break;
++    case XXX2:
++      buffer += 3;
++      break;
++    case XXX3:
++      buffer += 4;
++      break;
++    case XXX4:
++      buffer += 5;
++      break;
++    default:
++      return 0;
++  }
++
++  if (strncmp(buffer, "pst:", 4))
++    return 0;
++  return 1;
++}
++
++static int
++spc_handler_ps_tricks_parse_path (struct spc_env *spe, struct spc_arg *args,
++			      int flag)
++{
++  FILE* fp;
++  int k;
++  pdf_tmatrix M;
++  char *distiller_template = get_distiller_template();
++  char *gs_out;
++  char *clip;
++  int error;
++
++  if (!distiller_template)
++    distiller_template = get_distiller_template();
++
++  pdf_dev_currentmatrix(&M);
++  if (!gs_in) {
++    gs_in = dpx_create_temp_file();
++    if (!gs_in) {
++      WARN("Failed to create temporary input file for PSTricks image conversion.");
++      return  -1;
++    }
++    fp = fopen(gs_in, "w");
++    for (k = 0; k < num_ps_headers; k++)
++      fprintf(fp, "(%s) run\n", ps_headers[k]);
++    fprintf(fp, "[%f %f %f %f %f %f] concat %f %f translate 0 0 moveto\n", M.a, M.b, M.c, M.d, M.e, M.f, spe->x_user, spe->y_user);
++    fprintf(fp, "(%s) run\n", global_defs);
++    if (page_defs != 0)
++      fprintf(fp, "(%s) run\n", page_defs);
++
++#if 0
++    fprintf(fp, "/clip {stroke} def\n");
++    fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++#else
++    clip = strstr(args->curptr, " clip");
++    if (clip == 0 || clip > args->endptr - 5) {
++      fprintf(fp, "tx@TextPathDict begin /stroke {} def\n");
++      fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++      fprintf(fp, "\nend\n");
++      fclose(fp);
++      return 0;
++    } else {
++      fwrite(args->curptr, 1, clip - args->curptr, fp);
++      fprintf(fp, " stroke ");
++      skip_white(&clip, args->endptr);
++      parse_ident(&clip, args->endptr);
++      fwrite(clip, 1, args->endptr - clip, fp);
++    }
++#endif
++  } else {
++    fp = fopen(gs_in, "a");
++    fprintf(fp, "flattenpath stroke\n");
++  }
++  fclose(fp);
++
++  gs_out = dpx_create_temp_file();
++  if (!gs_out) {
++    WARN("Failed to create temporary output file for PSTricks image conversion.");
++    RELEASE(gs_in);
++    gs_in = 0;
++    return  -1;
++  }
++
++  error = dpx_file_apply_filter(distiller_template, gs_in, gs_out);
++  if (error) {
++    WARN("Image format conversion for PSTricks failed.");
++    RELEASE(gs_in);
++    gs_in = 0;
++    return error;
++  }
++
++  fp = fopen(gs_out, "r");
++   if (pdf_copy_clip(fp, 1, 0, 0) != 0) {
++    spc_warn(spe, "Failed to parse the clipping path.");
++    RELEASE(gs_in);
++    gs_in = 0;
++    RELEASE(gs_out);
++    return -1;
++  }
++  fclose(fp);
++
++  dpx_delete_temp_file(gs_out);
++  dpx_delete_temp_file(gs_in);
++  gs_in = 0;
++
++  return 0;
++}
++
++static int
++spc_handler_ps_tricks_render (struct spc_env *spe, struct spc_arg *args)
++{
++  FILE* fp;
++  int k;
++  pdf_tmatrix M;
++
++  if (!distiller_template)
++    distiller_template = get_distiller_template();
++
++  pdf_dev_currentmatrix(&M);
++  if (!gs_in) {
++    gs_in = dpx_create_temp_file();
++    if (!gs_in) {
++      WARN("Failed to create temporary input file for PSTricks image conversion.");
++      return  -1;
++    }
++    fp = fopen(gs_in, "w");
++    for (k = 0; k < num_ps_headers; k++)
++      fprintf(fp, "(%s) run\n", ps_headers[k]);
++    fprintf(fp, "[%f %f %f %f %f %f] concat %f %f translate 0 0 moveto\n", M.a, M.b, M.c, M.d, M.e, M.f, spe->x_user, spe->y_user);
++    fprintf(fp, "(%s) run\n", global_defs);
++    if (page_defs != 0)
++      fprintf(fp, "(%s) run\n", page_defs);
++  } else
++    fp = fopen(gs_in, "a");
++
++  fprintf(fp, "\nsave\n");
++  fwrite(args->curptr, 1, args->endptr - args->curptr, fp);
++  fprintf(fp, "\ncount 1 sub {pop} repeat restore\n");
++
++  if (check_next_obj(args->endptr)) {
++    fclose(fp);
++  } else {
++    char *distiller_template = get_distiller_template();
++    char *gs_out;
++    int error, form_id;
++    transform_info p;
++    transform_info_clear(&p);
++    pdf_invertmatrix(&M);
++    p.matrix = M;
++
++    fclose(fp);
++
++    gs_out = dpx_create_temp_file();
++    if (!gs_out) {
++      WARN("Failed to create temporary output file for PSTricks image conversion.");
++      RELEASE(gs_in);
++      gs_in = 0;
++      return  -1;
++    }
++
++    error = dpx_file_apply_filter(distiller_template, gs_in, gs_out);
++    if (error) {
++      WARN("Image format conversion for PSTricks failed.");
++      RELEASE(gs_in);
++      gs_in = 0;
++      return error;
++    }
++
++    form_id = pdf_ximage_findresource(gs_out, 1/*, 0*/);
++    if (form_id < 0) {
++      spc_warn(spe, "Failed to read converted PSTricks image file.");
++      RELEASE(gs_in);
++      gs_in = 0;
++      RELEASE(gs_out);
++      return  -1;
++    }
++    pdf_dev_put_image(form_id, &p, 0, 0);
++
++    dpx_delete_temp_file(gs_out);
++    dpx_delete_temp_file(gs_in);
++    gs_in = 0;
++  }
++
++  return 0;
++}
++
++typedef enum {
++  render	= 1 << 0,
++  global_def	= 1 << 1,
++  page_def	= 1 << 2,
++  new_temp	= 1 << 3,
++  add_temp	= 1 << 4,
++  begin_put	= 1 << 5,
++  end_put	= 1 << 6,
++  begin_rotate	= 1 << 7,
++  end_rotate	= 1 << 8,
++  parse		= 1 << 9,
++  req_ref	= 1 << 10
++} Operation;
++
++/*	ToDo: all the substring search must be centralized so that	*
++ *	keys can be read from external configuration.			*/
++struct pstricks_key_ {
++  char * key;
++  Operation exec;
++} pstricks_key[] = {
++  /* The first 5 are hard-coded here. */
++  {"LPut",	add_temp | req_ref},
++  {"HPutPos",	add_temp | req_ref},
++  {"PutBegin",	begin_put},
++  {"RotBegin",	begin_rotate},
++  {"clip",	parse},
++  /* The rest can be read from an external source. */
++  {"NewNode",	page_def | req_ref},
++  {"InitNC",	render | new_temp},
++  {"/Glbx",	add_temp},
++  {"NewtonSolving",	add_temp},
++  {"PutEnd",	end_put},
++  {"RotEnd",	end_rotate},
++  {"mtrxc",	parse},
++  {"stroke",	render},
++  {"fill",	render},
++  {"Fill",	render},
++  {" Glbx", req_ref},
++  {"TextPathShow", parse},
++  {"/rotAngle", page_def},
++  {"NAngle", req_ref}
++};
++
++static int
++spc_handler_ps_trickscmd (struct spc_env *spe, struct spc_arg *args)
++{
++  char *test_string;
++  int k, error = 0, f_exec = 0;
++
++  /* Hack time! */
++  /* The problem is that while any macros in pstricks.tex
++   * can be overridden by the codes in pstricks.con, you cannot
++   * modify the pst@Verb specials generated by other PSTricks
++   * packages.  So pstricks generate specials won't signal what
++   * to expect for you.
++   */
++  test_string = malloc(args->endptr - args->curptr + 1);
++  strncpy(test_string, args->curptr, args->endptr - args->curptr);
++  test_string[args->endptr - args->curptr] = 0;
++  for (k = 0; k < sizeof(pstricks_key) / sizeof(pstricks_key[0]); k++) {
++    if (strstr(test_string, pstricks_key[k].key) != 0)
++      f_exec |= pstricks_key[k].exec;
++  }
++  free(test_string);
++
++  if (f_exec & new_temp)
++    error |= spc_handler_ps_tricks_tdef(spe, args);
++  if (f_exec & render)
++    error |= spc_handler_ps_tricks_render(spe, args);
++  if (f_exec & parse)
++    error |= spc_handler_ps_tricks_parse_path(spe, args, f_exec);
++  if (f_exec & begin_put)
++    error |= spc_handler_ps_tricks_bput(spe, args, (f_exec & add_temp), (f_exec & req_ref));
++  if (f_exec & end_put)
++    error |= spc_handler_ps_tricks_eput(spe, args);
++  if (f_exec & begin_rotate)
++    error |= spc_handler_ps_tricks_brotate(spe, args);
++  if (f_exec & end_rotate)
++    error |= spc_handler_ps_tricks_erotate(spe, args);
++  if (f_exec & page_def)
++    error |= spc_handler_ps_tricks_pdef (spe, args);
++  if (f_exec == 0)
++    error |= spc_handler_ps_tricks_pdef (spe, args);
++
++  args->curptr = args->endptr;
++  return error;
++}
++
++static int
++spc_handler_ps_tricksobj (struct spc_env *spe, struct spc_arg *args)
++{
++  int error = spc_handler_ps_tricks_render(spe, args);
++  args->curptr = args->endptr;
++  return error;
++}
++
+ static int
+ spc_handler_ps_default (struct spc_env *spe, struct spc_arg *args)
+ {
+@@ -283,18 +777,30 @@
+ }
+ 
+ static struct spc_handler dvips_handlers[] = {
++  {"header",      spc_handler_ps_header},
+   {"PSfile",        spc_handler_ps_file},
+   {"psfile",        spc_handler_ps_file},
+   {"ps: plotfile",  spc_handler_ps_plotfile}, /* FIXME */
+   {"PS: plotfile",  spc_handler_ps_plotfile}, /* FIXME */
+   {"PS:",           spc_handler_ps_literal},
+   {"ps:",           spc_handler_ps_literal},
++  {"PST:",          spc_handler_ps_trickscmd},
++  {"pst:",          spc_handler_ps_tricksobj},
+   {"\" ",           spc_handler_ps_default}
+ };
+ 
+ int
+ spc_dvips_at_begin_page (void)
+ {
++  FILE* fp;
++
++  if (page_defs) {
++    dpx_delete_temp_file(page_defs);
++    page_defs = 0;
++  }
++
++  put_stack_depth = -1;
++
+   return  0;
+ }
+ 
+@@ -302,18 +808,31 @@
+ spc_dvips_at_end_page (void)
+ {
+   mps_eop_cleanup();
++  if (!temporary_defs) {
++    dpx_delete_temp_file(temporary_defs);
++    temporary_defs = 0;
++  }
+   return  0;
+ }
+ 
+ int
+ spc_dvips_at_begin_document (void)
+ {
++  FILE* fp;
++
++  /* This, together with \pscharpath support code, must be moved to xtex.pro header. */
++  global_defs = dpx_create_temp_file();
++  fp = fopen(global_defs, "w");
++  fprintf(fp, "tx@Dict begin /STV {} def end\n");
++  fclose(fp);
+   return  0;
+ }
+ 
+ int
+ spc_dvips_at_end_document (void)
+ {
++  dpx_delete_temp_file(global_defs);
++  dpx_delete_temp_file(page_defs);
+   return  0;
+ }
+ 
+@@ -376,8 +895,8 @@
+ 
+   for (i = 0;
+        i < sizeof(dvips_handlers) / sizeof(struct spc_handler); i++) {
+-    if (keylen == strlen(dvips_handlers[i].key) &&
+-	!strncmp(key, dvips_handlers[i].key, keylen)) {
++    if (keylen <= strlen(dvips_handlers[i].key) && 
++	!strncmp(key, dvips_handlers[i].key, strlen(dvips_handlers[i].key))) {
+ 
+       skip_white(&args->curptr, args->endptr);
+ 
+@@ -393,3 +912,50 @@
+   return  -1;
+ }
+ 
++#ifdef __EMX__
++#define GS_CALCULATOR "gsos2 -q -dNOPAUSE -dBATCH -sDEVICE=nullpage -f  "
++#else
++#define GS_CALCULATOR "gs -q -dNOPAUSE -dBATCH -sDEVICE=nullpage -f  "
++#endif
++
++static
++int calculate_PS (char *string, int length, double *res1, double *res2) {
++  char *formula, *cmd;
++  FILE *fp, *coord;
++  int k;
++
++  if (res1 == 0 && res2 == 0)
++    return -1;
++  formula = dpx_create_temp_file();
++  fp = fopen(formula, "w");
++  for (k = 0; k < num_ps_headers; k++)
++    fprintf(fp, "(%s) run\n", ps_headers[k]);
++  fprintf(fp, "0 0 moveto\n");
++  fprintf(fp, "(%s) run\n", global_defs);
++  if (page_defs != 0)
++    fprintf(fp, "(%s) run\n", page_defs);
++  if (temporary_defs)
++    fprintf(fp, "(%s) run\n", temporary_defs);
++  fwrite(string, 1, length, fp);
++  fclose(fp);
++  k = strlen(GS_CALCULATOR) + strlen(formula) + 2;
++  cmd = malloc(k);
++  strcpy(cmd, GS_CALCULATOR);
++  strcat(cmd, " ");
++  strcat(cmd, formula);
++
++  coord = popen(cmd, "r");
++  if (coord) {
++    if (res1 == 0)
++      fscanf(coord, " %lf ", res2);
++    else if (res2 == 0)
++      fscanf(coord, " %lf ", res1);
++    else
++      fscanf(coord, " %lf %lf ", res1, res2);
++  } else
++    return -1;
++
++  pclose(coord);
++  dpx_delete_temp_file(formula);
++  return 0;
++}
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_html.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_html.c	2007-01-21 12:58:36.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_html.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.5 2005/08/14 15:50:36 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.6 2007/01/19 11:00:48 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -635,7 +635,7 @@
+     return  error;
+   }
+ 
+-  id = pdf_ximage_findresource(pdf_string_value(src), 0, 0);
++  id = pdf_ximage_findresource(pdf_string_value(src), 0/*, 0*/);
+   if (id < 0) {
+     spc_warn(spe, "Could not find/load image: %s", pdf_string_value(src)); 
+     error = -1;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_misc.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_misc.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_misc.c	2008-05-28 18:46:46.000000000 +0200
+@@ -134,7 +134,7 @@
+   }
+   MFCLOSE(fp);
+ 
+-  form_id = pdf_ximage_findresource(filename, 0, 0);
++  form_id = pdf_ximage_findresource(filename, 0/*, 0*/);
+   if (form_id < 0) {
+     spc_warn(spe, "Failed to load image file: %s", filename);
+     return  -1;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_pdfm.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_pdfm.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_pdfm.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.24 2006/12/11 12:46:03 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.30 2008/02/13 20:22:21 matthias Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -331,7 +331,6 @@
+   }
+   skip_white(&ap->curptr, ap->endptr);
+ 
+-
+   obj2 = parse_pdf_object(&ap->curptr, ap->endptr);
+   if (!obj2) {
+     spc_warn(spe, "Missing (an) object(s) to put into \"%s\"!", ident);
+@@ -392,7 +391,7 @@
+     break;
+   }
+   pdf_release_obj(obj2);
+-
++  RELEASE(ident);
+ 
+   return  error;
+ }
+@@ -526,6 +525,7 @@
+   }
+ 
+   pdf_set_string(instring, wbuf, op - wbuf);
++
+   return 0;
+ }
+ 
+@@ -640,7 +640,7 @@
+   }
+ 
+   transform_info_clear(&ti);
+-  if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
++  if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+     if (ident)
+       RELEASE(ident);
+     return  -1;
+@@ -774,9 +774,9 @@
+   if (error)
+     spc_warn(spe, "Invalid color specification?");
+   else {
+-    pdf_color_push(); /* save currentcolor */
+-    pdf_dev_setcolor(&fc, 1);
+-    pdf_dev_setcolor(&sc, 0);
++    pdf_color_push(&sc, &fc); /* save currentcolor */
++    pdf_dev_set_strokingcolor(&sc);
++    pdf_dev_set_nonstrokingcolor(&fc);
+   }
+ 
+   return  error;
+@@ -802,8 +802,8 @@
+     spc_warn(spe, "Invalid color specification?");
+   else {
+     pdf_color_set_default(&fc); /* ????? */
+-    pdf_dev_setcolor(&fc, 1);
+-    pdf_dev_setcolor(&sc, 0);
++    pdf_dev_set_strokingcolor(&sc);
++    pdf_dev_set_nonstrokingcolor(&fc);
+   }
+ 
+   return  error;
+@@ -824,7 +824,7 @@
+   transform_info  ti;
+ 
+   transform_info_clear(&ti);
+-  if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
++  if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+     return -1;
+   }
+ 
+@@ -862,11 +862,29 @@
+ {
+   struct spc_pdf_ *sd = &_pdf_stat;
+   pdf_obj   *item_dict, *tmp;
+-  int        level;
++  int        level, is_open = -1;
+   int        current_depth;
+ 
+   skip_white(&args->curptr, args->endptr);
+ 
++  /*
++   * pdf:outline is extended to support open/close feature
++   *
++   * pdf:outline 1 ... (as DVIPDFM)
++   * pdf:outline [] 1 ... (open bookmark)
++   * pdf:outline [-] 1 ... (closed bookmark)
++   */
++  if (args->curptr+3 < args->endptr && *args->curptr == '[') {
++    args->curptr++;
++    if (*args->curptr == '-') {
++      args->curptr++;
++    } else {
++      is_open = 1;
++    }
++    args->curptr++;
++  }
++  skip_white(&args->curptr, args->endptr);
++
+   tmp = parse_pdf_object(&args->curptr, args->endptr);
+   if (!tmp) {
+     spc_warn(spe, "Missing number for outline item depth.");
+@@ -912,7 +930,7 @@
+       pdf_doc_bookmarks_down();
+   }
+ 
+-  pdf_doc_bookmarks_add(item_dict, -1); /* Use global setting for open/close */
++  pdf_doc_bookmarks_add(item_dict, is_open);
+ 
+   return  0;
+ }
+@@ -940,8 +958,8 @@
+   info_dict = parse_pdf_dict(&args->curptr, args->endptr);
+ #endif /* ENABLE_TOUNICODE */
+   if (!info_dict) {
+-    RELEASE(ident);
+     spc_warn(spe, "Ignoring article with invalid info dictionary.");
++    RELEASE(ident);
+     return  -1;
+   }
+ 
+@@ -981,7 +999,7 @@
+ 
+   /* If okay so far, try to get a bounding box */
+   transform_info_clear(&ti);
+-  if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
++  if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+     RELEASE(article_name);
+     return  -1;
+   }
+@@ -1035,6 +1053,7 @@
+   page_no = pdf_doc_current_page_number();
+   pdf_doc_add_bead(article_name, NULL, page_no, &rect);
+ 
++  RELEASE(article_name);
+   return  0;
+ }
+ 
+@@ -1046,6 +1065,7 @@
+   char            *ident = NULL;
+   pdf_obj         *fspec;
+   transform_info   ti;
++  long             page_no;
+ 
+   skip_white(&args->curptr, args->endptr);
+   if (args->curptr[0] == '@') {
+@@ -1059,7 +1079,8 @@
+   }
+ 
+   transform_info_clear(&ti);
+-  if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
++  page_no = 1;
++  if (spc_util_read_dimtrns(spe, &ti, args, &page_no, 0) < 0) {
+     if (ident)
+       RELEASE(ident);
+     return  -1;
+@@ -1075,10 +1096,12 @@
+   } else if (!PDF_OBJ_STRINGTYPE(fspec)) {
+     spc_warn(spe, "Missing filename string for pdf:image.");
+     pdf_release_obj(fspec);
++    if (ident)
++      RELEASE(ident);
+     return  -1;
+   }
+ 
+-  xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), 0, 0);
++  xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), page_no);
+   if (xobj_id < 0) {
+     spc_warn(spe, "Could not find image resource...");
+     pdf_release_obj(fspec);
+@@ -1311,8 +1334,8 @@
+ 
+   object = parse_pdf_object(&args->curptr, args->endptr);
+   if (!object) {
+-    RELEASE(ident);
+     spc_warn(spe, "Could not find an object definition for \"%s\".", ident);
++    RELEASE(ident);
+     return  -1;
+   } else {
+     spc_push_object(ident, object);
+@@ -1451,16 +1474,16 @@
+   pdf_release_obj(tmp);
+   if (!fullname) {
+     spc_warn(spe, "Could not find file.");
+-    RELEASE(ident);
+     pdf_release_obj(fstream);
++    RELEASE(ident);
+     return  -1;
+   }
+ 
+   fp = MFOPEN(fullname, FOPEN_RBIN_MODE);
+   if (!fp) {
+     spc_warn(spe, "Could not open file: %s", fullname);
+-    RELEASE(ident);
+     pdf_release_obj(fstream);
++    RELEASE(ident);
+     return -1;
+   }
+ 
+@@ -1488,8 +1511,8 @@
+     tmp = parse_pdf_dict(&args->curptr, args->endptr);
+     if (!tmp) {
+       spc_warn(spe, "Parsing dictionary failed.");
+-      RELEASE(ident);
+       pdf_release_obj(fstream);
++      RELEASE(ident);
+       return -1;
+     }
+     if (pdf_lookup_dict(tmp, "Length")) {
+@@ -1541,7 +1564,7 @@
+   }
+ 
+   transform_info_clear(&ti);
+-  if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
++  if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+     RELEASE(ident);
+     return  -1;
+   }
+@@ -1654,7 +1677,7 @@
+ 
+   transform_info_clear(&ti);
+   if (args->curptr < args->endptr) {
+-    if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
++    if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+       RELEASE(ident);
+       return  -1;
+     }
+@@ -1666,7 +1689,7 @@
+    */
+   xobj_id = findresource(sd, ident);
+   if (xobj_id < 0) {
+-    xobj_id = pdf_ximage_findresource(ident, 0, 0);
++    xobj_id = pdf_ximage_findresource(ident, 0);
+     if (xobj_id < 0) {
+       spc_warn(spe, "Specified (image) object doesn't exist: %s", ident);
+       RELEASE(ident);
+@@ -1814,6 +1837,7 @@
+   } else {
+     error = pdf_load_fontmap_file(mapfile, mode);
+   }
++  RELEASE(mapfile);
+ 
+   return  error;
+ }
+@@ -1825,7 +1849,6 @@
+ {
+   struct spc_pdf_ *sd = &_pdf_stat;
+   char *cmap_name;
+-  int   error = 0;
+ 
+   /* First clear */
+   sd->cd.cmap_id = -1;
+@@ -1845,19 +1868,20 @@
+   cmap_name = parse_ident(&args->curptr, args->endptr);
+   if (!cmap_name) {
+     spc_warn(spe, "Missing ToUnicode mapping name...");
+-    return  -1;
++    return -1;
+   }
+ 
+   sd->cd.cmap_id = CMap_cache_find(cmap_name);
+   if (sd->cd.cmap_id < 0) {
+     spc_warn(spe, "Failed to load ToUnicode mapping: %s", cmap_name);
+-    error = -1;
++    RELEASE(cmap_name);
++    return -1;
+   }
+ 
+   /* Shift-JIS like encoding may contain backslash in 2nd byte.
+    * WARNING: This will add nasty extension to PDF parser.
+    */
+-  if (!error && sd->cd.cmap_id >= 0) {
++  if (sd->cd.cmap_id >= 0) {
+     if (strstr(cmap_name, "RKSJ") ||
+         strstr(cmap_name, "B5")   ||
+         strstr(cmap_name, "GBK")  ||
+@@ -1865,8 +1889,7 @@
+       sd->cd.unescape_backslash = 1;
+   }
+   RELEASE(cmap_name);
+-
+-  return  error;
++  return 0;
+ }
+ #endif /* ENABLE_TOUNICODE */
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_util.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_util.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_util.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,8 +1,8 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.7 2005/08/12 16:27:52 chofchof Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.10 2008/02/13 20:22:21 matthias Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+-    Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
++    Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+     
+     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
+@@ -238,6 +238,8 @@
+   else
+     error = spc_read_color_pdf(spe, colorspec, ap);
+ 
++  skip_blank(&ap->curptr, ap->endptr);
++
+   return  error;
+ }
+ 
+@@ -267,26 +269,39 @@
+   v = atof(q);
+   RELEASE(q);
+ 
++  skip_white(&ap->curptr, ap->endptr);
+   q = parse_c_ident(&ap->curptr, ap->endptr);
+   if (q) {
+-    if (strlen(q) > strlen("true") &&
++    char *qq = q;
++    if (strlen(q) >= strlen("true") &&
+         !memcmp(q, "true", strlen("true"))) {
+       u /= spe->mag != 0.0 ? spe->mag : 1.0; /* inverse magnify */
+       q += strlen("true");
+     }
+-    for (k = 0; ukeys[k] && strcmp(ukeys[k], q); k++);
+-    switch (k) {
+-    case K_UNIT__PT: u *= 72.0 / 72.27; break;
+-    case K_UNIT__IN: u *= 72.0; break;
+-    case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
+-    case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
+-    case K_UNIT__BP: u *= 1.0 ; break;
+-    default:
+-      spc_warn(spe, "Unknown unit of measure: %s", q);
+-      error = -1;
+-      break;
++    if (strlen(q) == 0) {
++      RELEASE(qq);
++      skip_white(&ap->curptr, ap->endptr);
++      qq = q = parse_c_ident(&ap->curptr, ap->endptr);
++    }
++    if (q) {
++      for (k = 0; ukeys[k] && strcmp(ukeys[k], q); k++);
++      switch (k) {
++      case K_UNIT__PT: u *= 72.0 / 72.27; break;
++      case K_UNIT__IN: u *= 72.0; break;
++      case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
++      case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
++      case K_UNIT__BP: u *= 1.0 ; break;
++      default:
++        spc_warn(spe, "Unknown unit of measure: %s", q);
++        error = -1;
++        break;
++      }
++      RELEASE(qq);
++    }
++    else {
++        spc_warn(spe, "Missing unit of measure after \"true\"");
++        error = -1;
+     }
+-    RELEASE(q);
+   }
+ 
+   *vp = v * u;
+@@ -396,9 +411,8 @@
+       spc_warn(spe, "Missing value for dimension/transformation: %s", kp);
+       error = -1;
+     }
+-
++    RELEASE(kp);
+     if (!vp || error) {
+-      RELEASE(kp);
+       break;
+     }
+ 
+@@ -461,7 +475,7 @@
+ 
+ 
+ static int
+-spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *ap)
++spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *ap, long *page_no)
+ {
+   int     has_scale, has_xscale, has_yscale, has_rotate, has_matrix;
+   const char *_dtkeys[] = {
+@@ -478,6 +492,8 @@
+     "bbox", /* See "Dvipdfmx User's Manual", p.5 */
+ #define  K_TRN__MATRIX 8
+     "matrix",
++#define  K_TRN__PAGE   9
++    "page",
+      NULL
+   };
+   double xscale, yscale, rotate;
+@@ -577,6 +593,15 @@
+         }
+       }
+       break;
++    case  K_TRN__PAGE:
++      {
++	double page;
++	if (page_no && spc_util_read_numbers(&page, 1, spe, ap) == 1)
++	  *page_no = (long) page;
++	else
++	  error = -1;
++      }
++      break;
+     default:
+       error = -1;
+       break;
+@@ -615,14 +640,15 @@
+ }
+ 
+ int
+-spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *args, int syntax)
++spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *args, long *page_no, int syntax)
+ {
+   ASSERT(ti && spe && args);
+ 
+   if (syntax) {
++    ASSERT(!page_no);
+     return  spc_read_dimtrns_dvips(spe, ti, args);
+   } else {
+-    return  spc_read_dimtrns_pdfm (spe, ti, args);
++    return  spc_read_dimtrns_pdfm (spe, ti, args, page_no);
+   }
+ 
+   return  -1;
+@@ -636,6 +662,7 @@
+ #ifdef  cmyk
+ #undef  cmyk
+ #endif
++#define gray(g)       {1, {g}}
+ #define rgb8(r,g,b)   {3, {((r)/255.0), ((g)/255.0), ((b)/255.0), 0.0}}
+ #define cmyk(c,m,y,k) {4, {(c), (m), (y), (k)}}
+ 
+@@ -709,9 +736,13 @@
+   {"Sepia",          cmyk(0.00, 0.83, 1.00, 0.70)},
+   {"Brown",          cmyk(0.00, 0.81, 1.00, 0.60)},
+   {"Tan",            cmyk(0.14, 0.42, 0.56, 0.00)},
+-  {"Gray",           cmyk(0.00, 0.00, 0.00, 0.50)},
+-  {"Black",          cmyk(0.00, 0.00, 0.00, 1.00)},
+-  {"White",          cmyk(0.00, 0.00, 0.00, 0.00)},
++  /* Adobe Reader 7 and 8 had problem when gray and cmyk black colors
++   * are mixed. No problem with Previewer.app.
++   * It happens when \usepackage[dvipdfm]{graphicx} and then called
++   * \usepackage{color} without dvipdfm option. */
++  {"Gray",           gray(0.5)},
++  {"Black",          gray(0.0)},
++  {"White",          gray(1.0)},
+   {NULL}
+ };
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_util.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_util.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_util.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/spc_util.h,v 1.4 2005/07/30 11:44:18 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/spc_util.h,v 1.5 2008/02/13 20:22:21 matthias Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -36,7 +36,7 @@
+  * This is for reading *single* color specification.
+  */
+ extern int  spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *args, int syntax);
+-extern int  spc_util_read_dimtrns   (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, int syntax);
++extern int  spc_util_read_dimtrns   (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, long *page, int syntax);
+ extern int  spc_util_read_length    (struct spc_env *spe, double *length, struct spc_arg *ap);
+ 
+ extern int  spc_util_read_numbers   (double *values, int num_values, struct spc_env *spe, struct spc_arg *args);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_xtx.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_xtx.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_xtx.c	2008-05-28 18:46:46.000000000 +0200
+@@ -74,6 +74,7 @@
+ int
+ spc_xtx_at_begin_page (void)
+ {
++  /*pdf_dev_set_fixed_point(0, 0);*/
+   return  0;
+ }
+ 
+@@ -84,50 +85,106 @@
+ }
+ 
+ static int
+-spc_handler_xtx_scale (struct spc_env *spe, struct spc_arg *args)
++spc_handler_xtx_do_scale (double x_user, double y_user, double valueX, double valueY)
+ {
+   pdf_tmatrix     M = { 0, 0, 0, 0, 0, 0 };
+-  double          values[2];
++  pdf_coord       pt;
+ 
+-  if (spc_util_read_numbers(&values[0], 2, spe, args) < 2) {
+-    return -1;
+-  }
+ 
+   /* Create transformation matrix */
+-  M.a = values[0];
+-  M.d = values[1];
+-  M.e = ((1.0 - M.a) * spe->x_user - M.c * spe->y_user);
+-  M.f = ((1.0 - M.d) * spe->y_user - M.b * spe->x_user);
++  M.a = valueX;
++  M.d = valueY;
++  M.e = ((1.0 - M.a) * x_user - M.c * y_user);
++  M.f = ((1.0 - M.d) * y_user - M.b * x_user);
+ 
+   pdf_dev_concat(&M);
++  pdf_dev_get_fixed_point(&pt);
++  pdf_dev_set_fixed_point(x_user - pt.x, y_user - pt.y);
+ 
+   return  0;
+ }
++static int
++spc_handler_xtx_scale (struct spc_env *spe, struct spc_arg *args)
++{
++  double          values[2];
++
++  if (spc_util_read_numbers(&values[0], 2, spe, args) < 2) {
++    return -1;
++  }
++  args->curptr = args->endptr;
++
++  return spc_handler_xtx_do_scale(spe->x_user, spe->y_user, values[0], values[1]);
++}
++
++/* Scaling without gsave/grestore. */
++static pdf_coord *scaleFactors = 0;
++static int scaleFactorCount = -1;
+ 
+ static int
+-spc_handler_xtx_rotate (struct spc_env *spe, struct spc_arg *args)
++spc_handler_xtx_bscale (struct spc_env *spe, struct spc_arg *args)
+ {
+-  pdf_tmatrix     M = { 0, 0, 0, 0, 0, 0 };
+-  double          value;
++  double          values[2];
+ 
+-  if (spc_util_read_numbers(&value, 1, spe, args) < 1) {
++  if (!(++scaleFactorCount & 0x0f))
++    scaleFactors = realloc(scaleFactors, (scaleFactorCount + 16) * sizeof(pdf_coord));
++  if (spc_util_read_numbers(&values[0], 2, spe, args) < 2) {
+     return -1;
+   }
++  if (fabs(values[0]) < 1.e-7 || fabs(values[1]) < 1.e-7) {
++    return -1;
++  }
++  scaleFactors[scaleFactorCount].x = 1 / values[0];
++  scaleFactors[scaleFactorCount].y = 1 / values[1];
++  args->curptr = args->endptr;
++
++  return  spc_handler_xtx_do_scale (spe->x_user, spe->y_user, values[0], values[1]);
++}
++
++static int
++spc_handler_xtx_escale (struct spc_env *spe, struct spc_arg *args)
++{
++  pdf_coord factor = scaleFactors[scaleFactorCount--];
++
++  args->curptr = args->endptr;
++
++  return  spc_handler_xtx_do_scale (spe->x_user, spe->y_user, factor.x, factor.y);
++}
++
++int
++spc_handler_xtx_do_rotate (double x_user, double y_user, double value)
++{
++  pdf_tmatrix     M = { 0, 0, 0, 0, 0, 0 };
++  pdf_coord       pt;
+ 
+   /* Create transformation matrix */
+   M.a = cos(value * M_PI / 180);
+   M.b = sin(value * M_PI / 180);
+   M.c = -M.b;
+   M.d = M.a;
+-  M.e = ((1.0 - M.a) * spe->x_user - M.c * spe->y_user);
+-  M.f = ((1.0 - M.d) * spe->y_user - M.b * spe->x_user);
++  M.e = ((1.0 - M.a) * x_user - M.c * y_user);
++  M.f = ((1.0 - M.d) * y_user - M.b * x_user);
+ 
+   pdf_dev_concat(&M);
++  pdf_dev_get_fixed_point(&pt);
++  pdf_dev_set_fixed_point(x_user - pt.x, y_user - pt.y);
+ 
+   return  0;
+ }
+ 
+ static int
++spc_handler_xtx_rotate (struct spc_env *spe, struct spc_arg *args)
++{
++  double          value;
++
++  if (spc_util_read_numbers(&value, 1, spe, args) < 1) {
++    return -1;
++  }
++  args->curptr = args->endptr;
++
++  return  spc_handler_xtx_do_rotate (spe->x_user, spe->y_user, value);
++}
++
++static int
+ spc_handler_xtx_gsave (struct spc_env *spe, struct spc_arg *args)
+ {
+   pdf_dev_gsave();
+@@ -275,6 +332,61 @@
+   return  error;
+ }
+ 
++static char overlay_name[256];
++
++static int
++spc_handler_xtx_initoverlay (struct spc_env *spe, struct spc_arg *args)
++{
++  skip_white(&args->curptr, args->endptr);
++  if (args->curptr >= args->endptr)
++    return -1;
++  strncpy(overlay_name, args->curptr, args->endptr - args->curptr);
++  overlay_name[args->endptr - args->curptr] = 0;
++
++  args->curptr = args->endptr;
++  return 0;
++}
++
++static int
++spc_handler_xtx_clipoverlay (struct spc_env *spe, struct spc_arg *args)
++{
++  skip_white(&args->curptr, args->endptr);
++  if (args->curptr >= args->endptr)
++    return -1;
++  pdf_dev_grestore();
++  pdf_dev_gsave();
++  if (strncmp(overlay_name, args->curptr, strlen(overlay_name)) != 0
++   && strncmp("all", args->curptr, strlen("all")) != 0)
++    pdf_doc_add_page_content(" 0 0 m W n", 10);
++
++  args->curptr = args->endptr;
++  return 0;
++}
++
++static int
++spc_handler_xtx_renderingmode (struct spc_env *spe, struct spc_arg *args)
++{
++  double value;
++
++  if (spc_util_read_numbers(&value, 1, spe, args) < 1) {
++    return -1;
++  }
++  if ((int) value < 0 || (int) value > 7) {
++    spc_warn(spe, "Invalid text rendering mode %d.\n", (int) value);
++    return -1;
++  }
++  sprintf(work_buffer, " %d Tr", (int) value);
++  pdf_doc_add_page_content(work_buffer, strlen(work_buffer));
++  skip_white(&args->curptr, args->endptr);
++  if (args->curptr < args->endptr) {
++    pdf_doc_add_page_content(" ", 1);
++    pdf_doc_add_page_content(args->curptr, args->endptr - args->curptr);
++  }
++
++  args->curptr = args->endptr;
++  return 0;
++}
++
+ static int
+ spc_handler_xtx_unsupportedcolor (struct spc_env *spe, struct spc_arg *args)
+ {
+@@ -312,6 +424,8 @@
+   {"grestore",        spc_handler_xtx_grestore},
+ 
+   {"scale",           spc_handler_xtx_scale},
++  {"bscale",           spc_handler_xtx_bscale},
++  {"escale",           spc_handler_xtx_escale},
+   {"rotate",          spc_handler_xtx_rotate},
+ 
+   {"fontmapline",     spc_handler_xtx_fontmapline},
+@@ -319,6 +433,10 @@
+ 
+   {"shadow",          spc_handler_xtx_unsupported},
+   {"colorshadow",     spc_handler_xtx_unsupported},
++  {"renderingmode",   spc_handler_xtx_renderingmode},
++
++  {"initoverlay",     spc_handler_xtx_initoverlay},
++  {"clipoverlay",     spc_handler_xtx_clipoverlay},
+ };
+ 
+ int
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_xtx.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/spc_xtx.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/spc_xtx.h	2008-05-28 18:46:46.000000000 +0200
+@@ -38,5 +38,6 @@
+ extern int  spc_xtx_check_special (const char *buffer, long size);
+ extern int  spc_xtx_setup_handler (struct spc_handler *handle,
+ 				    struct spc_env *spe, struct spc_arg *args);
++extern int spc_handler_xtx_do_rotate (double x_user, double y_user, double value);
+ 
+ #endif /* _SPC_XTX_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/specials.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/specials.h	2007-01-21 12:57:57.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/specials.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/specials.h,v 1.3 2005/07/31 16:44:42 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/specials.h,v 1.4 2007/01/20 23:53:20 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/truetype.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/truetype.c	2006-12-14 17:15:20.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/truetype.c	2008-05-28 18:46:46.000000000 +0200
+@@ -117,10 +117,29 @@
+   ASSERT( fontdict && descriptor );
+ 
+   {
++    char  fontname[256];
++    int   n;
+     pdf_obj  *tmp;
+-    tmp  = tt_get_fontdesc(sfont, &embedding, 1);
++
++    memset(fontname, 0, 256);
++    length = tt_get_ps_fontname(sfont, fontname, 255);
++    if (length < 1) {
++      length = MIN(strlen(ident), 255);
++      strncpy(fontname, ident, length);
++    }
++    fontname[length] = '\0';
++    for (n = 0; n < length; n++) {
++      if (fontname[n] == 0) {
++        memmove(fontname + n, fontname + n + 1, length - n - 1);
++      }
++    }
++    if (strlen(fontname) == 0)
++      ERROR("Can't find valid fontname for \"%s\".", ident);
++    pdf_font_set_fontname(font, fontname);
++
++    tmp  = tt_get_fontdesc(sfont, &embedding, 1, fontname);
+     if (!tmp) {
+-      ERROR("Could not obtain neccesary font info.");
++      ERROR("Could not obtain necessary font info.");
+       sfnt_close(sfont);
+       if (fp)
+         DPXFCLOSE(fp);
+@@ -164,27 +183,6 @@
+     }
+   }
+ 
+-  {
+-    char  fontname[256];
+-    int   n;
+-
+-    memset(fontname, 0, 256);
+-    length = tt_get_ps_fontname(sfont, fontname, 255);
+-    if (length < 1) {
+-      length = MIN(strlen(ident), 255);
+-      strncpy(fontname, ident, length);
+-    }
+-    fontname[length] = '\0';
+-    for (n = 0; n < length; n++) {
+-      if (fontname[n] == 0) {
+-        memmove(fontname + n, fontname + n + 1, length - n - 1);
+-      }
+-    }
+-    if (strlen(fontname) == 0)
+-      ERROR("Can't find valid fontname for \"%s\".", ident);
+-    pdf_font_set_fontname(font, fontname);
+-  }
+-
+   sfnt_close(sfont);
+   if (fp)
+     DPXFCLOSE(fp);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_aux.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_aux.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_aux.c	2008-05-28 18:46:46.000000000 +0200
+@@ -38,6 +38,13 @@
+ 
+ extern int always_embed; /* flag declared in dvipdfmx.c */
+ 
++static int verbose = 0;
++
++void tt_aux_set_verbose()
++{
++  ++verbose;
++}
++
+ ULONG ttc_read_offset (sfnt *sfont, int ttc_idx)
+ {
+   LONG version;
+@@ -137,7 +144,7 @@
+ #define ALLCAP     (1 << 16) /* All-cap font */
+ #define SMALLCAP   (1 << 17) /* Small-cap font */
+ #define FORCEBOLD  (1 << 18) /* Force bold at small text sizes */
+-pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type)
++pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type, const char* fontname)
+ {
+   pdf_obj *descriptor = NULL;
+   pdf_obj *bbox = NULL;
+@@ -184,26 +191,16 @@
+       /* the least restrictive license granted takes precedence. */
+       *embed = 1;
+     } else if (os2->fsType & 0x0004) {
+-      static char previewWarningIssued = 0;
+-      if (previewWarningIssued == 0) {
+-        fprintf(stderr,
+-              "\n** NOTICE: This document contains a `Preview & Print only' licensed font **\n");
+-        previewWarningIssued = 1;
+-      }
++      if (verbose > 0)
++        MESG("** NOTICE: Font \"%s\" permits \"Preview & Print\" embedding only **\n", fontname);
+       *embed = 1;
+     } else {
+       if (always_embed) {
+-        static char licenseWarningIssued = 0;
+-        if (licenseWarningIssued == 0) {
+-          fprintf(stderr,
+-                "\n** NOTICE: This document contains an embedded font with licensing restrictions **\n");
+-          licenseWarningIssued = 1;
+-        }
++        MESG("** NOTICE: Font \"%s\" may be subject to embedding restrictions **\n", fontname);
+         *embed = 1;
+       }
+       else {
+-        fprintf(stderr,
+-                "\n*** Embedding disabled due to licensing restriction ***\n");
++        WARN("Embedding of font \"%s\" disabled due to license restrictions", fontname);
+         *embed = 0;
+       }
+     }
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_aux.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_aux.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_aux.h	2008-05-28 18:46:46.000000000 +0200
+@@ -26,10 +26,12 @@
+ #include "pdfobj.h"
+ #include "sfnt.h"
+ 
++extern void tt_aux_set_verbose();
++
+ /* TTC (TrueType Collection) */
+ extern ULONG    ttc_read_offset (sfnt *sfont, int ttc_idx);
+ 
+ /* FontDescriptor */
+-extern pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type);
++extern pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type, const char* fontname);
+ 
+ #endif /* _TT_AUX_H_ */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_cmap.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_cmap.c	2008-05-28 18:46:46.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_cmap.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.24 2005/07/08 14:18:05 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.25 2007/04/13 06:48:03 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -521,7 +521,7 @@
+     cmap->map = read_cmap12(sfont, length);
+     break;
+   default:
+-    WARN("Unrecognized TrueType cmap format.");
++    WARN("Unrecognized OpenType/TrueType cmap format.");
+     tt_cmap_release(cmap);
+     return NULL;
+   }
+@@ -557,7 +557,7 @@
+ 	release_cmap12(cmap->map);
+ 	break;
+       default:
+-	ERROR("Unrecognized TrueType cmap format.");
++	ERROR("Unrecognized OpenType/TrueType cmap format.");
+       }
+     }
+     RELEASE(cmap);
+@@ -575,7 +575,7 @@
+   ASSERT(cmap);
+ 
+   if (cc > 0xffffL && cmap->format < 12) {
+-    WARN("Four bytes charcode not supported in TrueType cmap format 0...6.");
++    WARN("Four bytes charcode not supported in OpenType/TrueType cmap format 0...6.");
+     return 0;
+   }
+ 
+@@ -596,7 +596,7 @@
+     gid = lookup_cmap12(cmap->map, (ULONG) cc);
+     break;
+   default:
+-    ERROR("Unrecognized TrueType cmap subtable format");
++    ERROR("Unrecognized OpenType/TrueType cmap subtable format");
+     break;
+   }
+ 
+@@ -889,6 +889,8 @@
+ 	  for (k = 0; k < unicode_count; ++k) {
+ 	    len += UC_sput_UTF16BE(unicodes[k], &p, wbuf+WBUF_SIZE);
+ 	  }
++	  wbuf[0] = (gid >> 8) & 0xff;
++	  wbuf[1] =  gid & 0xff;
+ 	  CMap_add_bfchar(cmap, wbuf, 2, wbuf + 2, len);
+ 	}
+       }
+@@ -1117,7 +1119,7 @@
+ #endif
+ 
+   if (!sfont) {
+-    ERROR("Could not open TrueType font file \"%s\"", font_name);
++    ERROR("Could not open OpenType/TrueType font file \"%s\"", font_name);
+   }
+ 
+   switch (sfont->type) {
+@@ -1133,7 +1135,7 @@
+   }
+ 
+   if (sfnt_read_table_directory(sfont, offset) < 0) {
+-    ERROR("Could not read TrueType table directory.");
++    ERROR("Could not read OpenType/TrueType table directory.");
+   }
+ 
+   cmap_add_id = CMap_cache_find(cmap_name);
+@@ -1162,7 +1164,7 @@
+     }
+   }
+   if (cmap_obj == NULL)
+-    WARN("Unable to read TrueType Unicode cmap table.");
++    WARN("Unable to read OpenType/TrueType Unicode cmap table.");
+   tt_cmap_release(ttcmap);
+   CMap_set_silent(0);
+ 
+@@ -1614,10 +1616,10 @@
+       rv = otl_gsub_select(gsub_list, script, language, feature);
+       if (rv < 0) {
+ 	if (flag == 'p') {
+-	  WARN("No GSUB featre %s.%s.%s loaded...",
++	  WARN("No GSUB feature %s.%s.%s loaded...",
+ 	       script, language, feature);
+ 	} else if (flag == 'r') {
+-	  ERROR("No GSUB featre %s.%s.%s loaded...",
++	  ERROR("No GSUB feature %s.%s.%s loaded...",
+ 		script, language, feature);
+ 	}
+       } else {
+@@ -1685,7 +1687,7 @@
+   sfont = sfnt_open(fp, -1);
+ #endif
+   if (!sfont) {
+-    ERROR("Could not open TrueType font file \"%s\"", map_name);
++    ERROR("Could not open OpenType/TrueType font file \"%s\"", map_name);
+   }
+   switch (sfont->type) {
+   case SFNT_TYPE_TTC:
+@@ -1699,12 +1701,12 @@
+     offset = 0;
+     break;
+   default:
+-    ERROR("Not a TrueType/TTC font?: %s", map_name);
++    ERROR("Not a OpenType/TrueType/TTC font?: %s", map_name);
+     break;
+   }
+ 
+   if (sfnt_read_table_directory(sfont, offset) < 0)
+-    ERROR("Could not read TrueType table directory.");
++    ERROR("Could not read OpenType/TrueType table directory.");
+ 
+   base_name = NEW(strlen(map_name)+strlen("-UCS4-H")+5, char);
+   if (wmode)
+@@ -1761,18 +1763,21 @@
+     return cmap_id;
+   }
+ 
+-  ttcmap = tt_cmap_read(sfont, 3, 10);
++  ttcmap = tt_cmap_read(sfont, 3, 10); /* Microsoft UCS4 */
+   if (!ttcmap) {
+-    ttcmap = tt_cmap_read(sfont, 3, 1);
+-  }
+-  if (!ttcmap) {
+-    ERROR("Unable to read TrueType Unicode cmap table.");
++    ttcmap = tt_cmap_read(sfont, 3, 1); /* Microsoft UCS2 */
++    if (!ttcmap) {
++      ttcmap = tt_cmap_read(sfont, 0, 3); /* Unicode 2.0 or later */
++      if (!ttcmap) {
++        ERROR("Unable to read OpenType/TrueType Unicode cmap table.");
++      }
++    }
+   }
+   cmap_id = load_base_CMap(base_name, wmode,
+ 			   (is_cidfont ? &csi : NULL),
+ 			   GIDToCIDMap, ttcmap);
+   if (cmap_id < 0)
+-    ERROR("Failed to read TrueType cmap table.");
++    ERROR("Failed to read OpenType/TrueType cmap table.");
+ 
+   if (!otl_tags) {
+     RELEASE(cmap_name);
+@@ -1847,7 +1852,7 @@
+       }
+       opt_conf = otl_conf_find_opt(conf, opt_tag);
+       if (!opt_conf)
+-	ERROR("There are no option \"%s\" in \"%s\".",
++	ERROR("There is no option \"%s\" in \"%s\".",
+ 	      opt_tag, conf_name);
+       load_gsub(opt_conf, gsub_list, sfont);
+     }
+@@ -1858,7 +1863,7 @@
+     if (opt_tag) {
+       opt_conf = otl_conf_find_opt(conf, opt_tag);
+       if (!opt_conf)
+-	ERROR("There are no option \"%s\" in \"%s\".",
++	ERROR("There is no option \"%s\" in \"%s\".",
+ 	      opt_tag, conf_name);
+       handle_gsub(opt_conf, ttcmap, gsub_list, &unencoded);
+     }
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_glyf.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_glyf.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_glyf.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/tt_glyf.c,v 1.2 2005/06/09 14:31:11 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/tt_glyf.c,v 1.3 2007/02/14 05:56:43 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -249,7 +249,7 @@
+   g->emsize = head->unitsPerEm;
+ 
+   sfnt_locate_table(sfont, "hmtx");
+-  hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics);
++  hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings);
+ 
+   os2 = tt_read_os2__table(sfont);
+   if (os2) {
+@@ -261,7 +261,7 @@
+     struct tt_vhea_table *vhea;
+     vhea = tt_read_vhea_table(sfont);
+     sfnt_locate_table(sfont, "vmtx");
+-    vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics);
++    vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings);
+     RELEASE(vhea);
+   } else {
+     vmtx = NULL;
+@@ -425,15 +425,15 @@
+       padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0;
+       glyf_table_size += g->gd[i].length + padlen;
+       if (!num_hm_known && last_advw != g->gd[i].advw) {
+-	hhea->numberOfHMetrics = g->gd[i].gid + 2;
++	hhea->numOfLongHorMetrics = g->gd[i].gid + 2;
+ 	num_hm_known = 1;
+       }
+     }
+     /* All advance widths are same. */
+     if (!num_hm_known) {
+-      hhea->numberOfHMetrics = 1;
++      hhea->numOfLongHorMetrics = 1;
+     }
+-    hmtx_table_size = hhea->numberOfHMetrics * 2 + (g->last_gid + 1) * 2;
++    hmtx_table_size = hhea->numOfLongHorMetrics * 2 + (g->last_gid + 1) * 2;
+ 
+     /*
+      * Choosing short format does not always give good result
+@@ -456,9 +456,9 @@
+       long gap, j;
+       gap = (long) g->gd[i].gid - prev - 1;
+       for (j = 1; j <= gap; j++) {
+-	if (prev + j == hhea->numberOfHMetrics - 1) {
++	if (prev + j == hhea->numOfLongHorMetrics - 1) {
+ 	  p += sfnt_put_ushort(p, last_advw);
+-	} else if (prev + j < hhea->numberOfHMetrics) {
++	} else if (prev + j < hhea->numOfLongHorMetrics) {
+ 	  p += sfnt_put_ushort(p, 0);
+ 	}
+ 	p += sfnt_put_short (p, 0);
+@@ -469,7 +469,7 @@
+ 	}
+       }
+       padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0;
+-      if (g->gd[i].gid < hhea->numberOfHMetrics) {
++      if (g->gd[i].gid < hhea->numOfLongHorMetrics) {
+ 	p += sfnt_put_ushort(p, g->gd[i].advw);
+       }
+       p += sfnt_put_short (p, g->gd[i].lsb);
+@@ -559,7 +559,7 @@
+   g->emsize = head->unitsPerEm;
+ 
+   sfnt_locate_table(sfont, "hmtx");
+-  hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics);
++  hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings);
+ 
+   os2 = tt_read_os2__table(sfont);
+   g->default_advh = os2->sTypoAscender - os2->sTypoDescender;
+@@ -569,7 +569,7 @@
+     struct tt_vhea_table *vhea;
+     vhea = tt_read_vhea_table(sfont);
+     sfnt_locate_table(sfont, "vmtx");
+-    vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics);
++    vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings);
+     RELEASE(vhea);
+   } else {
+     vmtx = NULL;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_post.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_post.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_post.c	2008-05-28 18:46:46.000000000 +0200
+@@ -138,15 +138,20 @@
+     post->names           = NULL;
+   } else if (post->Version == 0x00020000UL) {
+     if (read_v2_post_names(post, sfont) < 0) {
+-      WARN("Invalid TrueType 'post' table...");
++      WARN("Invalid version 2.0 'post' table");
+       tt_release_post_table(post);
+       post = NULL;
+     }
+-  } else if (post->Version == 0x00030000UL) {
++  } else if (post->Version == 0x00030000UL) { /* no glyph names provided */
+     post->numberOfGlyphs  = 0; /* wrong */
+     post->glyphNamePtr    = NULL;
+     post->count           = 0;
+     post->names           = NULL;
++  } else if (post->Version == 0x00040000UL) { /* Apple format for printer-based fonts */
++    post->numberOfGlyphs  = 0; /* don't bother constructing char names, not sure if they'll ever be needed */
++    post->glyphNamePtr    = NULL;
++    post->count           = 0;
++    post->names           = NULL;
+   } else {
+     WARN("Unknown 'post' version: %08X", post->Version);
+     tt_release_post_table(post);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_table.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_table.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_table.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.7 2004/09/11 14:50:29 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.8 2007/02/14 05:56:43 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -33,7 +33,7 @@
+ /*
+   tables contains information refered by other tables
+   maxp->numGlyphs, etc --> loca, etc
+-  hhea->numberOfHMetrics --> hmtx
++  hhea->numOfLongHorMetrics --> hmtx
+   head->indexToLocFormat --> loca
+   head->glyphDataFormat --> glyf
+ */
+@@ -163,20 +163,21 @@
+ 
+   p  = data = NEW(TT_HHEA_TABLE_SIZE, char);
+   p += sfnt_put_ulong(p, table->version);
+-  p += sfnt_put_short(p, table->Ascender);
+-  p += sfnt_put_short(p, table->Descender);
+-  p += sfnt_put_short(p, table->LineGap);
++  p += sfnt_put_short(p, table->ascent);
++  p += sfnt_put_short(p, table->descent);
++  p += sfnt_put_short(p, table->lineGap);
+   p += sfnt_put_ushort(p, table->advanceWidthMax);
+   p += sfnt_put_short(p, table->minLeftSideBearing);
+   p += sfnt_put_short(p, table->minRightSideBearing);
+   p += sfnt_put_short(p, table->xMaxExtent);
+   p += sfnt_put_short(p, table->caretSlopeRise);
+   p += sfnt_put_short(p, table->caretSlopeRun);
+-  for (i = 0; i < 5; i++) {
++  p += sfnt_put_short(p, table->caretOffset);
++  for (i = 0; i < 4; i++) {
+     p += sfnt_put_short(p, table->reserved[i]);
+   }
+   p += sfnt_put_short(p, table->metricDataFormat);
+-  p += sfnt_put_ushort(p, table->numberOfHMetrics);
++  p += sfnt_put_ushort(p, table->numOfLongHorMetrics);
+ 
+   return data;
+ }
+@@ -185,28 +186,32 @@
+ tt_read_hhea_table (sfnt *sfont)
+ {
+   int    i;
++  ULONG  len;
+   struct tt_hhea_table *table = NULL;
+ 
+-  table = NEW(1, struct tt_hhea_table);
+-
++  len = sfnt_find_table_len(sfont, "hhea");
+   sfnt_locate_table(sfont, "hhea");
+-  table->version   = sfnt_get_ulong(sfont);
+-  table->Ascender  = sfnt_get_short (sfont);
+-  table->Descender = sfnt_get_short(sfont);
+-  table->LineGap   = sfnt_get_short(sfont);
++
++  table = NEW(1, struct tt_hhea_table);
++  table->version = sfnt_get_ulong(sfont);
++  table->ascent  = sfnt_get_short (sfont);
++  table->descent = sfnt_get_short(sfont);
++  table->lineGap = sfnt_get_short(sfont);
+   table->advanceWidthMax     = sfnt_get_ushort(sfont);
+   table->minLeftSideBearing  = sfnt_get_short(sfont);
+   table->minRightSideBearing = sfnt_get_short(sfont);
+   table->xMaxExtent     = sfnt_get_short(sfont);
+   table->caretSlopeRise = sfnt_get_short(sfont);
+   table->caretSlopeRun  = sfnt_get_short(sfont);
+-  for(i = 0; i < 5; i++) {
++  table->caretOffset    = sfnt_get_short(sfont);
++  for(i = 0; i < 4; i++) {
+     table->reserved[i] = sfnt_get_short(sfont);
+   }
+   table->metricDataFormat = sfnt_get_short(sfont);
+   if (table->metricDataFormat != 0)
+-    ERROR("unknown metricDaraFormat");
+-  table->numberOfHMetrics = sfnt_get_ushort(sfont);
++    ERROR("unknown metricDataFormat");
++  table->numOfLongHorMetrics = sfnt_get_ushort(sfont);
++  table->numOfExSideBearings = (USHORT)((len - table->numOfLongHorMetrics * 4) / 2);
+ 
+   return table;
+ }
+@@ -230,9 +235,10 @@
+   p += sfnt_put_short(p, table->caretSlopeRise);
+   p += sfnt_put_short(p, table->caretSlopeRun);
+   p += sfnt_put_short(p, table->caretOffset);
+-  for(i = 0; i < 5; i++) {
++  for(i = 0; i < 4; i++) {
+     p += sfnt_put_short(p, table->reserved[i]);
+   }
++  p += sfnt_put_short(p, table->metricDataFormat);
+   p += sfnt_put_ushort(p, table->numOfLongVerMetrics);
+ 
+   return data;
+@@ -240,11 +246,13 @@
+ 
+ struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont)
+ {
+-  int i;
++  int   i;
++  ULONG len;
+   struct tt_vhea_table *table = NULL;
+ 
+   table = NEW(1, struct tt_vhea_table);
+ 
++  len = sfnt_find_table_len(sfont, "vhea");
+   sfnt_locate_table(sfont, "vhea");
+   table->version = sfnt_get_ulong(sfont);
+   table->vertTypoAscender = sfnt_get_short (sfont);
+@@ -257,10 +265,12 @@
+   table->caretSlopeRise = sfnt_get_short(sfont);
+   table->caretSlopeRun = sfnt_get_short(sfont);
+   table->caretOffset = sfnt_get_short(sfont);
+-  for(i=0;i<5;i++) {
++  for(i = 0; i < 4; i++) {
+     (table->reserved)[i] = sfnt_get_short(sfont);
+   }
++  table->metricDataFormat = sfnt_get_short(sfont);
+   table->numOfLongVerMetrics = sfnt_get_ushort(sfont);
++  table->numOfExSideBearings = (USHORT)((len - table->numOfLongVerMetrics * 4) / 2);
+ 
+   return table;
+ }
+@@ -310,17 +320,20 @@
+  */
+ 
+ struct tt_longMetrics *
+-tt_read_longMetrics (sfnt *sfont, USHORT numGlyphs, USHORT numLongMetrics)
++tt_read_longMetrics (sfnt *sfont, USHORT numGlyphs, USHORT numLongMetrics, USHORT numExSideBearings)
+ {
+   struct tt_longMetrics *m;
+   USHORT gid, last_adv = 0;
++  SHORT  last_esb = 0;
+ 
+   m = NEW(numGlyphs, struct tt_longMetrics);
+   for (gid = 0; gid < numGlyphs; gid++) {
+     if (gid < numLongMetrics)
+       last_adv = sfnt_get_ushort(sfont);
+-    m[gid].sideBearing = sfnt_get_short(sfont);
++    if (gid < numLongMetrics + numExSideBearings)
++      last_esb = sfnt_get_short(sfont);
+     m[gid].advance     = last_adv;
++    m[gid].sideBearing = last_esb;
+   }
+ 
+   return m;
+@@ -370,21 +383,30 @@
+   table->fsSelection      = sfnt_get_ushort(sfont);
+   table->usFirstCharIndex = sfnt_get_ushort(sfont);
+   table->usLastCharIndex  = sfnt_get_ushort(sfont);
+-  table->sTypoAscender    = sfnt_get_short(sfont);
+-  table->sTypoDescender   = sfnt_get_short(sfont);
+-  table->sTypoLineGap     = sfnt_get_short(sfont);
+-  table->usWinAscent      = sfnt_get_ushort(sfont);
+-  table->usWinDescent     = sfnt_get_ushort(sfont);
+-  table->ulCodePageRange1 = sfnt_get_ulong(sfont);
+-  table->ulCodePageRange2 = sfnt_get_ulong(sfont);
+-  if (table->version == 0x0002) {
+-    table->sxHeight      = sfnt_get_short(sfont);
+-    table->sCapHeight    = sfnt_get_short(sfont);
+-    table->usDefaultChar = sfnt_get_ushort(sfont);
+-    table->usBreakChar   = sfnt_get_ushort(sfont);
+-    table->usMaxContext  = sfnt_get_ushort(sfont);
++  if (sfnt_find_table_len(sfont, "OS/2") >= 78) {
++    /* these fields are not present in the original Apple spec (68-byte table),
++       but Microsoft's version of "format 0" does include them... grr! */
++    table->sTypoAscender    = sfnt_get_short(sfont);
++    table->sTypoDescender   = sfnt_get_short(sfont);
++    table->sTypoLineGap     = sfnt_get_short(sfont);
++    table->usWinAscent      = sfnt_get_ushort(sfont);
++    table->usWinDescent     = sfnt_get_ushort(sfont);
++    if (table->version > 0) {
++      /* format 1 adds the following 2 fields */
++      table->ulCodePageRange1 = sfnt_get_ulong(sfont);
++      table->ulCodePageRange2 = sfnt_get_ulong(sfont);
++      if (table->version > 1) {
++        /* and formats 2 and 3 (current) include 5 more.... these share the
++           same fields, only the precise definition of some was changed */
++        table->sxHeight      = sfnt_get_short(sfont);
++        table->sCapHeight    = sfnt_get_short(sfont);
++        table->usDefaultChar = sfnt_get_ushort(sfont);
++        table->usBreakChar   = sfnt_get_ushort(sfont);
++        table->usMaxContext  = sfnt_get_ushort(sfont);
++      }
++    }
+   }
+-
++  
+   return table;
+ }
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_table.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/tt_table.h	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/tt_table.h	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/tt_table.h,v 1.6 2004/09/11 14:50:29 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/tt_table.h,v 1.7 2007/02/14 05:56:43 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -51,18 +51,20 @@
+ struct tt_hhea_table
+ {
+   Fixed  version;
+-  FWord  Ascender;
+-  FWord  Descender;
+-  FWord  LineGap;
++  FWord  ascent;
++  FWord  descent;
++  FWord  lineGap;
+   uFWord advanceWidthMax;
+   FWord  minLeftSideBearing;
+   FWord  minRightSideBearing;
+   FWord  xMaxExtent;
+   SHORT  caretSlopeRise;
+   SHORT  caretSlopeRun;
+-  SHORT  reserved[5]; /* set to 0 */
++  FWord  caretOffset;
++  SHORT  reserved[4]; /* set to 0 */
+   SHORT  metricDataFormat;
+-  USHORT numberOfHMetrics;
++  USHORT numOfLongHorMetrics;
++  USHORT numOfExSideBearings; /* extra information */
+ };
+ 
+ struct tt_vhea_table
+@@ -78,8 +80,10 @@
+   SHORT  caretSlopeRise;
+   SHORT  caretSlopeRun;
+   SHORT  caretOffset;
+-  SHORT  reserved[5]; /* set to 0 */
++  SHORT  reserved[4]; /* set to 0 */
++  SHORT  metricDataFormat;
+   USHORT numOfLongVerMetrics;
++  USHORT numOfExSideBearings; /* extra information */
+ };
+ 
+ struct tt_maxp_table
+@@ -179,7 +183,7 @@
+ 
+ /* hmtx and vmtx */
+ extern struct tt_longMetrics *tt_read_longMetrics (sfnt *sfont,
+-	USHORT numGlyphs, USHORT numLongMetrics);
++	USHORT numGlyphs, USHORT numLongMetrics, USHORT numExSideBearings);
+ 
+ /* OS/2 table */
+ extern struct tt_os2__table *tt_read_os2__table (sfnt *sfont);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/type1.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/type1.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/type1.c	2008-05-28 18:46:46.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.38 2005/07/17 09:53:38 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.39 2007/04/17 10:06:30 chofchof Exp $
+ 
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -268,7 +268,7 @@
+ }
+ 
+ static void
+-add_metrics (pdf_font *font, cff_font *cffont, double *widths, long num_glyphs)
++add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, long num_glyphs)
+ {
+   pdf_obj *fontdict, *descriptor;
+   pdf_obj *tmp_array;
+@@ -321,7 +321,7 @@
+     }
+     for (code = firstchar; code <= lastchar; code++) {
+       if (usedchars[code]) {
+-	gid = cff_encoding_lookup(cffont, code);
++	gid = cff_glyph_lookup(cffont, enc_vec[code]);
+ 	pdf_add_array(tmp_array,
+ 		      pdf_new_number(ROUND(widths[gid], 1.0)));
+       } else {
+@@ -541,16 +541,12 @@
+ 		   pdf_new_name("Encoding"),
+ 		   pdf_new_name(pdf_encoding_get_name(encoding_id)));
+     } else {
+-#if 0
+-      /*
+-       * Gs not working with this.
+-       */
++      /* CAUTION: Ghostscript may not work with this. Which Ghostscript? */
+       pdf_add_dict(fontdict,
+ 		   pdf_new_name("Encoding"),
+-		   pdf_get_encoding_resource(enc));
+-#endif
++		   pdf_get_encoding_reference(encoding_id));
+       if (!pdf_lookup_dict(fontdict, "ToUnicode"))
+-      pdf_attach_ToUnicode_CMap(fontdict, encoding_id, usedchars);
++        pdf_attach_ToUnicode_CMap(fontdict, encoding_id, usedchars);
+     }
+     enc_vec = pdf_encoding_get_encoding(encoding_id);
+   } else {
+@@ -781,7 +777,7 @@
+   if (verbose > 2)
+     MESG("]");
+ 
+-  add_metrics(font, cffont, widths, num_glyphs);
++  add_metrics(font, cffont, enc_vec, widths, num_glyphs);
+ 
+   offset = write_fontfile(font, cffont, num_glyphs);
+   if (verbose > 1)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/type1c.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/type1c.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/type1c.c	2008-05-28 18:46:47.000000000 +0200
+@@ -142,7 +142,7 @@
+    * Create font descriptor from OpenType tables.
+    * We can also use CFF TOP DICT/Private DICT for this.
+    */
+-  tmp = tt_get_fontdesc(sfont, &embedding, 1);
++  tmp = tt_get_fontdesc(sfont, &embedding, 1, fontname);
+   if (!tmp) {
+     ERROR("Could not obtain neccesary font info from OpenType table.");
+     return -1;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/vf.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/xdvipdfmx/src/vf.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/xdvipdfmx/src/vf.c	2008-05-28 18:46:47.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*  $Header: /home/cvsroot/dvipdfmx/src/vf.c,v 1.16 2005/07/20 10:41:54 hirata Exp $
++/*  $Header: /home/cvsroot/dvipdfmx/src/vf.c,v 1.17 2007/04/17 10:12:04 chofchof Exp $
+     
+     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+ 
+@@ -768,7 +768,8 @@
+        * Warning message from virtual font.
+        */
+       if (!memcmp((char *)p, "Warning:", 8)) {
+-	WARN("VF:%s", p+8);
++        if (verbose)
++	  WARN("VF:%s", p+8);
+       } else {
+ 	dvi_do_special(buffer, len);
+       }
--- texlive-bin-2007.dfsg.2.orig/debian/patches/tl2007.2-xetex-fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/tl2007.2-xetex-fixes
@@ -0,0 +1,1683 @@
+---
+ build/source/texk/web2c/etexdir/etex.ch                   |   22 
+ build/source/texk/web2c/lib/texmfmp.c                     |   57 ++
+ build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp         |  144 +++---
+ build/source/texk/web2c/xetexdir/XeTeXFontMgr.h           |    8 
+ build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp |    7 
+ build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h   |   19 
+ build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp  |    2 
+ build/source/texk/web2c/xetexdir/XeTeX_ext.c              |   85 ++-
+ build/source/texk/web2c/xetexdir/XeTeX_ext.h              |    1 
+ build/source/texk/web2c/xetexdir/XeTeX_mac.c              |   25 +
+ build/source/texk/web2c/xetexdir/XeTeX_pic.c              |   16 
+ build/source/texk/web2c/xetexdir/appleGlyphNames.c        |    2 
+ build/source/texk/web2c/xetexdir/pdfimage.cpp             |   22 
+ build/source/texk/web2c/xetexdir/pdfimage.h               |    2 
+ build/source/texk/web2c/xetexdir/pool2c.pl                |   74 +++
+ build/source/texk/web2c/xetexdir/xetex-new.ch             |  330 ++++++++------
+ build/source/texk/web2c/xetexdir/xetex.defines            |    2 
+ build/source/texk/web2c/xetexdir/xetex.mk                 |   24 -
+ build/source/texk/web2c/xetexdir/xetexextra.in            |    2 
+ 19 files changed, 617 insertions(+), 227 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/etexdir/etex.ch
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/etexdir/etex.ch	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/etexdir/etex.ch	2008-05-28 17:20:28.000000000 +0200
+@@ -29,7 +29,7 @@
+ % (pdftexdir/pdftex.ch). Consequently, changes in these files have to be
+ % coordinated.
+ 
+-% e-TeX is copyright (C) 1999-2004 by P. Breitenlohner (1994,98 by the NTS
++% e-TeX is copyright (C) 1999-2008 by P. Breitenlohner (1994,98 by the NTS
+ % team); all rights are reserved. Copying of this file is authorized only if
+ % (1) you are P. Breitenlohner, or if (2) you make absolutely no changes to
+ % your copy. (Programs such as TIE allow the application of several change
+@@ -116,6 +116,9 @@
+ %                 direction typesetting;
+ %             fixed a bug in the revised glue rounding code, detected by
+ %                 Tigran Aivazian <tigran@@aivazian.fsnet.co.uk>, Oct 2004.
++% Version 2.3 development was started in Feb 2008; released in Mon Year.
++%             fixed a bug in hyph_code handling (\savinghyphcodes)
++%                 reported by Vladimir Volovich <vvv@@vsu.ru>, Feb 2008.
+ 
+ % Although considerable effort has been expended to make the e-TeX program
+ % correct and reliable, no warranty is implied; the author disclaims any
+@@ -3020,13 +3023,12 @@
+ if eTeX_ex then wterm_ln('entering extended mode');
+ @z
+ %---------------------------------------
+-@x [53] m.1363 l.24757 - e-TeX hyph_codes
+-adv_past(s)
++@x [53] m.1362 l.24751 adv_past - e-TeX hyph_codes
++    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);@+end
+ @y
+-if subtype(s)=language_node then
+-  begin cur_lang:=what_lang(s); l_hyf:=what_lhm(s); r_hyf:=what_rhm(s);
+-  set_hyph_index;
+-  end
++    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);
++    set_hyph_index;
++    end
+ @z
+ %---------------------------------------
+ @x [54] m.1379 l.24945 - e-TeX additions
+@@ -5915,7 +5917,7 @@
+ @!best_pl_glue:array[very_loose_fit..tight_fit] of scaled; {corresponding
+   glue stretch or shrink}
+ 
+-@ The new algorithm for the last line requires that the stretchability
++@ The new algorithm for the last line requires that the stretchability of
+ |par_fill_skip| is infinite and the stretchability of |left_skip| plus
+ |right_skip| is finite.
+ 
+@@ -5966,10 +5968,10 @@
+   if active_short(r)>0 then g:=max_dimen@+else g:=-max_dimen;
+ if g>0 then
+   @<Set the value of |b| to the badness of the last line for stretching,
+-    compute the corresponding |fit_class, and |goto found||@>
++    compute the corresponding |fit_class|, and |goto found|@>
+ else if g<0 then
+   @<Set the value of |b| to the badness of the last line for shrinking,
+-    compute the corresponding |fit_class, and |goto found||@>;
++    compute the corresponding |fit_class|, and |goto found|@>;
+ not_found:end
+ 
+ @ These badness computations are rather similar to those of the standard
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/lib/texmfmp.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/lib/texmfmp.c	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/lib/texmfmp.c	2008-05-28 17:20:28.000000000 +0200
+@@ -1953,22 +1953,65 @@
+   return ret;
+ }
+ 
+-#ifdef XeTeX
+-#define strstartar strstart
+-#endif
++#ifdef XeTeX /* the string pool is UTF-16 but we want a UTF-8 string */
++
++string
++gettexstring P1C(strnumber, s)
++{
++  unsigned bytesToWrite = 0;
++  poolpointer len, i, j;
++  string name;
++  len = strstart[s + 1 - 65536L] - strstart[s - 65536L];
++  name = (string)xmalloc(len * 3 + 1); /* max UTF16->UTF8 expansion (code units, not bytes) */
++  for (i = 0, j = 0; i < len; i++) {
++    unsigned c = strpool[i + strstart[s - 65536L]];
++    if (c >= 0xD800 && c <= 0xDBFF) {
++      unsigned lo = strpool[++i + strstart[s - 65536L]];
++      if (lo >= 0xDC00 && lo <= 0xDFFF)
++        c = (c - 0xD800) * 0x0400 + lo - 0xDC00;
++      else
++        c = 0xFFFD;
++    }
++    if (c < 0x80)
++      bytesToWrite = 1;
++    else if (c < 0x800)
++      bytesToWrite = 2;
++    else if (c < 0x10000)
++      bytesToWrite = 3;
++    else if (c < 0x110000)
++      bytesToWrite = 4;
++    else {
++      bytesToWrite = 3;
++      c = 0xFFFD;
++    }
++
++    j += bytesToWrite;
++    switch (bytesToWrite) { /* note: everything falls through. */
++      case 4: name[--j] = ((c | 0x80) & 0xBF); c >>= 6;
++      case 3: name[--j] = ((c | 0x80) & 0xBF); c >>= 6;
++      case 2: name[--j] = ((c | 0x80) & 0xBF); c >>= 6;
++      case 1: name[--j] =  (c | firstByteMark[bytesToWrite]);
++    }
++    j += bytesToWrite;
++  }
++  name[j] = 0;
++  return name;
++}
++
++#else
+ 
+ string
+ gettexstring P1C(strnumber, s)
+ {
+   poolpointer len;
+   string name;
+-#if !defined(Omega) && !defined(eOmega) && !defined(Aleph) && !defined(XeTeX)
++#if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
+   len = strstart[s + 1] - strstart[s];
+ #else
+   len = strstartar[s + 1 - 65536L] - strstartar[s - 65536L];
+ #endif
+   name = (string)xmalloc (len + 1);
+-#if !defined(Omega) && !defined(eOmega) && !defined(Aleph) && !defined(XeTeX)
++#if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
+   strncpy (name, (string)&strpool[strstart[s]], len);
+ #else
+   {
+@@ -1981,9 +2024,7 @@
+   return name;
+ }
+ 
+-#ifdef XeTeX
+-#undef strstartar
+-#endif
++#endif /* not XeTeX */
+ 
+ boolean
+ isnewsource P2C(strnumber, srcfilename, int, lineno)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp	2008-05-28 17:20:28.000000000 +0200
+@@ -34,7 +34,6 @@
+ #include "XeTeXFontMgr_FC.h"
+ #endif
+ 
+-#include "XeTeXLayoutInterface.h"
+ #include "XeTeXswap.h"
+ 
+ #include "Features.h"
+@@ -44,6 +43,8 @@
+ 
+ #include <math.h>
+ 
++extern Fixed loadedfontdesignsize;
++
+ XeTeXFontMgr*	XeTeXFontMgr::sFontManager = NULL;
+ char XeTeXFontMgr::sReqEngine = 0;
+ 
+@@ -83,17 +84,22 @@
+ 
+ PlatformFontRef
+ XeTeXFontMgr::findFont(const char* name, char* variant, double ptSize)
+-	// ptSize is in TeX points
++	// ptSize is in TeX points, or negative for 'scaled' factor
+ 	// "variant" string will be shortened (in-place) by removal of /B and /I if present
+ {
+ 	std::string	nameStr(name);
+ 	Font*	font = NULL;
+ 	
++	int dsize = 100;
++	loadedfontdesignsize = 655360L;
++
+ 	for (int pass = 0; pass < 2; ++pass) {
+ 		// try full name as given
+ 		std::map<std::string,Font*>::iterator i = nameToFont.find(nameStr);
+ 		if (i != nameToFont.end()) {
+ 			font = i->second;
++			if (font->opSizeInfo.designSize != 0)
++				dsize = font->opSizeInfo.designSize;
+ 			break;
+ 		}
+ 
+@@ -107,6 +113,8 @@
+ 				i = f->second->styles->find(style);
+ 				if (i != f->second->styles->end()) {
+ 					font = i->second;
++					if (font->opSizeInfo.designSize != 0)
++						dsize = font->opSizeInfo.designSize;
+ 					break;
+ 				}
+ 			}
+@@ -116,6 +124,8 @@
+ 		i = psNameToFont.find(nameStr);
+ 		if (i != psNameToFont.end()) {
+ 			font = i->second;
++			if (font->opSizeInfo.designSize != 0)
++				dsize = font->opSizeInfo.designSize;
+ 			break;
+ 		}
+ 		
+@@ -179,7 +189,7 @@
+ 	Family*	parent = font->parent;
+ 	
+ 	// if there are variant requests, try to apply them
+-	// and delete B or I codes from the string
++	// and delete B, I, and S=... codes from the string, just retain /engine option
+ 	sReqEngine = 0;
+ 	bool	reqBold = false;
+ 	bool	reqItal = false;
+@@ -248,9 +258,6 @@
+ 						++cp;
+ 					}
+ 				}
+-				if (varString.length() > 0 && *(varString.end() - 1) != '/')
+-					varString.append("/");
+-				varString.append(start, cp);
+ 				goto skip_to_slash;
+ 			}
+ 			
+@@ -359,8 +366,10 @@
+ 	}
+ 
+ 	// if there's optical size info, try to apply it
+-	if (font != NULL && font->opSizeInfo.subFamilyID != 0 && ptSize != 0.0) {
+-		ptSize = ptSize * 720 / 72.27;	// convert TeX points to PS decipoints for comparison with the opSize values
++	if (ptSize < 0.0)
++		ptSize = dsize / 10.0;
++	if (font != NULL && font->opSizeInfo.subFamilyID != 0 && ptSize > 0.0) {
++		ptSize = ptSize * 10.0;	// convert to decipoints for comparison with the opSize values
+ 		double	bestMismatch = my_fmax(font->opSizeInfo.minSize - ptSize, ptSize - font->opSizeInfo.maxSize);
+ 		if (bestMismatch > 0.0) {
+ 			Font*	bestMatch = font;
+@@ -378,6 +387,9 @@
+ 			font = bestMatch;
+ 		}
+ 	}
++	
++	if (font != NULL && font->opSizeInfo.designSize != 0)
++		loadedfontdesignsize = (font->opSizeInfo.designSize << 16L) / 10;
+ 
+ 	return font->fontRef;
+ }
+@@ -450,58 +462,82 @@
+ 	return bestMatch;
+ }
+ 
++const XeTeXFontMgr::OpSizeRec*
++XeTeXFontMgr::getOpSizePtr(XeTeXFont font)
++{
++	const GlyphPositioningTableHeader* gposTable = (const GlyphPositioningTableHeader*)getFontTablePtr(font, LE_GPOS_TABLE_TAG);
++	if (gposTable != NULL) {
++		const FeatureListTable*	featureListTable = (const FeatureListTable*)((const char*)gposTable + SWAP(gposTable->featureListOffset));
++		for (int i = 0; i < SWAP(featureListTable->featureCount); ++i) {
++			UInt32  tag = SWAPT(featureListTable->featureRecordArray[i].featureTag);
++			if (tag == LE_SIZE_FEATURE_TAG) {
++				const FeatureTable*	feature = (const FeatureTable*)((const char*)featureListTable
++												+ SWAP(featureListTable->featureRecordArray[i].featureTableOffset));
++				UInt16	offset = SWAP(feature->featureParamsOffset);
++				const OpSizeRec*	pSizeRec;
++				/* if featureParamsOffset < (offset of feature from featureListTable),
++				   then we have a correct size table;
++				   otherwise we (presumably) have a "broken" one from the old FDK */
++				for (int i = 0; i < 2; ++i) {
++					if (i == 0)
++						pSizeRec = (const OpSizeRec*)((char*)feature + offset);
++					else
++						pSizeRec = (const OpSizeRec*)((char*)featureListTable + offset);
++					if (SWAP(pSizeRec->designSize) == 0)
++						continue;	// incorrect 'size' feature format
++					if (SWAP(pSizeRec->subFamilyID) == 0
++						&& SWAP(pSizeRec->nameCode) == 0
++						&& SWAP(pSizeRec->minSize) == 0
++						&& SWAP(pSizeRec->maxSize) == 0)
++						return pSizeRec;	// feature is valid, but no 'size' range
++					if (SWAP(pSizeRec->designSize) < SWAP(pSizeRec->minSize))	// check values are valid
++						continue;												// else try different interpretation
++					if (SWAP(pSizeRec->designSize) > SWAP(pSizeRec->maxSize))
++						continue;
++					if (SWAP(pSizeRec->maxSize) < SWAP(pSizeRec->minSize))
++						continue;
++					if (SWAP(pSizeRec->nameCode) < 256)
++						continue;
++					if (SWAP(pSizeRec->nameCode) > 32767)
++						continue;
++					return pSizeRec;
++				}
++			}
++		}
++	}
++
++	return NULL;
++}
++
++double
++XeTeXFontMgr::getDesignSize(XeTeXFont font)
++{
++	const OpSizeRec* pSizeRec = getOpSizePtr(font);
++	if (pSizeRec != NULL)
++		return SWAP(pSizeRec->designSize) / 10.0;
++	else
++		return 10.0;
++}
++
+ void
+ XeTeXFontMgr::getOpSizeRecAndStyleFlags(Font* theFont)
+ {
+ 	XeTeXFont	font = createFont(theFont->fontRef, 655360);
+ 	if (font != 0) {
+-		const GlyphPositioningTableHeader* gposTable = (const GlyphPositioningTableHeader*)getFontTablePtr(font, LE_GPOS_TABLE_TAG);
+-		if (gposTable != NULL) {
+-			const FeatureListTable*	featureListTable = (const FeatureListTable*)((const char*)gposTable + SWAP(gposTable->featureListOffset));
+-			for (int i = 0; i < SWAP(featureListTable->featureCount); ++i) {
+-				UInt32  tag = SWAPT(featureListTable->featureRecordArray[i].featureTag);
+-				if (tag == LE_SIZE_FEATURE_TAG) {
+-					const FeatureTable*	feature = (const FeatureTable*)((const char*)featureListTable
+-													+ SWAP(featureListTable->featureRecordArray[i].featureTableOffset));
+-					UInt16	offset = SWAP(feature->featureParamsOffset);
+-					const OpSizeRec*	pSizeRec;
+-					/* if featureParamsOffset < (offset of feature from featureListTable),
+-					   then we have a correct size table;
+-					   otherwise we (presumably) have a "broken" one from the old FDK */
+-					for (int i = 0; i < 2; ++i) {
+-						if (i == 0)
+-							pSizeRec = (const OpSizeRec*)((char*)feature + offset);
+-						else
+-							pSizeRec = (const OpSizeRec*)((char*)featureListTable + offset);
+-						if (SWAP(pSizeRec->designSize) == 0)
+-							continue;	// incorrect 'size' feature format
+-						if (SWAP(pSizeRec->subFamilyID) == 0
+-							&& SWAP(pSizeRec->nameCode) == 0
+-							&& SWAP(pSizeRec->minSize) == 0
+-							&& SWAP(pSizeRec->maxSize) == 0)
+-							break;	// feature is valid, but no 'size' range
+-						if (SWAP(pSizeRec->designSize) < SWAP(pSizeRec->minSize))
+-							continue;
+-						if (SWAP(pSizeRec->designSize) > SWAP(pSizeRec->maxSize))
+-							continue;
+-						if (SWAP(pSizeRec->maxSize) <= SWAP(pSizeRec->minSize))
+-							continue;
+-						if (SWAP(pSizeRec->nameCode) < 256)
+-							continue;
+-						if (SWAP(pSizeRec->nameCode) > 32767)
+-							continue;
+-						// looks like we've found a usable feature!
+-						theFont->opSizeInfo.designSize = SWAP(pSizeRec->designSize);
+-						theFont->opSizeInfo.subFamilyID = SWAP(pSizeRec->subFamilyID);
+-						theFont->opSizeInfo.nameCode = SWAP(pSizeRec->nameCode);
+-						theFont->opSizeInfo.minSize = SWAP(pSizeRec->minSize);
+-						theFont->opSizeInfo.maxSize = SWAP(pSizeRec->maxSize);
+-						break;
+-					}
+-					break;
+-				}
+-			}
++		const OpSizeRec* pSizeRec = getOpSizePtr(font);
++		if (pSizeRec != NULL) {
++			theFont->opSizeInfo.designSize = SWAP(pSizeRec->designSize);
++			if (SWAP(pSizeRec->subFamilyID) == 0
++				&& SWAP(pSizeRec->nameCode) == 0
++				&& SWAP(pSizeRec->minSize) == 0
++				&& SWAP(pSizeRec->maxSize) == 0)
++				goto done_size;	// feature is valid, but no 'size' range
++			theFont->opSizeInfo.subFamilyID = SWAP(pSizeRec->subFamilyID);
++			theFont->opSizeInfo.nameCode = SWAP(pSizeRec->nameCode);
++			theFont->opSizeInfo.minSize = SWAP(pSizeRec->minSize);
++			theFont->opSizeInfo.maxSize = SWAP(pSizeRec->maxSize);
+ 		}
++	done_size:
+ 
+ 		const OS2TableHeader* os2Table = (const OS2TableHeader*)getFontTablePtr(font, LE_OS_2_TABLE_TAG);
+ 		if (os2Table != NULL) {
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXFontMgr.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeXFontMgr.h	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXFontMgr.h	2008-05-28 17:20:28.000000000 +0200
+@@ -43,6 +43,8 @@
+ typedef FcPattern*	PlatformFontRef;
+ #endif
+ 
++#include "XeTeXLayoutInterface.h"
++
+ #ifdef __cplusplus	/* allow inclusion in plain C files just to get the typedefs above */
+ 
+ #include <string>
+@@ -83,6 +85,7 @@
+ 											const char** famName, const char** styName) const;
+ 		// return Postscript, family, and style names, for use in .xdv
+ 
++	double							getDesignSize(XeTeXFont font);
+ 
+ 	char							getReqEngine() const;
+ 		// return the requested rendering technology for the most recent findFont
+@@ -118,7 +121,8 @@
+ 								, parent(NULL)
+ 								, fontRef(ref), weight(0), width(0), slant(0)
+ 								, isReg(false), isBold(false), isItalic(false)
+-								{ opSizeInfo.subFamilyID = 0; }
++								{ opSizeInfo.subFamilyID = 0;
++								  opSizeInfo.designSize = 100; } /* default to 10bp */
+ 							~Font()
+ 								{ delete fullName; delete psName; }
+ 
+@@ -181,6 +185,8 @@
+ 	void			prependToList(std::list<std::string>* list, const char* str);
+ 	void			addToMaps(PlatformFontRef platformFont, const NameCollection* names);
+ 
++	const OpSizeRec* getOpSizePtr(XeTeXFont font);
++
+ 	virtual void	getOpSizeRecAndStyleFlags(Font* theFont);
+ 	virtual void	searchForHostPlatformFonts(const std::string& name) = 0;
+ 	
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.cpp	2008-05-28 17:20:28.000000000 +0200
+@@ -144,6 +144,11 @@
+ 	return XeTeXFontMgr::GetFontManager()->getFullName(fontRef);
+ }
+ 
++double getDesignSize(XeTeXFont font)
++{
++	return XeTeXFontMgr::GetFontManager()->getDesignSize(font);
++}
++
+ const char* getFontFilename(XeTeXLayoutEngine engine)
+ {
+ 	return engine->font->getFilename();
+@@ -479,7 +484,7 @@
+ 	switch (SWAP(p->format)) {
+ 		case 0x00010000:
+ 			{
+-				char*	cp;
++				const char*	cp;
+ 				while ((cp = appleGlyphNames[g]) != 0) {
+ 					if (strcmp(glyphName, cp) == 0)
+ 						return g;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXLayoutInterface.h	2008-05-28 17:20:28.000000000 +0200
+@@ -28,10 +28,22 @@
+ authorization from SIL International.
+ \****************************************************************************/
+ 
++#ifndef XETEX_LAYOUT_INTERFACE_H
++#define XETEX_LAYOUT_INTERFACE_H 1
++
+ #ifdef XETEX_MAC
+ #include <Carbon/Carbon.h>
+ #endif
+ 
++#ifdef __cplusplus
++extern "C" {
++#endif
++typedef struct XeTeXFont_rec* XeTeXFont;
++typedef struct XeTeXLayoutEngine_rec* XeTeXLayoutEngine;
++#ifdef __cplusplus
++};
++#endif
++
+ #include "XeTeX_ext.h"
+ #include "XeTeXFontMgr.h"
+ 
+@@ -39,9 +51,6 @@
+ extern "C" {
+ #endif
+ 
+-typedef struct XeTeXFont_rec* XeTeXFont;
+-typedef struct XeTeXLayoutEngine_rec* XeTeXLayoutEngine;
+-
+ extern char	gPrefEngine;
+ 
+ int getCachedGlyphBBox(UInt16 fontID, UInt16 glyphID, GlyphBBox* bbox);
+@@ -67,6 +76,7 @@
+ const char* getFontFilename(XeTeXLayoutEngine engine);
+ 
+ void getNames(PlatformFontRef fontRef, const char** psName, const char** famName, const char** styName);
++double getDesignSize(XeTeXFont font);
+ 
+ void deleteFont(XeTeXFont font);
+ 
+@@ -139,3 +149,6 @@
+ #ifdef __cplusplus
+ };
+ #endif
++
++#endif /* XETEX_LAYOUT_INTERFACE_H */
++
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp	2008-05-28 17:20:28.000000000 +0200
+@@ -129,7 +129,7 @@
+ 			break;
+ 
+ 		case arabScriptCode:
+-		case hebrScriptCode:
++//		case hebrScriptCode:
+ 			result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
+ 			break;
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_ext.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2008-05-28 17:20:28.000000000 +0200
+@@ -710,9 +710,9 @@
+ 
+ 			if (strncmp(cp1, "vertical", 8) == 0) {
+ 				cp3 = cp2;
+-				if (*cp3 == ';' || *cp3 == ':')
++				if (*cp3 == ';' || *cp3 == ':' || *cp3 == ',')
+ 					--cp3;
+-				while (*cp3 == ' ' || *cp3 == '\t')
++				while (*cp3 == '\0' || *cp3 == ' ' || *cp3 == '\t')
+ 					--cp3;
+ 				if (*cp3)
+ 					++cp3;
+@@ -763,10 +763,11 @@
+ }
+ 
+ static void
+-splitFontName(char* name, char** var, char** feat, char** end)
++splitFontName(char* name, char** var, char** feat, char** end, int* index)
+ {
+ 	*var = NULL;
+ 	*feat = NULL;
++	*index = 0;
+ 	if (*name == '[') {
+ 		int	withinFileName = 1;
+ #ifdef WIN32
+@@ -784,8 +785,12 @@
+ #ifdef WIN32
+ 					&& !((name - start == 1) && isalpha(*start))
+ #endif
+-					)
+-					*var = name;
++					) {
++					++name;
++					while (*name >= '0' && *name <= '9')
++						*index = *index * 10 + *name++ - '0';
++					--name;
++				}
+ 				else if (!withinFileName && *feat == NULL)
+ 					*feat = name;
+ 			}
+@@ -811,9 +816,9 @@
+ 
+ void*
+ findnativefont(unsigned char* uname, integer scaled_size)
+-	/* scaled_size here is in TeX points */
++	/* scaled_size here is in TeX points, or is a negative integer for 'scaled' */
+ {
+-	void*	rval = 0;
++	void*	rval = NULL;
+ 	char*	nameString;
+ 	char*	var;
+ 	char*	feat;
+@@ -823,13 +828,13 @@
+ 	char*	featString = NULL;
+ 	PlatformFontRef	fontRef;
+ 	XeTeXFont	font;
++	int		index = 0;
+ 
+ 	loadedfontmapping = NULL;
+ 	loadedfontflags = 0;
+ 	loadedfontletterspace = 0;
+ 
+-	splitFontName(name, &var, &feat, &end);
+-
++	splitFontName(name, &var, &feat, &end, &index);
+ 	nameString = xmalloc(var - name + 1);
+ 	strncpy(nameString, name, var - name);
+ 	nameString[var - name] = 0;
+@@ -854,16 +859,22 @@
+ 		if (path == NULL)
+ 			path = kpse_find_file(nameString + 1, kpse_type1_format, 0);
+ 		if (path != NULL) {
+-			int index = 0;
+-			if (varString != NULL) {
+-				char* cp;
+-				for (cp = varString; *cp && isdigit(*cp); ++cp)
+-					index = index * 10 + *cp - '0';
++			if (scaled_size < 0) {
++				font = createFontFromFile(path, index, 655360L);
++				if (font != NULL) {
++					Fixed dsize = X2Fix(getDesignSize(font));
++					if (scaled_size == -1000)
++						scaled_size = dsize;
++					else
++						scaled_size = zxnoverd(dsize, -scaled_size, 1000);
++					deleteFont(font);
++				}
+ 			}
+ 			font = createFontFromFile(path, index, scaled_size);
+ 			if (font != NULL) {
++				loadedfontdesignsize = X2Fix(getDesignSize(font));
+ 				rval = loadOTfont(0, font, scaled_size, featString);
+-				if (rval == 0)
++				if (rval == NULL)
+ 					deleteFont(font);
+ 			}
+ 		}
+@@ -883,6 +894,18 @@
+ 			nameoffile = xmalloc(namelength + 4); /* +2 would be correct: initial space, final NUL */
+ 			nameoffile[0] = ' ';
+ 			strcpy((char*)nameoffile + 1, fullName);
++
++			if (scaled_size < 0) {
++				font = createFont(fontRef, scaled_size);
++				if (font != NULL) {
++					Fixed dsize = X2Fix(getDesignSize(font));
++					if (scaled_size == -1000)
++						scaled_size = dsize;
++					else
++						scaled_size = zxnoverd(dsize, -scaled_size, 1000);
++					deleteFont(font);
++				}
++			}
+ 	
+ #ifdef XETEX_MAC
+ 			/* decide whether to use AAT or OpenType rendering with this font */
+@@ -1568,7 +1591,7 @@
+ 				for (runIndex = 0; runIndex < nRuns; ++runIndex) {
+ 					dir = ubidi_getVisualRun(pBiDi, runIndex, &logicalStart, &length);
+ 					nGlyphs = layoutChars(engine, (UniChar*)txtPtr, logicalStart, length, txtLen,
+-											(dir == UBIDI_RTL), x, y, &status);
++											(dir == UBIDI_RTL), 0, 0, &status);
+ 	
+ 					getGlyphs(engine, glyphs, &status);
+ 					getGlyphPositions(engine, positions, &status);
+@@ -1576,13 +1599,13 @@
+ 					for (i = 0; i < nGlyphs; ++i) {
+ 						if (glyphs[i] < 0xfffe) {
+ 							glyphIDs[realGlyphCount] = glyphs[i];
+-							locations[realGlyphCount].x = X2Fix(positions[2*i]);
+-							locations[realGlyphCount].y = X2Fix(positions[2*i+1]);
++							locations[realGlyphCount].x = X2Fix(positions[2*i] + x);
++							locations[realGlyphCount].y = X2Fix(positions[2*i+1] + y);
+ 							++realGlyphCount;
+ 						}
+ 					}
+-					x = positions[2*i];
+-					y = positions[2*i+1];
++					x += positions[2*i];
++					y += positions[2*i+1];
+ 				}
+ 				wid = x;
+ 			}
+@@ -2299,10 +2322,22 @@
+ 			if (*p++ == '\"')
+ 				++len;
+ 		len += strlen(outputdriver);
+-		len += 8; /* space for -o flag, quotes, NUL */
++		if (output_directory)
++			len += strlen(output_directory);
++		len += 10; /* space for -o flag, quotes, NUL */
++		for (p = (const char*)nameoffile+1; *p; p++)
++			if (*p == '\"')
++				++len;	/* allow extra space to escape quotes in filename */
+ 		cmd = xmalloc(len);
+ 		strcpy(cmd, outputdriver);
+ 		strcat(cmd, " -o \"");
++		if (output_directory) {
++			len = strlen(output_directory);
++			if (IS_DIR_SEP(output_directory[len-1]))
++				output_directory[len-1] = '\0';
++			strcat(cmd, output_directory);
++			strcat(cmd, "/");
++		}
+ 		q = cmd + strlen(cmd);
+ 		for (p = (const char*)nameoffile+1; *p; p++) {
+ 			if (*p == '\"')
+@@ -2316,6 +2351,14 @@
+ 			free(cmd);
+ 			cmd = cmd2;
+ 		}
++		if (output_directory) {
++			char *fullname = concat3(output_directory, "/", nameoffile+1);
++			free(nameoffile);
++			namelength = strlen(fullname);
++			nameoffile = (char*)xmalloc(namelength+2);
++			strcpy(nameoffile+1, fullname);
++			free(fullname);
++		}
+ 		*fptr = popen(cmd, "w");
+ 		free(cmd);
+ 		return (*fptr != 0);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_ext.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.h	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_ext.h	2008-05-28 17:20:28.000000000 +0200
+@@ -260,6 +260,7 @@
+   
+ 	const char* getGlyphNamePtr(const char* buffer, int tableSize, UInt16 gid, int* len);
+ 
++	int countpdffilepages();
+ 	int find_pic_file(char** path, realrect* bounds, int pdfBoxType, int page);
+ 	int u_open_in(unicodefile* f, integer filefmt, const char* fopen_mode, integer mode, integer encodingData);
+ 	int open_dvi_output(FILE** fptr);
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_mac.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeX_mac.c	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_mac.c	2008-05-28 17:20:28.000000000 +0200
+@@ -961,6 +961,31 @@
+ }
+ 
+ int
++countpdffilepages()
++{
++	int	rval = 0;
++
++    char*		pic_path = kpse_find_file((char*)nameoffile + 1, kpse_pict_format, 1);
++	CFURLRef	picFileURL = NULL;
++	if (pic_path) {
++		picFileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8*)pic_path, strlen(pic_path), false);
++		if (picFileURL != NULL) {
++			FSRef	picFileRef;
++			CFURLGetFSRef(picFileURL, &picFileRef);
++			CGPDFDocumentRef	document = CGPDFDocumentCreateWithURL(picFileURL);
++			if (document != NULL) {
++				rval = CGPDFDocumentGetNumberOfPages(document);
++				CGPDFDocumentRelease(document);
++			}
++			CFRelease(picFileURL);
++		}
++		free(pic_path);
++	}
++
++	return rval;
++}
++
++int
+ find_pic_file(char** path, realrect* bounds, int pdfBoxType, int page)
+ {
+ 	*path = NULL;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_pic.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeX_pic.c	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeX_pic.c	2008-05-28 17:20:28.000000000 +0200
+@@ -32,6 +32,22 @@
+ #include "jpegimage.h"
+ #include "bmpimage.h"
+ 
++
++int
++countpdffilepages()
++{
++	int	rval = 0;
++
++    char*		pic_path = kpse_find_file((char*)nameoffile + 1, kpse_pict_format, 1);
++	if (pic_path) {
++		rval = pdf_count_pages(pic_path);
++		free(pic_path);
++	}
++
++	return rval;
++}
++
++
+ /*
+ 	locate picture file from /nameoffile+1/ using kpathsearch
+ 	pdfBoxType indicates which pdf bounding box to use (0 for \XeTeXpicfile)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/appleGlyphNames.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/appleGlyphNames.c	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/appleGlyphNames.c	2008-05-28 17:20:28.000000000 +0200
+@@ -28,7 +28,7 @@
+ authorization from SIL International.
+ \****************************************************************************/
+ 
+-char*	appleGlyphNames[] = {
++const char*	appleGlyphNames[] = {
+ 	".notdef",
+ 	".null",
+ 	"nonmarkingreturn",
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/pdfimage.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/pdfimage.cpp	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/pdfimage.cpp	2008-05-28 17:20:28.000000000 +0200
+@@ -96,3 +96,25 @@
+ 
+ 	return 0;
+ }
++
++int
++pdf_count_pages(char* filename)
++{
++	int			pages = 0;
++	GooString*	name = new GooString(filename);
++	PDFDoc*		doc = new PDFDoc(name);
++	
++	if (!doc) {
++		delete name;
++		return 0;
++	}
++	
++	/* if the doc got created, it now owns name, so we mustn't delete it! */
++	
++	if (doc->isOk())
++		pages = doc->getNumPages();
++
++	delete doc;
++
++	return pages;
++}
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/pdfimage.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/pdfimage.h	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/pdfimage.h	2008-05-28 17:20:28.000000000 +0200
+@@ -20,6 +20,8 @@
+ 
+ extern int pdf_get_rect(char* filename, int page_num, int pdf_box, realrect* box);
+ 
++extern int pdf_count_pages(char* filename);
++
+ #ifdef __cplusplus
+ };
+ #endif
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/pool2c.pl
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/pool2c.pl	2008-05-28 17:20:28.000000000 +0200
+@@ -0,0 +1,74 @@
++#! /usr/bin/perl
++
++# Convert web .pool file into C source
++# Result is an array of chars (bytes) containing the strings,
++# each prefixed by a length byte.
++# The function initpool() loads this data into TeX's pool.
++
++# usage: perl pool2c.pl NAME.pool
++# writes output to ${NAME}_pool.c if only one arg provided
++
++die "expected pool name as argument" unless $#ARGV >= 0;
++die "too many arguments" if $#ARGV > 1;
++
++$prog = `basename $ARGV[0] .pool`;
++chomp($prog);
++
++$outfile = ($#ARGV == 1) ? $ARGV[1] : "${prog}_pool.c";
++
++open IN, "< $ARGV[0]" or die "can't open input $ARGV[0]";
++open OUT, "> $outfile" or die "can't open output $outfile";
++
++print OUT <<__EOT__;
++/* This file is auto-generated from $ARGV[0] by pool2c.pl */
++#define EXTERN extern
++#include "${prog}d.h"
++
++#include <stdio.h>
++
++static unsigned char POOL[] =
++__EOT__
++$pool_len = 0;
++while (<IN>) {
++	chomp;
++	if (m/^([0-9]{2})(.*)$/) {
++		($len, $str) = ($1, $2);
++		if (length($str) != $len) {
++			die "*** pool string length error:\n$_\n";
++		}
++		$str =~ s/(["\\])/\\$1/g;
++		$str =~ s/\?\?\?/\\?\\?\\?/g;
++		printf OUT "\t\"\\x%02X\" \"%s\"\n", $len, $str;
++		$pool_len += $len + 1;
++	}
++	elsif (m/^\*[0-9]+$/) {
++		last;
++	}
++	else {
++		die "*** unexpected line in pool file:\n$_\n"; 
++	}
++}
++
++close IN;
++
++print OUT <<__EOT__;
++	;
++
++#define POOL_LEN $pool_len
++
++int initpool(int limit) {
++	int g = 0;
++	unsigned char *s = POOL;
++	while (s < POOL + POOL_LEN) {
++		int len = *s++;
++		if (poolptr + len >= limit)
++			return 0;
++		while (len-- > 0)
++			strpool[poolptr++] = *s++;
++		g = makestring();
++	}
++	return g;
++}
++__EOT__
++
++close OUT;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetex-new.ch
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/xetex-new.ch	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetex-new.ch	2008-05-28 17:20:45.000000000 +0200
+@@ -1,6 +1,6 @@
+ % /****************************************************************************\
+ %  Part of the XeTeX typesetting system
+-%  copyright (c) 1994-2006 by SIL International
++%  copyright (c) 1994-2008 by SIL International
+ %  written by Jonathan Kew
+ % 
+ % Permission is hereby granted, free of charge, to any person obtaining  
+@@ -55,8 +55,8 @@
+ @d eTeX_version_string=='-2.2' {current \eTeX\ version}
+ 
+ @d XeTeX_version=0
+-@d XeTeX_revision==".996"
+-@d XeTeX_version_string=='-0.996-patch1' {current \XeTeX\ version}
++@d XeTeX_revision==".996-patch2"
++@d XeTeX_version_string=='-0.996-patch2' {current \XeTeX\ version}
+ @z
+ 
+ @x
+@@ -346,41 +346,80 @@
+ @z
+ 
+ @x
++@ When the \.{WEB} system program called \.{TANGLE} processes the \.{TEX.WEB}
++description that you are now reading, it outputs the \PASCAL\ program
++\.{TEX.PAS} and also a string pool file called \.{TEX.POOL}. The \.{INITEX}
++@.WEB@>@.INITEX@>
++program reads the latter file, where each string appears as a two-digit decimal
++length followed by the string itself, and the information is recorded in
++\TeX's string memory.
++
++@<Glob...@>=
++@!init @!pool_file:alpha_file; {the string-pool file output by \.{TANGLE}}
++tini
++
++@ @d bad_pool(#)==begin wake_up_terminal; write_ln(term_out,#);
++  a_close(pool_file); get_strings_started:=false; return;
++  end
++@<Read the other strings...@>=
++name_length := strlen (pool_name);
+ name_of_file := xmalloc_array (ASCII_code, name_length + 1);
+-@y
+-name_of_file := xmalloc_array (UTF8_code, name_length + 1);
+-@z
++strcpy (stringcast(name_of_file+1), pool_name); {copy the string}
++if a_open_in (pool_file, kpse_texpool_format) then
++  begin c:=false;
++  repeat @<Read one string, but return |false| if the
++    string memory space is getting too tight for comfort@>;
++  until c;
++  a_close(pool_file); get_strings_started:=true;
++  end
++else  bad_pool('! I can''t read ', pool_name, '; bad path?')
++@.I can't read TEX.POOL@>
+ 
+-@x
++@ @<Read one string...@>=
++begin if eof(pool_file) then bad_pool('! ', pool_name, ' has no check sum.');
++@.TEX.POOL has no check sum@>
++read(pool_file,m); read(pool_file,n); {read two digits of string length}
++if m='*' then @<Check the pool check sum@>
+ else  begin if (xord[m]<"0")or(xord[m]>"9")or@|
+       (xord[n]<"0")or(xord[n]>"9") then
+-@y
+-else  begin if (m<"0")or(m>"9")or@|
+-      (n<"0")or(n>"9") then
+-@z
+-
+-@x
++    bad_pool('! ', pool_name, ' line doesn''t begin with two digits.');
++@.TEX.POOL line doesn't...@>
+   l:=xord[m]*10+xord[n]-"0"*11; {compute the length}
+-@y
+-  l:=m*10+n-"0"*11; {compute the length}
+-@z
+-
+-@x
++  if pool_ptr+l+string_vacancies>pool_size then
++    bad_pool('! You have to increase POOLSIZE.');
++@.You have to increase POOLSIZE@>
++  for k:=1 to l do
++    begin if eoln(pool_file) then m:=' '@+else read(pool_file,m);
+     append_char(xord[m]);
+-@y
+-    append_char(m);
+-@z
++    end;
++  read_ln(pool_file); g:=make_string;
++  end;
++end
+ 
+-@x
+-loop@+  begin if (xord[n]<"0")or(xord[n]>"9") then
+-@y
+-loop@+  begin if (n<"0")or(n>"9") then
+-@z
++@ The \.{WEB} operation \.{@@\$} denotes the value that should be at the
++end of this \.{TEX.POOL} file; any other value means that the wrong pool
++file has been loaded.
++@^check sum@>
+ 
+-@x
++@<Check the pool check sum@>=
++begin a:=0; k:=1;
++loop@+  begin if (xord[n]<"0")or(xord[n]>"9") then
++  bad_pool('! ', pool_name, ' check sum doesn''t have nine digits.');
++@.TEX.POOL check sum...@>
+   a:=10*a+xord[n]-"0";
++  if k=9 then goto done;
++  incr(k); read(pool_file,n);
++  end;
++done: if a<>@$ then
++  bad_pool('! ', pool_name, ' doesn''t match; tangle me again (or fix the path).');
++@.TEX.POOL doesn't match@>
++c:=true;
++end
+ @y
+-  a:=10*a+n-"0";
++@ @<Read the other strings...@>=
++if init_pool(pool_size-string_vacancies) = 0 then
++  get_strings_started:=false;
++get_strings_started:=true;
+ @z
+ 
+ @x
+@@ -501,11 +540,23 @@
+ end;
+ exit:end;
+ 
++@ @d native_room(#)==while native_text_size <= native_len+# do begin
++    native_text_size:=native_text_size+128;
++    native_text:=xrealloc(native_text, native_text_size * sizeof(UTF16_code));
++  end
++@d append_native(#)==begin native_text[native_len]:=#; incr(native_len); end
++
+ @ @<Glob...@>=
+-doing_special: boolean;
++@!doing_special: boolean;
++@!native_text: ^UTF16_code; { buffer for collecting native-font strings }
++@!native_text_size: integer; { size of buffer }
++@!native_len: integer;
++@!save_native_len: integer;
+ 
+ @ @<Set init...@>=
+ doing_special:=false;
++native_text_size:=128;
++native_text:=xmalloc(native_text_size * sizeof(UTF16_code));
+ @z
+ 
+ @x
+@@ -710,8 +761,7 @@
+ Then there is a field containing a C pointer to a glyph info array;
+ this and the glyph count are set by |set_native_metrics|.
+ Copying and freeing of these nodes needs to take account of this!
+-This is followed by |length| bytes, for the actual characters of the string.
+-(Yes, we count in bytes, even though what we store there is UTF-16.)
++This is followed by |2*length| bytes, for the actual characters of the string (in UTF-16).
+ 
+ So |native_node_size|, which does not include any space for the actual text, is 6.}
+ 
+@@ -1142,9 +1192,10 @@
+ @d eTeX_state_code=etex_int_base+9 {\eTeX\ state variables}
+ @d etex_int_pars=eTeX_state_code+eTeX_states {total number of \eTeX's integer parameters}
+ @y
+-@d XeTeX_linebreak_locale_code=etex_int_base+9 {string number of locale to use for linebreak locations}
+-@d XeTeX_linebreak_penalty_code=etex_int_base+10 {penalty to use at locale-dependent linebreak locations}
+-@d eTeX_state_code=etex_int_base+11 {\eTeX\ state variables}
++@d suppress_fontnotfound_error_code=etex_int_base+9 {suppress errors for missing fonts}
++@d XeTeX_linebreak_locale_code=etex_int_base+10 {string number of locale to use for linebreak locations}
++@d XeTeX_linebreak_penalty_code=etex_int_base+11 {penalty to use at locale-dependent linebreak locations}
++@d eTeX_state_code=etex_int_base+12 {\eTeX\ state variables}
+ @d etex_int_pars=eTeX_state_code+eTeX_states {total number of \eTeX's integer parameters}
+ @z
+ 
+@@ -1162,6 +1213,7 @@
+ @d saving_hyph_codes==int_par(saving_hyph_codes_code)
+ @y
+ @d saving_hyph_codes==int_par(saving_hyph_codes_code)
++@d suppress_fontnotfound_error==int_par(suppress_fontnotfound_error_code)
+ @d XeTeX_linebreak_locale==int_par(XeTeX_linebreak_locale_code)
+ @d XeTeX_linebreak_penalty==int_par(XeTeX_linebreak_penalty_code)
+ @z
+@@ -1805,7 +1857,7 @@
+ @#
+ @d XeTeX_int=eTeX_int+8 {first of \XeTeX\ codes for integers}
+ @#
+-@d eTeX_dim=XeTeX_int+29 {first of \eTeX\ codes for dimensions}
++@d eTeX_dim=XeTeX_int+30 {first of \eTeX\ codes for dimensions}
+  {changed for \XeTeX\ to make room for \XeTeX\ integers}
+ @z
+ 
+@@ -2536,6 +2588,7 @@
+ @!loaded_font_mapping: void_pointer; { used by load_native_font to return mapping, if any }
+ @!loaded_font_flags: char; { used by load_native_font to return flags }
+ @!loaded_font_letter_space: scaled;
++@!loaded_font_design_size: scaled;
+ @!mapped_text: ^UTF16_code; { scratch buffer used while applying font mappings }
+ @!xdv_buffer: ^char; { scratch buffer used in generating XDV output }
+ @z
+@@ -2548,9 +2601,9 @@
+ if quoted_filename then begin
+   { quoted name, so try for a native font }
+   g:=load_native_font(u,nom,aire,s);
+-  if g=null_font then goto bad_tfm else goto done;
++  if g<>null_font then goto done;
+ end;
+-{ it was an unquoted name, so try for a TFM file }
++{ it was an unquoted name, or not found as an installed font, so try for a TFM file }
+ @<Read and check the font data if file exists;
+   |abort| if the \.{TFM} file is
+ @z
+@@ -2559,16 +2612,15 @@
+ bad_tfm: @<Report that the font won't be loaded@>;
+ @y
+ if g<>null_font then goto done;
+-if file_name_quote_char=0 then begin
++if not quoted_filename then begin
+   { we failed to find a TFM file, so try for a native font }
+   g:=load_native_font(u,nom,aire,s);
+   if g<>null_font then goto done
+ end;
+ bad_tfm:
+-if (not file_opened) and (file_name_quote_char<>0) then begin
+-  @<Report that native font couldn't be found, and |goto done|@>;
+-end;
+-@<Report that the font won't be loaded@>;
++if suppress_fontnotfound_error=0 then begin
++  @<Report that the font won't be loaded@>;
++  end;
+ @z
+ 
+ @x
+@@ -2593,17 +2645,6 @@
+ @ @<Read and check...@>=
+ @<Open |tfm_file| for input@>;
+ @y
+-@ @<Report that native font couldn't be found, and |goto done|@>=
+-start_font_error_message;
+-@.Font x=xx not loadable...@>
+-print(" not loadable: installed font not found");
+-help4("I wasn't able to find this font in the Mac OS,")@/
+-("so I will ignore the font specification.")@/
+-("You might try inserting a different font spec;")@/
+-("e.g., type `I\font<same font id>=<substitute font name>'.");
+-error;
+-goto done
+-
+ @ @<Read and check...@>=
+ @<Open |tfm_file| for input and |begin|@>;
+ @z
+@@ -2945,21 +2986,22 @@
+ dvi_four(last_bop); last_bop:=page_loc;
+ @y
+ dvi_four(last_bop); last_bop:=page_loc;
++{ generate a pagesize \special at start of page }
++old_setting:=selector; selector:=new_string;
++print("pdf:pagesize ");
+ if (pdf_page_width > 0) and (pdf_page_height > 0) then begin
+-  { generate a papersize \special at start of page }
+-  old_setting:=selector; selector:=new_string;
+-  print("papersize ");
+-  if mag=1000 then print_scaled(pdf_page_width)
+-  else print_scaled(xn_over_d(pdf_page_width,mag,1000));
+-  print("pt"); print(",");
+-  if mag=1000 then print_scaled(pdf_page_height)
+-  else print_scaled(xn_over_d(pdf_page_height,mag,1000));
++  print("width"); print(" ");
++  print_scaled(pdf_page_width);
++  print("pt"); print(" ");
++  print("height"); print(" ");
++  print_scaled(pdf_page_height);
+   print("pt");
+-  selector:=old_setting;
+-  dvi_out(xxx1); dvi_out(cur_length);
+-  for s:=str_start_macro(str_ptr) to pool_ptr-1 do dvi_out(so(str_pool[s]));
+-  pool_ptr:=str_start_macro(str_ptr); {erase the string}
+-end;
++end else
++  print("default");
++selector:=old_setting;
++dvi_out(xxx1); dvi_out(cur_length);
++for s:=str_start_macro(str_ptr) to pool_ptr-1 do dvi_out(so(str_pool[s]));
++pool_ptr:=str_start_macro(str_ptr); {erase the string}
+ @z
+ 
+ @x
+@@ -3786,27 +3828,27 @@
+ @x
+ adjust_space_factor;@/
+ @y
+-
+ { added code for native font support }
+ if is_native_font(cur_font) then begin
+ 	if mode>0 then if language<>clang then fix_language;
+ 
+ 	main_h := 0;
+ 	main_f := cur_font;
+-
++	native_len := 0;
++	
+ collect_native:
+ 	adjust_space_factor;
+ 	if (cur_chr > @"FFFF) then begin
+-		str_room(2);
+-		append_char((cur_chr - @"10000) div 1024 + @"D800);
+-		append_char((cur_chr - @"10000) mod 1024 + @"DC00);
++		native_room(2);
++		append_native((cur_chr - @"10000) div 1024 + @"D800);
++		append_native((cur_chr - @"10000) mod 1024 + @"DC00);
+ 	end else begin
+-		str_room(1);
+-		append_char(cur_chr);
++		native_room(1);
++		append_native(cur_chr);
+ 	end;
+ 	is_hyph := (cur_chr = hyphen_char[main_f])
+ 		or (XeTeX_dash_break_en and (cur_chr = @"2014) or (cur_chr = @"2013));
+-	if (main_h = 0) and is_hyph then main_h := cur_length;
++	if (main_h = 0) and is_hyph then main_h := native_len;
+ 
+ 	{try to collect as many chars as possible in the same font}
+ 	get_next;
+@@ -3820,27 +3862,26 @@
+ 	end;
+ 
+ 	if (font_mapping[main_f] <> 0) then begin
+-		main_k := apply_mapping(font_mapping[main_f], address_of(str_pool[str_start_macro(str_ptr)]), cur_length);
+-		pool_ptr := str_start_macro(str_ptr); { flush the string, as we'll be using the mapped text instead }
+-		str_room(main_k);
++		main_k := apply_mapping(font_mapping[main_f], native_text, native_len);
++		native_len := 0;
++		native_room(main_k);
+ 		main_h := 0;
+ 		for main_p := 0 to main_k - 1 do begin
+-			append_char(mapped_text[main_p]);
++			append_native(mapped_text[main_p]);
+ 			if (main_h = 0) and ((mapped_text[main_p] = hyphen_char[main_f])
+ 				or (XeTeX_dash_break_en and ((mapped_text[main_p] = @"2014) or (mapped_text[main_p] = @"2013)) ) )
+-			then main_h := cur_length;
++			then main_h := native_len;
+ 		end
+ 	end;
+ 
+ 	if tracing_lost_chars > 0 then begin
+-		temp_ptr := str_start_macro(str_ptr);
+-		main_p := temp_ptr + cur_length;
+-		while (temp_ptr < main_p) do begin
+-			main_k := str_pool[temp_ptr];
++		temp_ptr := 0;
++		while (temp_ptr < native_len) do begin
++			main_k := native_text[temp_ptr];
+ 			incr(temp_ptr);
+ 			if (main_k >= @"D800) and (main_k < @"DC00) then begin
+ 				main_k := @"10000 + (main_k - @"D800) * 1024;
+-				main_k := main_k + str_pool[temp_ptr] - @"DC00;
++				main_k := main_k + native_text[temp_ptr] - @"DC00;
+ 				incr(temp_ptr);
+ 			end;
+ 			if map_char_to_glyph(main_f, main_k) = 0 then
+@@ -3848,48 +3889,54 @@
+ 		end
+ 	end;
+ 
+-	main_k := cur_length;
++	main_k := native_len;
+ 	main_pp := tail;
+ 
+ 	if mode=hmode then begin
+ 
+ 		main_ppp := head;
+-		if main_ppp<>main_pp then
+-			while (link(main_ppp)<>main_pp) do
+-				main_ppp:=link(main_ppp);	{ find node preceding tail }
++		if main_ppp<>main_pp then	{ find node preceding tail, skipping discretionaries }
++			while (link(main_ppp)<>main_pp) do begin
++				if (not is_char_node(main_ppp)) and (type(main_ppp=disc_node)) then begin
++					temp_ptr:=main_ppp;
++					for main_p:=1 to replace_count(temp_ptr) do main_ppp:=link(main_ppp);
++				end;
++				if main_ppp<>main_pp then main_ppp:=link(main_ppp);
++			end;
+ 
+-		temp_ptr := str_start_macro(str_ptr);
++		temp_ptr := 0;
+ 		repeat
+ 			if main_h = 0 then main_h := main_k;
+ 
+-			if (not is_char_node(main_pp))
++			if      (not is_char_node(main_pp))
+ 				and (type(main_pp)=whatsit_node)
+ 				and (subtype(main_pp)=native_word_node)
+ 				and (native_font(main_pp)=main_f)
+ 				and (main_ppp<>main_pp)
+-				and type(main_ppp)<>disc_node
++				and (not is_char_node(main_ppp))
++				and (type(main_ppp)<>disc_node)
+ 			then begin
+ 
+ 				{ make a new temp string that contains the concatenated text of |tail| + the current word/fragment }
+ 				main_k := main_h + native_length(main_pp);
+-				str_room(main_k);
++				native_room(main_k);
+ 				
+-				temp_ptr := pool_ptr;
++				save_native_len := native_len;
+ 				for main_p := 0 to native_length(main_pp) - 1 do
+-					append_char(get_native_char(main_pp, main_p));
+-				for main_p := str_start_macro(str_ptr) to temp_ptr - 1 do
+-					append_char(str_pool[main_p]);
+-
+-				do_locale_linebreaks(temp_ptr, main_k);
+-
+-				pool_ptr := temp_ptr;	{ discard the temp string }
+-				main_k := cur_length - main_h;	{ and set main_k to remaining length of new word }
+-				temp_ptr := str_start_macro(str_ptr) + main_h;	{ pointer to remaining fragment }
++					append_native(get_native_char(main_pp, main_p));
++				for main_p := 0 to main_h - 1 do
++					append_native(native_text[temp_ptr + main_p]);
++
++				do_locale_linebreaks(save_native_len, main_k);
++
++				native_len := save_native_len;	{ discard the temp string }
++				main_k := native_len - main_h - temp_ptr;	{ and set main_k to remaining length of new word }
++				temp_ptr := main_h;	{ pointer to remaining fragment }
+ 
+ 				main_h := 0;
+-				while (main_h < main_k) and (str_pool[temp_ptr + main_h] <> hyphen_char[main_f])
++				while (main_h < main_k) and (native_text[temp_ptr + main_h] <> hyphen_char[main_f])
+ 					and ( (not XeTeX_dash_break_en)
+-						or ((str_pool[temp_ptr + main_h] <> @"2014) and (str_pool[temp_ptr + main_h] <> @"2013)) )
++						or ((native_text[temp_ptr + main_h] <> @"2014) and (native_text[temp_ptr + main_h] <> @"2013)) )
+ 				do incr(main_h);	{ look for next hyphen or end of text }
+ 				if (main_h < main_k) then incr(main_h);
+ 
+@@ -3909,9 +3956,9 @@
+ 				main_k := main_k - main_h;	{ decrement remaining length }
+ 
+ 				main_h := 0;
+-				while (main_h < main_k) and (str_pool[temp_ptr + main_h] <> hyphen_char[main_f])
++				while (main_h < main_k) and (native_text[temp_ptr + main_h] <> hyphen_char[main_f])
+ 					and ( (not XeTeX_dash_break_en)
+-						or ((str_pool[temp_ptr + main_h] <> @"2014) and (str_pool[temp_ptr + main_h] <> @"2013)) )
++						or ((native_text[temp_ptr + main_h] <> @"2014) and (native_text[temp_ptr + main_h] <> @"2013)) )
+ 				do incr(main_h);	{ look for next hyphen or end of text }
+ 				if (main_h < main_k) then incr(main_h);
+ 
+@@ -3920,6 +3967,7 @@
+ 			if (main_k > 0) or is_hyph then begin
+ 				tail_append(new_disc);	{ add a break if we aren't at end of text (must be a hyphen),
+ 											or if last char in original text was a hyphen }
++				main_pp:=tail;
+ 			end;
+ 		until main_k = 0;
+ 		
+@@ -3935,7 +3983,7 @@
+ 				set_native_char(tail, main_p, get_native_char(main_pp, main_p));
+ 			{ append the new text }
+ 			for main_p := 0 to main_k - 1 do
+-				set_native_char(tail, main_p + native_length(main_pp), str_pool[str_start_macro(str_ptr) + main_p]);
++				set_native_char(tail, main_p + native_length(main_pp), native_text[main_p]);
+ 			set_native_metrics(tail, XeTeX_use_glyph_metrics);
+ 
+ 			{ remove the preceding node from the list }
+@@ -3951,12 +3999,11 @@
+ 			link(main_pp) := new_native_word_node(main_f, main_k);
+ 			tail := link(main_pp);
+ 			for main_p := 0 to main_k - 1 do
+-				set_native_char(tail, main_p, str_pool[str_start_macro(str_ptr) + main_p]);
++				set_native_char(tail, main_p, native_text[main_p]);
+ 			set_native_metrics(tail, XeTeX_use_glyph_metrics);
+ 		end
+ 	end;
+ 	
+-	pool_ptr := str_start_macro(str_ptr);
+ 	goto reswitch;
+ end;
+ { End of added code for native fonts }
+@@ -5004,16 +5051,39 @@
+ 
+ @x
+ @ @d adv_past(#)==@+if subtype(#)=language_node then
+-    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);@+end
++    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);
++    set_hyph_index;
++    end
++
++@<Advance \(p)past a whatsit node in the \(l)|line_break| loop@>=@+
++adv_past(cur_p)
+ @y
+-@ @d adv_past(#)==@+if subtype(#)=language_node then
+-    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);@+end
++@ @d adv_past_linebreak(#)==@+if subtype(#)=language_node then
++    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);
++    set_hyph_index;
++    end
+   else if (subtype(#)=native_word_node)
+   or (subtype(#)=glyph_node)
+   or (subtype(#)=pic_node)
+   or (subtype(#)=pdf_node)
+   then
+     begin act_width:=act_width+width(#); end
++
++@<Advance \(p)past a whatsit node in the \(l)|line_break| loop@>=@+
++adv_past_linebreak(cur_p)
++@z
++
++@x
++@ @<Advance \(p)past a whatsit node in the \(p)pre-hyphenation loop@>=@+
++adv_past(s)
++@y
++@ @d adv_past_prehyph(#)==@+if subtype(#)=language_node then
++    begin cur_lang:=what_lang(#); l_hyf:=what_lhm(#); r_hyf:=what_rhm(#);
++    set_hyph_index;
++    end
++
++@<Advance \(p)past a whatsit node in the \(p)pre-hyphenation loop@>=@+
++adv_past_prehyph(s)
+ @z
+ 
+ @x
+@@ -5565,6 +5635,8 @@
+ @d pdf_last_x_pos_code        = XeTeX_int+27
+ @d pdf_last_y_pos_code        = XeTeX_int+28
+ 
++@d XeTeX_pdf_page_count_code  = XeTeX_int+29
++
+ { NB: must update eTeX_dim when items are added here! }
+ @z
+ 
+@@ -5619,6 +5691,8 @@
+ 
+ primitive("pdflastxpos",last_item,pdf_last_x_pos_code);
+ primitive("pdflastypos",last_item,pdf_last_y_pos_code);
++
++primitive("XeTeXpdfpagecount",last_item,XeTeX_pdf_page_count_code);
+ @z
+ 
+ @x
+@@ -5662,6 +5736,8 @@
+ 
+   pdf_last_x_pos_code:  print_esc("pdflastxpos");
+   pdf_last_y_pos_code:  print_esc("pdflastypos");
++
++XeTeX_pdf_page_count_code: print_esc("XeTeXpdfpagecount");
+ @z
+ 
+ @x
+@@ -5835,6 +5911,12 @@
+   pdf_last_x_pos_code:  cur_val := pdf_last_x_pos;
+   pdf_last_y_pos_code:  cur_val := pdf_last_y_pos;
+ 
++XeTeX_pdf_page_count_code:
++  begin
++    scan_and_pack_name;
++    cur_val:=count_pdf_file_pages;
++  end;
++
+ @ Slip in an extra procedure here and there....
+ 
+ @<Error hand...@>=
+@@ -5984,6 +6066,7 @@
+ @x
+ eTeX_state_code+TeXXeT_code:print_esc("TeXXeTstate");
+ @y
++suppress_fontnotfound_error_code:print_esc("suppressfontnotfounderror");
+ eTeX_state_code+TeXXeT_code:print_esc("TeXXeTstate");
+ eTeX_state_code+XeTeX_dash_break_code:print_esc("XeTeXdashbreakstate");
+ @z
+@@ -5992,6 +6075,7 @@
+ primitive("TeXXeTstate",assign_int,eTeX_state_base+TeXXeT_code);
+ @!@:TeXXeT_state_}{\.{\\TeXXeT_state} primitive@>
+ @y
++primitive("suppressfontnotfounderror",assign_int,int_base+suppress_fontnotfound_error_code);@/
+ primitive("TeXXeTstate",assign_int,eTeX_state_base+TeXXeT_code);
+ @!@:TeXXeT_state_}{\.{\\TeXXeT_state} primitive@>
+ 
+@@ -6255,10 +6339,18 @@
+ 
+ 	load_native_font := null_font;
+ 
+-	if (s < 0) then actual_size := -s * unity div 100 else actual_size := s;
+-	font_engine := find_native_font(name_of_file + 1, actual_size);
++	font_engine := find_native_font(name_of_file + 1, s);
+ 	if font_engine = 0 then goto done;
+ 	
++	if s>=0 then
++		actual_size := s
++	else begin
++		if (s <> -1000) then
++			actual_size := xn_over_d(loaded_font_design_size,-s,1000)
++		else
++			actual_size := loaded_font_design_size;
++	end;
++
+ 	{ look again to see if the font is already loaded, now that we know its canonical name }
+ 	str_room(name_length);
+ 	for k := 1 to name_length do
+@@ -6289,7 +6381,7 @@
+ 	font_check[font_ptr].b2 := 0;
+ 	font_check[font_ptr].b3 := 0;
+ 	font_glue[font_ptr] := null;
+-	font_dsize[font_ptr] := 10 * unity;
++	font_dsize[font_ptr] := loaded_font_design_size;
+ 	font_size[font_ptr] := actual_size;
+ 
+ 	if (native_font_type_flag = aat_font_flag) then begin
+@@ -6344,7 +6436,7 @@
+ done:
+ end;
+ 
+-procedure do_locale_linebreaks(s: pointer; len: integer);
++procedure do_locale_linebreaks(s: integer; len: integer);
+ var
+ 	offs, prevOffs, i: integer;
+ 	use_penalty, use_skip: boolean;
+@@ -6353,12 +6445,12 @@
+ 		link(tail) := new_native_word_node(main_f, len);
+ 		tail := link(tail);
+ 		for i := 0 to len - 1 do
+-			set_native_char(tail, i, str_pool[s + i]);
++			set_native_char(tail, i, native_text[s + i]);
+ 		set_native_metrics(tail, XeTeX_use_glyph_metrics);
+ 	end else begin
+ 		use_skip := XeTeX_linebreak_skip <> zero_glue;
+ 		use_penalty := XeTeX_linebreak_penalty <> 0 or not use_skip;
+-		linebreak_start(XeTeX_linebreak_locale, address_of(str_pool[s]), len);
++		linebreak_start(XeTeX_linebreak_locale, native_text + s, len);
+ 		offs := 0;
+ 		repeat
+ 			prevOffs := offs;
+@@ -6373,7 +6465,7 @@
+ 				link(tail) := new_native_word_node(main_f, offs - prevOffs);
+ 				tail := link(tail);
+ 				for i := prevOffs to offs - 1 do
+-					set_native_char(tail, i - prevOffs, str_pool[s + i]);
++					set_native_char(tail, i - prevOffs, native_text[s + i]);
+ 				set_native_metrics(tail, XeTeX_use_glyph_metrics);
+ 			end;
+ 		until offs < 0;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetex.defines
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/xetex.defines	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetex.defines	2008-05-28 17:20:28.000000000 +0200
+@@ -61,6 +61,7 @@
+ @define procedure printutf8str();
+ @define procedure setinputfileencoding();
+ @define procedure terminatefontmanager;
++@define function initpool();
+ 
+ @define procedure memcpy();
+ @define function casttoptr();
+@@ -133,6 +134,7 @@
+ 
+ @define function findpicfile();
+ @define function picpathbyte();
++@define function countpdffilepages;
+ 
+ @define procedure makeidentity();
+ @define procedure makescale();
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetex.mk
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/xetex.mk	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetex.mk	2008-05-28 17:20:28.000000000 +0200
+@@ -112,10 +112,16 @@
+ 	grep '^@d XeTeX_version_string==' $(srcdir)/xetexdir/xetex-new.ch \
+ 	  | sed "s/^.*'-//;s/'.*$$//" >xetexdir/xetex.version
+ 
++# Extract etex version
++xetexdir/etex.version: $(srcdir)/etexdir/etex.ch
++	test -d xetexdir || mkdir xetexdir
++	grep '^@d eTeX_version_string==' $(srcdir)/etexdir/etex.ch \
++	  | sed "s/^.*'-//;s/'.*$$//" >xetexdir/etex.version
++
+ # The C sources.
+ xetex_c = xetexini.c xetex0.c xetex1.c xetex2.c
+ xetex_o = xetexini.o xetex0.o xetex1.o xetex2.o xetexextra.o
+-xetex_add_o = trans.o XeTeX_ext.o $(xetex_platform_o)
++xetex_add_o = trans.o XeTeX_ext.o xetex_pool.o $(xetex_platform_o)
+ 
+ # these compilations require the path to TECkit headers;
+ # just setting it in XCFLAGS doesn't seem to work when we're called
+@@ -130,6 +136,8 @@
+ 	$(compile) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@
+ xetexextra.o: xetexextra.c $(srcdir)/xetexdir/XeTeX_ext.h
+ 	$(compile) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@
++xetex_pool.o: xetex_pool.c $(srcdir)/xetexdir/XeTeX_ext.h
++	$(compile) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@
+ 
+ # image support
+ mfileio.o: $(srcdir)/xetexdir/mfileio.c $(srcdir)/xetexdir/mfileio.h
+@@ -209,11 +217,15 @@
+ 	$(web2c) xetex
+ xetexextra.c: lib/texmfmp.c xetexdir/xetexextra.h
+ 	sed s/TEX-OR-MF-OR-MP/xetex/ $(srcdir)/lib/texmfmp.c >$@
+-xetexdir/xetexextra.h: xetexdir/xetexextra.in xetexdir/xetex.version
++xetexdir/xetexextra.h: xetexdir/xetexextra.in xetexdir/xetex.version xetexdir/etex.version
+ 	test -d xetexdir || mkdir xetexdir
+-	sed s/XETEX-VERSION/`cat xetexdir/xetex.version`/ \
++	sed -e s/XETEX-VERSION/`cat xetexdir/xetex.version`/ \
++	    -e s/ETEX-VERSION/`cat xetexdir/etex.version`/ \
+ 	  $(srcdir)/xetexdir/xetexextra.in >$@
+ 
++xetex_pool.c: xetex.pool
++	perl $(srcdir)/xetexdir/pool2c.pl $< $@
++
+ # Tangling
+ xetex.p xetex.pool: ./otangle xetex.web # xetex.ch
+ 	./otangle xetex.web # xetex.ch
+@@ -262,7 +274,7 @@
+ clean:: xetex-clean
+ xetex-clean: # etrip-clean
+ 	$(LIBTOOL) --mode=clean $(RM) xetex
+-	rm -f $(xetex_o) $(xetex_c) xetexextra.c xetexcoerce.h xetexd.h
++	rm -f $(xetex_o) $(xetex_c) xetexextra.c xetex_pool.c xetexcoerce.h xetexd.h
+ 	rm -f xetexdir/xetexextra.h xetexdir/xetex.version
+ 	rm -f xetex.p xetex.pool xetex.web xetex.ch
+ 	rm -f xetex.fmt xetex.log
+@@ -293,7 +305,7 @@
+ # Install
+ install-xetex: install-xetex-exec install-xetex-data
+ install-xetex-exec: install-xetex-programs install-xetex-links
+-install-xetex-data: install-xetex-pool @FMU@ install-xetex-dumps
++install-xetex-data: @FMU@ install-xetex-dumps
+ install-xetex-dumps: install-xetex-fmts
+ 
+ install-programs: @XETEX@ install-xetex-programs
+@@ -314,7 +326,5 @@
+ 	    (cd ${DESTDIR}$(bindir) && (rm -f $$base; $(LN) xetex $$base)); done
+ 
+ install-data:: @XETEX@ install-xetex-data
+-install-xetex-pool: xetex.pool $(texpooldir)
+-	$(INSTALL_DATA) xetex.pool ${DESTDIR}$(texpooldir)/xetex.pool
+ 
+ # end of xetex.mk
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetexextra.in
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/xetexextra.in	2008-05-28 17:20:24.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/xetexextra.in	2008-05-28 17:20:28.000000000 +0200
+@@ -51,7 +51,7 @@
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+ 
+-#define BANNER "This is XeTeX, Version 3.141592-XETEX-VERSION"
++#define BANNER "This is XeTeX, Version 3.141592-ETEX-VERSION-XETEX-VERSION"
+ #define COPYRIGHT_HOLDER "SIL International"
+ #define AUTHOR "Jonathan Kew"
+ #define PROGRAM_HELP XETEXHELP
--- texlive-bin-2007.dfsg.2.orig/debian/patches/13_fmtutil_fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/13_fmtutil_fixes
@@ -0,0 +1,83 @@
+# 13_fmtutil_fixes
+#
+# Remove the following calls to BuildFormat:
+# - texmf/bin-metafont.tpm BuildFormat/metafont
+# 	call moved to texlive-base/metafont.tpm
+# - texmf/bin-etex.tpm BuildFormat/etex
+# 	call moved to texlive-base/plain.tpm
+# - texmf/bin-pdftex.tpm BuildFormat/pdftex
+# 	call moved to texlive-base/plain.tpm
+# - texmf/bin-tex.tpm BuildFormat/tex
+# 	call moved to texlive-base/plain.tpm
+# (see texlive-base/debian/patches/10_fmtutil_fixes)
+#
+# Reason behind: the ini files are only available in the texlive-base
+# package.
+#
+# We don't need to fix the formats.XXXX.cnf files itself, because they will
+# not be read at all. But we have to included FIXES format.XXXX.cnf files
+# in texlive-base, because the postrm script uses the information therein 
+# to remove the formats.
+
+ texmf/tpm/bin-etex.tpm     |    3 ---
+ texmf/tpm/bin-metafont.tpm |    3 ---
+ texmf/tpm/bin-pdftex.tpm   |    3 ---
+ texmf/tpm/bin-tex.tpm      |    3 ---
+ 4 files changed, 12 deletions(-)
+
+Index: texlive-bin-2007/texmf/tpm/bin-metafont.tpm
+===================================================================
+--- texlive-bin-2007.orig/texmf/tpm/bin-metafont.tpm	2007-02-07 12:34:15.000000000 +0100
++++ texlive-bin-2007/texmf/tpm/bin-metafont.tpm	2007-05-21 13:02:53.000000000 +0200
+@@ -94,9 +94,6 @@
+       <TPM:TLCore name="bin-kpathsea"/>
+       <TPM:TLCore name="lib-texmfmp"/>
+     </TPM:Requires>
+-    <TPM:Installation>
+-      <TPM:Execute function="BuildFormat" parameter="metafont"/>
+-    </TPM:Installation>
+     <TPM:Provides>TLCore/bin-metafont</TPM:Provides>
+   </rdf:Description>
+ </rdf:RDF>
+Index: texlive-bin-2007/texmf/tpm/bin-etex.tpm
+===================================================================
+--- texlive-bin-2007.orig/texmf/tpm/bin-etex.tpm	2007-05-21 13:05:05.000000000 +0200
++++ texlive-bin-2007/texmf/tpm/bin-etex.tpm	2007-05-21 13:05:53.000000000 +0200
+@@ -51,9 +51,6 @@
+       <TPM:TLCore name="bin-kpathsea"/>
+       <TPM:TLCore name="lib-texmfmp"/>
+     </TPM:Requires>
+-    <TPM:Installation>
+-      <TPM:Execute function="BuildFormat" parameter="etex"/>
+-    </TPM:Installation>
+     <TPM:Provides>TLCore/bin-etex</TPM:Provides>
+   </rdf:Description>
+ </rdf:RDF>
+Index: texlive-bin-2007/texmf/tpm/bin-pdftex.tpm
+===================================================================
+--- texlive-bin-2007.orig/texmf/tpm/bin-pdftex.tpm	2007-05-21 13:05:29.000000000 +0200
++++ texlive-bin-2007/texmf/tpm/bin-pdftex.tpm	2007-05-21 13:05:44.000000000 +0200
+@@ -212,9 +212,6 @@
+       <TPM:TLCore name="lib-texmfmp"/>
+       <TPM:TLCore name="lib-zlib"/>
+     </TPM:Requires>
+-    <TPM:Installation>
+-      <TPM:Execute function="BuildFormat" parameter="pdftex"/>
+-    </TPM:Installation>
+     <TPM:Provides>TLCore/bin-pdftex</TPM:Provides>
+   </rdf:Description>
+ </rdf:RDF>
+Index: texlive-bin-2007/texmf/tpm/bin-tex.tpm
+===================================================================
+--- texlive-bin-2007.orig/texmf/tpm/bin-tex.tpm	2007-05-21 13:05:24.000000000 +0200
++++ texlive-bin-2007/texmf/tpm/bin-tex.tpm	2007-05-21 13:06:00.000000000 +0200
+@@ -56,9 +56,6 @@
+       <TPM:TLCore name="bin-kpathsea"/>
+       <TPM:TLCore name="lib-texmfmp"/>
+     </TPM:Requires>
+-    <TPM:Installation>
+-      <TPM:Execute function="BuildFormat" parameter="tex"/>
+-    </TPM:Installation>
+     <TPM:Provides>TLCore/bin-tex</TPM:Provides>
+   </rdf:Description>
+ </rdf:RDF>
--- texlive-bin-2007.dfsg.2.orig/debian/patches/00_Build_script
+++ texlive-bin-2007.dfsg.2/debian/patches/00_Build_script
@@ -0,0 +1,38 @@
+---
+ build/source/Build |   22 ++++++++++++++++++----
+ 1 file changed, 18 insertions(+), 4 deletions(-)
+
+Index: texlive-bin-2007/build/source/Build
+===================================================================
+--- texlive-bin-2007.orig/build/source/Build	2006-12-14 03:12:38.000000000 +0100
++++ texlive-bin-2007/build/source/Build	2007-02-14 15:56:00.000000000 +0100
+@@ -47,11 +47,25 @@
+ 
+ # Force building xdvi-xaw; motif is not always free and/or available.
+ # --enable-gif is for sam2p; the gif patent has expired worldwide.
+-(set -x; \
+-  time $TL_CONFIGURE \
++case $1 in
++  configure)
++    shift
++    (set -x; \
++      $TL_CONFIGURE \
+          --prefix=$TL_INSTALL_DEST \
+          --datadir=$TL_INSTALL_DEST \
+          $TL_XDVI_TOOLKIT \
+          $TL_CONFIGURE_ARGS \
+-         "$@" \
+- && time $TL_MAKE $TL_TARGET)
++         "$@" )
++    ;;
++  build)
++    # not make world, this would strip
++    shift
++    make all
++    make install
++    ;;
++  *)
++    echo "This script must be invoked with argument configure or build"
++    ;;
++esac
++
--- texlive-bin-2007.dfsg.2.orig/debian/patches/hps-segfault-fix
+++ texlive-bin-2007.dfsg.2/debian/patches/hps-segfault-fix
@@ -0,0 +1,87 @@
+fix from upstream for CVE-2007-5935-patch
+---
+ build/source/texk/dvipsk/hps.c |   60 ++++++++++++++++++++++++++---------------
+ 1 file changed, 39 insertions(+), 21 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/dvipsk/hps.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/dvipsk/hps.c	2007-10-22 07:24:00.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/dvipsk/hps.c	2007-10-22 07:24:29.000000000 +0200
+@@ -441,19 +441,28 @@
+ 
+ void stamp_hps P1C(Hps_link *, pl)
+ {
+-  char tmpbuf[200] ;
++  char * tmpbuf;
+   if (pl == NULL) {
+-    error("Null pointer, oh no!") ;
++    error("stamp_hps: null pl pointer, oh no!") ;
+     return ;
+-  } else {
+-    /* print out the proper pdfm with local page info only 
+-     *  target info will be in the target dictionary */
+-    (void)sprintf(tmpbuf, 
+-		  " (%s) [[%.0f %.0f %.0f %.0f] [%i %i %i [%i %i]] [%.0f %.0f %.0f]] pdfm ", pl->title, pl->rect.llx, pl->rect.lly, pl->rect.urx, pl->rect.ury,
+-		  pl->border[0], pl->border[1], pl->border[2], pl->border[3],pl->border[4],
+-		  pl->color[0], pl->color[1], pl->color[2]) ;
+-    cmdout(tmpbuf) ; 
+-  }
++  } 
++  if(pl->title == NULL) {
++    error("stamp_hps: null pl->title pointer, oh no!") ;
++    return ;
++  } 
++
++  tmpbuf = (char *) xmalloc(strlen(pl->title)+200);
++
++  /* print out the proper pdfm with local page info only 
++   *  target info will be in the target dictionary */
++  (void)sprintf(tmpbuf, 
++		" (%s) [[%.0f %.0f %.0f %.0f] [%i %i %i [%i %i]] [%.0f %.0f %.0f]] pdfm ", 
++		pl->title, pl->rect.llx, pl->rect.lly, pl->rect.urx, pl->rect.ury,
++		pl->border[0], pl->border[1], pl->border[2], pl->border[3],pl->border[4],
++		pl->color[0], pl->color[1], pl->color[2]) ;
++  cmdout(tmpbuf) ; 
++  free(tmpbuf);
++  
+   
+ }
+ 
+@@ -462,18 +471,27 @@
+  */
+ void stamp_external P2C(char *, s, Hps_link *, pl) 
+ {
+-  char tmpbuf[200];
++  char *tmpbuf;
+   if (pl == NULL) {
+-    error("Null pointer, oh no!") ;
++    error("stamp_external: null pl pointer, oh no!") ;
+     return ;
+-  } else {
+-    /* print out the proper pdfm with local page info only 
+-     *  target info will be in the target dictionary */
+-    (void)sprintf(tmpbuf," [[%.0f %.0f %.0f %.0f] [%i %i %i [%i %i]] [%.0f %.0f %.0f]] (%s) pdfm ", pl->rect.llx, pl->rect.lly, pl->rect.urx, pl->rect.ury,
+-		  pl->border[0], pl->border[1], pl->border[2], pl->border[3],pl->border[4],
+-		  pl->color[0], pl->color[1], pl->color[2], s) ;
+-    cmdout(tmpbuf) ;
+-  }
++  } 
++
++  if (s == NULL) {
++    error("stamp_external: null s pointer, oh no!") ;
++    return ;
++  } 
++
++  tmpbuf = (char *) xmalloc(strlen(s) + 200);
++
++  /* print out the proper pdfm with local page info only 
++   *  target info will be in the target dictionary */
++  (void)sprintf(tmpbuf," [[%.0f %.0f %.0f %.0f] [%i %i %i [%i %i]] [%.0f %.0f %.0f]] (%s) pdfm ",
++		pl->rect.llx, pl->rect.lly, pl->rect.urx, pl->rect.ury,
++		pl->border[0], pl->border[1], pl->border[2], pl->border[3],pl->border[4],
++		pl->color[0], pl->color[1], pl->color[2], s) ;
++  cmdout(tmpbuf) ;
++  free(tmpbuf);
+ }
+ 
+ void finish_hps P1H(void) {
--- texlive-bin-2007.dfsg.2.orig/debian/patches/xetex-0996-patch1
+++ texlive-bin-2007.dfsg.2/debian/patches/xetex-0996-patch1
@@ -0,0 +1,1037 @@
+Patches from texlive release 2007.0 (DVD) to 2007.1 which consists of 
+fixes for the xetex version in TL2007 made by Jonathan Kew, from his mail
+to the texlive ML:
+: Regarding the actual fixes committed to the 2007 branch: these
+: primarily provide xetex compatibility on big-endian 64-bit systems.
+: In addition, they correct two minor bugs where xetex generated
+: incorrect output, and protect xetex and xdvipdfmx from certain kinds
+: of defective TrueType fonts that could cause crashes.
+---
+ build/source/libs/icu-xetex/layout/KernTable.cpp |   29 +++++-
+ build/source/texk/web2c/texmfmem.h               |   39 --------
+ build/source/texk/web2c/xetexdir/XeTeX_ext.c     |  100 +++++++++++------------
+ build/source/texk/web2c/xetexdir/XeTeX_ext.h     |   63 ++++++++------
+ build/source/texk/web2c/xetexdir/XeTeX_mac.c     |    2 
+ build/source/texk/web2c/xetexdir/jpegimage.c     |    2 
+ build/source/texk/web2c/xetexdir/xetex-new.ch    |   98 +++++++++++++---------
+ build/source/texk/web2c/xetexdir/xetex.defines   |    2 
+ build/source/texk/web2c/xetexdir/xetex.h         |    3 
+ build/source/texk/web2c/xetexdir/xetex.mk        |   10 +-
+ build/source/texk/xdvipdfmx/src/tt_cmap.c        |    9 ++
+ 11 files changed, 190 insertions(+), 167 deletions(-)
+
+Index: texlive-bin-2007/build/source/libs/icu-xetex/layout/KernTable.cpp
+===================================================================
+--- texlive-bin-2007.orig/build/source/libs/icu-xetex/layout/KernTable.cpp	2006-07-25 14:37:43.000000000 +0200
++++ texlive-bin-2007/build/source/libs/icu-xetex/layout/KernTable.cpp	2007-08-13 16:22:35.000000000 +0200
+@@ -16,8 +16,10 @@
+ U_NAMESPACE_BEGIN
+ 
+ struct PairInfo {
+-  le_uint32 key;   // sigh, MSVC compiler gags on union here
++  le_uint16	left;
++  le_uint16	right;
+   le_int16  value; // fword, kern value in funits
++  le_uint32	key() const { return ((le_uint32)SWAPW(left) << 16) | SWAPW(right); }
+ };
+ #define KERN_PAIRINFO_SIZE 6
+ 
+@@ -81,9 +83,24 @@
+       if (coverage & COVERAGE_HORIZONTAL) { // only handle horizontal kerning
+ 	const Subtable_0* table = (const Subtable_0*)((char*)subhead + KERN_SUBTABLE_HEADER_SIZE);
+ 	nPairs = SWAPW(table->nPairs);
++#if 0 // don't trust these fields as some old TTF fonts have bad data here
+ 	searchRange = SWAPW(table->searchRange);
+ 	entrySelector = SWAPW(table->entrySelector);
+ 	rangeShift = SWAPW(table->rangeShift);
++#else // recompute the binary search header fields
++	if (nPairs == 0) { // this probably shouldn't happen
++	  searchRange = entrySelector = 0;
++	} else {
++	  searchRange = 1;
++	  entrySelector = 0;
++	  while (searchRange * 2 <= nPairs) {
++	    searchRange *= 2;
++	    entrySelector += 1;
++	  }
++	}
++	rangeShift = (nPairs - searchRange) * KERN_PAIRINFO_SIZE;
++	searchRange *= KERN_PAIRINFO_SIZE;
++#endif
+ 	pairs = (const PairInfo*)((char*)table + KERN_SUBTABLE_0_HEADER_SIZE);
+ 
+ #if DEBUG
+@@ -103,9 +120,8 @@
+ 
+ 	  const PairInfo* p = pairs;
+ 	  for (i = 0; i < nPairs; ++i, p = (const PairInfo*)((char*)p+KERN_PAIRINFO_SIZE)) {
+-  	    le_uint32 k = SWAPL(p->key);
+-	    le_uint16 left = (k >> 16) & 0xffff;
+-	    le_uint16 right = k & 0xffff;
++	    le_uint16 left = SWAPW(p->left);
++	    le_uint16 right = SWAPW(p->right);
+ 	    if (left < 256 && right < 256) {
+ 	      char c = ids[left];
+ 	      if (c > 0x20 && c < 0x7f) {
+@@ -149,10 +165,11 @@
+       // but it is not in sorted order on win32 platforms because of the endianness difference
+       // so either I have to swap the element each time I examine it, or I have to swap
+       // all the elements ahead of time and store them in the font
++      // The key() accessor on PairInfo handles the swapping if needed
+ 
+       const PairInfo* p = pairs;
+       const PairInfo* tp = (const PairInfo*)((char*)p + rangeShift);
+-      if (key > SWAPL(tp->key)) {
++      if (key > tp->key()) {
+ 	p = tp;
+       }
+ 
+@@ -165,7 +182,7 @@
+       while (probe > KERN_PAIRINFO_SIZE) {
+         probe >>= 1;
+         tp = (const PairInfo*)((char*)p + probe);
+-	le_uint32 tkey = SWAPL(tp->key);
++	le_uint32 tkey = tp->key();
+ #if DEBUG
+ 	fprintf(stdout, "   %.3d (%0.8x)\n", ((char*)tp - (char*)pairs)/KERN_PAIRINFO_SIZE, tkey);
+ 	fflush(stdout);
+Index: texlive-bin-2007/build/source/texk/web2c/texmfmem.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/texmfmem.h	2006-06-20 14:03:18.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/texmfmem.h	2007-08-13 16:22:35.000000000 +0200
+@@ -112,25 +112,13 @@
+ #else
+   twohalves hhfield;
+ #endif
+-#ifdef WORDS_BIGENDIAN
+ #ifdef XeTeX
+-  struct
+-  {
+-    integer CINT;
+-    integer CINT1;
+-  } x;
+-#else
+-  integer cint;
++  voidpointer ptr;
+ #endif
++#ifdef WORDS_BIGENDIAN
++  integer cint;
+   fourquarters qqqq;
+ #else /* not WORDS_BIGENDIAN */
+-#ifdef XeTeX
+-  struct
+-  {
+-    integer CINT1;
+-    integer CINT;
+-  } x;
+-#else
+   struct
+   {
+ #if defined (TeX) && !defined (SMALLTeX) || defined (MF) && !defined (SMALLMF) || defined (MP) && !defined (SMALLMP)
+@@ -138,7 +126,6 @@
+ #endif /* big {TeX,MF,MP} */
+     integer CINT;
+   } u;
+-#endif
+ 
+   struct
+   {
+@@ -159,28 +146,13 @@
+ typedef union
+ {
+ #ifdef WORDS_BIGENDIAN
+-#ifdef XeTeX
+-  struct
+-  {
+-    integer CINT;
+-  } x;
+-#else
+   integer cint;
+-#endif
+   fourquarters qqqq;
+ #else /* not WORDS_BIGENDIAN */
+-#ifdef XeTeX
+-  struct
+-  {
+-    halfword junk;
+-    integer CINT;
+-  } x;
+-#else
+   struct
+   {
+     integer CINT;
+   } u;
+-#endif
+ 
+   struct
+   {
+@@ -199,14 +171,9 @@
+ #define rh v.RH
+ #define lhfield	v.LH
+ 
+-#ifdef XeTeX
+-#define cint  x.CINT
+-#define cint1 x.CINT1
+-#else
+ #ifndef WORDS_BIGENDIAN
+ #define cint u.CINT
+ #endif
+-#endif /* XeTeX */
+ 
+ #ifndef WORDS_BIGENDIAN
+ #define qqqq v.QQQQ
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-08-13 16:22:35.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-08-13 16:22:35.000000000 +0200
+@@ -236,9 +236,9 @@
+ }
+ 
+ 
+-extern char*	gettexstring(int strNumber);
++extern char*	gettexstring(integer strNumber);
+ void
+-setinputfileencoding(UFILE* f, int mode, int encodingData)
++setinputfileencoding(UFILE* f, integer mode, integer encodingData)
+ {
+ 	if ((f->encodingMode == ICUMAPPING) && (f->conversionData != NULL))
+ 		ucnv_close((UConverter*)(f->conversionData));
+@@ -288,9 +288,9 @@
+ static char* byteBuffer = NULL;
+ 
+ 	UInt32		bytesRead = 0;
+-	int			i;
++	int		i;
+ 	UConverter*	cnv;
+-	long		outLen;
++	int		outLen;
+ 	UErrorCode	errorCode = 0;
+ 
+ 	if (byteBuffer == NULL)
+@@ -355,10 +355,9 @@
+ static int				brkLocaleStrNum = 0;
+ 
+ void
+-linebreakstart(int localeStrNum, const UniChar* text, int textLength)
++linebreakstart(integer localeStrNum, const UniChar* text, integer textLength)
+ {
+ 	UErrorCode	status = 0;
+-	int i;
+ 
+ 	if ((localeStrNum != brkLocaleStrNum) && (brkIter != NULL)) {
+ 		ubrk_close(brkIter);
+@@ -392,8 +391,8 @@
+ 	return ubrk_next((UBreakIterator*)brkIter);
+ }
+ 
+-long
+-getencodingmodeandinfo(long* info)
++int
++getencodingmodeandinfo(integer* info)
+ {
+ 	/* \XeTeXinputencoding "enc-name"
+ 	 *   -> name is packed in |nameoffile| as a C string, starting at [1]
+@@ -811,7 +810,7 @@
+ }
+ 
+ void*
+-findnativefont(unsigned char* uname, long scaled_size)
++findnativefont(unsigned char* uname, integer scaled_size)
+ 	/* scaled_size here is in TeX points */
+ {
+ 	void*	rval = 0;
+@@ -950,7 +949,6 @@
+ otgetfontmetrics(void* pEngine, scaled* ascent, scaled* descent, scaled* xheight, scaled* capheight, scaled* slant)
+ {
+ 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
+-	long	rval = 0;
+ 	float	a, d;
+ 	int		glyphID;
+ 
+@@ -977,8 +975,8 @@
+ 		*capheight = *ascent; /* arbitrary figure if there's no 'X' in the font */
+ }
+ 
+-long
+-otfontget(int what, void* pEngine)
++integer
++otfontget(integer what, void* pEngine)
+ {
+ 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
+ 	XeTeXFont	fontInst = getFont(engine);
+@@ -995,8 +993,8 @@
+ }
+ 
+ 
+-long
+-otfontget1(int what, void* pEngine, long param)
++integer
++otfontget1(integer what, void* pEngine, integer param)
+ {
+ 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
+ 	XeTeXFont	fontInst = getFont(engine);
+@@ -1013,8 +1011,8 @@
+ }
+ 
+ 
+-long
+-otfontget2(int what, void* pEngine, long param1, long param2)
++integer
++otfontget2(integer what, void* pEngine, integer param1, integer param2)
+ {
+ 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
+ 	XeTeXFont	fontInst = getFont(engine);
+@@ -1032,8 +1030,8 @@
+ }
+ 
+ 
+-long
+-otfontget3(int what, void* pEngine, long param1, long param2, long param3)
++integer
++otfontget3(integer what, void* pEngine, integer param1, integer param2, integer param3)
+ {
+ 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
+ 	XeTeXFont	fontInst = getFont(engine);
+@@ -1091,7 +1089,7 @@
+ 		xdvbuffer = (char*)xmalloc(xdvBufSize);
+ 	}
+ 
+-	glyph_info = (void*)native_glyph_info_ptr(p);
++	glyph_info = native_glyph_info_ptr(p);
+ 	locations = (FixedPoint*)glyph_info;
+ 	glyphIDs = (UInt16*)(locations + glyphCount);
+ 	
+@@ -1138,8 +1136,8 @@
+ 	return ((char*)cp - xdvbuffer);
+ }
+ 
+-long
+-makefontdef(long f)
++int
++makefontdef(integer f)
+ {
+ 	UInt16	flags = 0;
+ 	UInt32	variationCount = 0;
+@@ -1349,7 +1347,7 @@
+ }
+ 
+ void
+-getnativecharheightdepth(int font, int ch, scaled* height, scaled* depth)
++getnativecharheightdepth(integer font, integer ch, scaled* height, scaled* depth)
+ {
+ #define QUAD(f)			fontinfo[6+parambase[f]].cint
+ #define X_HEIGHT(f)		fontinfo[5+parambase[f]].cint
+@@ -1389,7 +1387,7 @@
+ }
+ 
+ scaled
+-getnativecharht(int f, int c)
++getnativecharht(integer f, integer c)
+ {
+ 	scaled	h, d;
+ 	getnativecharheightdepth(f, c, &h, &d);
+@@ -1397,7 +1395,7 @@
+ }
+ 
+ scaled
+-getnativechardp(int f, int c)
++getnativechardp(integer f, integer c)
+ {
+ 	scaled	h, d;
+ 	getnativecharheightdepth(f, c, &h, &d);
+@@ -1405,7 +1403,7 @@
+ }
+ 
+ void
+-getnativecharsidebearings(int font, int ch, scaled* lsb, scaled* rsb)
++getnativecharsidebearings(integer font, integer ch, scaled* lsb, scaled* rsb)
+ {
+ 	float	l, r;
+ 
+@@ -1432,7 +1430,7 @@
+ }
+ 
+ scaled
+-getnativecharic(int f, int c)
++getnativecharic(integer f, integer c)
+ {
+ 	scaled	lsb, rsb;
+ 	getnativecharsidebearings(f, c, &lsb, &rsb);
+@@ -1443,7 +1441,7 @@
+ }
+ 
+ scaled
+-getnativecharwd(int f, int c)
++getnativecharwd(integer f, integer c)
+ {
+ 	scaled wd = 0;
+ #ifdef XETEX_MAC
+@@ -1515,7 +1513,7 @@
+ 		void*	glyph_info = 0;
+ 		static	float*	positions = 0;
+ 		static	UInt32*	glyphs = 0;
+-		static	long	maxGlyphs = 0;
++		static	int		maxGlyphs = 0;
+ 
+ 		FixedPoint*	locations;
+ 		UInt16*		glyphIDs;
+@@ -1591,7 +1589,7 @@
+ 
+ 			node_width(node) = X2Fix(wid);
+ 			native_glyph_count(node) = realGlyphCount;
+-			native_glyph_info_ptr(node) = (long)glyph_info;
++			native_glyph_info_ptr(node) = glyph_info;
+ 		}
+ 		else {
+ 			int i;
+@@ -1632,7 +1630,7 @@
+ 			}
+ 						
+ 			native_glyph_count(node) = realGlyphCount;
+-			native_glyph_info_ptr(node) = (long)glyph_info;
++			native_glyph_info_ptr(node) = glyph_info;
+ 		}
+ 
+ 		ubidi_close(pBiDi);
+@@ -1787,8 +1785,8 @@
+ 	}
+ }
+ 
+-int
+-mapchartoglyph(int font, unsigned int ch)
++integer
++mapchartoglyph(integer font, integer ch)
+ {
+ 	if (ch > 0x10ffff || ((ch >= 0xd800) && (ch <= 0xdfff)))
+ 		return 0;
+@@ -1805,8 +1803,8 @@
+ 	}
+ }
+ 
+-int
+-mapglyphtoindex(int font)
++integer
++mapglyphtoindex(integer font)
+ 	/* glyph name is at nameoffile+1 */
+ {
+ #ifdef XETEX_MAC
+@@ -1822,8 +1820,8 @@
+ 	}
+ }
+ 
+-int
+-getfontcharrange(int font, int first)
++integer
++getfontcharrange(integer font, int first)
+ {
+ #ifdef XETEX_MAC
+ 	if (fontarea[font] == AAT_FONT_FLAG)
+@@ -1928,10 +1926,10 @@
+ #endif
+ }
+ 
+-long
++int
+ atsufontget(int what, ATSUStyle style)
+ {
+-	long	rval = -1;
++	int	rval = -1;
+ 
+ #ifdef XETEX_MAC
+ 	ATSUFontID	fontID;
+@@ -1966,10 +1964,10 @@
+ 	return rval;
+ }
+ 
+-long
++int
+ atsufontget1(int what, ATSUStyle style, int param)
+ {
+-	long	rval = -1;
++	int	rval = -1;
+ 
+ #ifdef XETEX_MAC
+ 	ATSUFontID	fontID;
+@@ -2026,10 +2024,10 @@
+ 	return rval;
+ }
+ 
+-long
++int
+ atsufontget2(int what, ATSUStyle style, int param1, int param2)
+ {
+-	long	rval = -1;
++	int	rval = -1;
+ 
+ #ifdef XETEX_MAC
+ 	ATSUFontID	fontID;
+@@ -2063,10 +2061,10 @@
+ 	return rval;
+ }
+ 
+-long
++int
+ atsufontgetnamed(int what, ATSUStyle style)
+ {
+-	long	rval = -1;
++	int	rval = -1;
+ 
+ #ifdef XETEX_MAC
+ 	ATSUFontID	fontID;
+@@ -2090,10 +2088,10 @@
+ 	return rval;
+ }
+ 
+-long
++int
+ atsufontgetnamed1(int what, ATSUStyle style, int param)
+ {
+-	long	rval = -1;
++	int	rval = -1;
+ 
+ #ifdef XETEX_MAC
+ 	ATSUFontID	fontID;
+@@ -2220,7 +2218,7 @@
+ }
+ 
+ void
+-printglyphname(int font, int gid)
++printglyphname(integer font, integer gid)
+ {
+ 	char* s;
+ 	int   len = 0;
+@@ -2243,8 +2241,8 @@
+ 		printchar(*s++);
+ }
+ 
+-boolean
+-u_open_in(unicodefile* f, int filefmt, const_string fopen_mode, int mode, int encodingData)
++int
++u_open_in(unicodefile* f, integer filefmt, const_string fopen_mode, integer mode, integer encodingData)
+ {
+ 	boolean	rval;
+ 	*f = malloc(sizeof(UFILE));
+@@ -2287,7 +2285,7 @@
+ 	return rval;
+ }
+ 
+-boolean
++int
+ open_dvi_output(FILE** fptr)
+ {
+ 	if (nopdfoutput) {
+@@ -2391,7 +2389,7 @@
+ 	return rval;
+ }
+ 
+-boolean
++int
+ input_line(UFILE* f)
+ {
+ 	int i;
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.h	2006-12-29 18:54:26.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.h	2007-08-13 16:23:36.000000000 +0200
+@@ -141,10 +141,10 @@
+ #define node_width(node)			node[width_offset].cint
+ #define node_depth(node)			node[depth_offset].cint
+ #define node_height(node)			node[height_offset].cint
+-#define native_length(node)			node[native_info_offset].hh.v.RH
+-#define native_font(node)			node[native_info_offset].hh.b1
+-#define native_glyph_count(node)	node[native_glyph_info_offset].hh.v.LH
+-#define native_glyph_info_ptr(node)	node[native_glyph_info_offset].hh.v.RH
++#define native_length(node)			node[native_info_offset].qqqq.b2
++#define native_font(node)			node[native_info_offset].qqqq.b1
++#define native_glyph_count(node)	node[native_info_offset].qqqq.b3
++#define native_glyph_info_ptr(node)	node[native_glyph_info_offset].ptr
+ #define native_glyph_info_size		10	/* info for each glyph is location (FixedPoint) + glyph ID (UInt16) */
+ 
+ #define native_glyph(p)		native_length(p)	/* glyph ID field in a glyph_node */
+@@ -206,6 +206,8 @@
+ extern const UInt32 byteMask;
+ extern const UInt32 byteMark;
+ 
++#include <stdio.h> /* for FILE */
++
+ #include "trans.h"
+ 
+ #ifdef __cplusplus
+@@ -213,51 +215,62 @@
+ #endif
+ 	void initversionstring(char **versions);
+ 
+-	void setinputfileencoding(unicodefile f, int mode, int encodingData);
++	void setinputfileencoding(unicodefile f, integer mode, integer encodingData);
+ 	void uclose(unicodefile f);
+ 	int input_line_icu(unicodefile f);
+-	void linebreakstart(int localeStrNum, const UniChar* text, int textLength);
++	void linebreakstart(integer localeStrNum, const UniChar* text, integer textLength);
+ 	int linebreaknext();
+-	long getencodingmodeandinfo(long* info);
++	int getencodingmodeandinfo(integer* info);
+ 	void printutf8str(const unsigned char* str, int len);
+ 	void printchars(const unsigned short* str, int len);
+ 	void* load_mapping_file(const char* s, const char* e);
+-	void* findnativefont(unsigned char* name, long scaled_size);
++	void* findnativefont(unsigned char* name, integer scaled_size);
+ 	void releasefontengine(void* engine, int type_flag);
+ 
+-	/* 'integer' params here are really TeX 'scaled' values, but that typedef isn't available every place this is included */
++	/* the metrics params here are really TeX 'scaled' values, but that typedef isn't available every place this is included */
+ 	void otgetfontmetrics(void* engine, integer* ascent, integer* descent, integer* xheight, integer* capheight, integer* slant);
+-	void getnativecharheightdepth(int font, int ch, integer* height, integer* depth);
+-	void getnativecharsidebearings(int font, int ch, integer* lsb, integer* rsb);
++	void getnativecharheightdepth(integer font, integer ch, integer* height, integer* depth);
++	void getnativecharsidebearings(integer font, integer ch, integer* lsb, integer* rsb);
+ 
+ 	/* single-purpose metrics accessors */
+-	integer getnativecharwd(int font, int ch);
+-	integer getnativecharht(int font, int ch);
+-	integer getnativechardp(int font, int ch);
+-	integer getnativecharic(int font, int ch);
+-
+-	long otfontget(int what, void* engine);
+-	long otfontget1(int what, void* engine, long param);
+-	long otfontget2(int what, void* engine, long param1, long param2);
+-	long otfontget3(int what, void* engine, long param1, long param2, long param3);
++	integer getnativecharwd(integer font, integer ch);
++	integer getnativecharht(integer font, integer ch);
++	integer getnativechardp(integer font, integer ch);
++	integer getnativecharic(integer font, integer ch);
++
++	integer otfontget(integer what, void* engine);
++	integer otfontget1(integer what, void* engine, integer param);
++	integer otfontget2(integer what, void* engine, integer param1, integer param2);
++	integer otfontget3(integer what, void* engine, integer param1, integer param2, integer param3);
+ 	int makeXDVGlyphArrayData(void* p);
+-	long makefontdef(long f);
++	int makefontdef(integer f);
+ 	int applymapping(void* cnv, const UniChar* txtPtr, int txtLen);
+ 	void store_justified_native_glyphs(void* node);
+ 	void measure_native_node(void* node, int use_glyph_metrics);
+ 	Fixed get_native_ital_corr(void* node);
+ 	Fixed get_native_glyph_ital_corr(void* node);
+ 	void measure_native_glyph(void* node, int use_glyph_metrics);
+-	int mapchartoglyph(int font, unsigned int ch);
+-	int mapglyphtoindex(int font);
+-
++	integer mapchartoglyph(integer font, integer ch);
++	integer mapglyphtoindex(integer font);
++	integer getfontcharrange(integer font, int first);
++	void printglyphname(integer font, integer gid);
++
++  	double read_double(const char** s);
++  	unsigned int read_rgb_a(const char** cp);
++  
+ 	const char* getGlyphNamePtr(const char* buffer, int tableSize, UInt16 gid, int* len);
+ 
+ 	int find_pic_file(char** path, realrect* bounds, int pdfBoxType, int page);
++	int u_open_in(unicodefile* f, integer filefmt, const char* fopen_mode, integer mode, integer encodingData);
++	int open_dvi_output(FILE** fptr);
++	void dviclose(FILE* fptr);
++	int get_uni_c(UFILE* f);
++	int input_line(UFILE* f);
++	void makeutf16name();
+ 
+ #ifdef XETEX_MAC
+ /* functions in XeTeX_mac.c */
+-	void* loadAATfont(ATSFontRef fontRef, long scaled_size, const char* cp1);
++	void* loadAATfont(ATSFontRef fontRef, integer scaled_size, const char* cp1);
+ 	void DoAtsuiLayout(void* node, int justify);
+ 	void GetGlyphBBox_AAT(ATSUStyle style, UInt16 gid, GlyphBBox* bbox);
+ 	float GetGlyphWidth_AAT(ATSUStyle style, UInt16 gid);
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_mac.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/XeTeX_mac.c	2006-12-06 18:29:15.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_mac.c	2007-08-13 16:22:35.000000000 +0200
+@@ -162,7 +162,7 @@
+ 		lsDelta -= lsUnit;
+ 
+ 	native_glyph_count(node) = realGlyphCount;
+-	native_glyph_info_ptr(node) = (long)glyph_info;
++	native_glyph_info_ptr(node) = glyph_info;
+ 	
+ 	if (!justify)
+ 		node_width(node) = FixedPStoTeXPoints(layoutRec[count-1].realPos) + lsDelta;
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/jpegimage.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/jpegimage.c	2006-07-26 18:19:45.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/jpegimage.c	2007-08-13 16:22:35.000000000 +0200
+@@ -81,6 +81,8 @@
+ 
+ #include <memory.h>
+ 
++#include "kpathsea/lib.h" /* for xmalloc/xrealloc prototypes */
++
+ #define JPEG_DEBUG_STR "JPEG"
+ #define JPEG_DEBUG     3
+ 
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex-new.ch
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex-new.ch	2007-01-03 17:25:04.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex-new.ch	2007-08-13 16:22:35.000000000 +0200
+@@ -56,7 +56,7 @@
+ 
+ @d XeTeX_version=0
+ @d XeTeX_revision==".996"
+-@d XeTeX_version_string=='-0.996' {current \XeTeX\ version}
++@d XeTeX_version_string=='-0.996-patch1' {current \XeTeX\ version}
+ @z
+ 
+ @x
+@@ -706,29 +706,28 @@
+ 
+ To support ``native'' fonts, we build |native_word_nodes|, which are variable size whatsits.
+ These have the same |width|, |depth|, and |height| fields as a |box_node|, at offsets 1-3,
+-and then a word containing a size field for the node, a font number, and a length.
+-Then there is a field containing two halfwords, a glyph count and a C pointer to a glyph info array;
+-these are set by |set_native_metrics|. Copying and freeing of these nodes needs to take account of this!
++and then a word containing a size field for the node, a font number, a length, and a glyph count.
++Then there is a field containing a C pointer to a glyph info array;
++this and the glyph count are set by |set_native_metrics|.
++Copying and freeing of these nodes needs to take account of this!
+ This is followed by |length| bytes, for the actual characters of the string.
+ (Yes, we count in bytes, even though what we store there is UTF-16.)
+ 
+ So |native_node_size|, which does not include any space for the actual text, is 6.}
+ 
+-@d deleted_native_node=41 {native words that have been superseded by their successors}
+-
+ @d native_node_size=6 {size of a native_word node (plus the actual chars) -- see also xetex.h}
+-@d native_size(#)==mem[#+4].hh.b0
+-@d native_font(#)==mem[#+4].hh.b1
+-@d native_length(#)==mem[#+4].hh.rh
+-@d native_glyph_count(#)==mem[#+5].hh.lh
+-@d native_glyph_info_ptr(#)==mem[#+5].hh.rh
++@d native_size(#)==mem[#+4].qqqq.b0
++@d native_font(#)==mem[#+4].qqqq.b1
++@d native_length(#)==mem[#+4].qqqq.b2
++@d native_glyph_count(#)==mem[#+4].qqqq.b3
++@d native_glyph_info_ptr(#)==mem[#+5].ptr
+ @d native_glyph_info_size=10 { number of bytes of info per glyph: 16-bit glyph ID, 32-bit x and y coords }
+ 
+ @d free_native_glyph_info(#) ==
+   begin
+-    if native_glyph_info_ptr(#) <> 0 then begin
+-      libc_free(cast_to_ptr(native_glyph_info_ptr(#)));
+-      native_glyph_info_ptr(#) := 0;
++    if native_glyph_info_ptr(#) <> null_ptr then begin
++      libc_free(native_glyph_info_ptr(#));
++      native_glyph_info_ptr(#) := null_ptr;
+       native_glyph_count(#) := 0;
+     end
+   end
+@@ -736,10 +735,10 @@
+ @p procedure copy_native_glyph_info(src:pointer; dest:pointer);
+ var glyph_count:integer;
+ begin
+-  if native_glyph_info_ptr(src) <> 0 then begin
++  if native_glyph_info_ptr(src) <> null_ptr then begin
+     glyph_count := native_glyph_count(src);
+-    native_glyph_info_ptr(dest) := cast_to_integer(xmalloc_array(char, glyph_count * native_glyph_info_size));
+-    memcpy(cast_to_ptr(native_glyph_info_ptr(dest)), cast_to_ptr(native_glyph_info_ptr(src)), glyph_count * native_glyph_info_size);
++    native_glyph_info_ptr(dest) := xmalloc_array(char, glyph_count * native_glyph_info_size);
++    memcpy(native_glyph_info_ptr(dest), native_glyph_info_ptr(src), glyph_count * native_glyph_info_size);
+     native_glyph_count(dest) := glyph_count;
+   end
+ end;
+@@ -2936,8 +2935,7 @@
+ end
+ 
+ @ @<Advance |q| past ignorable nodes@>=
+-while (q <> null) and (not is_char_node(q))
+-  and ( (type(q) = disc_node) or ((type(q) = whatsit_node) and (subtype(q) = deleted_native_node)) ) do
++while (q <> null) and (not is_char_node(q)) and (type(q) = disc_node) do
+     q := link(q)
+ 
+ @ We ought to give special care to the efficiency of one part of |hlist_out|,
+@@ -3293,7 +3291,6 @@
+     or (subtype(v)=pic_node)
+     or (subtype(v)=pdf_node)
+     then break_width[1]:=break_width[1]-width(v)
+-	else if subtype(v)=deleted_native_node then do_nothing
+ 	else confusion("disc1a");
+   othercases confusion("disc1")
+ @z
+@@ -3307,7 +3304,6 @@
+     or (subtype(s)=pic_node)
+     or (subtype(s)=pdf_node)
+     then break_width[1]:=break_width[1]+width(s)
+-	else if subtype(s)=deleted_native_node then do_nothing
+ 	else confusion("disc2a");
+   othercases confusion("disc2")
+ @z
+@@ -3327,7 +3323,6 @@
+     or (subtype(s)=pic_node)
+     or (subtype(s)=pdf_node)
+     then disc_width:=disc_width+width(s)
+-	else if subtype(s)=deleted_native_node then do_nothing
+ 	else confusion("disc3a");
+   othercases confusion("disc3")
+ @z
+@@ -3341,7 +3336,6 @@
+     or (subtype(s)=pic_node)
+     or (subtype(s)=pdf_node)
+     then act_width:=act_width+width(s)
+-	else if subtype(s)=deleted_native_node then do_nothing
+ 	else confusion("disc4a");
+   othercases confusion("disc4")
+ @z
+@@ -3784,7 +3778,7 @@
+ @!main_p:pointer; {temporary register for list manipulation}
+ @y
+ @!main_p:pointer; {temporary register for list manipulation}
+-@!main_pp:pointer; {another temporary register for list manipulation}
++@!main_pp,@!main_ppp:pointer; {more temporary registers for list manipulation}
+ @!main_h:pointer; {temp for hyphen offset in native-font text}
+ @!is_hyph:boolean; {whether the last char seen is the font's hyphenchar}
+ @z
+@@ -3859,11 +3853,22 @@
+ 
+ 	if mode=hmode then begin
+ 
++		main_ppp := head;
++		if main_ppp<>main_pp then
++			while (link(main_ppp)<>main_pp) do
++				main_ppp:=link(main_ppp);	{ find node preceding tail }
++
+ 		temp_ptr := str_start_macro(str_ptr);
+ 		repeat
+ 			if main_h = 0 then main_h := main_k;
+ 
+-			if (not is_char_node(main_pp)) and (type(main_pp)=whatsit_node) and (subtype(main_pp)=native_word_node) and (native_font(main_pp)=main_f) then begin
++			if (not is_char_node(main_pp))
++				and (type(main_pp)=whatsit_node)
++				and (subtype(main_pp)=native_word_node)
++				and (native_font(main_pp)=main_f)
++				and (main_ppp<>main_pp)
++				and type(main_ppp)<>disc_node
++			then begin
+ 
+ 				{ make a new temp string that contains the concatenated text of |tail| + the current word/fragment }
+ 				main_k := main_h + native_length(main_pp);
+@@ -3888,9 +3893,13 @@
+ 				do incr(main_h);	{ look for next hyphen or end of text }
+ 				if (main_h < main_k) then incr(main_h);
+ 
+-				{ flag the previous node as no longer valid }
+-				free_native_glyph_info(main_pp);
+-				subtype(main_pp) := deleted_native_node;
++				{ remove the preceding node from the list }
++				link(main_ppp) := link(main_pp);
++				link(main_pp) := null;
++				flush_node_list(main_pp);
++				main_pp := tail;
++				while (link(main_ppp)<>main_pp) do
++					main_ppp:=link(main_ppp);
+ 
+ 			end else begin
+ 
+@@ -3929,9 +3938,14 @@
+ 				set_native_char(tail, main_p + native_length(main_pp), str_pool[str_start_macro(str_ptr) + main_p]);
+ 			set_native_metrics(tail, XeTeX_use_glyph_metrics);
+ 
+-			{ flag the previous node as no longer valid }
+-			free_native_glyph_info(main_pp);
+-			subtype(main_pp) := deleted_native_node;
++			{ remove the preceding node from the list }
++			main_p := head;
++			if main_p<>main_pp then
++				while link(main_p)<>main_pp do
++					main_p := link(main_p);
++			link(main_p) := link(main_pp);
++			link(main_pp) := null;
++			flush_node_list(main_pp);
+ 		end else begin
+ 			{ package the current string into a |native_word| whatsit }
+ 			link(main_pp) := new_native_word_node(main_f, main_k);
+@@ -3997,7 +4011,6 @@
+ @y
+     if type(p)<>kern_node then if type(p)<>ligature_node then
+ 	if (type(p)<>whatsit_node) or ((subtype(p)<>native_word_node)
+-									 and (subtype(p)<>deleted_native_node)
+ 									 and (subtype(p)<>glyph_node)) then
+       begin print_err("Improper discretionary list");
+ @z
+@@ -4802,8 +4815,10 @@
+ 	print_char(" ");
+ 	print_native_word(p);
+   end;
++@{
+ deleted_native_node:
+ 	print("[DELETED]");
++@}
+ glyph_node:begin
+     print_esc(font_id_text(native_font(p)));
+     print(" glyph#");
+@@ -4837,12 +4852,9 @@
+   r:=get_node(words);
+   while words > 0 do
+     begin decr(words); mem[r+words]:=mem[p+words]; end;
+-  native_glyph_info_ptr(r):=0; native_glyph_count(r):=0;
++  native_glyph_info_ptr(r):=null_ptr; native_glyph_count(r):=0;
+   copy_native_glyph_info(p, r);
+   end;
+-deleted_native_node: begin words:=native_size(p);
+-  r:=get_node(words);
+-  end;
+ glyph_node: begin r:=get_node(glyph_node_size);
+   words:=glyph_node_size;
+   end;
+@@ -4858,7 +4870,6 @@
+ othercases confusion("ext3")
+ @y
+ native_word_node: begin free_native_glyph_info(p); free_node(p,native_size(p)); end;
+-deleted_native_node: free_node(p,native_size(p));
+ glyph_node: free_node(p,glyph_node_size);
+ pic_node,pdf_node: free_node(p,total_pic_node_size(p));
+ pdf_save_pos_node:
+@@ -5106,7 +5117,7 @@
+ 			dvi_two(native_glyph(p));
+ 			cur_h := cur_h + width(p);
+ 		end else begin
+-			if native_glyph_info_ptr(p) <> 0 then begin
++			if native_glyph_info_ptr(p) <> null_ptr then begin
+ 				len := make_xdv_glyph_array_data(p);
+ 				for k := 0 to len-1 do
+ 					dvi_out(xdv_buffer_byte(k));
+@@ -5231,7 +5242,7 @@
+ @x
+ language_node:do_nothing;
+ @y
+-language_node,deleted_native_node:do_nothing;
++language_node:do_nothing;
+ @z
+ 
+ @x
+@@ -6012,6 +6023,11 @@
+     goto next_p;
+ 
+ @ Here we compute the effective width of a glue node as in |hlist_out|.
++
++@<Cases of |reverse|...@>=
++glue_node: begin round_glue;
++  @<Handle a glue node for mixed...@>;
++  end;
+ @z
+ 
+ @x
+@@ -6106,7 +6122,7 @@
+ 	native_length(q) := n;
+ 
+ 	native_glyph_count(q) := 0;
+-	native_glyph_info_ptr(q) := 0;
++	native_glyph_info_ptr(q) := null_ptr;
+ 
+ 	new_native_word_node := q;
+ end;
+@@ -6163,7 +6179,7 @@
+ 		
+ 		native_size(p) := native_node_size + 1;
+ 		native_glyph_count(p) := 0;
+-		native_glyph_info_ptr(p) := 0;
++		native_glyph_info_ptr(p) := null_ptr;
+ 		native_font(p) := f;
+ 
+ 		if c > @"FFFF then begin
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.defines
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex.defines	2006-12-06 18:29:15.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.defines	2007-08-13 16:22:35.000000000 +0200
+@@ -32,6 +32,8 @@
+ 
+ { xetex.defines: additions for xetex }
+ 
++@define @field ptr;
++@define const nullptr;
+ @define type voidpointer;
+ @define function getnativechar();
+ @define procedure setnativechar();
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex.h	2006-12-06 18:29:15.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.h	2007-08-13 16:22:35.000000000 +0200
+@@ -63,8 +63,7 @@
+ 
+ #define dviopenout(f)			open_dvi_output(&(f))
+ 
+-#define casttoptr(x)		(void*)(x)
+-#define casttointeger(x)	(long)(x)
++#define nullptr				(NULL)
+ #define glyphinfobyte(p,k)	((unsigned char*)p)[k]
+ #define casttoushort(x)		(unsigned short)(x)
+ 
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex.mk	2007-08-13 16:22:35.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk	2007-08-13 16:22:35.000000000 +0200
+@@ -279,7 +279,7 @@
+ 
+ xefmtdir = $(web2cdir)/xetex
+ $(xefmtdir)::
+-	$(SHELL) $(top_srcdir)/../mkinstalldirs $(xefmtdir)
++	$(SHELL) $(top_srcdir)/../mkinstalldirs ${DESTDIR}$(xefmtdir)
+ 
+ xetex.fmt: xetex
+ 	$(dumpenv) $(MAKE) progname=xetex files="xetex.ini unicode-letters.tex plain.tex cmr10.tfm" prereq-check
+@@ -298,7 +298,7 @@
+ 
+ install-programs: @XETEX@ install-xetex-programs
+ install-xetex-programs: xetex $(bindir)
+-	for p in xetex; do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done
++	for p in xetex; do $(INSTALL_LIBTOOL_PROG) $$p ${DESTDIR}$(bindir); done
+ 
+ install-links: @XETEX@ install-xetex-links
+ install-xetex-links: install-xetex-programs
+@@ -308,13 +308,13 @@
+ install-fmts: @XETEX@ install-xetex-fmts
+ install-xetex-fmts: xefmts $(xefmtdir)
+ 	xefmts="$(all_xefmts)"; \
+-	  for f in $$xefmts; do $(INSTALL_DATA) $$f $(xefmtdir)/$$f; done
++	  for f in $$xefmts; do $(INSTALL_DATA) $$f ${DESTDIR}$(xefmtdir)/$$f; done
+ 	xefmts="$(xefmts)"; \
+ 	  for f in $$xefmts; do base=`basename $$f .fmt`; \
+-	    (cd $(bindir) && (rm -f $$base; $(LN) xetex $$base)); done
++	    (cd ${DESTDIR}$(bindir) && (rm -f $$base; $(LN) xetex $$base)); done
+ 
+ install-data:: @XETEX@ install-xetex-data
+ install-xetex-pool: xetex.pool $(texpooldir)
+-	$(INSTALL_DATA) xetex.pool $(texpooldir)/xetex.pool
++	$(INSTALL_DATA) xetex.pool ${DESTDIR}$(texpooldir)/xetex.pool
+ 
+ # end of xetex.mk
+Index: texlive-bin-2007/build/source/texk/xdvipdfmx/src/tt_cmap.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/xdvipdfmx/src/tt_cmap.c	2006-09-29 17:15:10.000000000 +0200
++++ texlive-bin-2007/build/source/texk/xdvipdfmx/src/tt_cmap.c	2007-08-13 16:22:35.000000000 +0200
+@@ -303,6 +303,9 @@
+     if (cc >= map->startCount[i]) {
+       if (map->idRangeOffset[i] == 0) {
+ 	gid = (cc + map->idDelta[i]) & 0xffff;
++      } else if (cc == 0xffff && map->idRangeOffset[i] == 0xffff) {
++	/* this is for protection against some old broken fonts... */
++	gid = 0;
+       } else {
+ 	j  = map->idRangeOffset[i] - (segCount - i) * 2;
+ 	j  = (cc - map->startCount[i]) + (j / 2);
+@@ -630,6 +633,9 @@
+       ch = c0 + j;
+       if (map->idRangeOffset[i] == 0) {
+ 	gid = (ch + map->idDelta[i]) & 0xffff;
++      } else if (c0 == 0xffff && c1 == 0xffff && map->idRangeOffset[i] == 0xffff) {
++	/* this is for protection against some old broken fonts... */
++	gid = 0;
+       } else {
+ 	gid = (map->glyphIndexArray[j+d] +
+ 	       map->idDelta[i]) & 0xffff;
+@@ -952,6 +958,9 @@
+       ch = c0 + j;
+       if (map->idRangeOffset[i] == 0) {
+ 	gid = (ch + map->idDelta[i]) & 0xffff;
++      } else if (c0 == 0xffff && c1 == 0xffff && map->idRangeOffset[i] == 0xffff) {
++	/* this is for protection against some old broken fonts... */
++	gid = 0;
+       } else {
+ 	gid = (map->glyphIndexArray[j+d] +
+ 	       map->idDelta[i]) & 0xffff;
--- texlive-bin-2007.dfsg.2.orig/debian/patches/add-missing-fontinst-source
+++ texlive-bin-2007.dfsg.2/debian/patches/add-missing-fontinst-source
@@ -0,0 +1,112 @@
+---
+ texmf-dist/doc/fontinst/base/manual/roadmap.fig |   90 ++++++++++++++++++++++++
+ texmf-dist/tpm/fontinst.tpm                     |    1 
+ 2 files changed, 91 insertions(+)
+
+Index: texlive-bin-2007.dfsg.2/texmf-dist/doc/fontinst/base/manual/roadmap.fig
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ texlive-bin-2007.dfsg.2/texmf-dist/doc/fontinst/base/manual/roadmap.fig	2008-06-26 23:06:42.000000000 +0200
+@@ -0,0 +1,90 @@
++#FIG 3.1
++Portrait
++Center
++Inches
++1200 2
++5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 4284.375 1645.312 4275 1125 4650 1275 4800 1575
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3515.625 1645.312 3525 1125 3150 1275 3000 1575
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 2279.167 3512.500 2325 3000 2550 3075 2775 3375
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3720.833 3512.500 3675 3000 3450 3075 3225 3375
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 3525.000 1500.000 4725 2475 4500 2700 4125 2925
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 1 1 0 3493.269 4214.423 3000 4350 3225 4650 3525 4725
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 4291.717 3239.006 5700 3150 5325 4200 4275 4650
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 3787.500 1650.000 6600 3150 5700 4200 4275 4800
++	0 0 1.00 60.00 120.00
++5 1 0 1 -1 7 0 0 -1 0.000 0 0 1 0 2769.643 3133.928 4800 3150 4650 3900 4200 4575
++	0 0 1.00 60.00 120.00
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3900 2962 225 187 3675 2775 4125 3150
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3900 562 225 187 3675 375 4125 750
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3900 1762 225 187 3675 1575 4125 1950
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3000 1762 225 187 2775 1575 3225 1950
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 4800 1762 225 187 4575 1575 5025 1950
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 4800 2962 225 187 4575 2775 5025 3150
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 5700 2962 225 187 5475 2775 5925 3150
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 6600 2962 225 187 6375 2775 6825 3150
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 2100 2962 225 187 1875 2775 2325 3150
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3000 4162 225 187 2775 3975 3225 4350
++1 2 0 1 -1 7 0 0 -1 0.0000000 1 0.000 3900 5362 225 187 3675 5175 4125 5550
++2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
++	 3525 975 4275 975 4275 1275 3525 1275 3525 975
++2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
++	 3525 2175 4275 2175 4275 2475 3525 2475 3525 2175
++2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
++	 4425 2175 5175 2175 5175 2475 4425 2475 4425 2175
++2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
++	 2625 3375 3375 3375 3375 3675 2625 3675 2625 3375
++2 2 0 1 -1 7 0 0 -1 0.000 0 0 0 0 0 5
++	 3525 4575 4275 4575 4275 4875 3525 4875 3525 4575
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3900 750 3900 975
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3900 1275 3900 1575
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3900 1950 3900 2175
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3900 2475 3900 2775
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 4800 1950 4800 2175
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 4800 2475 4800 2775
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3000 1950 3000 3375
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3000 3675 3000 3975
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3900 3150 3900 4575
++2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2
++	0 0 1.00 60.00 120.00
++	 3900 4875 3900 5175
++4 1 -1 0 0 16 12 0.0000000 4 135 240 3900 3000 tfm\001
++4 1 -1 0 0 16 12 0.0000000 4 135 300 3900 600 afm\001
++4 1 -1 0 0 16 12 0.0000000 4 180 150 3900 1800 pl\001
++4 1 -1 0 0 16 12 0.0000000 4 180 240 4800 1800 vpl\001
++4 1 -1 0 0 16 12 0.0000000 4 135 150 3000 1800 fd\001
++4 1 -1 0 0 16 12 0.0000000 4 135 135 4800 3000 vf\001
++4 1 -1 0 0 16 12 0.0000000 4 180 255 5700 3000 pfa\001
++4 1 -1 0 0 16 12 0.0000000 4 180 255 6600 3000 pfb\001
++4 1 -1 0 0 16 12 0.0000000 4 120 240 2100 3000 tex\001
++4 1 -1 0 0 16 12 0.0000000 4 135 240 3000 4200 dvi\001
++4 1 -1 0 0 16 12 0.0000000 4 135 195 3900 5400 ps\001
++4 1 -1 0 0 29 12 0.0000000 4 180 570 3900 1175 fontinst\001
++4 1 -1 0 0 29 12 0.0000000 4 180 405 3900 2375 pltotf\001
++4 1 -1 0 0 29 12 0.0000000 4 180 480 4800 2375 vptovf\001
++4 1 -1 0 0 29 12 0.0000000 4 135 360 3000 3575 latex\001
++4 1 -1 0 0 29 12 0.0000000 4 180 390 3900 4775 dvips\001
+Index: texlive-bin-2007.dfsg.2/texmf-dist/tpm/fontinst.tpm
+===================================================================
+--- texlive-bin-2007.dfsg.2.orig/texmf-dist/tpm/fontinst.tpm	2008-06-26 23:06:55.000000000 +0200
++++ texlive-bin-2007.dfsg.2/texmf-dist/tpm/fontinst.tpm	2008-06-26 23:07:18.000000000 +0200
+@@ -165,6 +165,7 @@
+ texmf-dist/doc/fontinst/base/manual/intro98.pdf
+ texmf-dist/doc/fontinst/base/manual/intro98.tex
+ texmf-dist/doc/fontinst/base/manual/roadmap.eps
++texmf-dist/doc/fontinst/base/manual/roadmap.fig
+ texmf-dist/doc/fontinst/base/test/comparemetrics.sty
+ texmf-dist/doc/fontinst/base/test/comparepls.tex
+ texmf-dist/doc/fontinst/base/test/scaledtest.tex
--- texlive-bin-2007.dfsg.2.orig/debian/patches/dviljk-security-fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/dviljk-security-fixes
@@ -0,0 +1,2267 @@
+security fixes from Joachim Schrod <jschrod@acm.org>
+(present in the security branch of TeX Live 2007 branch2007)
+This update is all about security fixes:
+ 1) dviljk did not check any memory bounds. Any read operation, any
+    string handling was done without bounds checking and could be
+    exploited for buffer overflows.
+
+    I discovered ca. 30 places where this happens and fixed all of
+    them. I did not do a full code review and therefore can not
+    promise that there are even more, but all occurences of fread()
+    with arbitrary lengths, strcpy and friends, string copying by
+    "*dest++ = *src++", and other fixed array accesses are now
+    checked.
+
+ 2) dviljk had a tempfile creation race condition, due to the usage of
+    tmpnam(). (There are more cases in the texk source tree, btw.)
+    Since mkstemp() cannot be utilized here, I changed the code to use
+    a temporary directory created with mkdtemp(). (If mkdtemp() is not
+    available, I fall back to use tmpnam(); it's not worse than
+    before.) At the same time, the temporary files (and directory) are
+    deleted now at the end of the program run.
+---
+ build/source/texk/dviljk/ChangeLog    |   47 +
+ build/source/texk/dviljk/c-auto.in    |   26 
+ build/source/texk/dviljk/config.h     |   28 -
+ build/source/texk/dviljk/configure    |   56 ++
+ build/source/texk/dviljk/configure.in |    2 
+ build/source/texk/dviljk/dvi2xx.c     |  889 +++++++++++++++++-----------------
+ build/source/texk/dviljk/dvi2xx.h     |   30 -
+ 7 files changed, 631 insertions(+), 447 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/dviljk/ChangeLog
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/ChangeLog	2007-07-03 13:44:19.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/ChangeLog	2007-07-03 13:45:10.000000000 +0200
+@@ -1,3 +1,42 @@
++2007-07-02  Joachim Schrod  <jschrod@acm.org>
++
++	* dvi2xx.c (DoSpecial): Security issue: usage of tmpnam() caused
++	tempfile race condition. I use mkdtemp() if it's available and
++	fall back to tmpnam.
++
++	Special parsing of include files was inconsistent, unify it. The
++	current parsing code still allows lots of non-sensical special
++	commands, but at least it doesn't access unrelated variables any
++	more.
++
++2007-06-28  Joachim Schrod  <jschrod@acm.org>
++
++	* dvi2xx.c: Fixed a whole bunch of buffer overflows: The program
++	did not check memory bounds for any string operation. All places
++	where strings are copied with strcpy are replaced by dynamically
++	allocated strings (with xstrdup from kpathsea) or bounded string
++	operations. Fixed also manual string copy operations on special
++	strings. Fixed array buffer overflow in defpoint and fill special
++	operations.
++	(DoSpecial): Call of ghostscript for psfile special had also a
++	potential buffer overflow caused by unchecked usage of sprintf.
++	Fix core dump: Check if all required parameters of psfile special
++	are passed.
++
++	Bumped version number up to 2.6p3.
++
++	* dvi2xx.h: Some fixed sized string arrays are pointers now, they
++	get dynamically allocated.
++	(GetBytes): Another buffer overflow: Check that the buffer size is
++	sufficient to store the read bytes. That relies on the invariant
++	that the GetBytes macro is always called with an array as argument
++	and not with a pointer.
++
++	* config.h: Throw an error if kpathsea is not used. dvi2xx.c
++	had previously already kpathsea dependencies without protecting
++	them with #if KPATHSEA. We go that road further since upstream
++	does not exist any more.
++
+ 2006-05-29  Karl Berry  <karl@tug.org>
+ 
+ 	* Makefile.in (install-exec): cd $(bindir) in case we are doing
+@@ -17,7 +56,7 @@
+ 	Olaf Weber
+ Sat Jan 17 15:09:59 1998  Sebastian Rahtz  <s.rahtz@elsevier.co.uk>
+ 
+-	* assorted patches from Peter Breitenlohner, Olaf Weber, 
++	* assorted patches from Peter Breitenlohner, Olaf Weber,
+  	Eli Zaretskii, Fabrice Popineau etc. Hope it all still works.
+ 
+ 
+@@ -54,7 +93,7 @@
+ Mon Dec  9 00:53:30 1996  Ulrik Vieth  <vieth@thphy.uni-duesseldorf.de>
+ 
+ 	* dvihp: Use `basename $0` in usage and version messages for
+- 	consistency with other programs and scripts.  
++ 	consistency with other programs and scripts.
+ 	Also accept -help, -version in addition to --help, --version.
+ 
+ Sat Dec  7 17:15:54 1996  Karl Berry  <karl@cs.umb.edu>
+@@ -218,7 +257,7 @@
+ Fri Dec 30 15:25:54 1994  Karl Berry  <karl@cs.umb.edu>
+ 
+         * Makefile.in (install-exec): Don't depend on default, so dvilj4
+-        doesn't get made if the user didn't want it. 
++        doesn't get made if the user didn't want it.
+         (install-data): mkdirchain on texinputdir and fontdir.
+         From Joachim.
+ 
+@@ -325,7 +364,7 @@
+         * config.h (RESOLUTION, MFMODE) [LJ4L]: Set to 300/cx for this new
+         symbol.
+ 
+-        * dvi2xx.c (DecodeArgs): Always scale pgsiz_dots. 
++        * dvi2xx.c (DecodeArgs): Always scale pgsiz_dots.
+         (main) [LJ4]: Don't hardwire 600dpi.
+         These fixes from ajp@eng.cam.ac.uk.
+ 
+Index: texlive-bin-2007/build/source/texk/dviljk/c-auto.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/c-auto.in	2007-07-03 13:44:35.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/c-auto.in	2007-07-03 13:45:10.000000000 +0200
+@@ -1,9 +1,23 @@
+-/* c-auto.in.  Generated automatically from configure.in by autoheader.  */
++/* c-auto.in.  Generated from configure.in by autoheader.  */
++/* acconfig.h -- used by autoheader when generating c-auto.in.
+ 
+-/* Define if type char is unsigned and you are not using gcc.  */
+-#ifndef __CHAR_UNSIGNED__
+-#undef __CHAR_UNSIGNED__
+-#endif
++   If you're thinking of editing acconfig.h to fix a configuration
++   problem, don't. Edit the c-auto.h file created by configure,
++   instead.  Even better, fix configure to give the right answer.  */
++
++/* Define to 1 if you have the `mkdtemp' function. */
++#undef HAVE_MKDTEMP
++
++/* Define to 1 if you have the `rmdir' function. */
++#undef HAVE_RMDIR
+ 
+-/* The number of bytes in a long.  */
++/* Define to 1 if you have the `unlink' function. */
++#undef HAVE_UNLINK
++
++/* The size of a `long', as computed by sizeof. */
+ #undef SIZEOF_LONG
++
++/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
++#ifndef __CHAR_UNSIGNED__
++# undef __CHAR_UNSIGNED__
++#endif
+Index: texlive-bin-2007/build/source/texk/dviljk/config.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/config.h	2007-07-03 13:44:27.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/config.h	2007-07-03 13:45:10.000000000 +0200
+@@ -216,12 +216,7 @@
+ #endif
+ 
+ #ifndef KPATHSEA
+-extern bool findfile(
+-#if NeedFunctionPrototypes
+-char path[], char n[], long4 fontmag, char name[], 
+-	      bool tfm, int level
+-#endif
+-    );
++#error "Would need changed findfile, dviljk has changed allocation semantic of name member in tfontptr"
+ #endif
+ 
+ 
+@@ -444,3 +439,24 @@
+ /* If we have neither, should fall back to fprintf with fixed args.  */
+ #endif
+ #endif
++
++/* If unlink and rmdir are not there, we don't delete the temporary files. */
++#ifndef HAVE_RMDIR
++#define rmdir(dir)
++#endif
++#ifndef HAVE_UNLINK
++#define unlink(file)
++#endif
++
++/* If mkdtemp() does not exist, we have to use tmpnam(). */
++#ifndef HAVE_MKDTEMP
++#define mkdtemp(dir) (tmpnam(dir) ? \
++		      ( mkdir(dir, 0700) == -1 ? NULL : dir ) :	\
++		      ( errno = EINVAL, NULL ) )
++#endif
++
++#ifndef KPATHSEA
++/* FIXME: Should provide a strdup function. But currently this tree is
++   only used in connection with kpathsea anyhow. */
++#error "Need xstrdup and xmalloc function, e.g. from kpathsea"
++#endif
+Index: texlive-bin-2007/build/source/texk/dviljk/configure
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/configure	2007-07-03 13:43:54.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/configure	2007-07-03 13:45:10.000000000 +0200
+@@ -1283,6 +1283,62 @@
+ 
+ 
+ 
++for ac_func in rmdir unlink mkdtemp
++do
++echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
++echo "configure:1290: checking for $ac_func" >&5
++if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
++  echo $ac_n "(cached) $ac_c" 1>&6
++else
++  cat > conftest.$ac_ext <<EOF
++#line 1295 "configure"
++#include "confdefs.h"
++/* System header to define __stub macros and hopefully few prototypes,
++    which can conflict with char $ac_func(); below.  */
++#include <assert.h>
++/* Override any gcc2 internal prototype to avoid an error.  */
++/* We use char because int might match the return type of a gcc2
++    builtin and then its argument prototype would still apply.  */
++char $ac_func();
++
++int main() {
++
++/* The GNU C library defines this for functions which it implements
++    to always fail with ENOSYS.  Some functions are actually named
++    something starting with __ and the normal name is an alias.  */
++#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
++choke me
++#else
++$ac_func();
++#endif
++
++; return 0; }
++EOF
++if { (eval echo configure:1318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++  rm -rf conftest*
++  eval "ac_cv_func_$ac_func=yes"
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  rm -rf conftest*
++  eval "ac_cv_func_$ac_func=no"
++fi
++rm -f conftest*
++fi
++
++if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
++  echo "$ac_t""yes" 1>&6
++    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
++  cat >> confdefs.h <<EOF
++#define $ac_tr_func 1
++EOF
++ 
++else
++  echo "$ac_t""no" 1>&6
++fi
++done
++
++
+ ac_config_files="$ac_config_files Makefile"
+ 
+ trap '' 1 2 15
+Index: texlive-bin-2007/build/source/texk/dviljk/configure.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/configure.in	2007-07-03 13:44:09.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/configure.in	2007-07-03 13:45:10.000000000 +0200
+@@ -14,5 +14,7 @@
+ AC_C_CHAR_UNSIGNED
+ AC_CHECK_SIZEOF(long)
+ 
++AC_CHECK_FUNCS(rmdir unlink mkdtemp)
++
+ KPSE_CONFIG_FILES([Makefile])
+ AC_OUTPUT
+Index: texlive-bin-2007/build/source/texk/dviljk/dvi2xx.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/dvi2xx.c	2007-07-03 13:44:43.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/dvi2xx.c	2007-07-03 13:45:10.000000000 +0200
+@@ -1,5 +1,5 @@
+ /* $Id: dvi2xx.c,v 2.5 1997/12/08 20:52:20 neumann Exp $ */
+-#define VERSION "2.6p2 (dviljk)"
++#define VERSION "dviljk (version 2.6p3)"
+ /*
+ #define DEBUGGS 1
+ */
+@@ -165,7 +165,7 @@
+ # endif
+ #endif
+ 
+-  /* Initialize pixel_files */   
++  /* Initialize pixel_files */
+   for (i = 0; i <= MAXOPEN; i++)
+     pixel_files[i].pixel_file_id = FPNULL;
+ 
+@@ -173,7 +173,7 @@
+   y_origin = YDEFAULTOFF; /* y-origin in dots                    */
+ 
+   setbuf(ERR_STREAM, NULL);
+-  (void) strcpy(G_progname, argv[0]);
++  G_progname = argv[0];
+ #ifdef KPATHSEA
+   kpse_set_progname(argv[0]);
+   kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile);
+@@ -275,7 +275,7 @@
+   EMIT1("@PJL SET PAGEPROTECT=OFF\012");
+   EMIT1("@PJL ENTER LANGUAGE=PCL\012");
+   if (econoMode && LJ6)
+-      EMIT1("@PJL SET ECONOMODE=ON\012");  
++      EMIT1("@PJL SET ECONOMODE=ON\012");
+   EMIT3("\033&u%dD\033*t%dR",RESOLUTION,RESOLUTION);
+   if (econoMode && !LJ6)
+     EMIT1("\033*v1T");
+@@ -431,8 +431,8 @@
+           /*
+             fprintf(ERR_STREAM,"FirstPart\n count %d, mod %d, pp %d\n",(int)count[0],(int)count[0]%2,PageParity);
+             */
+-          SkipMode = 
+-            (bool)(PageParity != (short)((count[0]<0 ? 
++          SkipMode =
++            (bool)(PageParity != (short)((count[0]<0 ?
+                                           labs(count[0])+1 : count[0])%2));
+           if (count[0] == 0) SkipMode = (bool)!SkipMode;
+         }
+@@ -641,7 +641,7 @@
+    is not buffered. */
+ 
+ /* read a buffered byte */
+-char 
++char
+ #if NeedFunctionPrototypes
+ b_read(FILEPTR spfp)
+ #else
+@@ -661,7 +661,7 @@
+ }
+ 
+ #ifdef RISC_BUFFER
+-void 
++void
+ #if NeedFunctionPrototypes
+ b_write(FILEPTR spfp, char c) /* write a buffered byte */
+ #else
+@@ -677,7 +677,7 @@
+   buffout[boact++] = c;
+ }
+ 
+-void 
++void
+ #if NeedFunctionPrototypes
+ b_wrtmult(FILEPTR spfp, char *buf, int len) /* write a sequence of bytes to the output buffer */
+ #else
+@@ -693,22 +693,22 @@
+     write_multi(buffout,1,boact,spfp);
+     /* Copy only small blocks; large ones are written directly */
+     if (len < (BUFFSIZE/4)) {
+-      for (i = 0; i<len; i++) 
++      for (i = 0; i<len; i++)
+         buffout[i] = buf[i];
+       boact = len;
+     } else {
+-      write_multi(buf,1,len,spfp); 
++      write_multi(buf,1,len,spfp);
+       boact = 0;
+     }
+   }
+   else {
+-    for (i = 0; i<len; i++) 
++    for (i = 0; i<len; i++)
+       buffout[boact++] = buf[i];
+   }
+ }
+ 
+ /* flush the output buffer */
+-void 
++void
+ #if NeedFunctionPrototypes
+ b_oflush(FILEPTR spfp)
+ #else
+@@ -762,9 +762,9 @@
+ /***************************** CopyHPFile ******************************/
+ /*********************************************************************/
+ #if NeedFunctionPrototypes
+-int getnum(FILEPTR spfp, char *t, char *numstr) 
++int getnum(FILEPTR spfp, char *t, char *numstr)
+ #else
+-int getnum(spfp, t, numstr) 
++int getnum(spfp, t, numstr)
+ FILEPTR spfp;
+ char *t, *numstr;
+ #endif
+@@ -777,30 +777,30 @@
+ }
+ 
+ #if NeedFunctionPrototypes
+-void setOffset(char dir, char sign, int pos) 
++void setOffset(char dir, char sign, int pos)
+ #else
+-void setOffset(dir, sign, pos, first) 
++void setOffset(dir, sign, pos, first)
+ char dir, sign;
+ int pos;
+ #endif
+ {
+   if ((sign == '+' || sign == '-') && pos > 0 ) {
+     EMIT4("\033*p%c%d%c",sign,pos,dir);
+-#ifdef DEBUGGS   
++#ifdef DEBUGGS
+     fprintf(stderr, "relative: *p%c%d%c\n", sign, pos, dir);
+ #endif
+   } else if (pos>0) {
+     EMIT3("\033*p%d%c",pos,dir);
+-#ifdef DEBUGGS   
++#ifdef DEBUGGS
+     fprintf(stderr, "absolute: *p%d%c\n", pos, dir);
+ #endif
+-    if (dir == 'X') 
++    if (dir == 'X')
+       last_rx = pos;
+-    else 
++    else
+       last_ry = pos;
+   } else {
+     /*EMIT3("\033*p%d%c",pos,dir);*/
+-#ifdef DEBUGGS   
++#ifdef DEBUGGS
+     fprintf(stderr, "Relative: *p%d%c\n", pos, dir);
+ #endif
+   }
+@@ -832,7 +832,7 @@
+      unwanted commands from the input file and outputs the rest */
+ 
+   /* reset the input buffer */
+-  binumber = 0; 
++  binumber = 0;
+   biact = 0;
+ 
+   qfprintf(ERR_STREAM," [%s", str);
+@@ -853,16 +853,16 @@
+           /* of the commands (x first, y first) */
+ 
+           if (t=='Y' || t=='y') {
+-            if (numstr[0]!='+' && numstr[0]!='-' && num<miny) 
++            if (numstr[0]!='+' && numstr[0]!='-' && num<miny)
+               miny = num;
+             if (t=='y') {
+               num = getnum(spfp, &t, numstr);
+-              if (numstr[0]!='+' && numstr[0]!='-' && num<minx) 
++              if (numstr[0]!='+' && numstr[0]!='-' && num<minx)
+                 minx = num;
+             }
+           }
+           if (t=='X' || t=='x') {
+-            if (numstr[0]!='+' && numstr[0]!='-' && num<minx) 
++            if (numstr[0]!='+' && numstr[0]!='-' && num<minx)
+               minx = num;
+ 
+             if (t=='x') {
+@@ -920,16 +920,16 @@
+   }
+   qfprintf(ERR_STREAM," [%s", str);
+   /* reset input buffer again */
+-  binumber = 0; 
++  binumber = 0;
+   biact = 0;
+ 
+ 
+   /* Pass through the input file again but this time output the */
+   /* retained PCL commands */
+-#ifdef DEBUGGS   
+-  fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", 
++#ifdef DEBUGGS
++  fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n",
+           minx, miny, x_goffset, y_goffset);
+-#endif  
++#endif
+   do {
+     t = (char)b_read(spfp);
+     if (t==0x1B) {
+@@ -948,7 +948,7 @@
+             } else {
+               setOffset('Y',numstr[0], num);
+             }
+-            
++
+             if (t == 'y') {
+               num = getnum(spfp, &t,numstr);
+               if (numstr[0]!='+' && numstr[0]!='-') {
+@@ -960,16 +960,16 @@
+               }
+             }
+           }
+-            
++
+           if (t=='X' || t=='x') {
+             if (numstr[0]!='+' && numstr[0]!='-') {
+               /*Add in the correct horizontal offset*/
+               setOffset('X',numstr[0],
+                         num - minx + (int)PIXROUND(h,hconv) + x_goffset);
+-            } else { 
++            } else {
+               setOffset('X',numstr[0], num);
+             }
+-            
++
+             if (t=='x') {
+               num = getnum(spfp, &t,numstr);
+               if (numstr[0]!='+' && numstr[0]!='-') {
+@@ -1027,7 +1027,7 @@
+         case(0x63):
+           /* Rectangular draw commands */
+           EMIT1("\033*c");
+-          for (t = (char)b_read(spfp); t<0x40 || t>0x60; 
++          for (t = (char)b_read(spfp); t<0x40 || t>0x60;
+                t = (char)b_read(spfp))
+             EMITC(t);
+           EMITC(t);
+@@ -1110,7 +1110,7 @@
+   long4 x = 0;      /* number being constructed */
+   unsigned char h;
+   while (n--) {
+-    x <<= 8; 
++    x <<= 8;
+     read_byte(fp,h);
+     x |= h;
+   }
+@@ -1143,7 +1143,7 @@
+ #ifdef SIGN_DEBUG
+   long4    x0;      /* copy of x  */
+ #endif
+-  read_byte(fp,h); 
++  read_byte(fp,h);
+   x = h; /* get first (high-order) byte */
+   n1 = n--;
+   while (n--) {
+@@ -1296,7 +1296,7 @@
+                                         /* ---> result in DX       */
+ 
+   if (  (regs.h.dl & 0x80)              /* file handle points to a device */
+-        && !(regs.h.dl & 0x07) ) {      /* neither console i/o or null    */ 
++        && !(regs.h.dl & 0x07) ) {      /* neither console i/o or null    */
+ 
+     regs.h.dl  |= 0x20;                 /* set BINARY bit in device info  */
+     regs.h.ah = (unsigned char) 0x44;   /* IOCTL                  */
+@@ -1501,20 +1501,20 @@
+     /* For COMPRESSED CHARS */
+     if (PrevSize < nbpl) {
+       PrevSize = nbpl;
+-      if (PrevLine != NULL) 
++      if (PrevLine != NULL)
+         free(PrevLine);
+-      if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) 
++      if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char)))
+           == NULL) {
+-        PrevSize = 0; 
++        PrevSize = 0;
+         Fatal("EmitChar: Out of memory error!\n");
+       }
+     }
+     /* Clear seed line */
+-    for (i = 0; i<nbpl; i++) 
++    for (i = 0; i<nbpl; i++)
+       PrevLine[i] = 0;
+-    CChar_Off = 0; 
++    CChar_Off = 0;
+     CChar_Last = -1;
+-    
++
+     /* This bit copied from below... */
+ #  ifdef USEPXL
+     if (fontptr->id == pk89)
+@@ -1530,11 +1530,11 @@
+         CompressedCharLine(ce,nbpl,sl);
+       }
+ #  else
+-    for (i = num_rows; i > 0; i--) 
++    for (i = num_rows; i > 0; i--)
+       CompressedCharLine(ce,nbpl,(bits + (i-1)*nbpl));
+ #  endif /* USEPXL */
+   }
+-  else 
++  else
+     CChar_Off = -1;
+ # endif /* LJ4 */
+ 
+@@ -1544,10 +1544,10 @@
+ # ifdef LJ4
+   /* printf("raw: %d (%d * %d), comp: %d\n",
+      total,ce->width,ce->height,CChar_Off); */
+-  /* Characters that don't compress well are usually rather small so 
+-     reading them again and writing them uncompressed won't take 
++  /* Characters that don't compress well are usually rather small so
++     reading them again and writing them uncompressed won't take
+      much time anyway. */
+-  if (CChar_Off > total) 
++  if (CChar_Off > total)
+     CChar_Off = -1;
+   if (CChar_Off >= 0) {
+     EMIT4("\033*c%sd%dE\033(s%ldW", cnv_buffer,
+@@ -1606,7 +1606,7 @@
+       }
+ #endif
+     }
+-    
++
+ #ifdef IBM3812
+ #ifdef USEPXL
+   used_fontstorage += (long4)ce->height * ((ce->width + 15) >> 4) * 2 + 14;
+@@ -1652,7 +1652,7 @@
+ int     repeatcount;
+ 
+ void             /* <Read and translate raster description@>*/
+-#if NeedFunctionPrototypes 
++#if NeedFunctionPrototypes
+ PkRaster(struct char_entry *ce, int raster)
+ #else
+ PkRaster(ce, raster)
+@@ -1735,7 +1735,7 @@
+       if (wordweight < 31) {
+ #ifdef COMMENT
+ # ifdef DRAWGLYPH
+-        { 
++        {
+           int k;
+           for (k = 15; k>=0; k--) {
+             if ((power[k] & word)!=0) printf("Z");
+@@ -1749,7 +1749,7 @@
+         for (j = 3; j >= (wordwidth * 4 - (long4)nbpl); j--) {
+           OUTCHAR(((word >> (j << 3)) & 0xff));
+ #ifdef DRAWGLYPH
+-          { 
++          {
+             int k;
+             for (k = 7; k>=0; k--) {
+               if ((power[k] & ((word >> (j << 3)) & 0xff))!=0) printf("M");
+@@ -1760,9 +1760,9 @@
+         }
+ 
+       }
+-        
++
+       switch (raster) {
+-      case 1: 
++      case 1:
+         RasterLine(ce, nbpl, current_line, raster_line_buf);
+         current_line++;
+         break;
+@@ -1826,7 +1826,7 @@
+             OUTCHAR((tl       & 0xFF));
+ 
+ #ifdef DRAWGLYPH
+-            { 
++            {
+               int k;
+               for (k = 31; k>=0; k--) {
+                 if ((power[k] & row[ii])!=0) printf("M");
+@@ -1839,7 +1839,7 @@
+           for (j = 3; j >= (wordwidth *4 - (long4)nbpl); j--) {
+             OUTCHAR(((tl >> (j << 3)) & 0xff));
+ #ifdef DRAWGLYPH
+-            { 
++            {
+               int k;
+               for (k = 7; k>=0; k--) {
+                 if ((power[k] & ((tl >> (j << 3)) & 0xff))!=0) printf("M");
+@@ -1850,7 +1850,7 @@
+           }
+ 
+           switch (raster) {
+-          case 1: 
++          case 1:
+             RasterLine(ce, (unsigned int)nbpl, current_line, raster_line_buf);
+             current_line++;
+             break;
+@@ -1969,7 +1969,7 @@
+ 
+ #ifdef LJ4
+ /* Compress a raster line in compression mode 2 */
+-int 
++int
+ #if NeedFunctionPrototypes
+ CompressLine2(unsigned char *buffer, unsigned char *buffout, int emitbytes)
+ #else
+@@ -1984,13 +1984,13 @@
+   char last,c;
+ 
+   /* trap empty lines (otherwise problems with Packbits) */
+-  if (emitbytes == 0) 
++  if (emitbytes == 0)
+     return(0);
+   /* Use Packbits compression (mode 2) on raster line */
+-  pos = buffer; 
+-  litpos = buffer; 
+-  pack = 1; 
+-  ppos = buffout; 
++  pos = buffer;
++  litpos = buffer;
++  pack = 1;
++  ppos = buffout;
+   last = *pos++;
+   upper = buffer + emitbytes;
+   while (pos < upper) {
+@@ -2000,14 +2000,14 @@
+       /* At least three equal bytes ==> write out preceding literal sequence */
+       if ((pack == 3) && ((lit = (int)(pos - litpos - 3)) != 0)) {
+         while (lit >= 128) {
+-          *ppos++ = 127; 
+-          for (i = 1; i<=128; i++) 
++          *ppos++ = 127;
++          for (i = 1; i<=128; i++)
+             *ppos++ = *litpos++;
+           lit -= 128;
+         }
+         if (lit != 0) {
+-          *ppos++ = lit-1; 
+-          while ((lit--) > 0) 
++          *ppos++ = lit-1;
++          while ((lit--) > 0)
+             *ppos++ = *litpos++;
+           /* litpos is now pos-3 (i.e. first of the sequence) */
+         }
+@@ -2015,19 +2015,19 @@
+     }
+     else {
+       while (pack >= 128) {
+-        *ppos++ = 129; 
+-        *ppos++ = last; 
+-        litpos += 128; 
++        *ppos++ = 129;
++        *ppos++ = last;
++        litpos += 128;
+         pack -= 128;
+       }
+       /* At least 3 equal bytes or 2 that don't break a literal sequence
+          ==> write out packed sequence */
+       if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) {
+-        *ppos++ = 257 - pack; 
+-        *ppos++ = last; 
++        *ppos++ = 257 - pack;
++        *ppos++ = last;
+         litpos += pack;
+       }
+-      pack = 1; 
++      pack = 1;
+       last = c;
+     }
+     if (ppos > (buffout + BUFFSIZE/2 - 129)) {
+@@ -2036,28 +2036,28 @@
+       return(0);
+     }
+   }
+-  
++
+   while (pack >= 128) {
+-    *ppos++ = 129; 
+-    *ppos++ = last; 
+-    litpos += 128; 
++    *ppos++ = 129;
++    *ppos++ = last;
++    litpos += 128;
+     pack -= 128;
+   }
+   if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) {
+-    *ppos++ = 257 - pack; 
+-    *ppos++ = last; 
++    *ppos++ = 257 - pack;
++    *ppos++ = last;
+     litpos += pack;
+   }
+   else if ((lit = (int)(pos - litpos)) != 0) {
+     while (lit >= 128) {
+-      *ppos++ = 127; 
+-      for (i = 1; i<=128; i++) 
++      *ppos++ = 127;
++      for (i = 1; i<=128; i++)
+         *ppos++ = *litpos++;
+       lit -= 128;
+     }
+     if (lit != 0) {
+-      *ppos++ = lit-1; 
+-      while ((lit--) > 0) 
++      *ppos++ = lit-1;
++      while ((lit--) > 0)
+         *ppos++ = *litpos++;
+     }
+   }
+@@ -2079,24 +2079,24 @@
+   int lit,i,pack;
+ 
+   /* Use compression mode 3 */
+-  pos = buffer; 
+-  ppos = buffout; 
+-  upper = buffer + emitbytes; 
++  pos = buffer;
++  ppos = buffout;
++  upper = buffer + emitbytes;
+   prev = PrevLine;
+   while(pos < upper) {
+     litpos = pos;
+     while ((*prev == *pos) && (pos < upper)) {
+-      prev++; 
++      prev++;
+       pos++;
+     }
+     if (pos < upper) {
+-      pack = (int)(pos - litpos); 
++      pack = (int)(pos - litpos);
+       litpos = pos;
+-      i = upper - pos; 
+-      if (i > 8) 
++      i = upper - pos;
++      if (i > 8)
+         i = 8;
+       while ((*pos != *prev) && (i > 0)) {
+-        *prev++ = *pos++; 
++        *prev++ = *pos++;
+         i--;
+       }
+       i = (int)(pos - litpos - 1);
+@@ -2105,16 +2105,16 @@
+         *ppos++ = lit + pack;
+       }
+       else {
+-        *ppos++ = lit + 31; 
++        *ppos++ = lit + 31;
+         pack -= 31;
+         while (pack >= 255) {
+-          *ppos++ = 255; 
++          *ppos++ = 255;
+           pack -= 255;
+         }
+         *ppos++ = pack;
+       }
+       while (i >= 0) {
+-        *ppos++ = *litpos++; 
++        *ppos++ = *litpos++;
+         i--;
+       }
+     }
+@@ -2134,7 +2134,7 @@
+ /**********************************************************************/
+ void
+ #if NeedFunctionPrototypes
+-RasterLine(struct char_entry *ce, unsigned int nbpl, 
++RasterLine(struct char_entry *ce, unsigned int nbpl,
+            unsigned int current_line, unsigned char *buffer)
+ #else
+ RasterLine(ce, nbpl, current_line, buffer)
+@@ -2208,21 +2208,21 @@
+     EMIT2("\033*b%dW", emitbytes);
+     EMITL(emitbytes, buffer);
+     break;
+- 
++
+   case 2:
+     i = CompressLine2(buffer,buffin,emitbytes);
+     EMIT2("\033*b%dW", i);
+     EMITL(i,buffin);
+     break;
+- 
++
+   case 3:
+     i = CompressLine3(buffer,buffin + BUFFSIZE/2,(int)nbpl);
+     EMIT2("\033*b%dW", i);
+     EMITL(i,buffin + BUFFSIZE/2);
+     break;
+- 
+-  default: 
+-    fprintf(ERR_STREAM,"Unsupported compression mode!\n"); 
++
++  default:
++    fprintf(ERR_STREAM,"Unsupported compression mode!\n");
+   }
+ # else
+   EMIT2("\033*b%dW", emitbytes);
+@@ -2280,10 +2280,10 @@
+   if (CompressCharMode == 3) {
+     /* Check if PrevLine big enough; claim more space if not */
+     if (((int)nbpl) > PrevSize) {
+-      if (PrevLine != NULL) 
++      if (PrevLine != NULL)
+         free(PrevLine);
+       if ((PrevLine = (unsigned char *)malloc(nbpl*sizeof(char))) == NULL) {
+-        PrevSize = 0; 
++        PrevSize = 0;
+         Fatal("RasterChar: out of memory!\n");
+       }
+       PrevSize = (int)nbpl;
+@@ -2419,7 +2419,7 @@
+   if (bytes > 0) {
+     /* do NOT load Huge characters */
+     if ((bytes > HUGE_CHAR_PATTERN) && (fontptr->id != pk89)) {
+-      qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", 
++      qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n",
+                (char)c, bytes);
+       ptr->charsize = HUGE_SIZE;
+       ptr->where.isloaded = _FALSE;
+@@ -2505,7 +2505,7 @@
+     SetPosn(h, v);
+   }
+ 
+-  /*  
++  /*
+     fprintf(ERR_STREAM,
+             "(%d) hh=%ld (+%ld/+%ld), h=%ld, xh=%ld,xhh=%ld, [%ld|%ld] ->%d\n",
+             (int)do_posn,hh,(long4)ptr->cw,(long4)ptr->cw*(long4)hconv,h,
+@@ -2553,7 +2553,7 @@
+       int     tmp;
+       char    sign;
+ 
+-      if (!do_posn) 
++      if (!do_posn)
+         SetPosn(h, v);
+ 
+ #ifdef USEPXL
+@@ -2563,7 +2563,7 @@
+ #endif
+       if (tmp != 0) {
+         if (tmp < 0) {
+-          sign = '-'; 
++          sign = '-';
+           tmp = -tmp;
+         } else
+           sign = '+';
+@@ -2576,7 +2576,7 @@
+ #endif
+       if (tmp != 0) {
+         if (tmp < 0) {
+-          sign = '-'; 
++          sign = '-';
+           tmp = -tmp;
+         } else
+           sign = '+';
+@@ -2644,7 +2644,7 @@
+     fprintf(stderr,"--> hh(%ld) += cw(%ld) * hconv(%ld)",
+             (long)hh, (long)ptr->cw, (long) hconv);
+             */
+-#ifdef LJ    
++#ifdef LJ
+     /* the guessed position must be a multiple of pixels */
+     if (RESOLUTION == 300)
+       hh += (long4) ((ptr->cw)/4)*4*hconv;
+@@ -2661,7 +2661,7 @@
+   if (command <= SET4)
+     h += ptr->tfmw;
+ 
+-  if (pos_after) 
++  if (pos_after)
+     SetPosn(h, v);
+   else
+     last_rx = (int)PIXROUND(h, hconv) + x_goffset;
+@@ -2682,7 +2682,7 @@
+   }
+   fonts_used_on_this_page = 0;
+ #endif
+-  for (p = hfontptr; p; p = p->next) 
++  for (p = hfontptr; p; p = p->next)
+     p->used_on_this_page = _FALSE;
+ }
+ 
+@@ -2740,7 +2740,7 @@
+   rx = (int)PIXROUND(x, hconv) + x_goffset;
+   ry = (int)PIXROUND(y, vconv) + y_goffset;
+ 
+-  /*  
++  /*
+   fprintf(ERR_STREAM,
+ 	  "setposn to %ld/%ld, %d/%d, last: %d/%d\n",
+ 	  (long)x,(long)y,
+@@ -2804,13 +2804,13 @@
+    offset in the buffer, CChar_Last is the first byte of the last
+    compacted row (line repeat count).  Updates the previous line
+    (PrevLine) if necessary. */
+-void 
++void
+ #if NeedFunctionPrototypes
+ CompressedCharLine(struct char_entry *ce, int nbpl, unsigned char *buffer)
+ #else
+ CompressedCharLine(ce, nbpl, buffer)
+ struct char_entry *ce;
+-int nbpl; 
++int nbpl;
+ unsigned char *buffer;
+ #endif
+ {
+@@ -2821,31 +2821,31 @@
+     int t,mode,max;
+     register int x,y,i;
+ 
+-    prev = PrevLine; 
+-    obuf = buffer; 
+-    end = buffer + nbpl; 
++    prev = PrevLine;
++    obuf = buffer;
++    end = buffer + nbpl;
+     x = 0;
+     while (obuf < end) {
+       if (*obuf != *prev) {
+-        *prev = *obuf; 
++        *prev = *obuf;
+         x = 1;
+       }
+-      obuf++; 
++      obuf++;
+       prev++;
+     }
+     if (x == 0 && CChar_Last >= 0) {
+-      (buffin[CChar_Last])++; 
++      (buffin[CChar_Last])++;
+       return; /* line repeat count +1 */
+     }
+ 
+-    end = buffin + BUFFSIZE - 16; 
+-    obuf = buffin + CChar_Off; 
++    end = buffin + BUFFSIZE - 16;
++    obuf = buffin + CChar_Off;
+     buff = buffer;
+     *obuf++ = 0; /* Line repeat count = 0 */
+     t = 0;
+     CChar_Last = CChar_Off; /* Next line */
+-    mode = 0; 
+-    y = *buff++; 
++    mode = 0;
++    y = *buff++;
+     i = 7; /* i = current bit */
+     while ((t < ce->width) && (obuf < end)) {
+       max = ce->width - t; /* maximum pixels left to do */
+@@ -2853,13 +2853,13 @@
+       if (mode == 0) {
+         /* white run */
+         while ((y & (1<<i)) == 0 && x < max) {
+-          x++; 
+-          i--; 
++          x++;
++          i--;
+           if (i < 0) {
+-            i = 7; 
+-            y = *buff++; 
++            i = 7;
++            y = *buff++;
+             while (y == 0 && x < max) {
+-              x += 8; 
++              x += 8;
+               y = *buff++;
+             }
+           }
+@@ -2869,26 +2869,26 @@
+       else {
+         /* black run */
+         while ((y & (1<<i)) != 0 && x < max) {
+-          x++; 
+-          i--; 
++          x++;
++          i--;
+           if (i < 0) {
+-            i = 7; 
+-            y = *buff++; 
++            i = 7;
++            y = *buff++;
+             while (y == 0xff && x < max) {
+-              x += 8; 
++              x += 8;
+               y = *buff++;
+             }
+           }
+         }
+         mode = 0;
+       }
+-      if (x > max) 
++      if (x > max)
+         x = max;
+       t += x;
+       /* make precautions for very long runs */
+       while (x > 0xff) {
+-        *obuf++ = 0xff; 
+-        *obuf++ = 0; 
++        *obuf++ = 0xff;
++        *obuf++ = 0;
+         x -= 0xff;
+       }
+       *obuf++ = x;
+@@ -2968,8 +2968,8 @@
+ #endif
+ {
+   int     argind;            /* argument index for flags      */
+-  char    curarea[STRSIZE];  /* current file area             */
+-  char    curname[STRSIZE];  /* current file name             */
++  char    *curarea;	     /* current file area             */
++  char    *curname;   	     /* current file name             */
+   char    *tcp, *tcp1;       /* temporary character pointers  */
+   char    *this_arg;
+   double  x_offset = 0.0, y_offset = 0.0;
+@@ -2988,9 +2988,9 @@
+ #endif
+ #endif
+ 
+-  if (argc == 2 && (strcmp (argv[1], "--version") == 0)) {
++  if (argc == 2 && EQ(argv[1], "--version")) {
+     extern KPSEDLL char *kpathsea_version_string;
+-    puts ("dvilj(k) 2.6");
++    puts (VERSION);
+     puts (kpathsea_version_string);
+     puts ("Copyright (C) 1997 Gustaf Neumann.\n\
+ There is NO warranty.  You may redistribute this software\n\
+@@ -2998,7 +2998,7 @@
+ For more information about these matters, see the files\n\
+ named COPYING and dvi2xx.c.\n\
+ Primary author of Dvi2xx: Gustaf Neumann; -k maintainer: K. Berry.");
+-    exit (0); 
++    exit (0);
+   }
+ 
+ #ifdef LJ4
+@@ -3048,9 +3048,9 @@
+ #ifdef LJ2P
+       case 'd':       /* d selects DUPLEX mode  */
+         tcp++;
+-        if (*tcp == '1' ) 
++        if (*tcp == '1' )
+           DuplexMode = 1;
+-        else if (*tcp == '2') 
++        else if (*tcp == '2')
+           DuplexMode = 2;
+         else {
+           Warning("Invalid DUPLEX mode, assuming DUPLEX=1, Long-Edge Binding");
+@@ -3062,13 +3062,13 @@
+         DoublePage = _TRUE;
+         tcp++;
+         if (*tcp == '1' || *tcp == '2') {
+-          if (*tcp == '2') 
++          if (*tcp == '2')
+             PrintFirstPart = _FALSE;
+-          else             
++          else
+             PrintSecondPart = _FALSE;
+           tcp++;
+         }
+-        if (*tcp == '-') 
++        if (*tcp == '-')
+           PrintEmptyPages = _FALSE;
+         break;
+ #ifdef LJ4
+@@ -3256,14 +3256,14 @@
+ #ifdef LJ
+       case 'V':   /* bugfixes for various vendor's PCL emulations */
+         tcp++;
+-        if (*tcp == 'K' || *tcp == 'k') 
++        if (*tcp == 'K' || *tcp == 'k')
+           kyocera_mode = _TRUE;
+         else
+-          if (*tcp == 'B' || *tcp == 'b') 
++          if (*tcp == 'B' || *tcp == 'b')
+             brother_mode = _TRUE;
+ # ifdef LJ4
+ 	else
+-        if (*tcp == '6' || *tcp == '6') 
++        if (*tcp == '6' || *tcp == '6')
+ 	    LJ6 = _TRUE;
+ # endif
+         break;
+@@ -3306,7 +3306,7 @@
+ #endif
+ #ifdef __riscos
+       case 'i': /* name of directory to store diagrams in */
+-        tcp++; 
++        tcp++;
+         ddi = 0;
+         while (*tcp != ' ' && *tcp != '\0' && ddi < DIAGDIRSIZE-1) {
+           diagdir[ddi++] = *tcp++;
+@@ -3328,8 +3328,8 @@
+       }
+     } else {
+ 
+-      (void) strcpy(filename, tcp);
+-      if (!strcmp(filename, "-")) {
++      filename = tcp;
++      if (EQ(filename, "-")) {
+         EmitFileName = "-";
+ #ifdef RISC_USE_OSL
+         dvifp = BINOPEN("Kbd:");
+@@ -3339,57 +3339,68 @@
+ 	  AssureBinary(fileno(dvifp));
+ #endif
+       } else {
++	/* Since this code is used only once during startup, we don't care
++	   about free()ing the allocated strings that represent filenames.
++	   It will be more work to realize proper deallocation handling than
++	   it's worth in terms of saving a few bytes. We consider these
++	   bytes actually static memory where we don't know the size in
++	   advance and don't add them to the allocated_storage count.
++	   [27 Jun 07 -js] */
+ #ifdef KPATHSEA
+         /* split into directory + file name */
+ 	int tcplen, argvlen;
+ 	tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */
+ 	tcplen = strlen(tcp);
++	if ( tcplen == 0 ) {
++	  /* This happens when the DVI file name has a trailing slash; this
++	     is not a valid name. Then we terminate the argument parsing
++	     loop, a usage message will be output below. */
++	  break;
++	}
+ 	argvlen = strlen(argv[argind]);
+ 	if (tcplen == argvlen)
+-	  curarea[0] = '\0';
++	  curarea = "";
+ 	else {
+-	  (void) strcpy(curarea, argv[argind]);
++	  curarea = xstrdup(argv[argind]);
+ 	  curarea[argvlen-tcplen] = '\0';
+ 	}
+ #else
+         tcp = strrchr(argv[argind], '/');
+         /* split into directory + file name */
+         if (tcp == NULL) {
+-          curarea[0] = '\0';
++          curarea[0] = "";
+           tcp = argv[argind];
+         } else {
+-          (void) strcpy(curarea, argv[argind]);
++	  curarea = xstrdup(argv[argind]);
+           curarea[tcp-argv[argind]+1] = '\0';
+           tcp += 1;
+         }
+ #endif
+ 
+-        (void) strcpy(curname, tcp);
++        curname = (char *) xmalloc(strlen(tcp)+5);  /* + space for ".dvi" */
++	(void) strcpy(curname, tcp);
+         /* split into file name + extension */
+-        tcp1 = strrchr(tcp, '.');
++        tcp1 = strrchr(curname, '.');
+         if (tcp1 == NULL) {
+-          (void) strcpy(rootname, curname);
++          rootname = xstrdup(curname);
+           strcat(curname, ".dvi");
+         } else {
+           *tcp1 = '\0';
+-          (void) strcpy(rootname, curname);
++          rootname = xstrdup(curname);
+           *tcp1 = '.';
+         }
+ 
++	filename = (char *) xmalloc(strlen(curarea)+strlen(curname)+1);
+         (void) strcpy(filename, curarea);
+         (void) strcat(filename, curname);
+ 
+         if ((dvifp = BINOPEN(filename)) == FPNULL) {
+           /* do not insist on .dvi */
+           if (tcp1 == NULL) {
+-            int l = strlen(curname);
+-            if (l > 4)
+-              curname[l - 4] = '\0';
+-            l = strlen(filename);
+-            if (l > 4)
+-              filename[l - 4] = '\0';
++	    filename[strlen(filename) - 4] = '\0';
++	    dvifp = BINOPEN(filename);
+           }
+-          if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) {
++          if (dvifp == FPNULL) {
+ #ifdef MSC5
+             Fatal("%s: can't find DVI file \"%s\"\n\n",
+                   G_progname, filename);
+@@ -3411,7 +3422,7 @@
+   y_goffset = (short) MM_TO_PXL(y_offset) + y_origin;
+ 
+   if (dvifp == FPNULL) {
+-    fprintf(ERR_STREAM,"\nThis is the DVI to %s converter version %s",
++    fprintf(ERR_STREAM,"\nThis is the DVI to %s converter %s",
+             PRINTER, VERSION);
+ #ifdef SEVENBIT
+     fprintf(ERR_STREAM,", 7bit");
+@@ -3507,13 +3518,8 @@
+     exit(1);
+   }
+   if (EQ(EmitFileName, "")) {
+-    if ((EmitFileName = (char *)malloc( STRSIZE )) != NULL)
+-      allocated_storage += STRSIZE;
+-    else
+-      Fatal("Can't allocate storage of %d bytes\n",STRSIZE);
+-    (void) strcpy(EmitFileName, curname);
+-    if ((tcp1 = strrchr(EmitFileName, '.')))
+-      *tcp1 = '\0';
++    EmitFileName = (char *) xmalloc(strlen(rootname)+sizeof(EMITFILE_EXTENSION));
++    (void) strcpy(EmitFileName, rootname);
+     strcat(EmitFileName, EMITFILE_EXTENSION);
+   }
+   if (G_quiet)
+@@ -3668,7 +3674,7 @@
+   if (PrintTestPage) EMIT1("\033z");
+ #ifdef vms
+   /* last record is not flushed to file, unless it is completely filled */
+-  for (kk = (int)((*outfp)->_cnt); kk > 0; --kk) 
++  for (kk = (int)((*outfp)->_cnt); kk > 0; --kk)
+     putc('\0',outfp);
+   fflush(outfp);
+ #endif
+@@ -3698,6 +3704,8 @@
+ #endif
+   }
+   CloseFiles();
++  if ( tmp_dir[0] != '\0' )
++    rmdir (tmp_dir);			/* ignore errors */
+   exit(G_errenc);
+ }
+ 
+@@ -3764,15 +3772,15 @@
+ #endif
+ {
+   char *a,*b;
+-  
+-  a = s1; 
++
++  a = s1;
+   b = s2;
+   while (*a != '\0') {
+     if (tolower(*a) != tolower(*b)) return(_FALSE);
+-    a++; 
++    a++;
+     b++;
+   }
+-  *end = b; 
++  *end = b;
+   return(_TRUE);
+ }
+ 
+@@ -3791,18 +3799,18 @@
+ {
+   char *s;
+   int count = 0;
+-  
++
+   s = str;
+   while ((*s != '\0') && (count < number)) {
+-    while ((*s == ' ') || (*s == ',') || (*s == '=')) 
++    while ((*s == ' ') || (*s == ',') || (*s == '='))
+       s++;
+     if (*s != '\0') {
+       result[count++] = strtod(s,&s);
+     }
+   }
+-  while ((*s == ' ') || (*s == ',') || (*s == '=')) 
++  while ((*s == ' ') || (*s == ',') || (*s == '='))
+     s++;
+-  *end = s; 
++  *end = s;
+   return(count);
+ }
+ 
+@@ -3822,22 +3830,22 @@
+   int results[4],no;
+ 
+   s = str;
+-  while (*s == ' ') 
++  while (*s == ' ')
+     s++;
+   if ((StrCompare("drawfile",s,&s)) || (StrCompare("DVIview_diagram",s,&s))) {
+ 
+-    if (printdiag == _FALSE) 
++    if (printdiag == _FALSE)
+       return(_TRUE); /* it's a diagram, but don't print */
+ 
+-    while ((*s == ' ') || (*s == '=')) 
++    while ((*s == ' ') || (*s == '='))
+       s++; /* space or '=' separates keyword/keyval */
+ 
+     if (*s == '\0') {
+-      fprintf(ERR_STREAM,"No filename given for \\special-diagram!\n"); 
++      fprintf(ERR_STREAM,"No filename given for \\special-diagram!\n");
+       return(_TRUE);
+     }
+     sh = diagname;
+-    while ((*s != ' ') && (*s != ',') && (*s != '\0')) 
++    while ((*s != ' ') && (*s != ',') && (*s != '\0'))
+       *sh++ = *s++;
+     *sh = '\0';
+ 
+@@ -3845,7 +3853,7 @@
+     dt.scalex = dt.scaley = 100;
+     dt.cropl = dt.cropb = dt.cropr = dt.cropt = 0;
+     while (*s != '\0') {
+-      while ((*s == ' ') || (*s == ',')) 
++      while ((*s == ' ') || (*s == ','))
+         s++;
+       if (*s != '\0') {
+         if (StrCompare("scale",s,&s)) {
+@@ -3853,7 +3861,7 @@
+             fprintf(ERR_STREAM,
+                    "Too few arguments (%d) given for <scale> - ignored.\n",no);
+           }
+-          dt.scalex = results[0]; 
++          dt.scalex = results[0];
+           dt.scaley = results[1];
+         }
+         else if (StrCompare("crop",s,&s)) {
+@@ -3861,15 +3869,15 @@
+             fprintf(ERR_STREAM,
+                    "Too few arguments (%d) given for <crop> - ignored.\n",no);
+           }
+-          dt.cropl = results[0]; 
++          dt.cropl = results[0];
+           dt.cropr = results[1];
+-          dt.cropt = results[2]; 
++          dt.cropt = results[2];
+           dt.cropb = results[3];
+         }
+         else {
+           fprintf(ERR_STREAM,"Bad \\special keyword - <%s> ignored\n",s);
+           /* skip over this word */
+-          while ((*s != ' ') && (*s != ',') && (*s != '=') && (*s != '\0')) 
++          while ((*s != ' ') && (*s != ',') && (*s != '=') && (*s != '\0'))
+             s++;
+         }
+       }
+@@ -3879,7 +3887,7 @@
+     diagram(diagname,&dt);
+     return(_TRUE);
+   }
+-  else 
++  else
+     return(_FALSE);
+ }
+ # endif /* LJ */
+@@ -3895,70 +3903,58 @@
+ int  n;
+ #endif
+ {
+-  char    spbuf[STRSIZE], xs[STRSIZE], ys[STRSIZE];
+-  char    *sf = NULL, *psfile = NULL;
++  char    xs[STRSIZE], ys[STRSIZE];
++  char    *include_file = NULL;
++  enum    { VerbFile, HPFile, PSFile } file_type;
+   float   x,y;
+   long4   x_pos, y_pos;
+   KeyWord k;
+   int     i, j, j1;
+   static  int   GrayScale = 10, Pattern = 1;
+   static  bool  GrayFill = _TRUE;
+-  static  long4 p_x[80], p_y[80];
+-  int llx=0, lly=0, urx=0, ury=0, rwi=0, rhi=0;
+-#ifdef WIN32
+-  char    *gs_path;
+-#endif
++  static  long4 p_x[MAX_SPECIAL_DEFPOINTS], p_y[MAX_SPECIAL_DEFPOINTS];
++  int llx=0, lly=0, urx=0, ury=0, rwi=0;
+ 
+   str[n] = '\0';
+-  spbuf[0] = '\0';
++  for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ )
++    p_x[i] = p_y[i] = -1;
+ 
+   SetPosn(h, v);
+ #ifdef __riscos
+ #ifdef LJ
+-  if (ParseDiagram(str)) 
++  if (ParseDiagram(str))
+     return;
+ #endif
+ #endif
+- 
++
+   while ( (str = GetKeyStr(str, &k)) != NULL ) {
+     /* get all keyword-value pairs */
+     /* for compatibility, single words are taken as file names */
+     if ( k.vt == None && access(k.Key, 0) == 0) {
+-      if ( sf
+-#ifdef KPATHSEA
+-           && !kpse_tex_hush ("special")
+-#endif
+-         )
+-        Warning("More than one \\special file name given. %s ignored", sf);
+-      (void) strcpy(spbuf, k.Key);
+-      sf = spbuf;
+-      /*
+-        for (j = 1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++);
+-        */
+-    } else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 )
++      if ( include_file && !kpse_tex_hush ("special") ) {
++        Warning("More than one \\special file name given. %s ignored", include_file);
++	free (include_file);
++      }
++      include_file = xstrdup(k.Key);
++      file_type = VerbFile;
++    } else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 ) {
+       switch (i) {
+       case PSFILE:
+-        if (sf
+-#ifdef KPATHSEA
+-            && !kpse_tex_hush ("special")
+-#endif
+-            )
+-            Warning("More than one \\special file name given. %s ignored", sf);
+-        (void) strcpy(spbuf, k.Val);
+-        psfile = spbuf;
+-        /*
+-          for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++);
+-          */
++        if ( include_file ) {
++	  Warning("More than one \\special file name given. %s ignored", include_file);
++	  free(include_file);
++	}
++        include_file = xstrdup(k.Val);
++	file_type = PSFile;
+         break;
+-        
++
+       case HPFILE:
+-        if (sf)
+-            Warning("More than one \\special file name given. %s ignored", sf);
+-        (void) strcpy(spbuf, k.Val);
+-        sf = spbuf;
+-        /*
+-          for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++);
+-          */
++        if ( include_file && !kpse_tex_hush ("special") ) {
++	  Warning("More than one \\special file name given. %s ignored", include_file);
++	  free(include_file);
++	}
++        include_file = xstrdup(k.Val);
++	file_type = HPFile;
+         break;
+ 
+       case ORIENTATION:
+@@ -3977,24 +3973,26 @@
+           EMIT2("\033&l%dO\033*rF", (unsigned char)k.v.i);
+         }
+ #endif
+-        else
+-#ifdef KPATHSEA
+-           if (!kpse_tex_hush ("special"))
+-#endif
+-          Warning( "Invalid orientation (%d)given; ignored.", k.v.i);
++        else {
++	  Warning( "Invalid orientation (%d) given; ignored.", k.v.i);
++	}
+         break;
+ 
+       case RESETPOINTS:
+-        (void) strcpy(spbuf, k.Val);
+-
+-        sf = NULL;
++	for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ )
++	  p_x[i] = p_y[i] = -1;
+         break;
+ 
+       case DEFPOINT:
+-        (void) strcpy(spbuf, k.Val);
+-        i = sscanf(spbuf,"%d(%[^,],%s)",&j,xs,ys);
++	/* 254 is STRSIZE-1. cpp should be used to construct that number. */
++        i = sscanf(k.Val,"%d(%254[^,],%254s)",&j,xs,ys);
+         if (i>0) {
+-          x_pos = h; 
++	  if ( j < 0  ||  j >= MAX_SPECIAL_DEFPOINTS ) {
++	    Warning ("defpoint %d ignored, must be between 0 and %d",
++		     j, MAX_SPECIAL_DEFPOINTS);
++	    break;
++	  }
++          x_pos = h;
+           y_pos = v;
+           if (i>1) {
+             if (sscanf(xs,"%fpt",&x)>0) {
+@@ -4010,20 +4008,34 @@
+           }
+           p_x[j]=x_pos;
+           p_y[j]=y_pos;
+-        } else
+-#ifdef KPATHSEA
+-              if (!kpse_tex_hush ("special"))
+-#endif
+-          Warning("invalid point definition\n");
+-
+-        sf = NULL;
++        } else {
++	  Warning("invalid point definition");
++	}
+         break;
+ 
+       case FILL:
+-        (void) strcpy(spbuf, k.Val);
+-        i = sscanf(spbuf,"%d/%d %s",&j,&j1,xs);
++	/* 254 is STRSIZE-1. cpp should be used to construct that number. */
++        i = sscanf(k.Val,"%d/%d %254s",&j,&j1,xs);
+         if (i>1) {
+ #ifdef LJ
++	  if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) {
++	    Warning ("fill ignored, point %d must be between 0 and %d",
++		     j, MAX_SPECIAL_DEFPOINTS);
++	    break;
++	  }
++	  if ( p_x[j] == -1 ) {
++	    Warning ("fill ignored, point %d is undefined\n", j);
++	    break;
++	  }
++	  if ( j1 < 0 || j1 >= MAX_SPECIAL_DEFPOINTS ) {
++	    Warning ("fill ignored, point %d must be between 0 and %d",
++		     j1, MAX_SPECIAL_DEFPOINTS);
++	    break;
++	  }
++	  if ( p_x[j1] == -1 ) {
++	    Warning ("fill ignored, point %d is undefined\n", j1);
++	    break;
++	  }
+           SetPosn(p_x[j], p_y[j]);
+           x_pos = (long4)PIXROUND(p_x[j1]-p_x[j], hconv);
+           y_pos = (long4)PIXROUND(p_y[j1]-p_y[j], vconv);
+@@ -4043,22 +4055,18 @@
+         if ((k.v.i >= 0) && (k.v.i < 101)) {
+           GrayScale = k.v.i;
+           GrayFill = _TRUE;
+-        } else
+-#ifdef KPATHSEA
+-           if (!kpse_tex_hush ("special"))
+-#endif
++        } else {
+           Warning( "Invalid gray scale (%d) given; ignored.", k.v.i);
++	}
+         break;
+ 
+       case PATTERN:
+         if ((k.v.i >= 0) && (k.v.i < 7)) {
+           Pattern = k.v.i;
+           GrayFill = _FALSE;
+-        } else
+-#ifdef KPATHSEA
+-           if (!kpse_tex_hush ("special"))
+-#endif
++        } else {
+           Warning( "Invalid pattern (%d) given; ignored.", k.v.i);
++	}
+         break;
+ 
+       case LLX: llx = k.v.i; break;
+@@ -4066,103 +4074,161 @@
+       case URX: urx = k.v.i; break;
+       case URY: ury = k.v.i; break;
+       case RWI: rwi = k.v.i; break;
+-      case RHI: rhi = k.v.i; break;
++      case RHI:
++	if (!kpse_tex_hush ("special"))
++	  Warning("Whatever rhi was good for once, it is ignored now.");
++	break;
+ 
+       default:
+-#ifdef KPATHSEA
+-           if (!kpse_tex_hush ("special"))
+-#endif
+-        Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val);
++	if ( !kpse_tex_hush ("special") )
++	  Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val);
+         break;
+       }
+-      
+-    else
+-#ifdef KPATHSEA
+-           if (!kpse_tex_hush ("special"))
+-#endif
++
++    } else if (!kpse_tex_hush ("special")) {
+       Warning("Invalid keyword or value in \\special - <%s> ignored", k.Key);
++    }
++
++    free (k.Key);
++    if ( k.Val != NULL )  free(k.Val);
+   }
+ 
+-  if ( sf || psfile ) {
++  if ( include_file ) {
+     last_rx = last_ry = UNKNOWN;
+ #ifdef IBM3812
+     PMPflush;
+ #endif
+-    if (sf) {
+-      if (i == HPFILE) 
+-        CopyHPFile( sf );
+-      else 
+-        CopyFile( sf );
+-    }
+-    else
++
+ #ifdef LJ
+-      if (psfile) {
+-        /* int height = rwi * (urx - llx) / (ury - lly);*/
+-        int width  = urx - llx;
+-        int height = ury - lly;
+-        char cmd[255];
+-        int scale_factor    = 3000 * width / rwi;
+-        int adjusted_height = height * 300/scale_factor;
+-        int adjusted_llx    = llx    * 300/scale_factor;
+-        char *printer = "ljetplus"; /* use the most stupid one */
+-
+-
+-        char scale_file_name[255];
+-        char *scale_file = tmpnam(scale_file_name);
+-        char *pcl_file = tmpnam(NULL);  
+-        FILEPTR scalef;
+-
+-        if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) {
+-          Warning("Unable to open file %s for writing", scale_file );
+-          return;
+-        }
+-        fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n",  
+-                300.0/scale_factor, 300.0/scale_factor,
+-                0, adjusted_height == height ? 0 : ury);
+-        BCLOSE( scalef );
++    if ( file_type == PSFile) {
++      /* int height = rwi * (urx - llx) / (ury - lly);*/
++      int width  = urx - llx;
++      int height = ury - lly;
++      char cmd[255];
++      char *cmd_format = "%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit";
++      char *gs_cmd;
++      int scale_factor, adjusted_height, adjusted_llx;
++      char *printer = "ljetplus"; /* use the most stupid one */
++
++      char pcl_file[STRSIZE];
++      char scale_file[STRSIZE];
++      FILEPTR scalef;
++
++      if ( urx == 0 || ury == 0 || rwi == 0 ) {
++	/* Since dvips' psfile special has a different syntax, this might
++	   well be one of those specials, i.e., a non-dviljk special. Then
++	   the Warning should be suppressable. */
++	if ( !kpse_tex_hush ("special") )
++	  Warning ("Ignoring psfile special without urx, ury and rwi attributes");
++	free (include_file);
++	return;
++      }
++      scale_factor    = 3000 * width / rwi;
++      adjusted_height = height * 300/scale_factor;
++      adjusted_llx    = llx    * 300/scale_factor;
++
++      /* We cannot use mkstemp, as we cannot pass two open file descriptors
++	 portably to Ghostscript. We don't want to use tmpnam() or tempnam()
++	 either, as they have tempfile creation race conditions. Instead we
++	 create a temporary directory with mkdtemp() -- if that's available.
++	 If not, we are thrown back to tempnam(), to get our functionality
++	 at all. We need to create the temporary directory only once per
++	 run; it will be deleted in AllDone(). */
++      if ( tmp_dir[0] == '\0' ) {
++	char * base_dir;
++	if ( (base_dir = getenv("TMPDIR")) == NULL ) {
++	  base_dir = "/tmp";
++	} else if ( strlen(base_dir) > STRSIZE - sizeof("/dviljkXXXXXX/include.pcl") ) {
++	  Warning ("TMPDIR %s is too long, using /tmp instead", base_dir);
++	  base_dir = "/tmp";
++	}
++	if ( base_dir[0] == '/'  && base_dir[1] == '\0' ) {
++	  Warning ("Feeling naughty, do we? / is no temporary directory, dude");
++	  base_dir = "/tmp";
++	}
++	strcpy (tmp_dir, base_dir);
++	strcat (tmp_dir, "/dviljkXXXXXX");
++	if ( mkdtemp(tmp_dir) == NULL ) {
++	  Warning ("Could not create temporary directory %s, errno = %d; ignoring include file special",
++		   tmp_dir, errno);
++	  return;
++	}
++      }
++      strcpy(pcl_file, tmp_dir);
++      strcat(pcl_file, "/include.pcl");
++      strcpy(scale_file, tmp_dir);
++      strcat(scale_file, "/scale.ps");
++
++      if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) {
++	Warning("Unable to open file %s for writing", scale_file );
++	free (include_file);
++	unlink(scale_file);		/* ignore error */
++	return;
++      }
++      fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n",
++	      300.0/scale_factor, 300.0/scale_factor,
++	      0, adjusted_height == height ? 0 : ury);
++      BCLOSE( scalef );
+ 
+ #ifdef WIN32
+-	gs_path = getenv("GS_PATH");
+-	if (!gs_path)
+-	  gs_path = "gswin32c.exe";
+-        sprintf(cmd,"%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit",
+-		gs_path, printer, pcl_file, scale_file, psfile);
+-#else
+-        sprintf(cmd,"gs -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit",
+-                printer, pcl_file, scale_file, psfile);
+-#endif
+-#ifdef DEBUGGS   
+-        fprintf(stderr,
+-          "PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n",
+-                psfile, urx - llx, height, urx,ury,llx,lly, rwi);
+-        fprintf(stderr,"%s\n",cmd);
++      if ( (gs_cmd = getenv("GS_PATH")) == NULL )
++	gs_cmd = "gswin32c.exe";
++#else
++      gs_cmd = "gs";
+ #endif
+-        if (system(cmd)) {
+-          Warning("execution of '%s' returned an error", cmd);
+-        } else {
+-#ifdef DEBUGGS   
+-          fprintf(stderr, "o=%d, h=%d, so=%d, sh=%d\n", 
+-                  llx, height, adjusted_llx, adjusted_height);
+-          
+-          fprintf(stderr, "OLD x=%d, y=%d\n", 
+-                  (int)PIXROUND(h, hconv) + x_goffset,
+-                  (int)PIXROUND(v, vconv) + y_goffset);
+-#endif  
+-          v -= 65536l*adjusted_height; /**300/scale_factor;*/
+-          h -= 65536l*adjusted_llx; /* *300/scale_factor;*/
+-          SetPosn(h, v);
+-#ifdef DEBUGGS   
+-          fprintf(stderr, "NEW x=%d, y=%d\n", 
+-                  (int)PIXROUND(h, hconv) + x_goffset,
+-                  (int)PIXROUND(v, vconv) + y_goffset);
+-#endif
+-
+-          CopyHPFile( pcl_file );
+-          /* unlink(pcl_file); */
+-          /* unlink(scale_file); */
+-        }
++      if ( strlen(cmd_format)-10 + strlen(gs_cmd) + strlen(printer) +
++	       strlen(pcl_file) + strlen(scale_file) + strlen(include_file) +1 >
++	   sizeof(cmd) ) {
++	Warning ("Ghostscript command for %s would be too long, skipping special", include_file);
++	free (include_file);
++	unlink(scale_file);		/* ignore errors */
++	unlink(pcl_file);
++	return;
++      }
++      sprintf(cmd, cmd_format,
++	      gs_cmd, printer, pcl_file, scale_file, include_file);
++#ifdef DEBUGGS
++      fprintf(stderr,
++	"PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n",
++	      include_file, urx - llx, height, urx,ury,llx,lly, rwi);
++      fprintf(stderr,"%s\n",cmd);
++#endif
++      if (system(cmd)) {
++	Warning("execution of '%s' returned an error", cmd);
++      } else {
++#ifdef DEBUGGS
++	fprintf(stderr, "o=%d, h=%d, so=%d, sh=%d\n",
++		llx, height, adjusted_llx, adjusted_height);
++
++	fprintf(stderr, "OLD x=%d, y=%d\n",
++		(int)PIXROUND(h, hconv) + x_goffset,
++		(int)PIXROUND(v, vconv) + y_goffset);
++#endif
++	v -= 65536l*adjusted_height; /**300/scale_factor;*/
++	h -= 65536l*adjusted_llx; /* *300/scale_factor;*/
++	SetPosn(h, v);
++#ifdef DEBUGGS
++	fprintf(stderr, "NEW x=%d, y=%d\n",
++		(int)PIXROUND(h, hconv) + x_goffset,
++		(int)PIXROUND(v, vconv) + y_goffset);
++#endif
++
++	CopyHPFile( pcl_file );
+       }
++      unlink(scale_file);		/* ignore errors */
++      unlink(pcl_file);
++    }
++    else
+ #endif /* LJ */
++
++    if ( file_type == HPFile )
++      CopyHPFile( include_file );
++    else if ( file_type == VerbFile )
++      CopyFile( include_file );
++    else
++      Warning ("This can't happen: unknown file_type value %d", file_type);
++
++    if ( include_file != NULL )  free(include_file);
+   }
+ }
+ 
+@@ -4173,12 +4239,11 @@
+ /**********************************************************************/
+ /*****************************  GetKeyStr  ****************************/
+ /**********************************************************************/
+-/* extract first keyword-value pair from string (value part may be null)
+- * return pointer to remainder of string
+- * return NULL if none found
++/* Extract first keyword-value pair from string (value part may be null),
++ * keyword and value are allocated and must be free by caller.
++ * Return pointer to remainder of string,
++ * return NULL if none found.
+  */
+-char    KeyStr[STRSIZE];
+-char    ValStr[STRSIZE];
+ #if NeedFunctionPrototypes
+ char *GetKeyStr(char *str, KeyWord *kw )
+ #else
+@@ -4187,39 +4252,46 @@
+ KeyWord *kw;
+ #endif
+ {
+-  char    *s, *k, *v, t;
++  char *s, *start;
++  char save_char, quote_char;
+   if ( !str )
+     return( NULL );
+   for (s = str; *s == ' '; s++)
+     ;          /* skip over blanks */
+   if (*s == '\0')
+     return( NULL );
+-  for (k = KeyStr; /* extract keyword portion */
+-       *s != ' ' && *s != '\0' && *s != '=';
+-       *k++ = *s++)
+-    ;
+-  *k = '\0';
+-  kw->Key = KeyStr;
+-  kw->Val = v = NULL;
++  start = s++;				/* start of keyword */
++  while ( *s != ' ' && *s != '\0' && *s != '=' )  /* locate end */
++    s++;
++  save_char = *s;
++  *s = '\0';
++  kw->Key = xstrdup(start);
++  kw->Val = NULL;
+   kw->vt = None;
+-  for ( ; *s == ' '; s++)
+-    ;            /* skip over blanks */
+-  if ( *s != '=' )         /* look for "=" */
++  if ( save_char == '\0' )		/* shortcut when we're at the end */
++    return (s);
++  *s = save_char;			/* restore keyword end char */
++  while ( *s == ' ' ) s++ ;		/* skip over blanks */
++  if ( *s != '=' )			/* no "=" means no value */
+     return( s );
+-  for (s++; *s == ' '; s++);      /* skip over blanks */
+-  if ( *s == '\'' || *s == '\"' )  /* get string delimiter */
+-    t = *s++;
++  for (s++; *s == ' '; s++)
++    ;					/* skip over blanks */
++  if ( *s == '\'' || *s == '\"' )	/* get string delimiter */
++    quote_char = *s++;
+   else
+-    t = ' ';
+-  for (v = ValStr; /* copy value portion up to delim */
+-       *s != t && *s != '\0';
+-       *v++ = *s++)
+-    ;
+-  if ( t != ' ' && *s == t )
+-    s++;
+-  *v = '\0';
+-  kw->Val = ValStr;
++    quote_char = ' ';
++  start = s;				/* no increment, might be "" as value */
++  while ( *s != quote_char && *s != '\0' )
++    s++;			  /* locate end of value portion */
++  save_char = *s;
++  *s = '\0';
++  kw->Val = xstrdup(start);
+   kw->vt = String;
++  if ( save_char != '\0' ) {		/* save_char is now quote_char */
++    *s = save_char;
++    if ( quote_char != ' ' )		/* we had real quote chars */
++      s++;
++  }
+   return( s );
+ }
+ 
+@@ -4281,7 +4353,7 @@
+ #endif
+ {
+   char *x, *y;
+-  
++
+   for (x = a, y = b; *a; a++, b++)
+     if ( tolower(*a) != tolower(*b) )
+       return( _FALSE );
+@@ -4469,10 +4541,10 @@
+        *   process for simplicity always horizontally
+        */
+ 
+-      /* 
++      /*
+          fprintf(ERR_STREAM,"large box: w=%d,x=%d,y=%d\n",(int)yy,(int)xx,0);
+          */
+-      
++
+       hor_offset  = HOR_HALF(30);
+       MoveHor(hor_offset);
+       vert_offset = VERT_HALF(30);
+@@ -4547,7 +4619,7 @@
+       yy += (long4)pgsiz_dots - (long4)last_ry;
+ 
+     if ((yy>0) && (xx>0))
+-      EMIT4("\033*p-%ldY\033*c%lda%ldbP", 
++      EMIT4("\033*p-%ldY\033*c%lda%ldbP",
+             (long)yy - 1, (long)xx, (long)yy);
+ #endif
+     last_rx = last_ry = UNKNOWN;       /* next time full positioning */
+@@ -4708,7 +4780,7 @@
+       if ((fid = pixel_files[least_used].pixel_file_id) != NO_FILE) {
+         /* mark file as being closed in the entry */
+         fp = hfontptr;
+-        while (fp != NULL && fp->font_file_id != fid) 
++        while (fp != NULL && fp->font_file_id != fid)
+           fp = fp->next;
+         if (fp == NULL)
+           Fatal("Open file %x not found in font entry list.\n", fid);
+@@ -4763,9 +4835,9 @@
+       while ((fp != NULL) && (fp->font_file_id != f))
+         fp = fp->next;
+ 
+-      if (fp == NULL) 
++      if (fp == NULL)
+         Fatal("Open file %x not found in font entry list.\n",f);
+-      else 
++      else
+         fp->font_file_id = FPNULL;
+     }
+     BCLOSE(f);
+@@ -4819,13 +4891,14 @@
+      the resident fonts.  */
+   if (tfm_read_info(fontptr->n, &tfm_info)
+       && tfm_info.family[0]
+-      && strcmp((char *)tfm_info.family, "HPAUTOTFM") == 0) {
++      && EQ((char *)tfm_info.family, "HPAUTOTFM")) {
+     unsigned i;
+     double factor = fontptr->s / (double)0x100000;
+ 
+     resident_count++;
+     fontptr->resident_p = _TRUE;
+-    strcpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme);
++    strncpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme, 39);
++    fontptr->symbol_set[39] = '\0';
+     fontptr->resid = tfm_info.typeface_id;
+     fontptr->spacing = tfm_info.spacing;
+     fontptr->style = tfm_info.style;
+@@ -4878,7 +4951,7 @@
+     fontptr->resident_p = _FALSE;
+ 
+     if (tfm_info.family[0]
+-        && strcmp((char *)tfm_info.family, "UNSPECIFIED") == 0) {
++        && EQ((char *)tfm_info.family, "UNSPECIFIED")) {
+       Warning("font family for %s is UNSPECIFIED; need to run dvicopy?",
+               fontptr->n);
+       fontptr->font_file_id = NO_FILE;
+@@ -5005,7 +5078,7 @@
+   GetBytes(dvifp, tfontptr->n, tfontptr->a + tfontptr->l);
+   tfontptr->n[tfontptr->a+tfontptr->l] = '\0';
+ 
+-  tfontptr->font_mag = 
++  tfontptr->font_mag =
+     (long4)((ActualFactor((long4)(1000.0*tfontptr->s/(double)tfontptr->d+0.5))
+              * ActualFactor(mag)
+ #ifdef USEPXL
+@@ -5031,10 +5104,9 @@
+   if (tfontptr->resident_p)
+     return;
+ 
+-  if (!(resident_font_located)) {
++  if (!(resident_font_located))
+ #endif
+ 
+-#ifdef KPATHSEA
+     {
+       kpse_glyph_file_type font_ret;
+       char *name;
+@@ -5042,14 +5114,14 @@
+         = kpse_magstep_fix ((unsigned) (tfontptr->font_mag / 5.0 + .5),
+                             RESOLUTION, NULL);
+       tfontptr->font_mag = dpi * 5; /* save correct dpi */
+-      
++
+       name = kpse_find_pk (tfontptr->n, dpi, &font_ret);
+       if (name)
+         {
+           font_found = _TRUE;
+-          strcpy (tfontptr->name, name);
+-          free (name);
+-          
++          tfontptr->name = name;
++          allocated_storage += strlen(name)+1;
++
+           if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) {
+               fprintf (stderr,
+                        "dvilj: Font %s not found, using %s at %d instead.\n",
+@@ -5071,29 +5143,6 @@
+             tfontptr->n, dpi);
+         }
+     }
+-#else /* not KPATHSEA */
+-    if (!(findfile(PXLpath,
+-                   tfontptr->n,
+-                   tfontptr->font_mag,
+-                   tfontptr->name,
+-                   _FALSE,
+-                   0))) {
+-      Warning(tfontptr->name); /* contains error messsage */
+-      tfontptr->font_file_id = NO_FILE;
+-#ifdef __riscos
+-      MakeMetafontFile(PXLpath, tfontptr->n, tfontptr->font_mag);
+-#endif
+-    }
+-    else {
+-      font_found = _TRUE;
+-      if (G_verbose)
+-        fprintf(ERR_STREAM,"%d: using font <%s>\n", plusid, tfontptr->name);
+-    }
+-#endif /* not KPATHSEA */
+-
+-#ifdef LJ_RESIDENT_FONTS
+-  }
+-#endif
+ 
+   tfontptr->plusid = plusid;
+   plusid++;
+@@ -5107,7 +5156,7 @@
+           HANDLE_MAX_FONTS);
+ #endif
+   if (tfontptr != pfontptr) {
+-    if (font_found) 
++    if (font_found)
+       OpenFontFile();
+     else
+       pxlfp = NO_FILE;
+@@ -5146,7 +5195,7 @@
+     if (t == PK_PRE) {
+       unsigned char   temp_byte;
+       temp_byte = (unsigned char) NoSignExtend(pxlfp, 1);
+-      if (temp_byte != PK_ID) 
++      if (temp_byte != PK_ID)
+         Fatal( "Wrong Version of pk file!  (%d should be 89)\n",
+                (int)temp_byte);
+       else
+@@ -5163,7 +5212,7 @@
+ 
+     tfontptr->magnification = NoSignExtend(pxlfp, 4);
+     tfontptr->designsize    = NoSignExtend(pxlfp, 4);
+-        
++
+     if (tfontptr->id == id1001)
+       FSEEK(pxlfp, (long)(NoSignExtend(pxlfp, 4) * 4), SEEK_SET);
+     else
+@@ -5232,7 +5281,7 @@
+     hppp = NoSignExtend(pxlfp, 4);
+     vppp = NoSignExtend(pxlfp, 4);
+     if (hppp != vppp)
+-      Warning("aspect ratio is %ld:%ld (should be 1:1)!", 
++      Warning("aspect ratio is %ld:%ld (should be 1:1)!",
+               (long)hppp, (long)vppp);
+     tfontptr->magnification = (long4)(hppp * 72.27 * 5 / 65536l + 0.5);
+ 
+@@ -5515,7 +5564,7 @@
+ {
+   int     a, l;
+   char    n[STRSIZE];
+-  
++
+   (void) NoSignExtend(dvifp, 4);
+   (void) NoSignExtend(dvifp, 4);
+   (void) NoSignExtend(dvifp, 4);
+@@ -5524,7 +5573,7 @@
+   GetBytes(dvifp, n, a + l);
+ }
+ 
+-    
++
+ 
+ /*------------------------ end dvifont.c -------------------------------*/
+ 
+@@ -5598,7 +5647,7 @@
+ #endif
+   if ( G_nowarn || G_quiet )
+     return;
+-  
++
+   fprintf(ERR_STREAM, "%s: warning: ", G_progname);
+   vfprintf(ERR_STREAM, fmt, args);
+   fprintf(ERR_STREAM, "\n");
+Index: texlive-bin-2007/build/source/texk/dviljk/dvi2xx.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dviljk/dvi2xx.h	2007-07-03 13:44:51.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dviljk/dvi2xx.h	2007-07-03 13:45:10.000000000 +0200
+@@ -10,8 +10,8 @@
+ 
+ #ifdef KPATHSEA
+ #include <kpathsea/config.h>
++#include <kpathsea/c-std.h>
+ #include <kpathsea/c-limits.h>
+-#include <kpathsea/c-memstr.h>
+ #include <kpathsea/magstep.h>
+ #include <kpathsea/proginit.h>
+ #include <kpathsea/progname.h>
+@@ -24,6 +24,7 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <unistd.h>
+ #ifdef  unix
+ #include <limits.h>
+ #endif
+@@ -41,9 +42,6 @@
+ #ifdef MSC5
+ #include <dos.h>     /* only for binaryopen on device  */
+ #endif
+-#if defined (unix) && !defined (KPATHSEA)
+-#include <limits.h>
+-#endif
+ 
+ 
+ #include "config.h"
+@@ -116,6 +114,7 @@
+ #define  HUGE_SIZE  (unsigned char) 2
+ #define  HUGE_CHAR_PATTERN 32767l
+ #define  BYTES_PER_PIXEL_LINE 500    /* max number of bytes per pixel line */
++#define  MAX_SPECIAL_DEFPOINTS 80    /* max number of defpoint specials */
+ 
+ 
+ #define PK_POST 245
+@@ -281,7 +280,14 @@
+ #define VisChar(c) (unsigned char)(c)
+ #endif
+ 
+-#define GetBytes(fp,buf,n) read_multi(buf,1,n,fp) /* used to be a function */
++/* Used to be a function. buf is always an array, never a pointer.
++   Without that invariant, we would have to introduce full dynamic
++   memory management in this driver -- probably it would be easier to
++   write a new one. [27 Jun 07 -js] */
++#define GetBytes(fp,buf,n) \
++    ( sizeof(buf) != sizeof(void *) && sizeof(buf) > n ? \
++        read_multi(buf, 1, n, fp) \
++      : Fatal("Try to read %d bytes in an array of size %d", n, sizeof(buf)) )
+ 
+ 
+ /**********************************************************************/
+@@ -307,6 +313,7 @@
+ int     sscanf();
+ int     strcmp();
+ char   *strcpy();
++char   *strncpy();
+ #   ifdef MSC5
+ unsigned int strlen();
+ #   endif
+@@ -393,7 +400,7 @@
+     char n[STRSIZE];          /* FNT_DEF command parameters                */
+     long4    font_mag;         /* computed from FNT_DEF s and d parameters  */
+     /*char psname[STRSIZE];*/ /* PostScript name of the font               */
+-    char    name[STRSIZE];    /* full name of PXL file                     */
++    char    *name;	       /* full name of PXL file                     */
+     FILEPTR font_file_id;      /* file identifier (NO_FILE if none)         */
+ #ifdef USEPXL
+     long4    magnification;    /* magnification read from PXL file          */
+@@ -487,8 +494,8 @@
+ long4   NoSignExtend DVIPROTO((FILEPTR, int));
+ void    OpenFontFile DVIPROTO((void));
+ long4   PixRound DVIPROTO((long4, long4));
+-void    PkRaster DVIPROTO((struct char_entry *, int)); 
+-void    RasterLine DVIPROTO((struct char_entry *, unsigned int, 
++void    PkRaster DVIPROTO((struct char_entry *, int));
++void    RasterLine DVIPROTO((struct char_entry *, unsigned int,
+ 			     unsigned int, unsigned char *));
+ void    RasterChar DVIPROTO((struct char_entry *));
+ void    ReadFontDef DVIPROTO((long4));
+@@ -534,11 +541,12 @@
+ #ifndef KPATHSEA
+ char   *PXLpath = FONTAREA;
+ #endif
+-char    G_progname[STRSIZE];     /* program name                        */
+-char    filename[STRSIZE];       /* DVI file name                       */
+-char    rootname[STRSIZE];       /* DVI filename without extension      */
++char   *G_progname;		 /* program name                        */
++char   *filename;	         /* DVI file name                       */
++char   *rootname;		 /* DVI filename without extension      */
+ char   *HeaderFileName = "";     /* file name & path of Headerfile      */
+ char   *EmitFileName = "";       /* file name & path for output         */
++char    tmp_dir[STRSIZE] = "";	 /* temporary directory for auxilliary files */
+ #ifdef IBM3812
+ bool    FirstAlternate = _FALSE; /* first page from alternate casette ?   */
+ #endif
--- texlive-bin-2007.dfsg.2.orig/debian/patches/53_builtin-searchpath-fix
+++ texlive-bin-2007.dfsg.2/debian/patches/53_builtin-searchpath-fix
@@ -0,0 +1,85 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 53_builtin-searchpath-fix.dpatch
+##
+## DP: adjust built-in search paths for kpathsea library to Debian standard
+
+@DPATCH@
+ build/source/texk/kpathsea/Makefile.in |    5 -----
+ build/source/texk/kpathsea/texmf.in    |   14 +++++++-------
+ 2 files changed, 7 insertions(+), 12 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/kpathsea/Makefile.in
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/kpathsea/Makefile.in	2007-01-08 00:31:48.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/kpathsea/Makefile.in	2007-01-26 04:02:50.000000000 +0100
+@@ -127,11 +127,6 @@
+ 	| sed '/^$$/d' \
+ 	| sed 's/^\([^ 	=]*\)[ 	]*=*[ 	]*\(.*\)/#ifndef DEFAULT_\1%#define DEFAULT_\1 "\2"%#endif/' \
+ 	| tr '%' '\012' \
+-	| sed -e 's%\$$TEXMFMAIN%$(texmf)%g' \
+-	      -e 's%\$$TEXMF%$(texmf)%g' \
+-	      -e 's%\$$VARTEXFONTS%$(vartexfonts)%g' \
+-	      -e 's%\$$web2cdir%$(web2cdir)%g' \
+-	      -e 's%\$$prefix%$(prefix)%g' \
+ 	| sed -e 's%;%:%g' \
+ 	>>paths.tmp
+ 	@if cmp -s paths.h paths.tmp 2>/dev/null; then \
+Index: texlive-bin-2006.svn3816/build/source/texk/kpathsea/texmf.in
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/kpathsea/texmf.in	2007-01-20 01:38:30.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/kpathsea/texmf.in	2007-01-26 04:02:50.000000000 +0100
+@@ -56,15 +56,15 @@
+ 
+ % The tree containing the runtime files closely related to the specific
+ % program version used:
+-TEXMFMAIN = @texmf@
++TEXMFMAIN = /usr/share/texmf
+ 
+ % The main distribution tree:
+-TEXMFDIST = @texmf@-dist
++TEXMFDIST = /usr/share/texmf-texlive
+ 
+ % A place for local additions to a "standard" texmf tree.
+ % This tree is not used for local configuration maintained by
+ % texconfig, it uses TEXMFCONFIG below.
+-TEXMFLOCAL = @texmf@-local
++TEXMFLOCAL = /usr/local/share/texmf
+ 
+ % TEXMFSYSVAR, where texconfig-sys stores variable runtime data.
+ % With teTeX-3.0 or later, this must be set.
+@@ -72,7 +72,7 @@
+ %   TEXMFSYSVAR = $TEXMFMAIN
+ % For using a separate tree:
+ %   TEXMFSYSVAR = @texmf@-var
+-TEXMFSYSVAR = @texmf@-var
++TEXMFSYSVAR = /var/lib/texmf
+ 
+ % TEXMFSYSCONFIG, where texconfig-sys stores configuration data.
+ % With teTeX-3.0 or later, this must be set.
+@@ -80,7 +80,7 @@
+ %   TEXMFSYSCONFIG = $TEXMFMAIN
+ % For using a separate tree:
+ %   TEXMFSYSCONFIG = @texmf@-config
+-TEXMFSYSCONFIG = @texmf@-config
++TEXMFSYSCONFIG = /etc/texmf
+ 
+ % User texmf trees are allowed as follows.
+ % This used to be HOMETEXMF.
+@@ -122,7 +122,7 @@
+ % Where generated fonts may be written.  This tree is used when the sources
+ % were found in a system tree and either that tree wasn't writable, or the
+ % varfonts feature was enabled in MT_FEATURES in mktex.cnf.
+-VARTEXFONTS = @vartexfonts@
++VARTEXFONTS = /var/cache/fonts
+ 
+ % Where to look for ls-R files.  There need not be an ls-R in the
+ % directories in this path, but if there is one, Kpathsea will use it.
+@@ -382,7 +382,7 @@
+ %
+ % For security reasons, it is better not to have . part of the path.
+ %
+-TEXMFCNF = {$SELFAUTOLOC,$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,}/web2c};/.$TETEXDIR;$TEXMF/web2c;@web2c@
++TEXMFCNF = /usr/share/texmf/web2c;/usr/share/texmf-texlive/web2c;/usr/local/share/texmf/web2c
+ 
+ # $progname: kpathsea v. 3.5.3 or later overwrites this at runtime. To
+ # avoid empty expansions from binaries linked against an earlier
--- texlive-bin-2007.dfsg.2.orig/debian/patches/30_libpoppler_0.4.5
+++ texlive-bin-2007.dfsg.2/debian/patches/30_libpoppler_0.4.5
@@ -0,0 +1,440 @@
+# 30_libpoppler.dpatch
+#
+# use libpoppler instead of libxpdf in pdfetex and xetex
+# don't build pdftosrc as it needs libpoppler from experimental 
+
+@DPATCH@
+ build/source/configure                         |    6 +-
+ build/source/configure.in                      |    8 +--
+ build/source/texk/web2c/pdftexdir/Makefile.in  |    2 
+ build/source/texk/web2c/pdftexdir/depend.mk    |   58 +------------------------
+ build/source/texk/web2c/pdftexdir/pdftex.mk    |    9 ++-
+ build/source/texk/web2c/pdftexdir/pdftoepdf.cc |   43 +++++++++---------
+ build/source/texk/web2c/pdftexdir/pdftosrc.cc  |   37 ++++++++-------
+ build/source/texk/web2c/pdftexdir/utils.c      |    4 -
+ build/source/texk/web2c/xetexdir/XeTeX_ext.c   |    4 -
+ build/source/texk/web2c/xetexdir/pdfimage.cpp  |   24 ++++++++--
+ build/source/texk/web2c/xetexdir/xetex.mk      |    8 ++-
+ 11 files changed, 87 insertions(+), 116 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/depend.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/depend.mk	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/depend.mk	2007-04-16 15:30:03.000000000 +0200
+@@ -1,55 +1,5 @@
+-epdf.o: epdf.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-mapfile.o: mapfile.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-papersiz.o: papersiz.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-utils.o: utils.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h \
+- ../../../libs/zlib/zlib.h ../../../libs/zlib/zconf.h \
+- ../../../libs/md5/md5.h pdftexextra.h \
+- ../../../libs/obsdcompat/openbsd-compat.h
+-vfpacket.o: vfpacket.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-pkin.o: pkin.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writefont.o: writefont.c ../../../libs/xpdf/goo/gmem.h ptexlib.h \
+- ../pdftexd.h ../texmfmp.h ../cpascal.h ../config.h ../help.h \
+- ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writet1.o: writet1.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writet3.o: writet3.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writezip.o: writezip.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h ../../../libs/zlib/zlib.h ../../../libs/zlib/zconf.h
+-writeenc.o: writeenc.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-writettf.o: writettf.c ptexlib.h writettf.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h macnames.c
+-writejpg.o: writejpg.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-writepng.o: writepng.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-writeimg.o: writeimg.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-pdftoepdf.o: pdftoepdf.cc ../../../libs/xpdf/xpdf/Object.h \
+- ../../../libs/xpdf/goo/gmem.h ../../../libs/xpdf/xpdf/Array.h \
+- ../../../libs/xpdf/xpdf/Dict.h ../../../libs/xpdf/xpdf/Stream.h \
+- ../../../libs/xpdf/xpdf/XRef.h ../../../libs/xpdf/xpdf/Catalog.h \
+- ../../../libs/xpdf/xpdf/Page.h ../../../libs/xpdf/xpdf/GfxFont.h \
+- ../../../libs/xpdf/xpdf/Error.h epdf.h
++pdftoepdf.o: pdftoepdf.cc epdf.h ../../kpathsea/c-auto.h \
++  ../../kpathsea/c-proto.h ../../web2c/c-auto.h ../../web2c/config.h \
++  ../../kpathsea/c-fopen.h ../../web2c/pdftexdir/ptexmac.h
+ ttf2afm.o: ttf2afm.c writettf.h macnames.c
+-pdftosrc.o: pdftosrc.cc ../../../libs/xpdf/xpdf/Object.h \
+- ../../../libs/xpdf/xpdf/Array.h ../../../libs/xpdf/xpdf/Dict.h \
+- ../../../libs/xpdf/xpdf/Stream.h ../../../libs/xpdf/xpdf/XRef.h \
+- ../../../libs/xpdf/xpdf/Catalog.h ../../../libs/xpdf/xpdf/Page.h \
+- ../../../libs/xpdf/xpdf/PDFDoc.h ../../../libs/xpdf/xpdf/Link.h \
+- ../../../libs/xpdf/xpdf/Error.h ../../../libs/xpdf/xpdf/config.h
++pdftosrc.o: pdftosrc.cc
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftoepdf.cc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftoepdf.cc	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftoepdf.cc	2007-04-16 15:30:03.000000000 +0200
+@@ -26,25 +26,24 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <aconf.h>
+-#include <GString.h>
+-#include <gmem.h>
+-#include <gfile.h>
+-#include <config.h>
+ #include <assert.h>
+-#include "Object.h"
+-#include "Stream.h"
+-#include "Array.h"
+-#include "Dict.h"
+-#include "XRef.h"
+-#include "Catalog.h"
+-#include "Link.h"
+-#include "Page.h"
+-#include "GfxFont.h"
+-#include "PDFDoc.h"
+-#include "GlobalParams.h"
+-#include "Error.h"
+-
++#include <dirent.h>
++#include <poppler/poppler-config.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Link.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
+ #include "epdf.h"
+ 
+ // This file is mostly C and not very much C++; it's just used to interface
+@@ -169,7 +168,7 @@
+     fprintf(stderr, "\npdfTeX Debug: Creating %s (%d)\n", p->file_name,
+             p->occurences);
+ #endif
+-    GString *docName = new GString(p->file_name);
++    GooString *docName = new GooString(p->file_name);
+     p->doc = new PDFDoc(docName);       // takes ownership of docName
+     if (!p->doc->isOk() || !p->doc->okToPrint()) {
+         pdftex_fail("xpdf: reading PDF image failed");
+@@ -511,7 +510,7 @@
+     int i, l, c;
+     Ref ref;
+     char *p;
+-    GString *s;
++    GooString *s;
+     if (obj->isBool()) {
+         pdf_printf("%s", obj->getBool()? "true" : "false");
+     } else if (obj->isInt()) {
+@@ -677,7 +676,7 @@
+     float pdf_version_found, pdf_version_wanted;
+     // initialize
+     if (!isInit) {
+-        globalParams = new GlobalParams();
++        globalParams = new GlobalParams(NULL);
+         globalParams->setErrQuiet(gFalse);
+         isInit = gTrue;
+     }
+@@ -703,7 +702,7 @@
+     epdf_num_pages = pdf_doc->doc->getCatalog()->getNumPages();
+     if (page_name) {
+         // get page by name
+-        GString name(page_name);
++        GooString name(page_name);
+         LinkDest *link = pdf_doc->doc->findDest(&name);
+         if (link == 0 || !link->isOk())
+             pdftex_fail("PDF inclusion: invalid destination <%s>", page_name);
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftosrc.cc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftosrc.cc	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftosrc.cc	2007-04-16 15:30:03.000000000 +0200
+@@ -25,22 +25,23 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <aconf.h>
+ #include <assert.h>
+-#include <GString.h>
+-#include <gmem.h>
+-#include <gfile.h>
+-#include "Object.h"
+-#include "Stream.h"
+-#include "Array.h"
+-#include "Dict.h"
+-#include "XRef.h"
+-#include "Catalog.h"
+-#include "Page.h"
+-#include "GfxFont.h"
+-#include "PDFDoc.h"
+-#include "GlobalParams.h"
+-#include "Error.h"
++
++#include <dirent.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
+ 
+ static XRef *xref = 0;
+ 
+@@ -48,7 +49,7 @@
+ {
+     char *p, buf[1024];
+     PDFDoc *doc;
+-    GString *fileName;
++    GooString *fileName;
+     Stream *s;
+     Object srcStream, srcName, catalogDict;
+     FILE *outfile;
+@@ -62,8 +63,8 @@
+                 "Usage: pdftosrc <PDF-file> [<stream-object-number>]\n");
+         exit(1);
+     }
+-    fileName = new GString(argv[1]);
+-    globalParams = new GlobalParams();
++    fileName = new GooString(argv[1]);
++    globalParams = new GlobalParams(NULL);
+     doc = new PDFDoc(fileName);
+     if (!doc->isOk()) {
+         fprintf(stderr, "Invalid PDF file\n");
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/Makefile.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/Makefile.in	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/Makefile.in	2007-04-16 15:30:03.000000000 +0200
+@@ -8,7 +8,7 @@
+ kpathsea_srcdir_parent = $(srcdir)/../..
+ kpathsea_dir_parent = ../..
+ 
+-ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) @LIBXPDFCPPFLAGS@ -I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/..
++ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) -I/usr/include/poppler -I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/..
+ CXX = @CXX@
+ 
+ .SUFFIXES: .cc .o
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftex.mk	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftex.mk	2007-04-16 15:30:03.000000000 +0200
+@@ -2,6 +2,9 @@
+ # This fragment contains the parts of the makefile that are most likely to
+ # differ between releases of pdfeTeX.
+ 
++# use libpoppler instead of included xpdf code
++ADDLDFLAGS = -lpoppler
++
+ # We build pdftex
+ pdftex = @PETEX@ pdftex
+ pdftexdir = pdftexdir
+@@ -29,7 +32,7 @@
+ 
+ # Making pdftex
+ pdftex: pdftexd.h $(pdftex_o) $(pdftexextra_o) $(pdftexlibsdep)
+-	@CXXHACKLINK@ $(pdftex_o) $(pdftexextra_o) $(pdftexlibs) $(socketlibs) @CXXHACKLDLIBS@ @CXXLDEXTRA@
++	@CXXHACKLINK@ $(pdftex_o) $(pdftexextra_o) $(pdftexlibs) $(socketlibs) @CXXHACKLDLIBS@ @CXXLDEXTRA@ $(ADDLDFLAGS)
+ 
+ # C file dependencies.
+ $(pdftex_c) pdftexcoerce.h pdftexd.h: pdftex.p $(web2c_texmf) $(srcdir)/$(pdftexdir)/pdftex.defines $(srcdir)/$(pdftexdir)/pdftex.h
+@@ -153,10 +156,10 @@
+ 	rm -f ttf2afm.c macnames.c
+ # 
+ # pdftosrc
+-pdftosrc = pdftosrc
++pdftosrc = 
+ 
+ pdftosrc: $(pdftexdir)/pdftosrc.o $(LIBXPDFDEP)
+-	@CXXHACKLINK@ $(pdftexdir)/pdftosrc.o $(LDLIBXPDF) -lm @CXXLDEXTRA@
++	@CXXHACKLINK@ $(pdftexdir)/pdftosrc.o $(LDLIBXPDF) -lm @CXXLDEXTRA@  $(ADDLDFLAGS)
+ $(pdftexdir)/pdftosrc.o:$(srcdir)/$(pdftexdir)/pdftosrc.cc
+ 	cd $(pdftexdir) && $(MAKE) pdftosrc.o
+ check: pdftosrc-check
+Index: texlive-bin-2007/build/source/configure
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure	2007-04-16 15:29:55.000000000 +0200
++++ texlive-bin-2007/build/source/configure	2007-04-16 15:30:03.000000000 +0200
+@@ -3459,9 +3459,9 @@
+ 
+ # we need libxpdf for pdf[ex]tex, xetex
+ test ! -d $srcdir/$LIBXPDFDIR && : ${needs_libxpdf=no}
+-test "$with_pdftex"  != no    && : ${needs_libxpdf=yes}
+-test "$with_pdfetex" != no    && : ${needs_libxpdf=yes}
+-test "$with_xetex"   != no    && : ${needs_libxpdf=yes}
++test "$with_pdftex"  != no    && : ${needs_libxpdf=no}
++test "$with_pdfetex" != no    && : ${needs_libxpdf=no}
++test "$with_xetex"   != no    && : ${needs_libxpdf=no}
+ : ${needs_libxpdf=no}
+ export needs_libxpdf
+ 
+Index: texlive-bin-2007/build/source/configure.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure.in	2007-04-16 15:29:55.000000000 +0200
++++ texlive-bin-2007/build/source/configure.in	2007-04-16 15:30:03.000000000 +0200
+@@ -157,9 +157,9 @@
+ 
+ # we need libxpdf for pdf[ex]tex, xetex
+ test ! -d $srcdir/$LIBXPDFDIR && : ${needs_libxpdf=no}
+-test "$with_pdftex"  != no    && : ${needs_libxpdf=yes}
+-test "$with_pdfetex" != no    && : ${needs_libxpdf=yes}
+-test "$with_xetex"   != no    && : ${needs_libxpdf=yes}
++test "$with_pdftex"  != no    && : ${needs_libxpdf=no}
++test "$with_pdfetex" != no    && : ${needs_libxpdf=no}
++test "$with_xetex"   != no    && : ${needs_libxpdf=no}
+ : ${needs_libxpdf=no}
+ export needs_libxpdf
+ 
+@@ -207,7 +207,7 @@
+ sinclude(libs/libpng/libpng.ac)
+ sinclude(libs/zlib/zlib.ac)
+ sinclude(libs/ncurses/ncurses.ac)
+-sinclude(libs/xpdf/libxpdf.ac)
++#sinclude(libs/xpdf/libxpdf.ac)
+ sinclude(libs/t1lib/t1lib.ac)
+ sinclude(libs/gd/gd.ac)
+ sinclude(libs/freetype/freetype.ac)
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-01-15 14:04:36.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-04-16 15:30:03.000000000 +0200
+@@ -33,7 +33,7 @@
+  */
+ 
+ #ifdef XETEX_OTHER
+-#include "xpdf/config.h"
++#include "poppler/poppler-config.h"
+ #include "png.h"
+ #endif
+ 
+@@ -194,7 +194,7 @@
+ #else
+ 		"Compiled with fontconfig version %d.%d.%d; using %d.%d.%d\n"
+ 		"Compiled with libpng version %s; using %s\n"
+-		"Compiled with xpdf version %s\n"
++		"Compiled with libpoppler version %s\n"
+ #endif
+ 		;
+ 
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/pdfimage.cpp
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/pdfimage.cpp	2006-12-09 11:29:12.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/pdfimage.cpp	2007-04-16 15:30:03.000000000 +0200
+@@ -11,10 +11,24 @@
+ 
+ #include "pdfimage.h"
+ 
+-#include "PDFDoc.h"
+-#include "Catalog.h"
+-#include "Page.h"
+-#include "GString.h"
++#include <dirent.h>
++#include <poppler/poppler-config.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Link.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
++
+ 
+ #include "XeTeX_ext.h"
+ 
+@@ -28,7 +42,7 @@
+ int
+ pdf_get_rect(char* filename, int page_num, int pdf_box, realrect* box)
+ {
+-	GString*	name = new GString(filename);
++	GooString*	name = new GooString(filename);
+ 	PDFDoc*		doc = new PDFDoc(name);
+ 	
+ 	if (!doc) {
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex.mk	2007-01-20 13:44:35.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk	2007-04-16 15:30:03.000000000 +0200
+@@ -4,6 +4,10 @@
+ 
+ Makefile: $(srcdir)/xetexdir/xetex.mk
+ 
++# use libpoppler instead of included xpdf code
++ADDLDFLAGS = -lpoppler
++
++
+ # We build xetex unless configure decides to skip it
+ xetex = @XETEX@ xetex
+ 
+@@ -29,7 +33,7 @@
+ 
+ @XETEX_GENERIC@ XETEX_DEFINES = -DXETEX_OTHER
+ 
+-@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ @LDFONTCONFIG@
++@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ @LDFONTCONFIG@ $(ADDLDFLAGS)
+ 
+ @XETEX_GENERIC@ EXTRADEPS = @LIBXPDFDEP@ @LIBPNGDEP@
+ 
+@@ -144,7 +148,7 @@
+ 	$(compile) $(ALL_CFLAGS) $(LIBPNGCPPFLAGS) $(ZLIBCPPFLAGS) -c $< -o $@
+ 
+ pdfimage.o: $(srcdir)/xetexdir/pdfimage.cpp $(srcdir)/xetexdir/pdfimage.h
+-	$(CXX) $(ALL_CFLAGS) $(LIBXPDFCPPFLAGS) -c $< -o $@
++	$(CXX) $(ALL_CFLAGS) $(LIBXPDFCPPFLAGS) -I/usr/include/poppler -c $< -o $@
+ 
+ XeTeX_pic.o: $(srcdir)/xetexdir/XeTeX_pic.c $(srcdir)/xetexdir/XeTeX_ext.h $(XeTeXImageHdrs)
+ 	$(compile) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/utils.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/utils.c	2007-01-01 18:20:03.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/utils.c	2007-04-16 15:30:03.000000000 +0200
+@@ -37,7 +37,7 @@
+ #include "zlib.h"
+ #include "ptexlib.h"
+ #include "png.h"
+-#include "xpdf/config.h"        /* just to get the xpdf version */
++#include "poppler/poppler-config.h"        /* just to get the xpdf version */
+ 
+ #define check_nprintf(size_get, size_want) \
+     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
+@@ -1261,7 +1261,7 @@
+     (void) asprintf(versions,
+                     "Compiled with libpng %s; using libpng %s\n"
+                     "Compiled with zlib %s; using zlib %s\n"
+-                    "Compiled with xpdf version %s\n",
++                    "Compiled with libpoppler version %s\n",
+                     PNG_LIBPNG_VER_STRING, png_libpng_ver,
+                     ZLIB_VERSION, zlib_version, xpdfVersion);
+ }
--- texlive-bin-2007.dfsg.2.orig/debian/patches/a2ping-man-fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/a2ping-man-fixes
@@ -0,0 +1,522 @@
+a2ping-man-fixes
+remove all .pl extensions of a2ping in the a2ping script and its pod
+documentation. Then also update the man page
+---
+ build/source/texk/tetex/a2ping |   38 +++----
+ texmf/doc/man/man1/a2ping.1    |  221 ++++++++++++++++++++++++++++-------------
+ 2 files changed, 170 insertions(+), 89 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/a2ping
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/a2ping	2007-06-29 08:08:38.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/a2ping	2007-06-29 08:09:39.000000000 +0200
+@@ -12,8 +12,8 @@
+ #
+ # !! Imp: merge back to a2ping.pa
+ # !! Ghostcript compute pipe too slow
+-#      $ a2ping.pl -v debrecen-hyph.ps de                                                                                                                                   brecen-hyph.pdf
+-#      a2ping.pl 2.77p, 2004-04-28 -- Written by <pts@fazekas.hu> from April 2003.
++#      $ a2ping -v debrecen-hyph.ps de                                                                                                                                   brecen-hyph.pdf
++#      a2ping 2.77p, 2004-04-28 -- Written by <pts@fazekas.hu> from April 2003.
+ #      This is free software, GNU GPL >=2.0. There is NO WARRANTY.
+ #      (epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.)
+ #      * Strongest BoundingBox comment: %%HiResBoundingBox:
+@@ -340,7 +340,7 @@
+ BEGIN{$  INC{'Htex/a2ping.pm'}='Htex/a2ping.pm'}
+ 
+ package Htex::a2ping;
+-# a2ping.pl -- convert between PS, EPS and PDF and other page description formats
++# a2ping -- convert between PS, EPS and PDF and other page description formats
+ # by pts@fazekas.hu et al. at Wed Apr 16 14:54:13 CEST 2003
+ # a2ping.pa created at Sun Apr 20 22:25:47 2003
+ #
+@@ -358,7 +358,7 @@
+ # Imp: gs(704?!) sometimes finds too small bbox, see Univers.eps
+ # Imp: respect bbox in METAPOST %! (not EPS), don't use Compute-GS T-
+ # Imp: -sPDFPassword=...
+-# Imp: `a2ping.pl -v jf.eps pdf1: t.pdf' PDF1: must be forced to have --below
++# Imp: `a2ping -v jf.eps pdf1: t.pdf' PDF1: must be forced to have --below
+ # Imp: option to `clip' an EPS to the specified bbox -- does file size decrease?
+ # Imp: fix bug a2ping -v ~/a2ping_bug.ps a2ping_bug.pdf; running type1fix on
+ #      all fonts with dff.pl has fixed the problem
+@@ -387,7 +387,7 @@
+ # Imp: possibly accept /PageSize from %%DocumentMedia
+ # Imp: /DocumentMedia seems to screw up sub-pt placement in gv(1)
+ #
+-# Dat: example: a2ping.pl --extra=-c:ijg:50 -r86 nn1.eps nn1.jpg
++# Dat: example: a2ping --extra=-c:ijg:50 -r86 nn1.eps nn1.jpg
+ # Dat: calling ``showpage'' is not required for -sDEVICE=pdfwrite with gs 6.50,
+ #      but -sDEVICE=pgmraw depends on it
+ # Dat: the functionality of pdfboxes.pl cannot be provided here with a shorter
+@@ -400,7 +400,7 @@
+ #      /ImagingBBox /HWResolution /HWSize /.MediaSize (we undef all)
+ 
+ ### program identification
+-my $program = "a2ping.pl";
++my $program = "a2ping";
+ my $filedate="2007-03-07"; # my $filedate="2001/03/05";
+ my $copyright = "Written by <pts\@fazekas.hu> from April 2003.
+ This is free software, GNU GPL >=2.0. There is NO WARRANTY.
+@@ -1439,7 +1439,7 @@
+   #     chance to override its settings.) So we emit a fake
+   #     %%BeginSetup..%%EndSetup pair just before our code doing
+   #     `setpagedevice'.
+-  # !! ?? run pstops first, and then a2ping.pl
++  # !! ?? run pstops first, and then a2ping
+   # !! why does a PDF -> PS conversion need $is_restored?
+   # vvv Dat: `mark' is necessary, because pstops 1.17 from xpdf(1) emits lines
+   #     lines leaving `false' on the stack:
+@@ -1974,7 +1974,7 @@
+   my $ofn=$OutputFilename;
+   if (is_via_sam2p()) {
+     # Dat: fortunately the following file format names are commin in sam2p(1)
+-    #      and a2ping.pl: PNG XWD BMP TIFF JPEG GIF XPM
++    #      and a2ping: PNG XWD BMP TIFF JPEG GIF XPM
+     @pnm2sampled_cmd=('sam2p',"$FileFormat:",'--'); # Imp: use convert(1) if no sam2p(1)
+     $ofn=fix_force_out('SS.pnm');
+     push @pnm2sampled_cmd, $ofn, $OutputFilename;
+@@ -2263,7 +2263,7 @@
+ if (@pnm2sampled_cmd) { # $scale3_pnm_fn -> $OutputFilename
+   do_system @pnm2sampled_cmd; # Dat: uses @extra -- really share that?
+   temp_unlink $scale3_pnm_fn;
+-} else { # BUGFIX for `a2ping.pl -v --antialias=no negyzet.eps negyzet.png' at Wed Jul 20 21:34:29 CEST 2005
++} else { # BUGFIX for `a2ping -v --antialias=no negyzet.eps negyzet.png' at Wed Jul 20 21:34:29 CEST 2005
+   fix_close_out();
+ }
+ undef $unlink_OutputFilename;
+@@ -2298,14 +2298,14 @@
+ 
+ =head1 NAME
+ 
+-a2ping.pl -- convert between PS, EPS and PDF and other page description
++a2ping -- convert between PS, EPS and PDF and other page description
+ formats
+ 
+ =head1 SYNOPSIS
+ 
+-Z<> B<a2ping.pl> [B<-->]B<help>
+- B<a2ping.pl> [B<-->]B<doc>
+- B<a2ping.pl> [I<options>] <I<inputfile>> [[I<outformat>:] I<outputfile>]
++Z<> B<a2ping> [B<-->]B<help>
++ B<a2ping> [B<-->]B<doc>
++ B<a2ping> [I<options>] <I<inputfile>> [[I<outformat>:] I<outputfile>]
+ 
+ =head1 DESCRIPTION
+ 
+@@ -2338,8 +2338,8 @@
+ 
+ =head1 EXTERNAL PROGRAMS
+ 
+-The internal file format of B<a2ping.pl> is PS/EPS. Everything read is
+-first converted to PS or EPS, then processed by B<a2ping.pl>, then
++The internal file format of B<a2ping> is PS/EPS. Everything read is
++first converted to PS or EPS, then processed by B<a2ping>, then
+ converted to the output format.
+ 
+ To analyse the bounding box and other properties of non-EPS PS files
+@@ -2352,7 +2352,7 @@
+ 
+ Sampled input formats are PNG, JPEG, TIFF, PNM, BMP, GIF, LBM, XPM, PCX
+ and TGA. To read sampled input formats, B<sam2p> is used. B<sam2p> is
+-a raster image converter written in C++ by the author of B<a2ping.pl>.
++a raster image converter written in C++ by the author of B<a2ping>.
+ 
+ Extra output formats are PNG, XWD, BMP, TIFF, JPEG, GIF and XPM. To
+ write extra output formats, B<sam2p> and GS are used.
+@@ -2455,7 +2455,7 @@
+ =item *
+ 
+ If your EPS contains a wrong bounding box, you can fix it by running
+-C<a2ping.pl -v --bboxfrom=compute-gs thefile.eps -->
++C<a2ping -v --bboxfrom=compute-gs thefile.eps -->
+ 
+ =item *
+ 
+@@ -2481,7 +2481,7 @@
+ =item *
+ 
+ If you have an incompatible PS that GS can read but your printer cannot print,
+-just run C<a2ping.pl foo.ps PDF: - | a2ping.pl - PS: foo.ps>
++just run C<a2ping foo.ps PDF: - | a2ping - PS: foo.ps>
+ 
+ =item *
+ 
+@@ -2644,7 +2644,7 @@
+  * improved bbox discovery
+  * many bugfixes
+  * MetaPost EPS input fixes for prologues:=0;
+- * a2ping.pl -v --papersize=50,60 --bboxfrom=compute-gs t.ps t2.ps
++ * a2ping -v --papersize=50,60 --bboxfrom=compute-gs t.ps t2.ps
+  * consistent bbox, --PageSize, /PageSize handling
+  * consistent --Resolution and --Duplex handling
+ 
+Index: texlive-bin-2007/texmf/doc/man/man1/a2ping.1
+===================================================================
+--- texlive-bin-2007.orig/texmf/doc/man/man1/a2ping.1	2007-06-29 08:09:50.000000000 +0200
++++ texlive-bin-2007/texmf/doc/man/man1/a2ping.1	2007-06-29 08:10:05.000000000 +0200
+@@ -1,4 +1,4 @@
+-.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.13
++.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
+ .\"
+ .\" Standard preamble:
+ .\" ========================================================================
+@@ -25,11 +25,11 @@
+ ..
+ .\" Set up some character translations and predefined strings.  \*(-- will
+ .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+-.\" double quote, and \*(R" will give a right double quote.  | will give a
+-.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
+-.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
+-.\" expand to `' in nroff, nothing in troff, for use with C<>.
+-.tr \(*W-|\(bv\*(Tr
++.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
++.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
++.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
++.\" nothing in troff, for use with C<>.
++.tr \(*W-
+ .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+ .ie n \{\
+ .    ds -- \(*W-
+@@ -129,7 +129,7 @@
+ .\" ========================================================================
+ .\"
+ .IX Title "A2PING 1"
+-.TH A2PING 1 "2004-05-26" "perl v5.8.1" "User Contributed Perl Documentation"
++.TH A2PING 1 "2007-06-29" "perl v5.8.8" "User Contributed Perl Documentation"
+ .ds pts-dev \*[.T]
+ .do if '\*[.T]'ascii'  .ds pts-dev tty
+ .do if '\*[.T]'ascii8' .ds pts-dev tty
+@@ -145,13 +145,13 @@
+ .ad n
+ 
+ .SH "NAME"
+-a2ping.pl \-\- convert between PS, EPS and PDF and other page description
++a2ping \-\- convert between PS, EPS and PDF and other page description
+ formats
+ .SH "SYNOPSIS"
+ .IX Header "SYNOPSIS"
+-\&\& \fBa2ping.pl\fR [\fB\-\-\fR]\fBhelp\fR
+- \fBa2ping.pl\fR [\fB\-\-\fR]\fBdoc\fR
+- \fBa2ping.pl\fR [\fIoptions\fR] <\fIinputfile\fR> [[\fIoutformat\fR:] \fIoutputfile\fR]
++\&\& \fBa2ping\fR [\fB\-\-\fR]\fBhelp\fR
++ \fBa2ping\fR [\fB\-\-\fR]\fBdoc\fR
++ \fBa2ping\fR [\fIoptions\fR] <\fIinputfile\fR> [[\fIoutformat\fR:] \fIoutputfile\fR]
+ .SH "DESCRIPTION"
+ .IX Header "DESCRIPTION"
+ \&\fBa2ping\fR is a \s-1UNIX\s0 command line utility written in Perl that
+@@ -182,8 +182,8 @@
+ extension of the output file determines the FileFormat (\fIoutformat\fR).
+ .SH "EXTERNAL PROGRAMS"
+ .IX Header "EXTERNAL PROGRAMS"
+-The internal file format of \fBa2ping.pl\fR is \s-1PS/EPS\s0. Everything read is
+-first converted to \s-1PS\s0 or \s-1EPS\s0, then processed by \fBa2ping.pl\fR, then
++The internal file format of \fBa2ping\fR is \s-1PS/EPS\s0. Everything read is
++first converted to \s-1PS\s0 or \s-1EPS\s0, then processed by \fBa2ping\fR, then
+ converted to the output format.
+ .PP
+ To analyse the bounding box and other properties of non-EPS \s-1PS\s0 files
+@@ -196,42 +196,106 @@
+ .PP
+ Sampled input formats are \s-1PNG\s0, \s-1JPEG\s0, \s-1TIFF\s0, \s-1PNM\s0, \s-1BMP\s0, \s-1GIF\s0, \s-1LBM\s0, \s-1XPM\s0, \s-1PCX\s0
+ and \s-1TGA\s0. To read sampled input formats, \fBsam2p\fR is used. \fBsam2p\fR is
+-a raster image converter written in \*(C+ by the author of \fBa2ping.pl\fR.
++a raster image converter written in \*(C+ by the author of \fBa2ping\fR.
+ .PP
+ Extra output formats are \s-1PNG\s0, \s-1XWD\s0, \s-1BMP\s0, \s-1TIFF\s0, \s-1JPEG\s0, \s-1GIF\s0 and \s-1XPM\s0. To
+ write extra output formats, \fBsam2p\fR and \s-1GS\s0 are used.
+ .PP
+ \&\s-1PNM\s0 output formats are \s-1PGM\s0, \s-1PGM\s0 and \s-1PPM\s0. To write \s-1PNM\s0 output formats, \s-1GS\s0
+ is used.
++.SH "OPTIONS"
++.IX Header "OPTIONS"
++.Sh "General Options"
++.IX Subsection "General Options"
++.IP "\fB\-h\fR, \fB\-\-help\fR" 2
++.IX Item "-h, --help"
++Show a summary of the usage
++.IP "\fB\-\-doc\fR" 2
++.IX Item "--doc"
++Show the man page
++.IP "\fB\-v\fR, \fB\-\-(no)verbose\fR" 2
++.IX Item "-v, --(no)verbose"
++Show progress and debug messages (default: no)
++.Sh "Options for the Bounding box"
++.IX Subsection "Options for the Bounding box"
++.IP "\fB\-\-(no)hires\fR" 2
++.IX Item "--(no)hires"
++Use HiResBoundingBox in the input file, if present (default: yes)
++.IP "\fB\-\-(no)exact\fR" 2
++.IX Item "--(no)exact"
++Use ExactBoundingBox in the input file, if present (default: no)
++.IP "\fB\-\-(no)keepoldmediabox\fR" 2
++.IX Item "--(no)keepoldmediabox"
++keep only old, [0 0]\-based MediaBox in \s-1PDF\s0 (default: no)
++.IP "\fB\-\-bboxfrom=\fR\fIadsc|compute\-gs|guess|pagesize\fR" 2
++.IX Item "--bboxfrom=adsc|compute-gs|guess|pagesize"
++Method for determining the BoundingBox  (default: guess)
++.IP "\fB\-\-(no)below\fR" 2
++.IX Item "--(no)below"
++Allow page content below and left of the origin (default: no)
++.Sh "Options for graphics and fonts"
++.IX Subsection "Options for graphics and fonts"
++.IP "\fB\-\-(no)compress\fR" 2
++.IX Item "--(no)compress"
++use compression                   (default: best)
++.IP "\fB\-\-(no)antialias\fR" 2
++.IX Item "--(no)antialias"
++render shades at outlines.  Possible values: (=\fIscale3yes\fR =\fIno\fR =\fIyes\fR)  (default: scale3no)
++.IP "\fB\-\-(no)lossy\fR" 2
++.IX Item "--(no)lossy"
++allow lossy image filters (\s-1EPS\-\s0>\s-1PDF\s0) (default: yes)
++.IP "\fB\-\-papersize=\fR\fIunchanged|force\-unknown|600bpx5cm\fR" 2
++.IX Item "--papersize=unchanged|force-unknown|600bpx5cm"
++(default: default) (bp)
++.IP "\fB\-\-threshold=\fR" 2
++.IX Item "--threshold="
++min color for 1 in 8\->1 bit conv  (default: 128)
++.Sh "Options for debugging and changing internals"
++.IX Subsection "Options for debugging and changing internals"
++.IP "\fB\-\-(no)tmpunlink\fR" 2
++.IX Item "--(no)tmpunlink"
++Unlink temporary files (default: yes).  Use \fB\-\-notmpunklink\fR if you
++want to inspect intermediate files.
++.IP "\fB\-\-gs\-cmd=\fR\fIpath\fR" 2
++.IX Item "--gs-cmd=path"
++path to Ghostscript program (default: gs or gswin32c)
++.IP "\fB\-\-gs\-ccmd=\fR\fIpath\fR" 2
++.IX Item "--gs-ccmd=path"
++path to Ghostscript for BoundingBox calculation (default: gs or gswin32c)
++.IP "\fB\-\-gsextra=\fR\fI\s-1GS_ARGS\s0\fR" 2
++.IX Item "--gsextra=GS_ARGS"
++Pass extra arguments to gs
++.IP "\fB\-\-extra=\fR" 2
++.IX Item "--extra="
++Pass extra arguments to external program (i.e pdftops)
+ .SH "TIPS AND TRICKS"
+ .IX Header "TIPS AND TRICKS"
+-.IP "\(bu" 2
+-Call with the \fB\-v\fR option to see progress and debug messages.
+-.IP "\(bu" 2
++.RS 2
++.IP "*" 2
+ If your \s-1EPS\s0 contains a wrong bounding box, you can fix it by running
+-\&\f(CW\*(C`a2ping.pl \-v \-\-bboxfrom=compute\-gs thefile.eps \-\-\*(C'\fR
+-.IP "\(bu" 2
++\&\f(CW\*(C`a2ping \-v \-\-bboxfrom=compute\-gs thefile.eps \-\-\*(C'\fR
++.IP "*" 2
+ You can specify \fB\-\fR as \fIinputfile\fR to get stdin and as \fIoutputfile\fR
+ to get stdout. This works even for \s-1PDF\s0 files (which must be seekable),
+ because \fBa2ping\fR copies them to a temporary file automatically.
+-.IP "\(bu" 2
++.IP "*" 2
+ If \fIinputfile\fR and \fIoutputfile\fR are the same, \fBa2ping\fR copies the
+ \&\fIinputfile\fR to a temporary location first. However, this usage is
+ recommended only if there is a backup of the file to be restored in case
+ \&\fBa2ping\fR doesn't produce the desired result.
+-.IP "\(bu" 2
++.IP "*" 2
+ If you specify \fB\-\-\fR as \fIoutputfile\fR, it will be the same as \fIinputfile\fR.
+-.IP "\(bu" 2
++.IP "*" 2
+ \&\fBa2ping\fR respects \fB\-\-Duplex\fR for FileFormat \s-1PCL5\s0, even though \s-1GS\s0 doesn't.
+-.IP "\(bu" 2
++.IP "*" 2
+ If you have an incompatible \s-1PS\s0 that \s-1GS\s0 can read but your printer cannot print,
+-just run \f(CW\*(C`a2ping.pl foo.ps PDF: \- | a2ping.pl \- PS: foo.ps\*(C'\fR
+-.IP "\(bu" 2
++just run \f(CW\*(C`a2ping foo.ps PDF: \- | a2ping \- PS: foo.ps\*(C'\fR
++.IP "*" 2
+ If you have a \s-1PS\s0 coming from Win32 (often with extension \f(CW\*(C`.prn\*(C'\fR), run
+ it through \fBa2ping\fR. It will remove the resolution changes and the
+ progress text printed to the terminal (which confuses \fIgv\fR\|(1) and makes
+ some filters in the print queue emit incorrect output).
+-.IP "\(bu" 2
++.IP "*" 2
+ \&\fBa2ping\fR does antialiasing (\fB\-\-antialias=scale3no\fR) of glyphs and
+ curves when emitting a sampled image (FileFormats such as \s-1PGM\s0 and \s-1PPM\s0).
+ This improves readability of the glyphs. \fB=yes\fR instructs \s-1GS\s0 to do
+@@ -240,49 +304,59 @@
+ as big, and then scales it back down. \fB=scale3no\fR turns on both 3x3
+ scaling and \s-1GS\s0 internal antialiasing, which results in thicker lines and
+ worse quality in general.
+-.IP "\(bu" 2
++.IP "*" 2
+ When creating a \s-1PBM\s0 file, antialiasing usually doesn't improve the
+ quality, so it is switched off by default. But if you set
+ \&\fB\-\-antialias=scale3no\fR or \fB\-\-antialias=scale3yes\fR, \s-1GS\s0 will render a \s-1PGM\s0 file,
+ and the value of \fB\-\-threshold\fR determines the minimum intensity for white in
+ the final \s-1PBM\s0.
+-.IP "\(bu" 2
++.IP "*" 2
+ If you need a bigger sampled output file, specify a larger
+ \&\fB\-\-Resolution\fR. The default is \fB\-\-Resolution=72\fR. If your sampled output file
+ is going to be really big, you should specify \fB\-\-AntiAlias=yes\fR instead of
+ the default \fB\-\-AntiAlias=scale3no\fR to speed up conversion.
++.IP "*" 2
++To make sure fonts are included in a \s-1PDF\s0 file generated from eps, use
++\&\fB\-\-gsextra='\-dEmbedAllFonts=true \-dPDFSETTINGS=/printer'\fR.
++.RE
++.RS 2
+ .SH "MISC"
+ .IX Header "MISC"
+-.IP "\(bu" 2
++.IP "*" 2
+ Doesn't depend on the filename or extension of the input file.
+-.IP "\(bu" 2
++.IP "*" 2
+ Conversion from \s-1EPS\s0 to \s-1PDF:\s0 fixes glitches etc., calls gs
+ \&\-sDEVICE=pdfwrite
+-.IP "\(bu" 2
++.IP "*" 2
+ Conversion from \s-1EPS\s0 to \s-1EPS:\s0 fixes various glitches, moves (llx,lly) to
+ (0,0), removes binary junk from the beginning of the \s-1EPS\s0 etc.
+-.IP "\(bu" 2
++.IP "*" 2
+ Conversion from \s-1PDF\s0 to \s-1PDF:\s0 keeps the file intact
+-.IP "\(bu" 2
++.IP "*" 2
+ Conversion from \s-1PDF\s0 to \s-1EPS:\s0 calls pdftops \-eps (of the xpdf package)
+-.IP "\(bu" 2
++.IP "*" 2
+ Conversion from \s-1PS\s0 to \s-1EPS:\s0 keeps 1st page only, removes setpagedevice etc.
++.RE
++.RS 2
+ .SH "AUTHORS"
+ .IX Header "AUTHORS"
+-The author of \fBa2ping\fR is Szabó Péter <\fIpts@fazekas.hu\fR>.
+-.PP
++The author of \fBa2ping\fR is Péter Szabó <\fIpts@fazekas.hu\fR>.
++.Sp
+ \&\fBa2ping\fR is inspired by and historically based on the \fBepstopdf\fR Perl
+ script modified by Thomas Esser, Sept. 1998, but his modifications have
+ been removed from \fBa2ping\fR, and also \fBa2ping\fR and \fBepstopdf\fR do not
+ share common code anymore.  \fBepstopdf\fR is written by Sebastian Rahtz,
+ for Elsevier Science. \fBepstopdf\fR contained extra tricks from Hans Hagen's
+ texutil.
++.Sp
++\&\fBa2ping\fR contains contributions from several people, see the \s-1HISTORY\s0 for
++details. Thank you all for contributing!
+ .SH "HISTORY"
+ .IX Header "HISTORY"
+ .Sh "1999/05/06 v2.5 (Heiko Oberdiek)"
+ .IX Subsection "1999/05/06 v2.5 (Heiko Oberdiek)"
+ .Vb 14
+-\& * New options: --hires, --exact, --filter, --help.
++\& * New options: \-\-hires, \-\-exact, \-\-filter, \-\-help.
+ \& * Many cosmetics: title, usage, ...
+ \& * New code for debug, warning, error
+ \& * Detecting of cygwin perl
+@@ -308,73 +382,80 @@
+ \& * Newline before grestore for the case that there is no
+ \&   whitespace at the end of the eps file.
+ .Ve
+-.Sh "2003/02/02 (Szabó Péter)"
+-.IX Subsection "2003/02/02 (Szabó Péter)"
++.Sh "2003/02/02 (Péter Szabó)"
++.IX Subsection "2003/02/02 (Péter Szabó)"
+ .Vb 10
+-\& * option --below
++\& * option \-\-below
+ \& * removes DOS EPSF binary junk correctly
+ \& * adds all 3 BoundingBox DSC comments
+ \& * reads all 3 BoundingBox DSC comments, and picks the best
+ \& * forces BoundingBox to be an integer
+-\& * adds %%EndComments and proper %!PS-Adobe-?-? EPSF-?.? header
++\& * adds %%EndComments and proper %!PS\-Adobe\-?\-? EPSF\-?.? header
+ \& * adds %%Pages:
+ \& * adds invocation syntax: a2ping <infile.eps> <outfile.eps|pdf>
+ \& * can convert PDF to EPS (by calling pdftops(1)) and PDF to PDF
+ \& * emulates work for PDF input
+ .Ve
+-.Sh "2003/04/16 (Szabó Péter)"
+-.IX Subsection "2003/04/16 (Szabó Péter)"
++.Sh "2003/04/16 (Péter Szabó)"
++.IX Subsection "2003/04/16 (Péter Szabó)"
+ .Vb 7
+ \& * added PS and sam2p support, renamed to a2ping
+-\& * sam2p and pdftops if $InputFilename eq '-';
++\& * sam2p and pdftops if $InputFilename eq '\-';
+ \& * remove PJL UEL header from the beginning
+-\& * works for PS non-EPS files for input
++\& * works for PS non\-EPS files for input
+ \& * input support for PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA via sam2p
+ \& * removes ^L (form feed) from end of EPS file
+-\& * -x=-c:rle to add sam2p options
++\& * \-x=\-c:rle to add sam2p options
+ .Ve
+-.Sh "2003/04/26 (Szabó Péter)"
+-.IX Subsection "2003/04/26 (Szabó Péter)"
++.Sh "2003/04/26 (Péter Szabó)"
++.IX Subsection "2003/04/26 (Péter Szabó)"
+ .Vb 14
+ \& * omit the unnecessary setpagedevice calls when creating normal eps
+-\& * --noverbose --nocompress supported differently
+-\& * no more option defaults :-(
++\& * \-\-noverbose \-\-nocompress supported differently
++\& * no more option defaults :\-(
+ \& * justlib2
+-\& * multi-page output with PS:, PDF:, PCL5:
+-\& * after `a2ping -pa4', file out.pcl says: `HP PCL printer data - A4 page
++\& * multi\-page output with PS:, PDF:, PCL5:
++\& * after `a2ping \-pa4', file out.pcl says: `HP PCL printer data \- A4 page
+ \&   size', instead of `US letter'
+-\& * justlib2-ified doesn't depend on Getopt::Long anymore
++\& * justlib2\-ified doesn't depend on Getopt::Long anymore
+ \& * fully supports filtering (stdin and/or stdout), PDF and PCL5 output to
+ \&   pipe (!$$ll_zero)
+ \& * adds DSC ``%%DocumentMedia: plain 612 792 0 () ()''
+-\& * BoundingBox precedence for EPS input: --PageSize, %%*BoundingBox,
+-\&   setpagedevice. Precedence for other inputs: --PageSize, setpagedevice,
++\& * BoundingBox precedence for EPS input: \-\-PageSize, %%*BoundingBox,
++\&   setpagedevice. Precedence for other inputs: \-\-PageSize, setpagedevice,
+ \&   %%*BoundingBox
+ .Ve
+-.Sh "2003/09/25 (Szabó Péter)"
+-.IX Subsection "2003/09/25 (Szabó Péter)"
++.Sh "2003/09/25 (Péter Szabó)"
++.IX Subsection "2003/09/25 (Péter Szabó)"
+ .Vb 7
+-\& * --bboxfrom=adsc: %%BoundingBox overrides -sDEVICE=bbox
++\& * \-\-bboxfrom=adsc: %%BoundingBox overrides \-sDEVICE=bbox
+ \& * improved bbox discovery
+ \& * many bugfixes
+ \& * MetaPost EPS input fixes for prologues:=0;
+-\& * a2ping.pl -v --papersize=50,60 --bboxfrom=compute-gs t.ps t2.ps
+-\& * consistent bbox, --PageSize, /PageSize handling
+-\& * consistent --Resolution and --Duplex handling
++\& * a2ping \-v \-\-papersize=50,60 \-\-bboxfrom=compute\-gs t.ps t2.ps
++\& * consistent bbox, \-\-PageSize, /PageSize handling
++\& * consistent \-\-Resolution and \-\-Duplex handling
+ .Ve
+-.Sh "2003/12/02 (Szabó Péter)"
+-.IX Subsection "2003/12/02 (Szabó Péter)"
++.Sh "2003/12/02 (Péter Szabó)"
++.IX Subsection "2003/12/02 (Péter Szabó)"
+ .Vb 1
+-\& * --bboxfrom=compute-gs option to fix PS -> EPS bbox (gs -sDEVICE=bbox), tuzv.eps
++\& * \-\-bboxfrom=compute\-gs option to fix PS \-> EPS bbox (gs \-sDEVICE=bbox), tuzv.eps
+ .Ve
+-.Sh "2004/02/10 v2.77 (Szabó Péter)"
+-.IX Subsection "2004/02/10 v2.77 (Szabó Péter)"
++.Sh "2004/02/10 v2.77p fixed (Péter Szabó)"
++.IX Subsection "2004/02/10 v2.77p fixed (Péter Szabó)"
+ .Vb 7
+-\& * the compute-pipe routine is now run unless --bboxfrom=guess with EPS
+-\& * added --gsextra=
+-\& * added --antialias=
++\& * the compute\-pipe routine is now run unless \-\-bboxfrom=guess with EPS
++\& * added \-\-gsextra=
++\& * added \-\-antialias=
+ \& * added FileFormat PBM, PGM, PPM
+ \& * separated FileFormat features to FL_* constants
+-\& * added --doc
++\& * added \-\-doc
+ \& * there is no default FileFormat (PDF) anymore
+ .Ve
++.Sh "2007/03/07 (Péter Szabó and Frank Küster)"
++.IX Subsection "2007/03/07 (Péter Szabó and Frank Küster)"
++.Vb 3
++\& * various improvements for tetex2 and tetex3 compatibility
++\& * various other improvements
++\& * POD documentation enhancements (font embedding tricks) by Frank Küster
++.Ve
--- texlive-bin-2007.dfsg.2.orig/debian/patches/patgen-manpage-fix
+++ texlive-bin-2007.dfsg.2/debian/patches/patgen-manpage-fix
@@ -0,0 +1,359 @@
+---
+ build/source/texk/web2c/man/patgen.man |   77 +++++++++++++++++++++------------
+ texmf/doc/man/man1/patgen.1            |   77 +++++++++++++++++++++------------
+ 2 files changed, 98 insertions(+), 56 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/man/patgen.man
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/man/patgen.man	2007-11-26 07:18:18.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/man/patgen.man	2007-11-26 07:18:33.000000000 +0100
+@@ -1,9 +1,10 @@
+-.TH PATGEN 1 "23 August 2004" "Web2C @VERSION@"
++.TH PATGEN 1 "25 November 2007" "Web2C @VERSION@"
+ .\"=====================================================================
+ .if t .ds TX \fRT\\h'-0.1667m'\\v'0.20v'E\\v'-0.20v'\\h'-0.125m'X\fP
+ .if n .ds TX TeX
+ .ie t .ds OX \fIT\v'+0.25m'E\v'-0.25m'X\fP for troff
+-.el .ds OX TeX for nroff
++.el .ds OX TeX
++.\" that's for nroff.
+ .\" the same but obliqued
+ .\" BX definition must follow TX so BX can use TX
+ .if t .ds BX \fRB\s-2IB\s0\fP\*(TX
+@@ -19,19 +20,18 @@
+ .I dictionary_file pattern_file patout_file translate_file
+ .\"=====================================================================
+ .SH DESCRIPTION
+-This manual page is not meant to be exhaustive.  The complete
+-documentation for this version of \*(TX can be found in the info file
+-or manual
++This manual page is not meant to be exhaustive.  
++See also the Info file or manual
+ .IR "Web2C: A TeX implementation" .
+ .PP
+ The
+-.B patgen
++.I patgen
+ program reads the
+ .I dictionary_file
+ containing a list of hyphenated words and the
+ .I pattern_file
+ containing previously-generated patterns (if any) for a particular
+-language, and produces the
++language (not a complete TeX source file; see below), and produces the
+ .I patout_file
+ with (previously- plus newly-generated) hyphenation patterns for that
+ language. The
+@@ -43,28 +43,26 @@
+ language. Further details of the pattern generation process such as
+ hyphenation levels and pattern lengths are requested interactively from
+ the user's terminal. Optionally
+-.B patgen
++.I patgen
+ creates a new dictionary file
+ .BI pattmp. n
+ showing the good and bad hyphens found by the generated patterns, where
+ .I n
+-is the highest hypenation level.
++is the highest hyphenation level.
+ .PP
+ The patterns generated by
+-.B patgen
++.I patgen
+ can be read by
+ .B initex
+-for use in hyphenating words. For a (very) long example of
++for use in hyphenating words. For a real-life example of
+ .IR patgen 's
+ output, see
+ .IR $TEXMFMAIN/tex/generic/hyphen/hyphen.tex ,
+-which contains the patterns \*(TX uses for English.
+-At some sites, patterns for several other languages may be available,
++which contains the patterns \*(TX uses for English by default.
++At some sites, patterns for (many) other languages may be available,
+ and the local
+ .B tex
+-programs may have them preloaded; consult your
+-.I Local Guide
+-or your system administrator for details.
++programs may have them preloaded.
+ .PP
+ All filenames must be complete; no adding of default
+ extensions or path searching is done.
+@@ -79,7 +77,7 @@
+ of a word), and letters. In pattern files for non-English languages
+ letters are often represented by macros or other expandable constructs.
+ For the purpose of
+-.B patgen
++.I patgen
+ these are just character sequences, subject to the condition that no
+ such sequence is a prefix of another one.
+ .TP \w'@@'u+2n
+@@ -95,10 +93,23 @@
+ found, \`good' hyphens (correctly found by the patterns), and \`bad'
+ hyphens (erroneously found by the patterns) respectively; when reading a
+ dictionary file \`*' is treated like \`-' and \`.' is ignored.
+-.TP \w'@@'u+2n
++.TP
++.B Pattern file
++A pattern file contains only patterns in the format above, e.g., from a
++previous run of patgen.  It may \fInot\fR contain any \*(TX comments or
++control sequences.  For instance, this is not a valid pattern file:
++.nf
++
++% this is a pattern file read by TeX.
++\\patterns{%
++ ...
++}
++.fi
++It can only contain the actual patterns, i.e., the `...'.
++.TP
+ .B Translate file
+ A translate file starts with a line containing the values of
+-.I left_hypen_min
++.I left_hyphen_min
+ in columns 1-2,
+ .I right_hyphen_min
+ in columns 3-4, and either a blank or the replacement for one of the
+@@ -112,19 +123,19 @@
+ another delimiter.
+ 
+ If the translate file is empty, the values
+-.IR left_hypen_min "=2, " right_hyphen_min "=3,"
++.IR left_hyphen_min "=2, " right_hyphen_min "=3,"
+ and the 26 lower case letters
+ .IR a ... z
+ with their upper case representations
+ .IR A ... Z
+ are assumed.
+-.TP \w'@@'u+2n
++.TP
+ .B Terminal input
+ After reading the
+ .I translate_file
+ and any previously-generated patterns from
+ .IR pattern_file,
+-.B patgen
++.I patgen
+ requests input from the user's terminal.
+ 
+ First the integer values of
+@@ -143,19 +154,30 @@
+ patterns.
+ 
+ Finally the decision (\`y' or \`Y' vs. anything else) whether or not to
+-produce a hypenated word list.
++produce a hyphenated word list.
+ .\"=====================================================================
+ .SH FILES
+ .TP \w'@@'u+2n
+ .I $TEXMFMAIN/tex/generic/hyphen/hyphen.tex
+-Patterns for English.
++The original hyphenation patterns for English, by Donald Knuth and Frank
++Liang.
++.TP
++.I $TEXMFMAIN/tex/generic/hyphen/ushyphmax.tex
++Maximal hyphenation patterns for English, extended by Gerard Kuiken.
++.TP
++.I http://www.ctan.org/tex-archive/language/
++Patterns and support for many other languages
+ .\"=====================================================================
+ .SH "SEE ALSO"
++Frank Liang and Peter Breitenlohner,
++patgen.web.
++.PP
+ Frank Liang,
+ .IR "Word hy-phen-a-tion by com-puter" ,
+ STAN-CS-83-977,
+-Stanford University Ph.D. thesis, 1983.
+-.br
++Stanford University Ph.D. thesis, 1983,
++http://tug.org/docs/liang.
++.PP
+ Donald E. Knuth,
+ .IR "The \*(OXbook" ,
+ Addison-Wesley, 1986, ISBN 0-201-13447-0, Appendix H.
+@@ -166,5 +188,4 @@
+ substantial revision in 1991 for \*(TX 3.
+ The first version was published as the appendix to the
+ .I \*(OXware
+-technical report, available from the \*(TX Users Group. Howard Trickey
+-originally ported it to Unix.
++technical report. Howard Trickey originally ported it to Unix.
+Index: texlive-bin-2007.dfsg.1/texmf/doc/man/man1/patgen.1
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/texmf/doc/man/man1/patgen.1	2007-11-26 07:18:18.000000000 +0100
++++ texlive-bin-2007.dfsg.1/texmf/doc/man/man1/patgen.1	2007-11-26 07:19:22.000000000 +0100
+@@ -1,9 +1,10 @@
+-.TH PATGEN 1 "23 August 2004" "Web2C 7.5.6"
++.TH PATGEN 1 "25 November 2007" "Web2C 7.5.6"
+ .\"=====================================================================
+ .if t .ds TX \fRT\\h'-0.1667m'\\v'0.20v'E\\v'-0.20v'\\h'-0.125m'X\fP
+ .if n .ds TX TeX
+ .ie t .ds OX \fIT\v'+0.25m'E\v'-0.25m'X\fP for troff
+-.el .ds OX TeX for nroff
++.el .ds OX TeX
++.\" that's for nroff.
+ .\" the same but obliqued
+ .\" BX definition must follow TX so BX can use TX
+ .if t .ds BX \fRB\s-2IB\s0\fP\*(TX
+@@ -19,19 +20,18 @@
+ .I dictionary_file pattern_file patout_file translate_file
+ .\"=====================================================================
+ .SH DESCRIPTION
+-This manual page is not meant to be exhaustive.  The complete
+-documentation for this version of \*(TX can be found in the info file
+-or manual
++This manual page is not meant to be exhaustive.  
++See also the Info file or manual
+ .IR "Web2C: A TeX implementation" .
+ .PP
+ The
+-.B patgen
++.I patgen
+ program reads the
+ .I dictionary_file
+ containing a list of hyphenated words and the
+ .I pattern_file
+ containing previously-generated patterns (if any) for a particular
+-language, and produces the
++language (not a complete TeX source file; see below), and produces the
+ .I patout_file
+ with (previously- plus newly-generated) hyphenation patterns for that
+ language. The
+@@ -43,28 +43,26 @@
+ language. Further details of the pattern generation process such as
+ hyphenation levels and pattern lengths are requested interactively from
+ the user's terminal. Optionally
+-.B patgen
++.I patgen
+ creates a new dictionary file
+ .BI pattmp. n
+ showing the good and bad hyphens found by the generated patterns, where
+ .I n
+-is the highest hypenation level.
++is the highest hyphenation level.
+ .PP
+ The patterns generated by
+-.B patgen
++.I patgen
+ can be read by
+ .B initex
+-for use in hyphenating words. For a (very) long example of
++for use in hyphenating words. For a real-life example of
+ .IR patgen 's
+ output, see
+ .IR $TEXMFMAIN/tex/generic/hyphen/hyphen.tex ,
+-which contains the patterns \*(TX uses for English.
+-At some sites, patterns for several other languages may be available,
++which contains the patterns \*(TX uses for English by default.
++At some sites, patterns for (many) other languages may be available,
+ and the local
+ .B tex
+-programs may have them preloaded; consult your
+-.I Local Guide
+-or your system administrator for details.
++programs may have them preloaded.
+ .PP
+ All filenames must be complete; no adding of default
+ extensions or path searching is done.
+@@ -79,7 +77,7 @@
+ of a word), and letters. In pattern files for non-English languages
+ letters are often represented by macros or other expandable constructs.
+ For the purpose of
+-.B patgen
++.I patgen
+ these are just character sequences, subject to the condition that no
+ such sequence is a prefix of another one.
+ .TP \w'@@'u+2n
+@@ -95,10 +93,23 @@
+ found, \`good' hyphens (correctly found by the patterns), and \`bad'
+ hyphens (erroneously found by the patterns) respectively; when reading a
+ dictionary file \`*' is treated like \`-' and \`.' is ignored.
+-.TP \w'@@'u+2n
++.TP
++.B Pattern file
++A pattern file contains only patterns in the format above, e.g., from a
++previous run of patgen.  It may \fInot\fR contain any \*(TX comments or
++control sequences.  For instance, this is not a valid pattern file:
++.nf
++
++% this is a pattern file read by TeX.
++\\patterns{%
++ ...
++}
++.fi
++It can only contain the actual patterns, i.e., the `...'.
++.TP
+ .B Translate file
+ A translate file starts with a line containing the values of
+-.I left_hypen_min
++.I left_hyphen_min
+ in columns 1-2,
+ .I right_hyphen_min
+ in columns 3-4, and either a blank or the replacement for one of the
+@@ -112,19 +123,19 @@
+ another delimiter.
+ 
+ If the translate file is empty, the values
+-.IR left_hypen_min "=2, " right_hyphen_min "=3,"
++.IR left_hyphen_min "=2, " right_hyphen_min "=3,"
+ and the 26 lower case letters
+ .IR a ... z
+ with their upper case representations
+ .IR A ... Z
+ are assumed.
+-.TP \w'@@'u+2n
++.TP
+ .B Terminal input
+ After reading the
+ .I translate_file
+ and any previously-generated patterns from
+ .IR pattern_file,
+-.B patgen
++.I patgen
+ requests input from the user's terminal.
+ 
+ First the integer values of
+@@ -143,19 +154,30 @@
+ patterns.
+ 
+ Finally the decision (\`y' or \`Y' vs. anything else) whether or not to
+-produce a hypenated word list.
++produce a hyphenated word list.
+ .\"=====================================================================
+ .SH FILES
+ .TP \w'@@'u+2n
+ .I $TEXMFMAIN/tex/generic/hyphen/hyphen.tex
+-Patterns for English.
++The original hyphenation patterns for English, by Donald Knuth and Frank
++Liang.
++.TP
++.I $TEXMFMAIN/tex/generic/hyphen/ushyphmax.tex
++Maximal hyphenation patterns for English, extended by Gerard Kuiken.
++.TP
++.I http://www.ctan.org/tex-archive/language/
++Patterns and support for many other languages
+ .\"=====================================================================
+ .SH "SEE ALSO"
++Frank Liang and Peter Breitenlohner,
++patgen.web.
++.PP
+ Frank Liang,
+ .IR "Word hy-phen-a-tion by com-puter" ,
+ STAN-CS-83-977,
+-Stanford University Ph.D. thesis, 1983.
+-.br
++Stanford University Ph.D. thesis, 1983,
++http://tug.org/docs/liang.
++.PP
+ Donald E. Knuth,
+ .IR "The \*(OXbook" ,
+ Addison-Wesley, 1986, ISBN 0-201-13447-0, Appendix H.
+@@ -166,5 +188,4 @@
+ substantial revision in 1991 for \*(TX 3.
+ The first version was published as the appendix to the
+ .I \*(OXware
+-technical report, available from the \*(TX Users Group. Howard Trickey
+-originally ported it to Unix.
++technical report. Howard Trickey originally ported it to Unix.
--- texlive-bin-2007.dfsg.2.orig/debian/patches/54_checklib_fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/54_checklib_fixes
@@ -0,0 +1,62 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 54_checklib_fixes.dpatch by Norbert Preining
+##
+## DP: fix unnecessary libraries in the ELF header, ie libs which were
+## DP: added to teh bin at linking stage
+
+@DPATCH@
+ build/source/texk/web2c/Makefile.in    |    4 ++--
+ build/source/texk/xdvik/Makefile.in    |    4 ++--
+ build/source/utils/pdfopen/Makefile.in |    2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/web2c/Makefile.in
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/web2c/Makefile.in	2007-01-10 18:39:42.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/web2c/Makefile.in	2007-01-26 04:03:16.000000000 +0100
+@@ -55,10 +55,10 @@
+ # All the x_... variables will be empty if we aren't supporting X.
+ x_cppflags = @X_CFLAGS@
+ x_ldflags = @X_LIBS@
+-x_pre_libs = @X_PRE_LIBS@
++x_pre_libs =    # disabled since it created unnecessary deps @X_PRE_LIBS@
+ x_extra_libs = @X_EXTRA_LIBS@
+ x_tool_libs = @x_tool_libs@
+-x_ext_lib = @x_ext_lib@
++x_ext_lib = 	# disabled since it created unnecessary deps @x_ext_lib@
+ wlibs = @wlibs@
+ # Follow the library order used in X11R6 itself:
+ #   -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 (some may not be present).
+Index: texlive-bin-2006.svn3816/build/source/texk/xdvik/Makefile.in
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/xdvik/Makefile.in	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/xdvik/Makefile.in	2007-01-26 04:03:16.000000000 +0100
+@@ -17,13 +17,13 @@
+ # This matches web2c (needed only for Metafont).
+ x_cppflags=@X_CFLAGS@ @iconv_includes@
+ x_ldflags=@X_LIBS@ @x_linker_options@ @iconv_libpath@
+-x_pre_libs=@X_PRE_LIBS@
++x_pre_libs=		# disabled as it generates unnecessary deps @X_PRE_LIBS@
+ x_extra_libs=@X_EXTRA_LIBS@ @iconv_libs@
+ x_tool_libs=@x_tool_libs@
+ x_xmu_lib=@x_xmu_lib@
+ x_xpm_libs=@x_xpm_libs@
+ # -lXp and -lXext
+-x_ext_lib=@x_ext_lib@
++x_ext_lib=		# disabled as it generates unnecessary deps @x_ext_lib@
+ 
+ # Follow the library order used in X11R6 itself.
+ # It seems that on Cygwin, libXaw needs _XpmReadFileToPixmap, so we put
+Index: texlive-bin-2006.svn3816/build/source/utils/pdfopen/Makefile.in
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/utils/pdfopen/Makefile.in	2006-06-15 15:28:00.000000000 +0200
++++ texlive-bin-2006.svn3816/build/source/utils/pdfopen/Makefile.in	2007-01-26 04:03:16.000000000 +0100
+@@ -158,7 +158,7 @@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
+ AM_CFLAGS = $(X_CFLAGS)
+-LDADD = $(X_LIBS) -lX11 -lXmu $(X_EXTRA_LIBS)
++LDADD = $(X_LIBS) -lX11 $(X_EXTRA_LIBS)
+ pdfopen_SOURCES = pdfopen.c sendx.c
+ pdfclose_SOURCES = pdfclose.c sendx.c
+ all: all-am
--- texlive-bin-2007.dfsg.2.orig/debian/patches/12e_fix_vpe_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/12e_fix_vpe_invocation
@@ -0,0 +1,15 @@
+---
+ build/source/texk/texlive/vpe |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/texlive/vpe
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/texlive/vpe	2007-05-19 16:37:45.000000000 +0200
++++ texlive-bin-2007/build/source/texk/texlive/vpe	2007-05-19 16:37:54.000000000 +0200
+@@ -1,5 +1,4 @@
+-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
+-  if 0;
++#!/usr/bin/perl -w
+ use strict;
+ #
+ # vpe.pl
--- texlive-bin-2007.dfsg.2.orig/debian/patches/64_fix_makempx_installation
+++ texlive-bin-2007.dfsg.2/debian/patches/64_fix_makempx_installation
@@ -0,0 +1,21 @@
+64_fix_makempx_installation by Sanjoy Mahajan <sanjoy@mrao.cam.ac.uk>
+
+building with --enable-shared installs the makempx script instead of the
+binary build
+---
+ build/source/texk/web2c/mpware/Makefile.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: texlive-bin-2007/build/source/texk/web2c/mpware/Makefile.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/mpware/Makefile.in	2007-05-19 20:04:58.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/mpware/Makefile.in	2007-05-19 20:05:19.000000000 +0200
+@@ -49,7 +49,7 @@
+ 	$(INSTALL_PROGRAM) newer $(bindir)/newer
+ 	$(INSTALL_LIBTOOL_PROG) dmp $(bindir)
+ 	$(INSTALL_LIBTOOL_PROG) mpto $(bindir)
+-	$(INSTALL_SCRIPT) makempx $(scriptdir)/makempx
++	$(INSTALL_LIBTOOL_PROG) makempx $(bindir)
+ install-data:
+ 
+ kpse_include ../make/tkpathsea.mk
--- texlive-bin-2007.dfsg.2.orig/debian/patches/series
+++ texlive-bin-2007.dfsg.2/debian/patches/series
@@ -0,0 +1,59 @@
+00_Build_script
+01_tmp_configure_without_installextra
+a2ping-upstream-fixes
+a2ping-man-fixes
+10_mktexlsr_fixes
+11_fix_pkfix_invocation
+12_fix_epstopdf_invocation
+12a_fix_thumbpdf_invocation
+12b_fix_a2ping_invocation
+12c_fix_pdfcrop_invocation
+12d_fix_ebong_invocation
+12e_fix_vpe_invocation
+13_fmtutil_fixes
+#14_etex_takes_buildformat
+16_texdoctk
+17_texdoc
+19_dvipdfm_config
+22_xdvi
+23_use_xdvi.bin
+# for backports with poppler << 0.5 (etch)
+30_libpoppler_0.4.5
+# for new libpoppler
+#30_libpoppler_0.5.4
+# for double new libpoppler >= 0.5.9 (unstable)
+#30_libpoppler_0.5.9
+#31_pdftex_gcc_ICE-on-alpha
+32_dvips_fontbug_fix_upstream
+41_maketexmf
+50_fmtutil_deb
+51_fmtutil_keep_failedlog
+53_builtin-searchpath-fix
+54_checklib_fixes
+55_texconfig_stuff
+56_updmap_deb
+#60_getnonfreefonts_bash
+61_dvipdfm_timezone
+62_dvips_absolutepath_doc
+63_texmf.cnf_for_comparison_temp
+64_fix_makempx_installation
+xetex-0996-patch1
+config.ps-update
+dviljk-security-fixes
+icu-powerpc-buildfix-patch
+disable-character-shifting
+gcc43-compile-fix
+hps-segfault-fix
+patgen-manpage-fix
+# disabled, should we do this?
+#metapost-1.02
+fix-thumbpdf-perlwarning
+fix-ovp2ovf-segfault
+tl2007.2-xetex-fixes
+tl2007.2-xdvipdfmx-fixes
+# sinhala support in xetex
+# patch from Anuradha Ratnaweera <anuradha@taprobane.org>
+# currently disable, it is not completely correct
+#xetex-sinhala-support
+mktexlsr-ignore-more-vcs
+add-missing-fontinst-source
--- texlive-bin-2007.dfsg.2.orig/debian/patches/30_libpoppler_0.5.4
+++ texlive-bin-2007.dfsg.2/debian/patches/30_libpoppler_0.5.4
@@ -0,0 +1,510 @@
+# 30_libpoppler.dpatch
+#
+# use libpoppler instead of libxpdf in pdfetex and xetex
+# don't build pdftosrc as it needs libpoppler from experimental 
+
+@DPATCH@
+ build/source/configure                           |    6 +-
+ build/source/configure.in                        |    8 +--
+ build/source/texk/web2c/pdftexdir/Makefile.in    |    2 
+ build/source/texk/web2c/pdftexdir/depend.mk      |   58 +----------------------
+ build/source/texk/web2c/pdftexdir/pdftex.mk      |    9 ++-
+ build/source/texk/web2c/pdftexdir/pdftexextra.in |    2 
+ build/source/texk/web2c/pdftexdir/pdftoepdf.cc   |   54 ++++++++++-----------
+ build/source/texk/web2c/pdftexdir/pdftosrc.cc    |   40 ++++++++-------
+ build/source/texk/web2c/pdftexdir/utils.c        |    4 -
+ build/source/texk/web2c/xetexdir/XeTeX_ext.c     |    4 -
+ build/source/texk/web2c/xetexdir/pdfimage.cpp    |   24 +++++++--
+ build/source/texk/web2c/xetexdir/xetex.mk        |    8 ++-
+ 12 files changed, 96 insertions(+), 123 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/depend.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/depend.mk	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/depend.mk	2007-05-19 14:21:27.000000000 +0200
+@@ -1,55 +1,5 @@
+-epdf.o: epdf.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-mapfile.o: mapfile.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-papersiz.o: papersiz.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-utils.o: utils.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h \
+- ../../../libs/zlib/zlib.h ../../../libs/zlib/zconf.h \
+- ../../../libs/md5/md5.h pdftexextra.h \
+- ../../../libs/obsdcompat/openbsd-compat.h
+-vfpacket.o: vfpacket.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-pkin.o: pkin.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writefont.o: writefont.c ../../../libs/xpdf/goo/gmem.h ptexlib.h \
+- ../pdftexd.h ../texmfmp.h ../cpascal.h ../config.h ../help.h \
+- ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writet1.o: writet1.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writet3.o: writet3.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writezip.o: writezip.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h ../../../libs/zlib/zlib.h ../../../libs/zlib/zconf.h
+-writeenc.o: writeenc.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-writettf.o: writettf.c ptexlib.h writettf.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h macnames.c
+-writejpg.o: writejpg.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-writepng.o: writepng.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-writeimg.o: writeimg.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-pdftoepdf.o: pdftoepdf.cc ../../../libs/xpdf/xpdf/Object.h \
+- ../../../libs/xpdf/goo/gmem.h ../../../libs/xpdf/xpdf/Array.h \
+- ../../../libs/xpdf/xpdf/Dict.h ../../../libs/xpdf/xpdf/Stream.h \
+- ../../../libs/xpdf/xpdf/XRef.h ../../../libs/xpdf/xpdf/Catalog.h \
+- ../../../libs/xpdf/xpdf/Page.h ../../../libs/xpdf/xpdf/GfxFont.h \
+- ../../../libs/xpdf/xpdf/Error.h epdf.h
++pdftoepdf.o: pdftoepdf.cc epdf.h ../../kpathsea/c-auto.h \
++  ../../kpathsea/c-proto.h ../../web2c/c-auto.h ../../web2c/config.h \
++  ../../kpathsea/c-fopen.h ../../web2c/pdftexdir/ptexmac.h
+ ttf2afm.o: ttf2afm.c writettf.h macnames.c
+-pdftosrc.o: pdftosrc.cc ../../../libs/xpdf/xpdf/Object.h \
+- ../../../libs/xpdf/xpdf/Array.h ../../../libs/xpdf/xpdf/Dict.h \
+- ../../../libs/xpdf/xpdf/Stream.h ../../../libs/xpdf/xpdf/XRef.h \
+- ../../../libs/xpdf/xpdf/Catalog.h ../../../libs/xpdf/xpdf/Page.h \
+- ../../../libs/xpdf/xpdf/PDFDoc.h ../../../libs/xpdf/xpdf/Link.h \
+- ../../../libs/xpdf/xpdf/Error.h ../../../libs/xpdf/xpdf/config.h
++pdftosrc.o: pdftosrc.cc
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftoepdf.cc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftoepdf.cc	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftoepdf.cc	2007-05-19 14:21:27.000000000 +0200
+@@ -26,25 +26,25 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <aconf.h>
+-#include <GString.h>
+-#include <gmem.h>
+-#include <gfile.h>
+-#include <config.h>
+ #include <assert.h>
+-#include "Object.h"
+-#include "Stream.h"
+-#include "Array.h"
+-#include "Dict.h"
+-#include "XRef.h"
+-#include "Catalog.h"
+-#include "Link.h"
+-#include "Page.h"
+-#include "GfxFont.h"
+-#include "PDFDoc.h"
+-#include "GlobalParams.h"
+-#include "Error.h"
+-
++#include <dirent.h>
++#include <poppler/poppler-config.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/UGooString.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Link.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
+ #include "epdf.h"
+ 
+ // This file is mostly C and not very much C++; it's just used to interface
+@@ -169,7 +169,7 @@
+     fprintf(stderr, "\npdfTeX Debug: Creating %s (%d)\n", p->file_name,
+             p->occurences);
+ #endif
+-    GString *docName = new GString(p->file_name);
++    GooString *docName = new GooString(p->file_name);
+     p->doc = new PDFDoc(docName);       // takes ownership of docName
+     if (!p->doc->isOk() || !p->doc->okToPrint()) {
+         pdftex_fail("xpdf: reading PDF image failed");
+@@ -212,7 +212,7 @@
+     obj->initDict(xref);
+     for (int i = 0, l = dict->getLength(); i < l; i++) {
+         Object obj1;
+-        obj->dictAdd(copyString(dict->getKey(i)), dict->getValNF(i, &obj1));
++        obj->dictAdd(*(new UGooString (*dict->getKey(i))), dict->getValNF(i, &obj1));
+     }
+ }
+ 
+@@ -291,7 +291,7 @@
+ static void copyDictEntry(Object * obj, int i)
+ {
+     PdfObject obj1;
+-    copyName(obj->dictGetKey(i));
++    copyName(obj->dictGetKey(i)->getCString());
+     pdf_puts(" ");
+     obj->dictGetValNF(i, &obj1);
+     copyObject(&obj1);
+@@ -318,7 +318,7 @@
+     pdf_puts("<<\n");
+     assert(r->type == objFont); // FontDescriptor is in fd_tree
+     for (i = 0, l = obj->dictGetLength(); i < l; ++i) {
+-        key = obj->dictGetKey(i);
++        key = obj->dictGetKey(i)->getCString();
+         if (strncmp("FontDescriptor", key, strlen("FontDescriptor")) == 0
+             || strncmp("BaseFont", key, strlen("BaseFont")) == 0
+             || strncmp("Encoding", key, strlen("Encoding")) == 0)
+@@ -424,7 +424,7 @@
+     for (i = 0, l = obj->dictGetLength(); i < l; ++i) {
+         obj->dictGetValNF(i, &fontRef);
+         if (fontRef->isRef())
+-            copyFont(obj->dictGetKey(i), &fontRef);
++            copyFont(obj->dictGetKey(i)->getCString(), &fontRef);
+         else
+             pdftex_fail("PDF inclusion: invalid font in reference type <%s>",
+                         fontRef->getTypeName());
+@@ -511,7 +511,7 @@
+     int i, l, c;
+     Ref ref;
+     char *p;
+-    GString *s;
++    GooString *s;
+     if (obj->isBool()) {
+         pdf_printf("%s", obj->getBool()? "true" : "false");
+     } else if (obj->isInt()) {
+@@ -677,7 +677,7 @@
+     float pdf_version_found, pdf_version_wanted;
+     // initialize
+     if (!isInit) {
+-        globalParams = new GlobalParams();
++        globalParams = new GlobalParams(NULL);
+         globalParams->setErrQuiet(gFalse);
+         isInit = gTrue;
+     }
+@@ -703,7 +703,7 @@
+     epdf_num_pages = pdf_doc->doc->getCatalog()->getNumPages();
+     if (page_name) {
+         // get page by name
+-        GString name(page_name);
++        UGooString name(page_name);
+         LinkDest *link = pdf_doc->doc->findDest(&name);
+         if (link == 0 || !link->isOk())
+             pdftex_fail("PDF inclusion: invalid destination <%s>", page_name);
+@@ -924,7 +924,7 @@
+         pdf_puts("/Resources <<\n");
+         for (i = 0, l = obj1->dictGetLength(); i < l; ++i) {
+             obj1->dictGetVal(i, &obj2);
+-            key = obj1->dictGetKey(i);
++            key = obj1->dictGetKey(i)->getCString();
+             if (strcmp("Font", key) == 0)
+                 copyFontResources(&obj2);
+             else if (strcmp("ProcSet", key) == 0)
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftosrc.cc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftosrc.cc	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftosrc.cc	2007-05-19 14:21:27.000000000 +0200
+@@ -25,22 +25,24 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <aconf.h>
+ #include <assert.h>
+-#include <GString.h>
+-#include <gmem.h>
+-#include <gfile.h>
+-#include "Object.h"
+-#include "Stream.h"
+-#include "Array.h"
+-#include "Dict.h"
+-#include "XRef.h"
+-#include "Catalog.h"
+-#include "Page.h"
+-#include "GfxFont.h"
+-#include "PDFDoc.h"
+-#include "GlobalParams.h"
+-#include "Error.h"
++
++#include <dirent.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/UGooString.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
+ 
+ static XRef *xref = 0;
+ 
+@@ -48,7 +50,7 @@
+ {
+     char *p, buf[1024];
+     PDFDoc *doc;
+-    GString *fileName;
++    GooString *fileName;
+     Stream *s;
+     Object srcStream, srcName, catalogDict;
+     FILE *outfile;
+@@ -62,8 +64,8 @@
+                 "Usage: pdftosrc <PDF-file> [<stream-object-number>]\n");
+         exit(1);
+     }
+-    fileName = new GString(argv[1]);
+-    globalParams = new GlobalParams();
++    fileName = new GooString(argv[1]);
++    globalParams = new GlobalParams(NULL);
+     doc = new PDFDoc(fileName);
+     if (!doc->isOk()) {
+         fprintf(stderr, "Invalid PDF file\n");
+@@ -83,7 +85,7 @@
+     }
+     srcStream.initNull();
+     if (objnum == 0) {
+-        catalogDict.dictLookup("SourceObject", &srcStream);
++        catalogDict.dictLookup(UGooString("SourceObject"), &srcStream);
+         if (!srcStream.isStream("SourceFile")) {
+             fprintf(stderr, "No SourceObject found\n");
+             exit(1);
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/Makefile.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/Makefile.in	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/Makefile.in	2007-05-19 14:21:27.000000000 +0200
+@@ -8,7 +8,7 @@
+ kpathsea_srcdir_parent = $(srcdir)/../..
+ kpathsea_dir_parent = ../..
+ 
+-ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) @LIBXPDFCPPFLAGS@ -I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/..
++ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) -I/usr/include/poppler -I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/..
+ CXX = @CXX@
+ 
+ .SUFFIXES: .cc .o
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftex.mk	2006-12-27 00:37:34.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftex.mk	2007-05-19 14:21:27.000000000 +0200
+@@ -2,6 +2,9 @@
+ # This fragment contains the parts of the makefile that are most likely to
+ # differ between releases of pdfeTeX.
+ 
++# use libpoppler instead of included xpdf code
++ADDLDFLAGS = -lpoppler
++
+ # We build pdftex
+ pdftex = @PETEX@ pdftex
+ pdftexdir = pdftexdir
+@@ -29,7 +32,7 @@
+ 
+ # Making pdftex
+ pdftex: pdftexd.h $(pdftex_o) $(pdftexextra_o) $(pdftexlibsdep)
+-	@CXXHACKLINK@ $(pdftex_o) $(pdftexextra_o) $(pdftexlibs) $(socketlibs) @CXXHACKLDLIBS@ @CXXLDEXTRA@
++	@CXXHACKLINK@ $(pdftex_o) $(pdftexextra_o) $(pdftexlibs) $(socketlibs) @CXXHACKLDLIBS@ @CXXLDEXTRA@ $(ADDLDFLAGS)
+ 
+ # C file dependencies.
+ $(pdftex_c) pdftexcoerce.h pdftexd.h: pdftex.p $(web2c_texmf) $(srcdir)/$(pdftexdir)/pdftex.defines $(srcdir)/$(pdftexdir)/pdftex.h
+@@ -153,10 +156,10 @@
+ 	rm -f ttf2afm.c macnames.c
+ # 
+ # pdftosrc
+-pdftosrc = pdftosrc
++pdftosrc = 
+ 
+ pdftosrc: $(pdftexdir)/pdftosrc.o $(LIBXPDFDEP)
+-	@CXXHACKLINK@ $(pdftexdir)/pdftosrc.o $(LDLIBXPDF) -lm @CXXLDEXTRA@
++	@CXXHACKLINK@ $(pdftexdir)/pdftosrc.o $(LDLIBXPDF) -lm @CXXLDEXTRA@  $(ADDLDFLAGS)
+ $(pdftexdir)/pdftosrc.o:$(srcdir)/$(pdftexdir)/pdftosrc.cc
+ 	cd $(pdftexdir) && $(MAKE) pdftosrc.o
+ check: pdftosrc-check
+Index: texlive-bin-2007/build/source/configure
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure	2007-05-19 14:21:16.000000000 +0200
++++ texlive-bin-2007/build/source/configure	2007-05-19 14:21:27.000000000 +0200
+@@ -3459,9 +3459,9 @@
+ 
+ # we need libxpdf for pdf[ex]tex, xetex
+ test ! -d $srcdir/$LIBXPDFDIR && : ${needs_libxpdf=no}
+-test "$with_pdftex"  != no    && : ${needs_libxpdf=yes}
+-test "$with_pdfetex" != no    && : ${needs_libxpdf=yes}
+-test "$with_xetex"   != no    && : ${needs_libxpdf=yes}
++test "$with_pdftex"  != no    && : ${needs_libxpdf=no}
++test "$with_pdfetex" != no    && : ${needs_libxpdf=no}
++test "$with_xetex"   != no    && : ${needs_libxpdf=no}
+ : ${needs_libxpdf=no}
+ export needs_libxpdf
+ 
+Index: texlive-bin-2007/build/source/configure.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure.in	2007-05-19 14:21:16.000000000 +0200
++++ texlive-bin-2007/build/source/configure.in	2007-05-19 14:21:27.000000000 +0200
+@@ -157,9 +157,9 @@
+ 
+ # we need libxpdf for pdf[ex]tex, xetex
+ test ! -d $srcdir/$LIBXPDFDIR && : ${needs_libxpdf=no}
+-test "$with_pdftex"  != no    && : ${needs_libxpdf=yes}
+-test "$with_pdfetex" != no    && : ${needs_libxpdf=yes}
+-test "$with_xetex"   != no    && : ${needs_libxpdf=yes}
++test "$with_pdftex"  != no    && : ${needs_libxpdf=no}
++test "$with_pdfetex" != no    && : ${needs_libxpdf=no}
++test "$with_xetex"   != no    && : ${needs_libxpdf=no}
+ : ${needs_libxpdf=no}
+ export needs_libxpdf
+ 
+@@ -207,7 +207,7 @@
+ sinclude(libs/libpng/libpng.ac)
+ sinclude(libs/zlib/zlib.ac)
+ sinclude(libs/ncurses/ncurses.ac)
+-sinclude(libs/xpdf/libxpdf.ac)
++#sinclude(libs/xpdf/libxpdf.ac)
+ sinclude(libs/t1lib/t1lib.ac)
+ sinclude(libs/gd/gd.ac)
+ sinclude(libs/freetype/freetype.ac)
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-01-15 14:04:36.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-05-19 14:21:27.000000000 +0200
+@@ -33,7 +33,7 @@
+  */
+ 
+ #ifdef XETEX_OTHER
+-#include "xpdf/config.h"
++#include "poppler/poppler-config.h"
+ #include "png.h"
+ #endif
+ 
+@@ -194,7 +194,7 @@
+ #else
+ 		"Compiled with fontconfig version %d.%d.%d; using %d.%d.%d\n"
+ 		"Compiled with libpng version %s; using %s\n"
+-		"Compiled with xpdf version %s\n"
++		"Compiled with libpoppler version %s\n"
+ #endif
+ 		;
+ 
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/pdfimage.cpp
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/pdfimage.cpp	2006-12-09 11:29:12.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/pdfimage.cpp	2007-05-19 14:21:27.000000000 +0200
+@@ -11,10 +11,24 @@
+ 
+ #include "pdfimage.h"
+ 
+-#include "PDFDoc.h"
+-#include "Catalog.h"
+-#include "Page.h"
+-#include "GString.h"
++#include <dirent.h>
++#include <poppler/poppler-config.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Link.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
++
+ 
+ #include "XeTeX_ext.h"
+ 
+@@ -28,7 +42,7 @@
+ int
+ pdf_get_rect(char* filename, int page_num, int pdf_box, realrect* box)
+ {
+-	GString*	name = new GString(filename);
++	GooString*	name = new GooString(filename);
+ 	PDFDoc*		doc = new PDFDoc(name);
+ 	
+ 	if (!doc) {
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex.mk	2007-01-20 13:44:35.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk	2007-05-19 14:21:27.000000000 +0200
+@@ -4,6 +4,10 @@
+ 
+ Makefile: $(srcdir)/xetexdir/xetex.mk
+ 
++# use libpoppler instead of included xpdf code
++ADDLDFLAGS = -lpoppler
++
++
+ # We build xetex unless configure decides to skip it
+ xetex = @XETEX@ xetex
+ 
+@@ -29,7 +33,7 @@
+ 
+ @XETEX_GENERIC@ XETEX_DEFINES = -DXETEX_OTHER
+ 
+-@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ @LDFONTCONFIG@
++@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ @LDFONTCONFIG@ $(ADDLDFLAGS)
+ 
+ @XETEX_GENERIC@ EXTRADEPS = @LIBXPDFDEP@ @LIBPNGDEP@
+ 
+@@ -144,7 +148,7 @@
+ 	$(compile) $(ALL_CFLAGS) $(LIBPNGCPPFLAGS) $(ZLIBCPPFLAGS) -c $< -o $@
+ 
+ pdfimage.o: $(srcdir)/xetexdir/pdfimage.cpp $(srcdir)/xetexdir/pdfimage.h
+-	$(CXX) $(ALL_CFLAGS) $(LIBXPDFCPPFLAGS) -c $< -o $@
++	$(CXX) $(ALL_CFLAGS) $(LIBXPDFCPPFLAGS) -I/usr/include/poppler -c $< -o $@
+ 
+ XeTeX_pic.o: $(srcdir)/xetexdir/XeTeX_pic.c $(srcdir)/xetexdir/XeTeX_ext.h $(XeTeXImageHdrs)
+ 	$(compile) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/utils.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/utils.c	2007-01-01 18:20:03.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/utils.c	2007-05-19 14:21:27.000000000 +0200
+@@ -37,7 +37,7 @@
+ #include "zlib.h"
+ #include "ptexlib.h"
+ #include "png.h"
+-#include "xpdf/config.h"        /* just to get the xpdf version */
++#include "poppler/poppler-config.h"        /* just to get the xpdf version */
+ 
+ #define check_nprintf(size_get, size_want) \
+     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
+@@ -1261,7 +1261,7 @@
+     (void) asprintf(versions,
+                     "Compiled with libpng %s; using libpng %s\n"
+                     "Compiled with zlib %s; using zlib %s\n"
+-                    "Compiled with xpdf version %s\n",
++                    "Compiled with libpoppler version %s\n",
+                     PNG_LIBPNG_VER_STRING, png_libpng_ver,
+                     ZLIB_VERSION, zlib_version, xpdfVersion);
+ }
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftexextra.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftexextra.in	2007-05-19 14:23:01.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftexextra.in	2007-05-19 14:23:31.000000000 +0200
+@@ -26,7 +26,7 @@
+    (generated from ../lib/texmfmp.c).
+ */
+ 
+-#define BANNER "This is pdfTeX, Version 3.141592-PDFTEX-VERSION-ETEX-VERSION"
++#define BANNER "This is pdfTeX using libpoppler, Version 3.141592-PDFTEX-VERSION-ETEX-VERSION"
+ #define COPYRIGHT_HOLDER "Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX)"
+ #define AUTHOR NULL
+ #define PROGRAM_HELP PDFTEXHELP
--- texlive-bin-2007.dfsg.2.orig/debian/patches/50_fmtutil_deb
+++ texlive-bin-2007.dfsg.2/debian/patches/50_fmtutil_deb
@@ -0,0 +1,144 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50_fmtutil_deb.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: debianize fmtutil, updmap etc, taken from tetex
+
+@DPATCH@
+ build/source/texk/tetex/fmtutil |   23 ++++++-----------------
+ texmf/doc/man/man1/fmtutil.1    |   38 ++++++++++++++++++++++++++++----------
+ 2 files changed, 34 insertions(+), 27 deletions(-)
+
+Index: texlive-bin-2007/texmf/doc/man/man1/fmtutil.1
+===================================================================
+--- texlive-bin-2007.orig/texmf/doc/man/man1/fmtutil.1	2007-06-20 15:21:14.000000000 +0200
++++ texlive-bin-2007/texmf/doc/man/man1/fmtutil.1	2007-06-20 15:21:16.000000000 +0200
+@@ -1,4 +1,4 @@
+-.TH "fmtutil" "8" "February 2005" "teTeX" "teTeX" 
++.TH "fmtutil" "1" "February 2005" "teTeX" "teTeX"
+ .PP 
+ .SH "NAME" 
+ fmtutil \- utility for maintaining TeX format files
+@@ -20,21 +20,36 @@
+ .PP 
+ .IP "\fB--all\fP" 
+ recreate all format files
+-.IP "\fB--byfmt\fP \fIformatname\fP" 
++.IP "\fB--missing\fP"
++create any missing format files
++.IP "\fB--refresh\fP"
++recreate only existing format files
++.IP "\fB--byfmt\fP \fIformatname\fP"
+ (re)create the format for
+ format \fIformatname\fP
+-.IP "\fB--byhyphen\fP \fIhyphenfile\fP" 
++.IP "\fB--byhyphen\fP \fIhyphenfile\fP"
+ (re)create formats that
+ depend on the hyphenation file
+ \fIhyphenfile\fP
+-.IP "\fB--help\fP" 
+-print a summary of commands and options
+-.IP "\fB--missing\fP" 
+-create any missing format files
+-.IP "\fB--showhyphen\fP \fIformatname\fP" 
++.IP "\fB--enablefmt\fP \fIformatname\fP"
++enable formatname in config file
++.IP "\fB--disablefmt\fP \fIformatname\fP"
++disable formatname in config file
++.IP "\fB--listcfg\fP"
++list (enabled and disabled) configurations, filtered to available
++formats
++.IP "\fB--catcfg\fP"
++output the content of the config file
++.IP "\fB--showhyphen\fP \fIformatname\fP"
+ print the name of the
+ hyphenation file for the format
+ \fIformatname\fP
++.IP "\fB--edit\fP"
++edit fmtutil.cnf file (disabled in Debian)
++.IP "\fB--version\fP"
++show version info
++.IP "\fB--help\fP"
++print a summary of commands and options
+ .PP 
+ .SH "OPTIONS" 
+ .PP 
+@@ -56,12 +71,15 @@
+ .PP 
+ .SH "FILES" 
+ .PP 
+-.IP "\fIfmtutil\&.cnf\fP" 
++.IP "\fIfmtutil\&.cnf\fP"
+ default configuration file
++.IP "\fI/etc/texmf/fmt.d/\fP"
++Debian-specific directory for configuration file snippets
+ .PP 
+ .SH "SEE ALSO" 
+ .PP 
+-\fBkpsewhich\fP(1)
++\fBkpsewhich\fP(1),
++\fBupdate-fmtutil\fP(1)
+ .PP 
+ Web page: <http://tug\&.org/teTeX/>
+ .PP 
+Index: texlive-bin-2007/build/source/texk/tetex/fmtutil
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/fmtutil	2007-06-20 15:21:14.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/fmtutil	2007-06-20 15:33:51.000000000 +0200
+@@ -478,7 +478,8 @@
+       cleanup $?
+       ;;
+     edit)
+-      ${VISUAL-${EDITOR-vi}} $cnf_file
++      # defined by debianize-fmtutil
++      debianEditWarnAndShow
+       ;;
+     enablefmt|disablefmt)
+       $cmd $arg
+@@ -493,22 +494,6 @@
+       ;;
+   esac
+ 
+-  if test -n "$cfgmaint"; then
+-    if test -z "$cfgparam"; then
+-      ci=`tcfmgr --tmp $tmpdir --cmd ci --id $id`
+-      if test $? = 0; then
+-        if test -n "$ci"; then
+-          verboseMsg "$progname: configuration file updated: \`$ci'"
+-        else
+-          verboseMsg "$progname: configuration file unchanged."
+-        fi
+-      else
+-        abort "failed to update configuration file."
+-      fi
+-    fi
+-    cleanup $?
+-  fi
+-
+   # set up destdir:
+   if test -z "$destdir"; then
+     : ${MT_TEXMFVAR=`kpsewhich -var-value=TEXMFVAR`}
+@@ -859,6 +844,7 @@
+ ###############################################################################
+ # disablefmt(format)
+ #   disables format in configuration file
++#    [ redefined by debianize-fmtutil ]
+ ###############################################################################
+ disablefmt()
+ {
+@@ -875,6 +861,7 @@
+ ###############################################################################
+ #  enablefmt(format)
+ #    enables format in configuration file
++#    [ redefined by debianize-fmtutil ]
+ ###############################################################################
+ enablefmt()
+ {
+@@ -887,5 +874,7 @@
+   (exit 0); return 0
+ }
+ 
++. /usr/share/texlive-bin/debianize-fmtutil
++
+ main ${1+"$@"}
+ cleanup 0
--- texlive-bin-2007.dfsg.2.orig/debian/patches/41_maketexmf
+++ texlive-bin-2007.dfsg.2/debian/patches/41_maketexmf
@@ -0,0 +1,43 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 41_maketexmf.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: fix for mktexmf script from perforce depot
+
+@DPATCH@
+ build/source/texk/kpathsea/mktexmf |   19 +++++++++++--------
+ 1 file changed, 11 insertions(+), 8 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/kpathsea/mktexmf
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/kpathsea/mktexmf	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/kpathsea/mktexmf	2007-01-26 04:01:50.000000000 +0100
+@@ -36,17 +36,20 @@
+   rootfile=$sauterroot
+   rootname=b-$rootname
+ else
+-  case $rootname in
++  case $name in
+     # csso12[0-5][0-9] from CJK package; unsupported by mktexmf
+     csso12[0-5][0-9])
+-       rootfile=;;
+-    cs*|lcsss*|icscsc*|icstt*|ilcsss*)
+-       rootfile=`kpsewhich cscode.mf`;;
+-    wn[bcdfirstuv]*|rx[bcdfiorstuvx][bcfhilmostx]|l[abcdhl][bcdfiorstuvx]*)
+-       lhprefix=`echo "$name" | sed 's/^\(..\).*/\1/'`
+-       rootfile=`kpsewhich ${lhprefix}codes.mf 2>/dev/null`;;
++      rootfile=;;
+     *)
+-       rootfile=`kpsewhich $rootname.mf 2>/dev/null`;;
++      case $rootname in
++        cs*|lcsss*|icscsc*|icstt*|ilcsss*)
++          rootfile=`kpsewhich cscode.mf`;;
++        wn[bcdfirstuv]*|rx[bcdfiorstuvx][bcfhilmostx]|l[abcdhl][bcdfiorstuvx]*)
++          lhprefix=`echo "$name" | sed 's/^\(..\).*/\1/'`
++          rootfile=`kpsewhich ${lhprefix}codes.mf 2>/dev/null`;;
++        *)
++          rootfile=`kpsewhich $rootname.mf 2>/dev/null`;;
++      esac;;
+   esac
+ fi
+ { test -z "$rootfile" || test ! -f "$rootfile"; } && exit 1
--- texlive-bin-2007.dfsg.2.orig/debian/patches/gcc43-compile-fix
+++ texlive-bin-2007.dfsg.2/debian/patches/gcc43-compile-fix
@@ -0,0 +1,32 @@
+Fix compilation of teckit with recent gcc (>= 4.3) compiler.
+Patch taken from 2007-12ubuntu3, so I assume it was made by
+Matthias Klose <doko@ubuntu.com>.
+---
+ build/source/libs/teckit/source/Engine.cpp         |    1 +
+ build/source/libs/teckit/source/ulong_chartraits.h |    1 +
+ 2 files changed, 2 insertions(+)
+
+Index: texlive-bin-2007/build/source/libs/teckit/source/Engine.cpp
+===================================================================
+--- texlive-bin-2007.orig/build/source/libs/teckit/source/Engine.cpp	2007-09-24 16:00:10.000000000 +0200
++++ texlive-bin-2007/build/source/libs/teckit/source/Engine.cpp	2007-09-24 16:00:48.000000000 +0200
+@@ -64,6 +64,7 @@
+ int	traceLevel = 1;
+ #endif
+ 
++#include <cstring>
+ #include <cstdlib>
+ #include <algorithm>
+ 
+Index: texlive-bin-2007/build/source/libs/teckit/source/ulong_chartraits.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/libs/teckit/source/ulong_chartraits.h	2007-09-24 16:00:03.000000000 +0200
++++ texlive-bin-2007/build/source/libs/teckit/source/ulong_chartraits.h	2007-09-24 16:00:48.000000000 +0200
+@@ -3,6 +3,7 @@
+ 
+ #include <iostream>
+ #include <string>
++#include <cstring>
+ 
+ /*
+ 	This used to be defined for unsigned long; changed to unsigned int for 64-bit architecture.
--- texlive-bin-2007.dfsg.2.orig/debian/patches/30_libpoppler_0.5.9
+++ texlive-bin-2007.dfsg.2/debian/patches/30_libpoppler_0.5.9
@@ -0,0 +1,454 @@
+# 30_libpoppler.dpatch
+#
+# use libpoppler instead of libxpdf in pdfetex and xetex
+# don't build pdftosrc as it needs libpoppler from experimental 
+
+@DPATCH@
+ build/source/configure                           |    6 +-
+ build/source/configure.in                        |    8 +--
+ build/source/texk/web2c/pdftexdir/Makefile.in    |    2 
+ build/source/texk/web2c/pdftexdir/depend.mk      |   58 +----------------------
+ build/source/texk/web2c/pdftexdir/pdftex.mk      |    9 ++-
+ build/source/texk/web2c/pdftexdir/pdftexextra.in |    2 
+ build/source/texk/web2c/pdftexdir/pdftoepdf.cc   |   54 ++++++++++-----------
+ build/source/texk/web2c/pdftexdir/pdftosrc.cc    |   40 ++++++++-------
+ build/source/texk/web2c/pdftexdir/utils.c        |    4 -
+ build/source/texk/web2c/xetexdir/XeTeX_ext.c     |    4 -
+ build/source/texk/web2c/xetexdir/pdfimage.cpp    |   24 +++++++--
+ build/source/texk/web2c/xetexdir/xetex.mk        |    8 ++-
+ 12 files changed, 96 insertions(+), 123 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/depend.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/depend.mk	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/depend.mk	2007-07-03 12:08:40.000000000 +0200
+@@ -1,55 +1,5 @@
+-epdf.o: epdf.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-mapfile.o: mapfile.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-papersiz.o: papersiz.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-utils.o: utils.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h \
+- ../../../libs/zlib/zlib.h ../../../libs/zlib/zconf.h \
+- ../../../libs/md5/md5.h pdftexextra.h \
+- ../../../libs/obsdcompat/openbsd-compat.h
+-vfpacket.o: vfpacket.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-pkin.o: pkin.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writefont.o: writefont.c ../../../libs/xpdf/goo/gmem.h ptexlib.h \
+- ../pdftexd.h ../texmfmp.h ../cpascal.h ../config.h ../help.h \
+- ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writet1.o: writet1.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writet3.o: writet3.c ptexlib.h ../pdftexd.h ../texmfmp.h ../cpascal.h \
+- ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h ptexmac.h
+-writezip.o: writezip.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h ../../../libs/zlib/zlib.h ../../../libs/zlib/zconf.h
+-writeenc.o: writeenc.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h
+-writettf.o: writettf.c ptexlib.h writettf.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h macnames.c
+-writejpg.o: writejpg.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-writepng.o: writepng.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-writeimg.o: writeimg.c ptexlib.h ../pdftexd.h ../texmfmp.h \
+- ../cpascal.h ../config.h ../help.h ../texmfmem.h ../pdftexcoerce.h \
+- ptexmac.h image.h
+-pdftoepdf.o: pdftoepdf.cc ../../../libs/xpdf/xpdf/Object.h \
+- ../../../libs/xpdf/goo/gmem.h ../../../libs/xpdf/xpdf/Array.h \
+- ../../../libs/xpdf/xpdf/Dict.h ../../../libs/xpdf/xpdf/Stream.h \
+- ../../../libs/xpdf/xpdf/XRef.h ../../../libs/xpdf/xpdf/Catalog.h \
+- ../../../libs/xpdf/xpdf/Page.h ../../../libs/xpdf/xpdf/GfxFont.h \
+- ../../../libs/xpdf/xpdf/Error.h epdf.h
++pdftoepdf.o: pdftoepdf.cc epdf.h ../../kpathsea/c-auto.h \
++  ../../kpathsea/c-proto.h ../../web2c/c-auto.h ../../web2c/config.h \
++  ../../kpathsea/c-fopen.h ../../web2c/pdftexdir/ptexmac.h
+ ttf2afm.o: ttf2afm.c writettf.h macnames.c
+-pdftosrc.o: pdftosrc.cc ../../../libs/xpdf/xpdf/Object.h \
+- ../../../libs/xpdf/xpdf/Array.h ../../../libs/xpdf/xpdf/Dict.h \
+- ../../../libs/xpdf/xpdf/Stream.h ../../../libs/xpdf/xpdf/XRef.h \
+- ../../../libs/xpdf/xpdf/Catalog.h ../../../libs/xpdf/xpdf/Page.h \
+- ../../../libs/xpdf/xpdf/PDFDoc.h ../../../libs/xpdf/xpdf/Link.h \
+- ../../../libs/xpdf/xpdf/Error.h ../../../libs/xpdf/xpdf/config.h
++pdftosrc.o: pdftosrc.cc
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftoepdf.cc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftoepdf.cc	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftoepdf.cc	2007-07-03 12:08:40.000000000 +0200
+@@ -26,25 +26,24 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <aconf.h>
+-#include <GString.h>
+-#include <gmem.h>
+-#include <gfile.h>
+-#include <config.h>
+ #include <assert.h>
+-#include "Object.h"
+-#include "Stream.h"
+-#include "Array.h"
+-#include "Dict.h"
+-#include "XRef.h"
+-#include "Catalog.h"
+-#include "Link.h"
+-#include "Page.h"
+-#include "GfxFont.h"
+-#include "PDFDoc.h"
+-#include "GlobalParams.h"
+-#include "Error.h"
+-
++#include <dirent.h>
++#include <poppler/poppler-config.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Link.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
+ #include "epdf.h"
+ 
+ // This file is mostly C and not very much C++; it's just used to interface
+@@ -169,7 +168,7 @@
+     fprintf(stderr, "\npdfTeX Debug: Creating %s (%d)\n", p->file_name,
+             p->occurences);
+ #endif
+-    GString *docName = new GString(p->file_name);
++    GooString *docName = new GooString(p->file_name);
+     p->doc = new PDFDoc(docName);       // takes ownership of docName
+     if (!p->doc->isOk() || !p->doc->okToPrint()) {
+         pdftex_fail("xpdf: reading PDF image failed");
+@@ -511,7 +510,7 @@
+     int i, l, c;
+     Ref ref;
+     char *p;
+-    GString *s;
++    GooString *s;
+     if (obj->isBool()) {
+         pdf_printf("%s", obj->getBool()? "true" : "false");
+     } else if (obj->isInt()) {
+@@ -703,7 +702,7 @@
+     epdf_num_pages = pdf_doc->doc->getCatalog()->getNumPages();
+     if (page_name) {
+         // get page by name
+-        GString name(page_name);
++        GooString name(page_name);
+         LinkDest *link = pdf_doc->doc->findDest(&name);
+         if (link == 0 || !link->isOk())
+             pdftex_fail("PDF inclusion: invalid destination <%s>", page_name);
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftosrc.cc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftosrc.cc	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftosrc.cc	2007-07-03 12:08:58.000000000 +0200
+@@ -25,22 +25,23 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <aconf.h>
+ #include <assert.h>
+-#include <GString.h>
+-#include <gmem.h>
+-#include <gfile.h>
+-#include "Object.h"
+-#include "Stream.h"
+-#include "Array.h"
+-#include "Dict.h"
+-#include "XRef.h"
+-#include "Catalog.h"
+-#include "Page.h"
+-#include "GfxFont.h"
+-#include "PDFDoc.h"
+-#include "GlobalParams.h"
+-#include "Error.h"
++
++#include <dirent.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
+ 
+ static XRef *xref = 0;
+ 
+@@ -48,7 +49,7 @@
+ {
+     char *p, buf[1024];
+     PDFDoc *doc;
+-    GString *fileName;
++    GooString *fileName;
+     Stream *s;
+     Object srcStream, srcName, catalogDict;
+     FILE *outfile;
+@@ -62,8 +63,8 @@
+                 "Usage: pdftosrc <PDF-file> [<stream-object-number>]\n");
+         exit(1);
+     }
+-    fileName = new GString(argv[1]);
+-    globalParams = new GlobalParams();
++    fileName = new GooString(argv[1]);
++    globalParams = new GlobalParams(NULL);
+     doc = new PDFDoc(fileName);
+     if (!doc->isOk()) {
+         fprintf(stderr, "Invalid PDF file\n");
+@@ -83,7 +84,7 @@
+     }
+     srcStream.initNull();
+     if (objnum == 0) {
+-        catalogDict.dictLookup("SourceObject", &srcStream);
++        catalogDict.dictLookup(UGooString("SourceObject"), &srcStream);
+         if (!srcStream.isStream("SourceFile")) {
+             fprintf(stderr, "No SourceObject found\n");
+             exit(1);
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/Makefile.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/Makefile.in	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/Makefile.in	2007-07-03 12:08:40.000000000 +0200
+@@ -8,7 +8,7 @@
+ kpathsea_srcdir_parent = $(srcdir)/../..
+ kpathsea_dir_parent = ../..
+ 
+-ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) @LIBXPDFCPPFLAGS@ -I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/..
++ALL_CXXFLAGS = @CXXFLAGS@ @DEFS@ $(XXCFLAGS) -I. -I$(srcdir) -I$(kpathsea_dir_parent) -I$(kpathsea_srcdir_parent) -I/usr/include/poppler -I$(LIBOBSDCOMPATDIR) -I$(LIBOBSDCOMPATDIR)/.. -I$(LIBOBSDCOMPATFSRCDIR) -I$(LIBOBSDCOMPATFSRCDIR)/..
+ CXX = @CXX@
+ 
+ .SUFFIXES: .cc .o
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftex.mk	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftex.mk	2007-07-03 12:08:40.000000000 +0200
+@@ -2,6 +2,9 @@
+ # This fragment contains the parts of the makefile that are most likely to
+ # differ between releases of pdfeTeX.
+ 
++# use libpoppler instead of included xpdf code
++ADDLDFLAGS = -lpoppler
++
+ # We build pdftex
+ pdftex = @PETEX@ pdftex
+ pdftexdir = pdftexdir
+@@ -29,7 +32,7 @@
+ 
+ # Making pdftex
+ pdftex: pdftexd.h $(pdftex_o) $(pdftexextra_o) $(pdftexlibsdep)
+-	@CXXHACKLINK@ $(pdftex_o) $(pdftexextra_o) $(pdftexlibs) $(socketlibs) @CXXHACKLDLIBS@ @CXXLDEXTRA@
++	@CXXHACKLINK@ $(pdftex_o) $(pdftexextra_o) $(pdftexlibs) $(socketlibs) @CXXHACKLDLIBS@ @CXXLDEXTRA@ $(ADDLDFLAGS)
+ 
+ # C file dependencies.
+ $(pdftex_c) pdftexcoerce.h pdftexd.h: pdftex.p $(web2c_texmf) $(srcdir)/$(pdftexdir)/pdftex.defines $(srcdir)/$(pdftexdir)/pdftex.h
+@@ -153,10 +156,10 @@
+ 	rm -f ttf2afm.c macnames.c
+ # 
+ # pdftosrc
+-pdftosrc = pdftosrc
++pdftosrc = 
+ 
+ pdftosrc: $(pdftexdir)/pdftosrc.o $(LIBXPDFDEP)
+-	@CXXHACKLINK@ $(pdftexdir)/pdftosrc.o $(LDLIBXPDF) -lm @CXXLDEXTRA@
++	@CXXHACKLINK@ $(pdftexdir)/pdftosrc.o $(LDLIBXPDF) -lm @CXXLDEXTRA@  $(ADDLDFLAGS)
+ $(pdftexdir)/pdftosrc.o:$(srcdir)/$(pdftexdir)/pdftosrc.cc
+ 	cd $(pdftexdir) && $(MAKE) pdftosrc.o
+ check: pdftosrc-check
+Index: texlive-bin-2007/build/source/configure
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure	2007-07-03 12:08:40.000000000 +0200
++++ texlive-bin-2007/build/source/configure	2007-07-03 12:08:40.000000000 +0200
+@@ -3459,9 +3459,9 @@
+ 
+ # we need libxpdf for pdf[ex]tex, xetex
+ test ! -d $srcdir/$LIBXPDFDIR && : ${needs_libxpdf=no}
+-test "$with_pdftex"  != no    && : ${needs_libxpdf=yes}
+-test "$with_pdfetex" != no    && : ${needs_libxpdf=yes}
+-test "$with_xetex"   != no    && : ${needs_libxpdf=yes}
++test "$with_pdftex"  != no    && : ${needs_libxpdf=no}
++test "$with_pdfetex" != no    && : ${needs_libxpdf=no}
++test "$with_xetex"   != no    && : ${needs_libxpdf=no}
+ : ${needs_libxpdf=no}
+ export needs_libxpdf
+ 
+Index: texlive-bin-2007/build/source/configure.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure.in	2007-07-03 12:08:40.000000000 +0200
++++ texlive-bin-2007/build/source/configure.in	2007-07-03 12:08:40.000000000 +0200
+@@ -157,9 +157,9 @@
+ 
+ # we need libxpdf for pdf[ex]tex, xetex
+ test ! -d $srcdir/$LIBXPDFDIR && : ${needs_libxpdf=no}
+-test "$with_pdftex"  != no    && : ${needs_libxpdf=yes}
+-test "$with_pdfetex" != no    && : ${needs_libxpdf=yes}
+-test "$with_xetex"   != no    && : ${needs_libxpdf=yes}
++test "$with_pdftex"  != no    && : ${needs_libxpdf=no}
++test "$with_pdfetex" != no    && : ${needs_libxpdf=no}
++test "$with_xetex"   != no    && : ${needs_libxpdf=no}
+ : ${needs_libxpdf=no}
+ export needs_libxpdf
+ 
+@@ -207,7 +207,7 @@
+ sinclude(libs/libpng/libpng.ac)
+ sinclude(libs/zlib/zlib.ac)
+ sinclude(libs/ncurses/ncurses.ac)
+-sinclude(libs/xpdf/libxpdf.ac)
++#sinclude(libs/xpdf/libxpdf.ac)
+ sinclude(libs/t1lib/t1lib.ac)
+ sinclude(libs/gd/gd.ac)
+ sinclude(libs/freetype/freetype.ac)
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/XeTeX_ext.c	2007-07-03 12:08:40.000000000 +0200
+@@ -33,7 +33,7 @@
+  */
+ 
+ #ifdef XETEX_OTHER
+-#include "xpdf/config.h"
++#include "poppler/poppler-config.h"
+ #include "png.h"
+ #endif
+ 
+@@ -194,7 +194,7 @@
+ #else
+ 		"Compiled with fontconfig version %d.%d.%d; using %d.%d.%d\n"
+ 		"Compiled with libpng version %s; using %s\n"
+-		"Compiled with xpdf version %s\n"
++		"Compiled with libpoppler version %s\n"
+ #endif
+ 		;
+ 
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/pdfimage.cpp
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/pdfimage.cpp	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/pdfimage.cpp	2007-07-03 12:08:40.000000000 +0200
+@@ -11,10 +11,24 @@
+ 
+ #include "pdfimage.h"
+ 
+-#include "PDFDoc.h"
+-#include "Catalog.h"
+-#include "Page.h"
+-#include "GString.h"
++#include <dirent.h>
++#include <poppler/poppler-config.h>
++#include <poppler/goo/GooString.h>
++#include <poppler/goo/gmem.h>
++#include <poppler/goo/gfile.h>
++#include "poppler/Object.h"
++#include "poppler/Stream.h"
++#include "poppler/Array.h"
++#include "poppler/Dict.h"
++#include "poppler/XRef.h"
++#include "poppler/Link.h"
++#include "poppler/Catalog.h"
++#include "poppler/Page.h"
++#include "poppler/GfxFont.h"
++#include "poppler/PDFDoc.h"
++#include "poppler/GlobalParams.h"
++#include "poppler/Error.h"
++
+ 
+ #include "XeTeX_ext.h"
+ 
+@@ -28,7 +42,7 @@
+ int
+ pdf_get_rect(char* filename, int page_num, int pdf_box, realrect* box)
+ {
+-	GString*	name = new GString(filename);
++	GooString*	name = new GooString(filename);
+ 	PDFDoc*		doc = new PDFDoc(name);
+ 	
+ 	if (!doc) {
+Index: texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/xetexdir/xetex.mk	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/xetexdir/xetex.mk	2007-07-03 12:08:40.000000000 +0200
+@@ -4,6 +4,10 @@
+ 
+ Makefile: $(srcdir)/xetexdir/xetex.mk
+ 
++# use libpoppler instead of included xpdf code
++ADDLDFLAGS = -lpoppler
++
++
+ # We build xetex unless configure decides to skip it
+ xetex = @XETEX@ xetex
+ 
+@@ -29,7 +33,7 @@
+ 
+ @XETEX_GENERIC@ XETEX_DEFINES = -DXETEX_OTHER
+ 
+-@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ @LDFONTCONFIG@
++@XETEX_GENERIC@ EXTRALIBS = @LDLIBXPDF@ @LDLIBPNG@ @LDFONTCONFIG@ $(ADDLDFLAGS)
+ 
+ @XETEX_GENERIC@ EXTRADEPS = @LIBXPDFDEP@ @LIBPNGDEP@
+ 
+@@ -144,7 +148,7 @@
+ 	$(compile) $(ALL_CFLAGS) $(LIBPNGCPPFLAGS) $(ZLIBCPPFLAGS) -c $< -o $@
+ 
+ pdfimage.o: $(srcdir)/xetexdir/pdfimage.cpp $(srcdir)/xetexdir/pdfimage.h
+-	$(CXX) $(ALL_CFLAGS) $(LIBXPDFCPPFLAGS) -c $< -o $@
++	$(CXX) $(ALL_CFLAGS) $(LIBXPDFCPPFLAGS) -I/usr/include/poppler -c $< -o $@
+ 
+ XeTeX_pic.o: $(srcdir)/xetexdir/XeTeX_pic.c $(srcdir)/xetexdir/XeTeX_ext.h $(XeTeXImageHdrs)
+ 	$(compile) $(TECKITFLAGS) $(ALL_CFLAGS) $(XETEX_DEFINES) -c $< -o $@
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/utils.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/utils.c	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/utils.c	2007-07-03 12:08:40.000000000 +0200
+@@ -37,7 +37,7 @@
+ #include "zlib.h"
+ #include "ptexlib.h"
+ #include "png.h"
+-#include "xpdf/config.h"        /* just to get the xpdf version */
++#include "poppler/poppler-config.h"        /* just to get the xpdf version */
+ 
+ #define check_nprintf(size_get, size_want) \
+     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
+@@ -1261,7 +1261,7 @@
+     (void) asprintf(versions,
+                     "Compiled with libpng %s; using libpng %s\n"
+                     "Compiled with zlib %s; using zlib %s\n"
+-                    "Compiled with xpdf version %s\n",
++                    "Compiled with libpoppler version %s\n",
+                     PNG_LIBPNG_VER_STRING, png_libpng_ver,
+                     ZLIB_VERSION, zlib_version, xpdfVersion);
+ }
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftexextra.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/pdftexextra.in	2007-07-03 12:03:20.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/pdftexextra.in	2007-07-03 12:08:40.000000000 +0200
+@@ -26,7 +26,7 @@
+    (generated from ../lib/texmfmp.c).
+ */
+ 
+-#define BANNER "This is pdfTeX, Version 3.141592-PDFTEX-VERSION-ETEX-VERSION"
++#define BANNER "This is pdfTeX using libpoppler, Version 3.141592-PDFTEX-VERSION-ETEX-VERSION"
+ #define COPYRIGHT_HOLDER "Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX)"
+ #define AUTHOR NULL
+ #define PROGRAM_HELP PDFTEXHELP
--- texlive-bin-2007.dfsg.2.orig/debian/patches/56_updmap_deb
+++ texlive-bin-2007.dfsg.2/debian/patches/56_updmap_deb
@@ -0,0 +1,138 @@
+Index: texlive-bin-2007/texmf/doc/man/man1/updmap.1
+===================================================================
+--- texlive-bin-2007.orig/texmf/doc/man/man1/updmap.1	2006-05-15 20:16:32.000000000 +0200
++++ texlive-bin-2007/texmf/doc/man/man1/updmap.1	2007-06-11 14:18:40.000000000 +0200
+@@ -32,11 +32,20 @@
+ line, \fBupdmap\fP will write generated map files to a directory of
+ your choosing (via one of the \fB--*outputdir\fP options), or automatically
+ determine where to place the files\&.  In the latter case, it tries to
+-use the tree where the variable TEXMFVAR points to.
++use the tree where the variable TEXMFVAR -- or TEXMFSYSVAR if called
++as \fBupdmap-sys\fP -- points to.
++.PP
+ When used with the options \fB--edit\fP, \fB--setoption\fP,
+-\fB--enable\fP, \fB--disable\fP, or \fB--syncwithtrees\fP, \fBupdmap\fP will first write
+-\fBupdmap\&.cfg\fP(5) and regenerate the map files only if this file
+-has been changed\&.
++\fB--enable\fP, \fB--disable\fP, or \fB--syncwithtrees\fP,
++\fBupdmap\fP will first write \fBupdmap\&.cfg\fP(5) and regenerate the
++map files only if this file has been changed\&.  In Debian, updmap has
++been adapted so that \fB--enable\fP and \fB--disable\fP do the "right
++thing": change the configuration snippets in \fIupdmap.d\fP instead,
++call \fBupdate-updmap\fP(1) to regenerate \fBupdmap\&.cfg\fP(5) and
++regenerate the map files afterwards.  There are some limitations,
++though: \fBupdmap\fP will regenerate the map files even if
++\fBupdmap\&.cfg\fP(5) has not been changed, and \fB--edit\fP and
++\fB--syncwithtrees\fP cannot be used.
+ .PP
+ .SH "OPTIONS"
+ .PP
+@@ -98,10 +107,10 @@
+ \fBdvipdfmDownloadBase14\fP
+ .IP
+ .IP "\fB--enable\fP \fImaptype\fP \fImapfile\fP"
+-Add or enable a \fBMap\fP or \fBMixedMap\fP for \fImapfile\fP\&.
++Permanently add or enable a \fBMap\fP or \fBMixedMap\fP for \fImapfile\fP\&.
+ .IP
+ .IP "\fB--enable Map=\fImapfile\fP"
+-Add or enable a Map for \fImapfile\fP\&.
++Permanently add or enable a Map for \fImapfile\fP\&.
+ .IP
+ .IP "\fB--enable MixedMap=\fP\fImapfile\fP"
+ Add or enable a MixedMap for \fImapfile\fP\&.
+@@ -126,7 +135,9 @@
+ .IP "\fIupdmap\&.cfg\fP"
+ Main configuration file\&.  In
+ \fItexmf/web2c\fP by default, but may be located elsewhere
+-depending on your distribution\&.
++depending on your distribution\&. \fBNote for Debian\fP: On Debian
+++ that file is generated out of files in \fI/etc/texmf/updmap.d\fP.
+++ See \fBupdate-updmap\fP(8) or the \fITeX-on-Debian\fP document.
+ .IP
+ .IP "\fIdvips35\&.map\fP"
+ Map file for standard 35 PostScript fonts for
+@@ -240,7 +251,7 @@
+ .PP
+ .SH "SEE ALSO"
+ .PP
+-\fBupdmap\&.cfg\fP(5), \fBdvipdfm\fP(1), \fBdvips\fP(1),
++\fBupdmap\&.cfg\fP(5), \fBupdate-updmap\fP(8), \fBdvipdfm\fP(1), \fBdvips\fP(1),
+ \fBgsftopk\fP(1), \fBpdftex\fP(1), \fBps2pk\fP(1),
+ \fBtexhash\fP(1), \fBxdvi\fP(1)\&.
+ .PP
+Index: texlive-bin-2007/build/source/texk/tetex/updmap
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/updmap	2006-12-25 19:43:31.000000000 +0100
++++ texlive-bin-2007/build/source/texk/tetex/updmap	2007-06-11 15:05:43.000000000 +0200
+@@ -325,6 +325,8 @@
+ #   sets option to value in the config file (replacing the existing setting
+ #   or by adding a new line to the config file).
+ ###############################################################################
++# for Debian, this is superseded by a function defined in debianize-updmap
++# (see below)
+ setOption()
+ {
+   opt=$1
+@@ -359,6 +361,8 @@
+ # enableMap (type, map)
+ #   enables an entry in the config file for map with a given type.
+ ###############################################################################
++# for Debian, this is superseded by a function defined in debianize-updmap
++# (see below)
+ enableMap()
+ {
+   case $1 in
+@@ -381,6 +385,8 @@
+ # disableMap (map)
+ #   disables map in config file (any type)
+ ###############################################################################
++# for Debian, this is superseded by a function defined in debianize-updmap
++# (see below)
+ disableMap()
+ {
+   #mapType=`awk '($1 == "MixedMap" || $1 == "Map") && $2 == map { print $1 }' \
+@@ -734,12 +740,8 @@
+ !!! ERROR! The map file \`$2' has not been found at all.
+ 
+     Either put this file into the right place or remove the
+-    reference from the configuration file. An automatic way
+-    to disable unavailable map files is to call
+-      $progname --syncwithtrees
+-
+-    For manual editing, call
+-      $progname --edit
++    reference from the configuration files - see
++    update-updmap(1).
+ "
+ 
+     false; return 1
+@@ -1037,6 +1039,8 @@
+ #   update the config file: uncomment all lines which refer to map files that
+ #   are unavailabe in the texmf trees
+ ###############################################################################
++# for Debian, this is superseded by a function defined in debianize-updmap
++# (see below)
+ syncWithTrees()
+ {
+   for i in `egrep '^(Mixed)?Map' "$cnfFile" | sed 's@.* @@'`; do
+@@ -1050,6 +1054,11 @@
+ }
+ 
+ ###############################################################################
++# source Debian-specific changes, superseding the last three functions
++###############################################################################
++. /usr/share/tex-common/debianize-updmap
++
++###############################################################################
+ # normalizeLines()
+ #   remove comments, whitespace is exactly one space, no empty lines,
+ #   no whitespace at end of line, one space before and after ",
+@@ -1341,7 +1350,7 @@
+ 
+     case "$cmd" in
+       edit)
+-        ${VISUAL-${EDITOR-vi}} "$cnfFile";;
++	debianEditWarnAndShow;;
+       setoption)
+         setOption "$setoptionOpt" "$setoptionVal";;
+       enable)
--- texlive-bin-2007.dfsg.2.orig/debian/patches/31_pdftex_gcc_ICE-on-alpha
+++ texlive-bin-2007.dfsg.2/debian/patches/31_pdftex_gcc_ICE-on-alpha
@@ -0,0 +1,24 @@
+---
+ build/source/texk/web2c/pdftexdir/writezip.c |    8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+Index: texlive-bin-2007/build/source/texk/web2c/pdftexdir/writezip.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/pdftexdir/writezip.c	2007-04-16 15:31:57.000000000 +0200
++++ texlive-bin-2007/build/source/texk/web2c/pdftexdir/writezip.c	2007-04-16 15:32:16.000000000 +0200
+@@ -51,7 +51,15 @@
+     for (;;) {
+         if (c_stream.avail_out == 0) {
+             pdfgone += xfwrite(zipbuf, 1, ZIP_BUF_SIZE, pdffile);
++#ifdef __alpha__
++	    /* work around http://gcc.gnu.org/PR28623 */
++	    {
++		volatile int o = ZIP_BUF_SIZE - 1;
++                pdflastbyte = zipbuf[o];
++	    }
++#else
+             pdflastbyte = zipbuf[ZIP_BUF_SIZE - 1];     /* not needed */
++#endif
+             c_stream.next_out = (Bytef *) zipbuf;
+             c_stream.avail_out = ZIP_BUF_SIZE;
+         }
--- texlive-bin-2007.dfsg.2.orig/debian/patches/01_tmp_configure_without_installextra
+++ texlive-bin-2007.dfsg.2/debian/patches/01_tmp_configure_without_installextra
@@ -0,0 +1,1147 @@
+---
+ build/source/configure              |  272 +++++++++++++++++++-----------------
+ build/source/configure.in           |    3 
+ build/source/texk/web2c/Makefile.in |    2 
+ build/source/withenable.ac          |    3 
+ 4 files changed, 151 insertions(+), 129 deletions(-)
+
+Index: texlive-bin-2007/build/source/configure
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure	2007-02-19 18:03:57.000000000 +0100
++++ texlive-bin-2007/build/source/configure	2007-02-19 18:04:06.000000000 +0100
+@@ -35,6 +35,8 @@
+ ac_help="$ac_help
+   --without-texinfo       do not build the texinfo package"
+ ac_help="$ac_help
++  --without-install-extra	do not initialize the installed tree"
++ac_help="$ac_help
+   --without-bibtex8          do not build the bibtex8 package"
+ ac_help="$ac_help
+   --without-cjkutils         do not build the cjkutils package"
+@@ -55,6 +57,8 @@
+ ac_help="$ac_help
+   --without-dvipng           do not build the dvipng package"
+ ac_help="$ac_help
++  --without-dvipos           do not build the dvipos package"
++ac_help="$ac_help
+   --without-dvipsk           do not build the dvipsk package"
+ ac_help="$ac_help
+   --without-gsftopk          do not build the gsftopk package"
+@@ -789,7 +793,7 @@
+ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+ 
+ echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+-echo "configure:793: checking whether ${MAKE-make} sets \${MAKE}" >&5
++echo "configure:797: checking whether ${MAKE-make} sets \${MAKE}" >&5
+ set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -818,7 +822,7 @@
+ # Extract the first word of "gcc", so it can be a program name with args.
+ set dummy gcc; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:822: checking for $ac_word" >&5
++echo "configure:826: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -849,7 +853,7 @@
+   # Extract the first word of "cc", so it can be a program name with args.
+ set dummy cc; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:853: checking for $ac_word" >&5
++echo "configure:857: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -901,7 +905,7 @@
+       # Extract the first word of "cl", so it can be a program name with args.
+ set dummy cl; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:905: checking for $ac_word" >&5
++echo "configure:909: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -934,7 +938,7 @@
+ fi
+ 
+ echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+-echo "configure:938: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
++echo "configure:942: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+ 
+ ac_ext=c
+ # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+@@ -945,12 +949,12 @@
+ 
+ cat > conftest.$ac_ext << EOF
+ 
+-#line 949 "configure"
++#line 953 "configure"
+ #include "confdefs.h"
+ 
+ main(){return(0);}
+ EOF
+-if { (eval echo configure:954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   ac_cv_prog_cc_works=yes
+   # If we can't run a trivial program, we are probably using a cross compiler.
+   if (./conftest; exit) 2>/dev/null; then
+@@ -976,12 +980,12 @@
+   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+-echo "configure:980: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
++echo "configure:984: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+ echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+ cross_compiling=$ac_cv_prog_cc_cross
+ 
+ echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+-echo "configure:985: checking whether we are using GNU C" >&5
++echo "configure:989: checking whether we are using GNU C" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -990,7 +994,7 @@
+   yes;
+ #endif
+ EOF
+-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:994: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
++if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:998: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+   ac_cv_prog_gcc=yes
+ else
+   ac_cv_prog_gcc=no
+@@ -1009,7 +1013,7 @@
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS=
+ echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+-echo "configure:1013: checking whether ${CC-cc} accepts -g" >&5
++echo "configure:1017: checking whether ${CC-cc} accepts -g" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1045,7 +1049,7 @@
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:1049: checking for $ac_word" >&5
++echo "configure:1053: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1078,7 +1082,7 @@
+ 
+ 
+ echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+-echo "configure:1082: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
++echo "configure:1086: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+ 
+ ac_ext=C
+ # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+@@ -1089,12 +1093,12 @@
+ 
+ cat > conftest.$ac_ext << EOF
+ 
+-#line 1093 "configure"
++#line 1097 "configure"
+ #include "confdefs.h"
+ 
+ int main(){return(0);}
+ EOF
+-if { (eval echo configure:1098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   ac_cv_prog_cxx_works=yes
+   # If we can't run a trivial program, we are probably using a cross compiler.
+   if (./conftest; exit) 2>/dev/null; then
+@@ -1120,12 +1124,12 @@
+   { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+-echo "configure:1124: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
++echo "configure:1128: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+ echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
+ cross_compiling=$ac_cv_prog_cxx_cross
+ 
+ echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
+-echo "configure:1129: checking whether we are using GNU C++" >&5
++echo "configure:1133: checking whether we are using GNU C++" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1134,7 +1138,7 @@
+   yes;
+ #endif
+ EOF
+-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1138: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
++if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1142: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+   ac_cv_prog_gxx=yes
+ else
+   ac_cv_prog_gxx=no
+@@ -1153,7 +1157,7 @@
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS=
+ echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+-echo "configure:1157: checking whether ${CXX-g++} accepts -g" >&5
++echo "configure:1161: checking whether ${CXX-g++} accepts -g" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1188,7 +1192,7 @@
+ # Extract the first word of "flex", so it can be a program name with args.
+ set dummy flex; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:1192: checking for $ac_word" >&5
++echo "configure:1196: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1223,7 +1227,7 @@
+   *) ac_lib=l ;;
+   esac
+   echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6
+-echo "configure:1227: checking for yywrap in -l$ac_lib" >&5
++echo "configure:1231: checking for yywrap in -l$ac_lib" >&5
+ ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1231,7 +1235,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-l$ac_lib  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 1235 "configure"
++#line 1239 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -1242,7 +1246,7 @@
+ yywrap()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -1286,7 +1290,7 @@
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:1290: checking for $ac_word" >&5
++echo "configure:1294: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1362,7 +1366,7 @@
+ fi
+ 
+ echo $ac_n "checking host system type""... $ac_c" 1>&6
+-echo "configure:1366: checking host system type" >&5
++echo "configure:1370: checking host system type" >&5
+ 
+ host_alias=$host
+ case "$host_alias" in
+@@ -1383,7 +1387,7 @@
+ echo "$ac_t""$host" 1>&6
+ 
+ echo $ac_n "checking target system type""... $ac_c" 1>&6
+-echo "configure:1387: checking target system type" >&5
++echo "configure:1391: checking target system type" >&5
+ 
+ target_alias=$target
+ case "$target_alias" in
+@@ -1401,7 +1405,7 @@
+ echo "$ac_t""$target" 1>&6
+ 
+ echo $ac_n "checking build system type""... $ac_c" 1>&6
+-echo "configure:1405: checking build system type" >&5
++echo "configure:1409: checking build system type" >&5
+ 
+ build_alias=$build
+ case "$build_alias" in
+@@ -1425,7 +1429,7 @@
+ 
+ 
+ echo $ac_n "checking whether to define additional compiler specific flags""... $ac_c" 1>&6
+-echo "configure:1429: checking whether to define additional compiler specific flags" >&5
++echo "configure:1433: checking whether to define additional compiler specific flags" >&5
+ case "$target" in
+     alpha*-dec*)
+         if test "$CC" = "cc"; then
+@@ -1449,12 +1453,12 @@
+ esac
+ 
+ echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
+-echo "configure:1453: checking for sys/wait.h that is POSIX.1 compatible" >&5
++echo "configure:1457: checking for sys/wait.h that is POSIX.1 compatible" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1458 "configure"
++#line 1462 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <sys/wait.h>
+@@ -1470,7 +1474,7 @@
+ s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1474: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   ac_cv_header_sys_wait_h=yes
+ else
+@@ -1503,7 +1507,7 @@
+ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+ # ./install, which can be erroneously created by make from ./install.sh.
+ echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+-echo "configure:1507: checking for a BSD compatible install" >&5
++echo "configure:1511: checking for a BSD compatible install" >&5
+ if test -z "$INSTALL"; then
+ if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1558,7 +1562,7 @@
+ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+ 
+ echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+-echo "configure:1562: checking whether ${MAKE-make} sets \${MAKE}" >&5
++echo "configure:1566: checking whether ${MAKE-make} sets \${MAKE}" >&5
+ set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1585,7 +1589,7 @@
+ fi
+ 
+ echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+-echo "configure:1589: checking whether ln -s works" >&5
++echo "configure:1593: checking whether ln -s works" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1608,7 +1612,7 @@
+ fi
+ 
+ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+-echo "configure:1612: checking how to run the C preprocessor" >&5
++echo "configure:1616: checking how to run the C preprocessor" >&5
+ # On Suns, sometimes $CPP names a directory.
+ if test -n "$CPP" && test -d "$CPP"; then
+   CPP=
+@@ -1623,13 +1627,13 @@
+   # On the NeXT, cc -E runs the code through the compiler's parser,
+   # not just through cpp.
+   cat > conftest.$ac_ext <<EOF
+-#line 1627 "configure"
++#line 1631 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+ Syntax Error
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1633: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:1637: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   :
+@@ -1640,13 +1644,13 @@
+   rm -rf conftest*
+   CPP="${CC-cc} -E -traditional-cpp"
+   cat > conftest.$ac_ext <<EOF
+-#line 1644 "configure"
++#line 1648 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+ Syntax Error
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1650: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:1654: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   :
+@@ -1657,13 +1661,13 @@
+   rm -rf conftest*
+   CPP="${CC-cc} -nologo -E"
+   cat > conftest.$ac_ext <<EOF
+-#line 1661 "configure"
++#line 1665 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+ Syntax Error
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1667: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:1671: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   :
+@@ -1690,19 +1694,19 @@
+ # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+ # for constant arguments.  Useless!
+ echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
+-echo "configure:1694: checking for working alloca.h" >&5
++echo "configure:1698: checking for working alloca.h" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1699 "configure"
++#line 1703 "configure"
+ #include "confdefs.h"
+ #include <alloca.h>
+ int main() {
+ char *p = alloca(2 * sizeof(int));
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1706: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1710: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   ac_cv_header_alloca_h=yes
+ else
+@@ -1723,12 +1727,12 @@
+ fi
+ 
+ echo $ac_n "checking for alloca""... $ac_c" 1>&6
+-echo "configure:1727: checking for alloca" >&5
++echo "configure:1731: checking for alloca" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1732 "configure"
++#line 1736 "configure"
+ #include "confdefs.h"
+ 
+ #ifdef __GNUC__
+@@ -1756,7 +1760,7 @@
+ char *p = (char *) alloca(1);
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1760: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   ac_cv_func_alloca_works=yes
+ else
+@@ -1788,12 +1792,12 @@
+ 
+ 
+ echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+-echo "configure:1792: checking whether alloca needs Cray hooks" >&5
++echo "configure:1796: checking whether alloca needs Cray hooks" >&5
+ if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1797 "configure"
++#line 1801 "configure"
+ #include "confdefs.h"
+ #if defined(CRAY) && ! defined(CRAY2)
+ webecray
+@@ -1818,12 +1822,12 @@
+ if test $ac_cv_os_cray = yes; then
+ for ac_func in _getb67 GETB67 getb67; do
+   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+-echo "configure:1822: checking for $ac_func" >&5
++echo "configure:1826: checking for $ac_func" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1827 "configure"
++#line 1831 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func(); below.  */
+@@ -1846,7 +1850,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_$ac_func=yes"
+ else
+@@ -1873,7 +1877,7 @@
+ fi
+ 
+ echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
+-echo "configure:1877: checking stack direction for C alloca" >&5
++echo "configure:1881: checking stack direction for C alloca" >&5
+ if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1881,7 +1885,7 @@
+   ac_cv_c_stack_direction=0
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1885 "configure"
++#line 1889 "configure"
+ #include "confdefs.h"
+ find_stack_direction ()
+ {
+@@ -1900,7 +1904,7 @@
+   exit (find_stack_direction() < 0);
+ }
+ EOF
+-if { (eval echo configure:1904: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:1908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   ac_cv_c_stack_direction=1
+ else
+@@ -1924,7 +1928,7 @@
+ # Extract the first word of "ranlib", so it can be a program name with args.
+ set dummy ranlib; ac_word=$2
+ echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+-echo "configure:1928: checking for $ac_word" >&5
++echo "configure:1932: checking for $ac_word" >&5
+ if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1957,7 +1961,7 @@
+ # Uses ac_ vars as temps to allow command line to override cache and checks.
+ # --without-x overrides everything else, but does not touch the cache.
+ echo $ac_n "checking for X""... $ac_c" 1>&6
+-echo "configure:1961: checking for X" >&5
++echo "configure:1965: checking for X" >&5
+ 
+ # Check whether --with-x or --without-x was given.
+ if test "${with_x+set}" = set; then
+@@ -2019,12 +2023,12 @@
+ 
+   # First, try using that file with no special directory specified.
+ cat > conftest.$ac_ext <<EOF
+-#line 2023 "configure"
++#line 2027 "configure"
+ #include "confdefs.h"
+ #include <$x_direct_test_include>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:2028: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:2032: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -2094,14 +2098,14 @@
+   ac_save_LIBS="$LIBS"
+   LIBS="-l$x_direct_test_library $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 2098 "configure"
++#line 2102 "configure"
+ #include "confdefs.h"
+ #include <${x_direct_test_include}>
+ int main() {
+ ${x_direct_test_function}(${x_direct_test_arguments})
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2109: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   LIBS="$ac_save_LIBS"
+ # We can link X programs with no special library path.
+@@ -2337,6 +2341,13 @@
+ fi
+ 
+ 
++# Check whether --with-install-extra or --without-install-extra was given.
++if test "${with_install_extra+set}" = set; then
++  withval="$with_install_extra"
++  :
++fi
++
++
+ 
+ 
+ # Check whether --with-bibtex8 or --without-bibtex8 was given.
+@@ -2399,6 +2410,12 @@
+   :
+ fi
+ 
++# Check whether --with-dvipos or --without-dvipos was given.
++if test "${with_dvipos+set}" = set; then
++  withval="$with_dvipos"
++  :
++fi
++
+ # Check whether --with-dvipsk or --without-dvipsk was given.
+ if test "${with_dvipsk+set}" = set; then
+   withval="$with_dvipsk"
+@@ -2505,7 +2522,7 @@
+ 
+ 
+ echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
+-echo "configure:2509: checking whether to enable maintainer-specific portions of Makefiles" >&5
++echo "configure:2526: checking whether to enable maintainer-specific portions of Makefiles" >&5
+     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+ if test "${enable_maintainer_mode+set}" = set; then
+   enableval="$enable_maintainer_mode"
+@@ -2524,7 +2541,7 @@
+ 
+ 
+ echo $ac_n "checking for loader (symbol LD)""... $ac_c" 1>&6
+-echo "configure:2528: checking for loader (symbol LD)" >&5
++echo "configure:2545: checking for loader (symbol LD)" >&5
+ if eval "test \"`echo '$''{'cf_cv_subst_LD'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -2538,7 +2555,7 @@
+ 
+ 
+ echo $ac_n "checking for archiver (symbol AR)""... $ac_c" 1>&6
+-echo "configure:2542: checking for archiver (symbol AR)" >&5
++echo "configure:2559: checking for archiver (symbol AR)" >&5
+ if eval "test \"`echo '$''{'cf_cv_subst_AR'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -2552,7 +2569,7 @@
+ 
+ 
+ echo $ac_n "checking for archiver options (symbol ARFLAGS)""... $ac_c" 1>&6
+-echo "configure:2556: checking for archiver options (symbol ARFLAGS)" >&5
++echo "configure:2573: checking for archiver options (symbol ARFLAGS)" >&5
+ if eval "test \"`echo '$''{'cf_cv_subst_ARFLAGS'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -2622,7 +2639,7 @@
+ 
+ 
+ echo $ac_n "checking where the main texmf tree is located""... $ac_c" 1>&6
+-echo "configure:2626: checking where the main texmf tree is located" >&5
++echo "configure:2643: checking where the main texmf tree is located" >&5
+ case $prefix in
+   */) prefix=`echo "$prefix" | sed 's@/*$@@'`;;
+ esac
+@@ -2756,12 +2773,12 @@
+   # -lsocket is needed on Solaris, at least.  Maybe -lnsl on SCO, too?
+   # See ac_path_xtra.
+   echo $ac_n "checking for connect""... $ac_c" 1>&6
+-echo "configure:2760: checking for connect" >&5
++echo "configure:2777: checking for connect" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 2765 "configure"
++#line 2782 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char connect(); below.  */
+@@ -2784,7 +2801,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_connect=yes"
+ else
+@@ -2805,7 +2822,7 @@
+ 
+   if test x$ac_cv_func_connect = xno; then
+     echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
+-echo "configure:2809: checking for connect in -lsocket" >&5
++echo "configure:2826: checking for connect in -lsocket" >&5
+ ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -2813,7 +2830,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lsocket  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 2817 "configure"
++#line 2834 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -2824,7 +2841,7 @@
+ connect()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2845: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3514,7 +3531,7 @@
+ 
+   if test "$with_system_pnglib" = yes; then
+       echo $ac_n "checking for png_set_read_fn in -lpng""... $ac_c" 1>&6
+-echo "configure:3518: checking for png_set_read_fn in -lpng" >&5
++echo "configure:3535: checking for png_set_read_fn in -lpng" >&5
+ ac_lib_var=`echo png'_'png_set_read_fn | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3522,7 +3539,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lpng -lz -lm $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3526 "configure"
++#line 3543 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3533,7 +3550,7 @@
+ png_set_read_fn()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3604,7 +3621,7 @@
+ 
+   if test "$with_system_zlib" = yes; then
+     echo $ac_n "checking for inflate in -lz""... $ac_c" 1>&6
+-echo "configure:3608: checking for inflate in -lz" >&5
++echo "configure:3625: checking for inflate in -lz" >&5
+ ac_lib_var=`echo z'_'inflate | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3612,7 +3629,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lz  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3616 "configure"
++#line 3633 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3623,7 +3640,7 @@
+ inflate()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3644: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3659,17 +3676,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:3663: checking for $ac_hdr" >&5
++echo "configure:3680: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3668 "configure"
++#line 3685 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:3673: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:3690: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -3755,7 +3772,7 @@
+   CURSESCPPFLAGS=
+   if test "$try_ncurses" = yes; then
+     echo $ac_n "checking for wresize in -lncurses""... $ac_c" 1>&6
+-echo "configure:3759: checking for wresize in -lncurses" >&5
++echo "configure:3776: checking for wresize in -lncurses" >&5
+ ac_lib_var=`echo ncurses'_'wresize | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3763,7 +3780,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lncurses  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3767 "configure"
++#line 3784 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3774,7 +3791,7 @@
+ wresize()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3805,17 +3822,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:3809: checking for $ac_hdr" >&5
++echo "configure:3826: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3814 "configure"
++#line 3831 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:3819: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:3836: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -3856,17 +3873,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:3860: checking for $ac_hdr" >&5
++echo "configure:3877: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3865 "configure"
++#line 3882 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:3870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:3887: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -3914,17 +3931,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:3918: checking for $ac_hdr" >&5
++echo "configure:3935: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3923 "configure"
++#line 3940 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:3928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:3945: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -4033,7 +4050,7 @@
+ 
+   if test "$with_system_t1lib" = yes; then
+       echo $ac_n "checking for T1_AddFont in -lt1""... $ac_c" 1>&6
+-echo "configure:4037: checking for T1_AddFont in -lt1" >&5
++echo "configure:4054: checking for T1_AddFont in -lt1" >&5
+ ac_lib_var=`echo t1'_'T1_AddFont | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -4041,7 +4058,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lt1 -lz -lm $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 4045 "configure"
++#line 4062 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -4052,7 +4069,7 @@
+ T1_AddFont()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4073: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -4079,13 +4096,13 @@
+   LIBS="-lt1 -lm $LIBS"
+   if test "$with_system_t1lib" = yes; then
+       echo $ac_n "checking whether installed T1 lib is >= v 5.0.0 ""... $ac_c" 1>&6
+-echo "configure:4083: checking whether installed T1 lib is >= v 5.0.0 " >&5
++echo "configure:4100: checking whether installed T1 lib is >= v 5.0.0 " >&5
+       if test "$cross_compiling" = yes; then
+   ac_compile_t1lib=1
+ 	]
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 4089 "configure"
++#line 4106 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdlib.h>
+@@ -4117,7 +4134,7 @@
+ }
+ 	
+ EOF
+-if { (eval echo configure:4121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:4138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   ac_compile_t1lib=0
+ else
+@@ -4185,7 +4202,7 @@
+ 
+   if test "$with_system_gd" = yes; then
+     echo $ac_n "checking for gdImageCreateFromPng in -lgd""... $ac_c" 1>&6
+-echo "configure:4189: checking for gdImageCreateFromPng in -lgd" >&5
++echo "configure:4206: checking for gdImageCreateFromPng in -lgd" >&5
+ ac_lib_var=`echo gd'_'gdImageCreateFromPng | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -4193,7 +4210,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lgd  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 4197 "configure"
++#line 4214 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -4204,7 +4221,7 @@
+ gdImageCreateFromPng()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4208: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -4237,7 +4254,7 @@
+ 
+   if test "$with_system_gd" = yes; then
+     echo $ac_n "checking for gdImageGif in -lgd""... $ac_c" 1>&6
+-echo "configure:4241: checking for gdImageGif in -lgd" >&5
++echo "configure:4258: checking for gdImageGif in -lgd" >&5
+ ac_lib_var=`echo gd'_'gdImageGif | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -4245,7 +4262,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lgd  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 4249 "configure"
++#line 4266 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -4256,7 +4273,7 @@
+ gdImageGif()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -4292,17 +4309,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:4296: checking for $ac_hdr" >&5
++echo "configure:4313: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 4301 "configure"
++#line 4318 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:4306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:4323: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -4381,7 +4398,7 @@
+ 
+   if test "$with_system_freetype" = yes; then
+     echo $ac_n "checking for TT_Init_FreeType in -lttf""... $ac_c" 1>&6
+-echo "configure:4385: checking for TT_Init_FreeType in -lttf" >&5
++echo "configure:4402: checking for TT_Init_FreeType in -lttf" >&5
+ ac_lib_var=`echo ttf'_'TT_Init_FreeType | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -4389,7 +4406,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lttf  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 4393 "configure"
++#line 4410 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -4400,7 +4417,7 @@
+ TT_Init_FreeType()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -4436,17 +4453,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:4440: checking for $ac_hdr" >&5
++echo "configure:4457: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 4445 "configure"
++#line 4462 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:4450: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:4467: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -4525,7 +4542,7 @@
+ 
+   if test "$with_system_freetype2" = yes; then
+     echo $ac_n "checking for FT_Init_FreeType in -lfreetype""... $ac_c" 1>&6
+-echo "configure:4529: checking for FT_Init_FreeType in -lfreetype" >&5
++echo "configure:4546: checking for FT_Init_FreeType in -lfreetype" >&5
+ ac_lib_var=`echo freetype'_'FT_Init_FreeType | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -4533,7 +4550,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lfreetype  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 4537 "configure"
++#line 4554 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -4544,7 +4561,7 @@
+ FT_Init_FreeType()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -4580,17 +4597,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:4584: checking for $ac_hdr" >&5
++echo "configure:4601: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 4589 "configure"
++#line 4606 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:4594: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:4611: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -4669,7 +4686,7 @@
+ 
+   if test "$with_system_icu" = yes; then
+     echo $ac_n "checking for ubidi_open in -licuuc""... $ac_c" 1>&6
+-echo "configure:4673: checking for ubidi_open in -licuuc" >&5
++echo "configure:4690: checking for ubidi_open in -licuuc" >&5
+ ac_lib_var=`echo icuuc'_'ubidi_open | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -4677,7 +4694,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-licuuc  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 4681 "configure"
++#line 4698 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -4688,7 +4705,7 @@
+ ubidi_open()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -4724,17 +4741,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:4728: checking for $ac_hdr" >&5
++echo "configure:4745: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 4733 "configure"
++#line 4750 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:4738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:4755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -4875,7 +4892,8 @@
+ 
+ 
+ # initialize texmf tree with fmtutil only for teTeX and TeX Live
+-if test ! -d $srcdir/texk/tetex || test -n "$xdvik_standalone" || test "x$cross_compiling" = xyes; then
++if test ! -d $srcdir/texk/tetex || test -n "$xdvik_standalone" || \
++  test "x$cross_compiling" = xyes || test "$with_install_extra" = no; then
+   FMU=
+ else
+   FMU='# '
+Index: texlive-bin-2007/build/source/configure.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/configure.in	2007-02-19 18:03:57.000000000 +0100
++++ texlive-bin-2007/build/source/configure.in	2007-02-19 18:04:06.000000000 +0100
+@@ -273,7 +273,8 @@
+ AC_SUBST(LIBSDIRS)
+ 
+ # initialize texmf tree with fmtutil only for teTeX and TeX Live
+-if test ! -d $srcdir/texk/tetex || test -n "$xdvik_standalone" || test "x$cross_compiling" = xyes; then
++if test ! -d $srcdir/texk/tetex || test -n "$xdvik_standalone" || \
++  test "x$cross_compiling" = xyes || test "$with_install_extra" = no; then
+   FMU=
+ else
+   FMU='# '
+Index: texlive-bin-2007/build/source/withenable.ac
+===================================================================
+--- texlive-bin-2007.orig/build/source/withenable.ac	2007-02-19 18:03:57.000000000 +0100
++++ texlive-bin-2007/build/source/withenable.ac	2007-02-19 18:04:06.000000000 +0100
+@@ -29,3 +29,6 @@
+ 
+ AC_ARG_WITH([texinfo],
+         [  --without-texinfo       do not build the texinfo package])
++
++AC_ARG_WITH([install-extra],
++	[  --without-install-extra	do not initialize the installed tree])
+Index: texlive-bin-2007/build/source/texk/web2c/Makefile.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/web2c/Makefile.in	2007-02-19 18:09:08.000000000 +0100
++++ texlive-bin-2007/build/source/texk/web2c/Makefile.in	2007-02-19 18:09:11.000000000 +0100
+@@ -782,7 +782,7 @@
+ 
+ # 
+ install: install-exec install-data
+-install-exec:: install-programs @FMU@ install-links
++install-exec:: install-programs install-links
+ install-data:: install-tex-data install-mf-data install-mpost-data
+ install-dumps: install-tex-dumps install-mf-dumps install-mpost-dumps
+ 
--- texlive-bin-2007.dfsg.2.orig/debian/patches/61_dvipdfm_timezone
+++ texlive-bin-2007.dfsg.2/debian/patches/61_dvipdfm_timezone
@@ -0,0 +1,59 @@
+# 61_dvipdfm_timezone by "Mark A. Wicks" <mwicks@kettering.edu>
+#
+# fix crash of dvipdfm with 0.5 timezones
+
+ build/source/texk/dvipdfm/pdfdoc.c |   34 +++++++++++++++++++++++-----------
+ 1 file changed, 23 insertions(+), 11 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/dvipdfm/pdfdoc.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipdfm/pdfdoc.c	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2007/build/source/texk/dvipdfm/pdfdoc.c	2007-02-15 15:53:08.000000000 +0100
+@@ -232,13 +232,7 @@
+ 
+ static char *asn_date (void)
+ {
+-#ifndef HAVE_TIMEZONE
+-  #ifdef TM_GM_TOFF
+-     #define timezone (bdtime->gm_toff)
+-  #else
+-     #define timezone 0l
+-#endif /* TM_GM_TOFF */
+-#endif /* HAVE_TIMEZONE */
++  long tz_offset;
+   static char date_string[24];
+   time_t current_time;
+   struct tm *bd_time;
+@@ -247,10 +241,28 @@
+   }
+   time(&current_time);
+   bd_time = localtime(&current_time);
+-  sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%+03ld'%02ld'",
+-	   bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
+-	   bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
+-	   -timezone/3600, timezone%3600);
++
++#ifdef HAVE_TM_GMTOFF  /* Preferred way to get time zone offset */
++  tz_offset = bd_time->tm_gmtoff;
++#else
++#ifdef HAVE_TIMEZONE   /* Plan B --- use external variable 'timezone'
++                       /* (may not provide correct offset for daylight savings time) */
++  tz_offset = - timezone;
++#else                  /* Last resort --- without more information, set offset to zero */
++  tz_offset = 0l;
++#endif /* HAVE_TIMEZONE */
++#endif /* HAVE_TM_GMTOFF */
++
++  if (tz_offset == 0l) {
++    sprintf (date_string, "D:%04d%02d%02d%02d%02d%02dZ00'00'",
++	     bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
++	     bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec);
++  } else {
++    sprintf (date_string, "D:%04d%02d%02d%02d%02d%02d%c%02ld'%02ld'",
++             bd_time -> tm_year+1900, bd_time -> tm_mon+1, bd_time -> tm_mday,
++             bd_time -> tm_hour, bd_time -> tm_min, bd_time -> tm_sec,
++	     (tz_offset>0)? '+':'-', labs(tz_offset)/3600, (labs(tz_offset)/60)%60);
++  }
+   return date_string;
+ }
+ 
--- texlive-bin-2007.dfsg.2.orig/debian/patches/52_feynmf-perl-sec-fix
+++ texlive-bin-2007.dfsg.2/debian/patches/52_feynmf-perl-sec-fix
@@ -0,0 +1,31 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 52_feynmf-perl-sec-fix.dpatch by Kevin B. McCarty
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: secure tmp file handling
+
+@DPATCH@
+--- ./texmf-dist/source/latex/feynmf/feynmf.pl.orig
++++ ./texmf-dist/source/latex/feynmf/feynmf.pl
+@@ -270,10 +270,11 @@
+     my @tfm = @_;
+     # Prepare a fake temporary PL file
+     # (/dev/null won't do, because the font must not be empty):
+-    my ($pl) = "/tmp/feynmf$$.pl";
++    my ($pl) = `/bin/tempfile -p feynmf -s .pl`;
+     my ($tfm);
+     $pltotf_prog
+ 	or die "feynmf: fatal: pltopf programm required unless -notfm\n";
++    chop ($pl);
+     open (PL, ">$pl") or die "feynmf: can't open temporary file $pl: $!\n";
+     push @temporay_files, $pl;
+     print PL <<__END_PL__;
+@@ -373,7 +374,7 @@
+ 			maybe_run "$gftopk_prog $gf" if $gftopk_prog;
+ 		    }
+ 		}
+-		close (<LOG>);
++		close (LOG);
+ 	    }
+ 	}
+     }
--- texlive-bin-2007.dfsg.2.orig/debian/patches/16_texdoctk
+++ texlive-bin-2007.dfsg.2/debian/patches/16_texdoctk
@@ -0,0 +1,170 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 21_texdoctk.dpatch by Preining, Küster
+##
+## DP: fix for loading Tk, stolen from tetex
+## DP: make texdoctk work with texmf-tetex and texmf-texlive pathes
+
+@DPATCH@
+ build/source/texk/tetex/texdoctk |   48 ++++++++++++++++++++++++++++++---------
+ texmf/texdoctk/texdocrc.defaults |   21 ++++++++---------
+ 2 files changed, 48 insertions(+), 21 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/texdoctk
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/texdoctk	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2007/build/source/texk/tetex/texdoctk	2007-05-03 08:54:15.000000000 +0200
+@@ -9,11 +9,30 @@
+ # and the full disclaimer.
+ ###############################################################################
+ use strict;
+-use Tk;
+ use Getopt::Long;
+ Getopt::Long::config('bundling');
+ use File::Basename;
+ 
++BEGIN {
++    eval { require Tk; import Tk; };
++    if ($@) {
++	my $progname = basename($0);
++	my $message;
++	if ($@ =~ /^Can\'t locate Tk\.pm/) {
++	    $message = "$progname: you must have the perl-tk package installed\nto use this script\n";
++	} else {
++	    $message = "$progname: problem loading the Tk module:\n  $@\nHave you installed the perl-tk package?\n";
++	}
++
++	if (! -t STDOUT and exists $ENV{DISPLAY})
++	{
++	    exec("xmessage", $message);
++	} else {
++	    die $message;
++	}
++    }
++}
++
+ my $IsWin32 = ($^O =~ /MSWin32/i);
+ 
+ #if ($IsWin32) {
+@@ -32,8 +51,8 @@
+ my $srchflag=0;
+ my $tmpfno;
+ # system variables
+-my ($texmfmain,$texmfdist,$texmfdoc,$texmflocal,$texmfhome,
+-    $texdocpath,$distdocpath,$docdocpath,$localdocpath,$homedocpath,
++my ($texmfmain,$texmfdist_tetex,$texmfdist_texlive,$texmfdoc,$texmflocal,$texmfhome,
++    $texdocpath,$distdocpath_tetex,$distdocpath_texlive,$docdocpath,$localdocpath,$homedocpath,
+     $datadir,
+     $dvi_viewer,$dvips_conv,$ps_viewer,$pdf_viewer,
+     $pdfps_conv,$html_viewer,$htmlps_conv,$htmlps_redir,
+@@ -637,7 +656,7 @@
+ sub finddoc {
+     my($slcdoc,$slc,$parframe)=@_;
+     my ($dummy,$status);
+-  SLCDOCFIND: foreach ($texdocpath,$distdocpath,$docdocpath) {
++  SLCDOCFIND: foreach ($texdocpath,$distdocpath_tetex,$distdocpath_texlive,$docdocpath) {
+       $slcdoc="$_/$slc";
+       if (-e $slcdoc) {
+ #       found where it should be
+@@ -721,7 +740,8 @@
+     my $found=0;
+     if ($docselect =~ /\.sty$/) {
+     STYPATH: foreach my $fullpath ("$texmfmain/tex/$docselect",
+-				   "$texmfdist/tex/$docselect",
++				   "$texmfdist_tetex/tex/$docselect",
++				   "$texmfdist_texlive/tex/$docselect",
+ 				   "$texmflocal/tex/$docselect",
+ 				   "$texmfhome/tex/$docselect") {
+ 	if (-e $fullpath) {
+@@ -734,7 +754,8 @@
+ 	&popmsg(2,"Selected file:\n$docselect\ndoes not exist.",$tpbframe) }
+     } else {
+     DOCPATH: foreach my $fullpath ("$texdocpath/$docselect",
+-				   "$distdocpath/$docselect",
++				   "$distdocpath_tetex/$docselect",
++				   "$distdocpath_texlive/$docselect",
+ 				   "$docdocpath/$docselect",
+ 				   "$localdocpath/$docselect",
+ 				   "$homedocpath/$docselect") {
+@@ -950,7 +971,8 @@
+ 							-fill=>'x',
+ 							-expand=>1);
+     my $docframestring="\nDistribution documentation root path(s):\n$texdocpath";
+-    $docframestring.=", $distdocpath" if (-e $distdocpath);
++    $docframestring.=", $distdocpath_tetex" if (-e $distdocpath_tetex);
++    $docframestring.=", $distdocpath_texlive" if (-e $distdocpath_texlive);
+     $docframestring.=", $docdocpath" if (length $docdocpath);
+     if ($localdocpath && $localdocpath ne $texdocpath) {
+ 	$docframestring.="\nLocal documentation root path: $localdocpath\n";
+@@ -1536,10 +1558,14 @@
+ 	$texmfmain=`kpsewhich --expand-path=${qq}\$TEXMFMAIN${qq}`;
+ 	chomp $texmfmain;
+ 	$texdocpath="$texmfmain/$texdocpath";
+-	$texmfdist=`kpsewhich --expand-path=${qq}\$TEXMFDIST${qq}`;
+-	chomp $texmfdist;
+-	$distdocpath=join('/',"$texmfdist",basename($texdocpath,""))
+-			  if (length $texmfdist);
++# 	$texmfdist=`kpsewhich --expand-path=${qq}\$TEXMFDIST${qq}`;
++# 	chomp $texmfdist;
++	$texmfdist_tetex="/usr/share/texmf-tetex";
++	$texmfdist_texlive="/usr/share/texmf-texlive";
++	$distdocpath_tetex=join('/',"$texmfdist_tetex",basename($texdocpath,""))
++			  if (length $texmfdist_tetex);
++	$distdocpath_texlive=join('/',"$texmfdist_texlive",basename($texdocpath,""))
++			  if (length $texmfdist_texlive);
+ 	# TeXLive has this texmf-doc
+ 	$texmfdoc=join('/',"$texmfmain-doc",basename($texdocpath,""));
+ 	if (-e $texmfdoc) {
+Index: texlive-bin-2007/texmf/texdoctk/texdocrc.defaults
+===================================================================
+--- texlive-bin-2007.orig/texmf/texdoctk/texdocrc.defaults	2007-05-03 08:54:54.000000000 +0200
++++ texlive-bin-2007/texmf/texdoctk/texdocrc.defaults	2007-05-03 08:57:22.000000000 +0200
+@@ -7,7 +7,7 @@
+ # item empty, but *do not* delete/uncomment it. The same holds for options you 
+ # want/need to leave empty.
+ 
+-# root of doc directory (from $TEXMFMAIN)
++# root of doc directory (from $TEXMFMAIN and $TEXMFDIST)
+ TEXDOCPATH=doc
+ # root of local doc directory (from $TEXMFLOCAL)
+ # can be left empty if equal to TEXDOCPATH or if $TEXMFLOCAL is undefined
+@@ -22,30 +22,31 @@
+ DVIPS_OPTS=-q
+ 
+ # PostScript handling
+-PS_VIEWER=ghostview
++PS_VIEWER=see
+ 
+ # PDF handling
+-PDF_VIEWER=acroread
+-PDFPS_CONV=acroread
+-PDFPS_OPTS=-toPostScript -pairs
++PDF_VIEWER=see
++PDFPS_CONV=pdf2ps
++PDFPS_OPTS=
++#PDFPS_OPTS=-toPostScript -pairs
+ 
+ # HTML handling
+-HTML_VIEWER=netscape
+-HTMLPS_CONV=
++HTML_VIEWER=x-terminal-emulator -e see
++HTMLPS_CONV=html2ps
+ # HTMLPS_REDIR must be on, if the html->ps converter normally writes its output
+ # to stdout instead of a file (e.g. as html2ps) (y or yes to make active)
+-HTMLPS_REDIR=
++HTMLPS_REDIR=y
+ 
+ # Plain text handling
+ # TDK_OWN is texdoctk's own text file viewer
+ TXT_VIEWER=TDK_OWN
+-TXTPS_CONV=a2ps
++TXTPS_CONV=a2ps -q
+ # TXTPS_REDIR must be on, if the txt->ps converter normally writes its output
+ # to stdout instead of a file (e.g. as a2ps) (y or yes to make active)
+ TXTPS_REDIR=yes
+ 
+ # printer
+ PRINT_CMD=lpr
+-PRINT_OPTS=-h -Plp
++PRINT_OPTS=-h
+ 
+ # end of config
--- texlive-bin-2007.dfsg.2.orig/debian/patches/60_getnonfreefonts_bash
+++ texlive-bin-2007.dfsg.2/debian/patches/60_getnonfreefonts_bash
@@ -0,0 +1,14 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 60_getnonfreefonts_bash.dpatch by Norbert Preining
+##
+## DP: use bash as shell for getnonfreefonts
+
+@DPATCH@
+--- ./bin.special/getnonfreefonts.orig	2006-12-09 15:57:40.000000000 +0100
++++ ./bin.special/getnonfreefonts	2006-12-09 15:57:46.000000000 +0100
+@@ -1,4 +1,4 @@
+-#!/bin/sh
++#!/bin/bash
+ 
+ ## getnonfreefonts
+ ## Copyright 2005 Reinhard Kotucha <reinhard.kotucha@web.de>
--- texlive-bin-2007.dfsg.2.orig/debian/patches/metapost-1.02
+++ texlive-bin-2007.dfsg.2/debian/patches/metapost-1.02
@@ -0,0 +1,763 @@
+---
+ build/source/texk/web2c/dvitomp.ch            |    8 -
+ build/source/texk/web2c/dvitomp.web           |    2 
+ build/source/texk/web2c/lib/texmfmp.c         |    4 
+ build/source/texk/web2c/metapost.mk           |   22 +-
+ build/source/texk/web2c/mp.web                |  204 +++++++++++++++++++-------
+ build/source/texk/web2c/mpdir/Makefile.in     |    4 
+ build/source/texk/web2c/mpdir/mp.defines      |    1 
+ build/source/texk/web2c/mpdir/mplib.h         |    4 
+ build/source/texk/web2c/mpdir/turningnumber.c |  113 ++++++++++++++
+ build/source/texk/web2c/mpdir/writefont.c     |   11 -
+ build/source/texk/web2c/mpware/dmp.c          |    4 
+ build/source/texk/web2c/mpware/makempx.c      |    2 
+ build/source/texk/web2c/mpware/mpto.c         |   51 +++---
+ build/source/texk/web2c/mpware/newer.c        |    2 
+ 14 files changed, 323 insertions(+), 109 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/dvitomp.ch
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/dvitomp.ch	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/dvitomp.ch	2007-11-29 13:50:22.000000000 +0100
+@@ -26,12 +26,12 @@
+ @z
+ 
+ @x [1] Duplicate banner line for use in |print_version_and_exit|.
+-@d banner=='% Written by DVItoMP, Version 0.992'
++@d banner=='% Written by DVItoMP, Version 1.002'
+   {the first line of the output file}
+ @y
+-@d banner=='% Written by DVItoMP, Version 0.992/color'
++@d banner=='% Written by DVItoMP, Version 1.002/color'
+   {the first line of the output file}
+-@d term_banner=='This is DVItoMP, Version 0.992/color'
++@d term_banner=='This is DVItoMP, Version 1.002/color'
+   {the same in the usual format, as it would be shown on a terminal}
+ @z
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/dvitomp.web
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/dvitomp.web	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/dvitomp.web	2007-11-29 13:50:22.000000000 +0100
+@@ -65,7 +65,7 @@
+ The |banner| string defined here should be changed whenever \.{DVItoMP}
+ gets modified.
+ 
+-@d banner=='% Written by DVItoMP, Version 0.992'
++@d banner=='% Written by DVItoMP, Version 1.002'
+   {the first line of the output file}
+ 
+ @ This program is written in standard \PASCAL, except where it is necessary
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/lib/texmfmp.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/lib/texmfmp.c	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/lib/texmfmp.c	2007-11-29 13:50:22.000000000 +0100
+@@ -87,9 +87,9 @@
+ #define edit_var "MFEDIT"
+ #endif /* MF */
+ #ifdef MP
+-#define BANNER "This is MetaPost, Version 0.993"
++#define BANNER "This is MetaPost, Version 1.002"
+ #define COPYRIGHT_HOLDER "AT&T Bell Laboratories"
+-#define AUTHOR "John Hobby"
++#define AUTHOR "John Hobby.\nCurrent maintainer of MetaPost: Taco Hoekwater"
+ #define PROGRAM_HELP MPHELP
+ #define BUG_ADDRESS "tex-k@mail.tug.org"
+ #define DUMP_VAR MPmemdefault
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/metapost.mk
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/metapost.mk	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/metapost.mk	2007-11-29 13:50:22.000000000 +0100
+@@ -1,5 +1,5 @@
+ # Makefile fragment for MetaPost.
+-# $Id: metapost.mk,v 1.2 2005/07/25 10:03:53 olaf Exp $
++# $Id: metapost.mk,v 1.15 2005/07/04 07:51:41 taco Exp $
+ #
+ # Public domain. 
+ #
+@@ -20,21 +20,19 @@
+ mp_c = mpini.c mp0.c mp1.c mp2.c
+ mp_o = mpini.o mp0.o mp1.o mp2.o mpextra.o loadpool.o
+ 
+-# this will break cross-compiles, but i dont know how to fix.
+-# -- Taco 
+ loadpool.c: mp.pool $(mpostdir)/makecpool
+-	./$(mpostdir)/makecpool mp.pool mpdir/mplib.h > loadpool.c
+-
++	$(mpostdir)/makecpool mp.pool mpdir/mplib.h > loadpool.c
++# mpostlibsdep also includes makecpool
+ mpost: $(mp_o) $(mpostlibsdep)
+ 	$(kpathsea_link) $(mp_o) $(mpostlibs) $(LOADLIBES)
+-$(mp_c) mpcoerce.h mpd.h: mp.p $(web2c_texmf) $(srcdir)/$(mpostdir)/mp.defines web2c/cvtmf1.sed web2c/cvtmf2.sed
++$(mp_c) mpcoerce.h mpd.h: mp.p $(web2c_texmf) $(srcdir)/$(mpostdir)/mp.defines  web2c/cvtmf1.sed web2c/cvtmf2.sed
+ 	$(web2c) mp
+ mpextra.c: lib/texmfmp.c
+ 	sed s/TEX-OR-MF-OR-MP/mp/ $(srcdir)/lib/texmfmp.c >$@
+-mp.p mp.pool: tangle mp.web mp.ch
+-	$(tangle) mp.web mp.ch
++mp.p mp.pool: tie tangle mp.web mp.ch
++	$(tangle) $(srcdir)/mp.web $(srcdir)/mp.ch
+ check: mpost-check
+-mpost-check: mptrap mpost.mem $(mpware_programs)
++mpost-check: mptrap mpost.mem $(mpware)
+ 	./mpost --progname=mpost '&./mpost \tracingstats:=1; end.'
+ 	TEXMFCNF=../kpathsea \
+ 	  MAKEMPX_BINDIR=`pwd`:`pwd`/mpware MPXCOMMAND=mpware/makempx \
+@@ -96,9 +94,13 @@
+ # mpware
+ 
+ # We put mpware (written directly in C) in a subdirectory.
++$(mpware): $(mpware_programs)
++
+ $(mpware_programs): $(mpware_sources)
+-	cd mpware && $(MAKE) $(common_makeargs)
++	cd $(mpware) && $(MAKE) $(common_makeargs)
+ 
+ install-programs: install-mpware-programs
+ install-mpware-programs: $(mpware_programs)
+ 	cd $(mpware) && $(MAKE) $(install_makeargs) install-exec
++
++mp-programs: $(metapost) $(mpware)
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mp.web
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mp.web	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mp.web	2007-11-29 13:50:22.000000000 +0100
+@@ -97,8 +97,8 @@
+ @^extensions to \MP@>
+ @^system dependencies@>
+ 
+-@d banner=='This is MetaPost, Version 0.993' {printed when \MP\ starts}
+-@d metapost_version=="0.993"
++@d banner=='This is MetaPost, Version 1.002' {printed when \MP\ starts}
++@d metapost_version=="1.002"
+ 
+ @ Different \PASCAL s have slightly different conventions, and the present
+ @!@:PASCAL H}{\ph@>
+@@ -17088,10 +17088,7 @@
+ found:pict_length:=n;
+ end;
+ 
+-@ The turning number is computed only with respect to a triangular pen whose
+-@:turning_number_}{\&{turningnumber} primitive@>
+-vertices are $(0,1)$ and $(\pm{1\over2},0)$.  The choice of pen isn't supposed
+-to matter but rounding error could make a difference if the path has a cusp.
++@ Implement |turningnumber|
+ 
+ @<Additional cases of unary...@>=
+ turning_op:if cur_type=pair_type then flush_cur_exp(0)
+@@ -17099,9 +17096,100 @@
+   else if left_type(cur_exp)=endpoint then
+      flush_cur_exp(0) {not a cyclic path}
+   else  begin
+-    flush_cur_exp(turn_cycles(cur_exp));
++    flush_cur_exp(turn_cycles_wrapper(cur_exp));
+     end;
+ 
++@ The function |an_angle| returns the value of the |angle| primitive, or $0$ if the
++argument is |origin|.
++
++@<Declare unary action...@>=
++function an_angle (@!xpar,@!ypar:scaled):angle;
++begin
++  if (not ((xpar=0) and (ypar=0))) then
++    an_angle := n_arg(xpar,ypar)
++  else
++    an_angle := 0;
++end;
++
++@ The actual turning number is (for the moment) computed in a C function
++that receives eight integers corresponding to the four controlling points,
++and returns a single angle.  Besides those, we have to account for discrete
++moves at the actual points.
++
++@d p_nextnext==link(link(p))
++@d p_next==link(p)
++
++@d seven_twenty_deg==@'5500000000 {$720\cdot2^{20}$, represents $720^\circ$}
++
++@<Declare unary action...@>=
++function new_turn_cycles (@!c:pointer):scaled;
++label exit;
++var @!res,ang:angle; { the angles of intermediate results }
++@!turns:scaled;  { the turn counter }
++@!p:pointer;     { for running around the path }
++@!xp,yp:integer;   { coordinates of next point }
++@!x,y:integer;   { helper coordinates }
++@!in_angle,out_angle:angle;     { helper angles}
++@!old_setting:0..max_selector; {saved |selector| setting}
++begin
++res:=0;
++turns:= 0;
++p:=c;
++old_setting := selector; selector:=term_only;
++if internal[tracing_commands]>unity then begin
++  begin_diagnostic;
++  print_nl("");
++  end_diagnostic(false);
++end;
++repeat
++  xp := x_coord(p_next); yp := y_coord(p_next);
++  ang  := bezier_slope(x_coord(p), y_coord(p), right_x(p), right_y(p),
++                      left_x(p_next), left_y(p_next), xp, yp, internal[tracing_commands]);
++  if ang>seven_twenty_deg then begin
++    print_err("Strange path");
++    error;
++    new_turn_cycles := 0;
++    return;
++    end;
++  res  := res + ang;
++  if res > one_eighty_deg then begin
++    res := res - three_sixty_deg;
++    turns := turns + unity;
++  end;
++  if res <= -one_eighty_deg then begin
++    res := res + three_sixty_deg;
++    turns := turns - unity;
++  end;
++  { incoming angle at next point }
++  x := left_x(p_next);  y := left_y(p_next);
++  if (xp=x)and(yp=y) then begin x := right_x(p);  y := right_y(p);  end;
++  if (xp=x)and(yp=y) then begin x := x_coord(p);  y := y_coord(p);  end;
++  in_angle := an_angle(xp - x, yp - y);
++  { outgoing angle at next point }
++  x := right_x(p_next);  y := right_y(p_next);
++  if (xp=x)and(yp=y) then begin x := left_x(p_nextnext);  y := left_y(p_nextnext);  end;
++  if (xp=x)and(yp=y) then begin x := x_coord(p_nextnext); y := y_coord(p_nextnext); end;
++  out_angle := an_angle(x - xp, y- yp);
++  ang  := (out_angle - in_angle);
++  reduce_angle(ang);
++  if ang<>0 then begin
++    res  := res + ang;
++    if res >= one_eighty_deg then begin
++      res := res - three_sixty_deg;
++      turns := turns + unity;
++    end;
++    if res <= -one_eighty_deg then begin
++      res := res + three_sixty_deg;
++      turns := turns - unity;
++    end;
++  end;
++  p := link(p);
++until p=c;
++new_turn_cycles := turns;
++exit:
++selector:=old_setting;
++end;
++
+ 
+ @ This code is based on Bogus\l{}av Jackowski's
+ |emergency_turningnumber| macro, with some minor changes by Taco
+@@ -17130,19 +17218,6 @@
+ paths as well. All known bugs that were triggered by the original code no longer occur
+ with this code, and it runs roughly 3 times as fast because the algorithm is much simpler.
+ 
+-@ The macro |Angle()| returns the value of the |angle| primitive, or $0$ if the argument is
+-|origin|. Converting that calling convention to web code gives the |an_angle| function.
+-
+-@<Declare unary action...@>=
+-function an_angle (@!xpar,@!ypar:scaled):angle;
+-begin
+-  if (not ((xpar=0) and (ypar=0))) then
+-    an_angle := n_arg(xpar,ypar)
+-  else
+-    an_angle := 0;
+-end;
+-
+-
+ @ It is possible to overflow the return value of the |turn_cycles|
+ function when the path is sufficiently long and winding, but I am not
+ going to bother testing for that. In any case, it would only return
+@@ -17163,29 +17238,50 @@
+ @!turns:scaled;  { the turn counter }
+ @!p:pointer;     { for running around the path }
+ begin  res:=0;  turns:= 0; p:=c;
+-if ((link(p) = p) or (link(link(p)) = p)) then
+-  if an_angle (x_coord(p) - right_x(p),  y_coord(p) - right_y(p)) >= 0 then
+-     turn_cycles := unity
+-  else
+-     turn_cycles := -unity
+-else begin
+-  repeat
+-    ang  := an_angle (x_coord(p_to) - x_coord(p_here), y_coord(p_to) - y_coord(p_here))
+-      	- an_angle (x_coord(p_here) - x_coord(p_from), y_coord(p_here) - y_coord(p_from));
+-    reduce_angle(ang);
+-    res  := res + ang;
+-    if res >= three_sixty_deg then  begin
+-      res := res - three_sixty_deg;
+-      turns := turns + unity;
+-    end;
+-    if res <= -three_sixty_deg then begin
+-      res := res + three_sixty_deg;
+-      turns := turns - unity;
+-    end;
+-    p := link(p);
+-  until p=c;
+-  turn_cycles := turns;
++repeat
++  ang  := an_angle (x_coord(p_to) - x_coord(p_here), y_coord(p_to) - y_coord(p_here))
++    	- an_angle (x_coord(p_here) - x_coord(p_from), y_coord(p_here) - y_coord(p_from));
++  reduce_angle(ang);
++  res  := res + ang;
++  if res >= three_sixty_deg then  begin
++    res := res - three_sixty_deg;
++    turns := turns + unity;
++  end;
++  if res <= -three_sixty_deg then begin
++    res := res + three_sixty_deg;
++    turns := turns - unity;
++  end;
++  p := link(p);
++until p=c;
++turn_cycles := turns;
+ end;
++
++@ @<Declare unary action...@>=
++function turn_cycles_wrapper (@!c:pointer):scaled;
++  var nval,oval:scaled;
++  saved_t_o:scaled; {tracing\_online saved }
++begin
++ if (link(c)=c)or(link(link(c))=c) then
++   if an_angle (x_coord(c) - right_x(c),  y_coord(c) - right_y(c)) > 0 then
++     turn_cycles_wrapper := unity
++   else
++     turn_cycles_wrapper := -unity
++ else begin
++   nval := new_turn_cycles(c);
++   oval := turn_cycles(c);
++   if nval<>oval then begin
++     saved_t_o:=internal[tracing_online];
++     internal[tracing_online]:=unity;
++     begin_diagnostic;
++     print_nl ("Warning: the turningnumber algorithms do not agree. The current computed value is ");
++     print_scaled(nval);
++     print(", but the 'connect-the-dots' algorithm returned ");
++     print_scaled(oval);
++     end_diagnostic(false);
++     internal[tracing_online]:=saved_t_o;
++   end;
++   turn_cycles_wrapper := nval;
++   end;
+ end;
+ 
+ @ @<Declare unary action...@>=
+@@ -21649,6 +21745,7 @@
+ procedure lost_warning(@!f:font_number;@!k:pool_pointer);
+ begin if internal[tracing_lost_chars]>0 then
+   begin begin_diagnostic;
++  if selector=log_only then incr(selector);
+   print_nl("Missing character: There is no ");
+ @.Missing character@>
+   print(so(str_pool[k])); print(" in font ");
+@@ -21786,8 +21883,7 @@
+ begin
+     new_dummy_font := read_font_info("dummy");
+ end;
+-
+-@x
++@#
+ function round_xn_over_d(@!x:scaled; @!n,@!d:integer):scaled;
+ var positive:boolean; {was |x>=0|?}
+ @!t,@!u,@!v:nonnegative_integer; {intermediate quantities}
+@@ -22395,9 +22491,9 @@
+       (gs_colormodel<>cmyk_model) then
+       begin
+       if color_model(p)=uninitialized_model then begin
+-        gs_red:=unity;
+-        gs_green:=unity;
+-        gs_blue:=unity;
++        gs_red:=0;
++        gs_green:=0;
++        gs_blue:=0;
+         gs_black:=unity;@/
+         end
+       else begin
+@@ -22649,14 +22745,14 @@
+ else begin
+   if fill_also then print_nl("B") else print_ln;
+   if (txy<>0)or(tyx<>0) then
+-    begin {print_ln;}
++    begin
+     print(" [");
+     ps_pair_out(txx,tyx);
+     ps_pair_out(txy,tyy);@/
+     ps_print("0 0] t");
+     end
+   else if (txx<>unity)or(tyy<>unity) then
+-    begin {print_ln;}
++    begin
+     ps_pair_out(txx,tyy);
+     print(" s");
+     end;
+@@ -22673,7 +22769,7 @@
+ txy:=right_x(p);
+ tyy:=right_y(p);
+ if (x_coord(p)<>0)or(y_coord(p)<>0) then
+-  begin print_ln; print_cmd("gsave ","q ");
++  begin print_nl(""); print_cmd("gsave ","q ");
+   ps_pair_out(x_coord(p),y_coord(p));
+   ps_print("translate ");@/
+   txx:=txx-x_coord(p);
+@@ -23046,9 +23142,7 @@
+ @ @<Print any pending specials@>=
+ t:=link(spec_head);
+ while t<>null do
+-  begin if length(value(t))<=emergency_line_length then print(value(t))
+-  else overflow("output line length",emergency_line_length);
+-@:MetaPost capacity exceeded output line length}{\quad output line length@>
++  begin  print(value(t));
+   print_ln;
+   t:=link(t);
+   end;
+@@ -23202,7 +23296,7 @@
+         end
+       else begin
+ 	begin_diagnostic;
+-        {selector:=term_and_log;}
++        if selector=log_only then incr(selector);
+ 	print_err("Warning: font ");
+ 	print(font_name[f]);
+ 	print(" cannot be found in any fontmapfile!");
+@@ -23696,11 +23790,13 @@
+     end;
+   end;
+ if internal[mpprocset]>0 then begin
++  print_nl("%%BeginResource: procset mpost");
+   if (internal[prologues]>0)and(ldf<>null_font) then
+     print("/bd{bind def}bind def/fshow {exch findfont exch scalefont setfont show}bd")
+   else
+     print_nl("/bd{bind def}bind def");
+   @<Print the procset@>;
++  print_nl("%%EndResource");
+   print_ln;
+   end;
+ end
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/Makefile.in
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpdir/Makefile.in	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/Makefile.in	2007-11-29 13:50:22.000000000 +0100
+@@ -14,7 +14,7 @@
+ 
+ XCPPFLAGS=-I.. -I$(srcdir)/.. -I../.. -I$(srcdir)/../..
+ 
+-OBJS = mapfile.o avl.o avlstuff.o utils.o writeenc.o writet1.o writefont.o
++OBJS = mapfile.o avl.o avlstuff.o utils.o writeenc.o writet1.o writefont.o turningnumber.o
+ 
+ all: libmpost.a makecpool
+ 
+@@ -34,7 +34,7 @@
+ depend:
+ 	rm -f $(OBJS)
+ 	XXCFLAGS=-MM XCFLAGS=-MM $(MAKE) -k $(OBJS) | \
+-	    grep -v "^$(CC)\|$(CXX)\|$(AR)\|make\|klibtool" | \
++	    grep -v "^$(CC)\|$(CXX)\|$(AR)\|make" | \
+ 	    sed 's: [^ ]*/\.\./libs/[^ ]*::g' > $(srcdir)/depend.mk
+ 
+ kpse_include mpdir/depend.mk
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/mp.defines
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpdir/mp.defines	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/mp.defines	2007-11-29 13:50:22.000000000 +0100
+@@ -54,4 +54,4 @@
+ 
+ { function from turningnumber.c }
+ 
+-@define function bezierslope();
+\ No newline at end of file
++@define function bezierslope();
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/mplib.h
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpdir/mplib.h	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/mplib.h	2007-11-29 13:50:22.000000000 +0100
+@@ -297,4 +297,8 @@
+ extern void avlputobj (integer, integer);
+ extern integer avlfindobj (integer, integer, integer);
+ 
++/* turningnumber.c */
++
++extern angle bezierslope(integer,integer,integer,integer,integer,integer,integer,integer,int);
++
+ #endif                          /* MPOSTLIB */
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/turningnumber.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/turningnumber.c	2007-11-29 13:50:22.000000000 +0100
+@@ -0,0 +1,113 @@
++/* $Id$ */
++
++#include "mplib.h"
++
++#define bezier_error (720<<20)+1
++
++#define sign(v) ((v)>0 ? 1 : ((v)<0 ? -1 : 0 ))
++
++#define print_roots(a) { if (debuglevel>(65536*2))			\
++      fprintf(stdout,"bezierslope(): %s, i=%f, o=%f, angle=%f\n",	\
++	      (a),in,out,res); }
++
++#define out ((double)(xo>>20))
++#define mid ((double)(xm>>20))
++#define in  ((double)(xi>>20))
++
++#define divisor (256*256)
++
++#define double2angle(a) (int)floor(a*256.0*256.0*16.0)
++
++angle 
++bezierslope(integer AX,integer AY,integer BX,integer BY,
++            integer CX,integer CY,integer DX,integer DY, int debuglevel) {
++  double a, b, c;
++  integer deltax,deltay;
++  double ax,ay,bx,by,cx,cy,dx,dy;
++
++  angle xi = 0, xo = 0, xm = 0;
++  double res = 0;
++
++  ax=AX/divisor;  ay=AY/divisor;
++  bx=BX/divisor;  by=BY/divisor;
++  cx=CX/divisor;  cy=CY/divisor;
++  dx=DX/divisor;  dy=DY/divisor;
++
++  deltax = (BX-AX); deltay = (BY-AY);
++  if (deltax==0 && deltay == 0) { deltax=(CX-AX); deltay=(CY-AY); }
++  if (deltax==0 && deltay == 0) { deltax=(DX-AX); deltay=(DY-AY); }
++  xi = anangle(deltax,deltay);
++
++  deltax = (CX-BX); deltay = (CY-BY);
++  xm = anangle(deltax,deltay);
++
++  deltax = (DX-CX); deltay = (DY-CY);
++  if (deltax==0 && deltay == 0) { deltax=(DX-BX); deltay=(DY-BY); }
++  if (deltax==0 && deltay == 0) { deltax=(DX-AX); deltay=(DY-AY); }
++  xo = anangle(deltax,deltay);
++
++  a = (bx-ax)*(cy-by) - (cx-bx)*(by-ay); /* a = (bp-ap)x(cp-bp); */
++  b = (bx-ax)*(dy-cy) - (by-ay)*(dx-cx);; /* b = (bp-ap)x(dp-cp);*/
++  c = (cx-bx)*(dy-cy) - (dx-cx)*(cy-by); /* c = (cp-bp)x(dp-cp);*/
++
++  if (debuglevel>(65536*2)) {
++    fprintf(stdout,
++    "bezierslope(): (%.2f,%.2f),(%.2f,%.2f),(%.2f,%.2f),(%.2f,%.2f)\n",
++             ax,ay,bx,by,cx,cy,dx,dy);
++    fprintf(stdout,"bezierslope(): a,b,c,b^2,4ac: (%.2f,%.2f,%.2f,%.2f,%.2f)\n",a,b,c,b*b,4*a*c);
++  }
++
++  if ((a==0)&&(c==0)) {
++    res = (b==0 ?  0 :  (out-in)); 
++    print_roots("no roots (a)");
++  } else if ((a==0)||(c==0)) {
++    if ((sign(b) == sign(a)) || (sign(b) == sign(c))) {
++      res = out-in; /* ? */
++      if (res<-180.0) 
++	res += 360.0;
++      else if (res>180.0)
++	res -= 360.0;
++      print_roots("no roots (b)");
++    } else {
++      res = out-in; /* ? */
++      print_roots("one root (a)");
++    }
++  } else if ((sign(a)*sign(c))<0) {
++    res = out-in; /* ? */
++      if (res<-180.0) 
++	res += 360.0;
++      else if (res>180.0)
++	res -= 360.0;
++    print_roots("one root (b)");
++  } else {
++    if (sign(a) == sign(b)) {
++      res = out-in; /* ? */
++      if (res<-180.0) 
++	res += 360.0;
++      else if (res>180.0)
++	res -= 360.0;
++      print_roots("no roots (d)");
++    } else {
++      if ((b*b) == (4*a*c)) {
++	res = bezier_error;
++	/* print_roots("double root"); *//* cusp */
++      } else if ((b*b) < (4*a*c)) {
++	res = out-in; /* ? */
++	if (res<=0.0 &&res>-180.0) 
++	  res += 360.0;
++        else if (res>=0.0 && res<180.0)
++	  res -= 360.0;
++	print_roots("no roots (e)");
++      } else {
++	res = out-in;
++	if (res<-180.0) 
++	  res += 360.0;
++        else if (res>180.0)
++	  res -= 360.0;
++	print_roots("two roots"); /* two inflections */
++      }
++    }
++  }
++  return double2angle(res);
++}
++
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/writefont.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpdir/writefont.c	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpdir/writefont.c	2007-11-29 13:50:22.000000000 +0100
+@@ -184,17 +184,6 @@
+ 	  if (encodings_only || (!is_subsetted (fm))) {
+ 	    e = fm->encoding;
+ 	    write_enc (NULL, e, 0);
+-	  }
+-	}
+-      }
+-    }
+-  }
+-  for (f=nullfont+1;f<=lastfnum;f++) {
+-    if (fontsizes[f]!=0 && hasfmentry (f)) { 
+-      fm = (fm_entry *) mpfontmap[f];
+-      if (fm != NULL && (fm->ps_name != NULL)) {
+-	if (is_reencoded (fm)) {
+-	  if (encodings_only || (!is_subsetted (fm))) {
+             /* clear for next run */
+             e->objnum = 0;
+ 	  }
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/dmp.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpware/dmp.c	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/dmp.c	2007-11-29 13:50:22.000000000 +0100
+@@ -23,8 +23,8 @@
+  *  gets modified.
+  */
+ 
+-char *banner = "% Written by DMP, Version 0.992";	/* first line of output */
+-char *term_banner = "This is DMP, Version 0.992";
++char *banner = "% Written by DMP, Version 1.002";	/* first line of output */
++char *term_banner = "This is DMP, Version 1.002";
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/makempx.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpware/makempx.c	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/makempx.c	2007-11-29 13:50:22.000000000 +0100
+@@ -95,7 +95,7 @@
+ #define GETCWD getcwd
+ #endif
+ 
+-#define version "0.993"
++#define version "1.002"
+ 
+ #define ERRLOG "mpxerr.log"
+ #define TEXERR "mpxerr.tex"
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/mpto.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpware/mpto.c	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/mpto.c	2007-11-29 13:50:22.000000000 +0100
+@@ -25,9 +25,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+-#ifdef WIN32
+ #include <string.h>
+-#endif
+ 
+ 
+ /* MetaPost itself has a configurable max line length, but we can afford to
+@@ -49,7 +47,7 @@
+     "  \\ht0=0pt \\dp0=0pt \\box0 \\egroup}\n"
+     "\\mpxshipout%% line %d %s\n";
+ char *tex_pretex = "\\mpxshipout%% line %d %s\n";
+-char *tex_posttex = "\\stopmpxshipout\n";
++char *tex_posttex = "\n\\stopmpxshipout\n";
+ char *tex_preverb1 = "";	/* if very first instance */
+ char *tex_preverb = "%% line %d %s\n";	/* all other instances */
+ char *tex_postverb = "%\n";
+@@ -122,7 +120,7 @@
+ 
+ 
+ /* Return nonzero if a prefix of string s matches the null-terminated string t
+- * and the next character is not a letter of an underscore.
++ * and the next character is not a letter or an underscore.
+  */
+ int
+ match_str(char *s, char *t)
+@@ -300,23 +298,14 @@
+ {
+     char *s;			/* where a string to print stops */
+     char c;
+-
+-    while (*aa == ' ' || *aa == '\t')
+-	aa++;
+-    if (*aa == 0)
+-	if ((aa = getline()) == NULL)
+-	    err("btex section does not end");
++    char *res = NULL;
+     do {
+ 	if (*aa == 0)
+-	    if ((aa = getline()) == NULL)
+-		err("btex section does not end");
+-	    else
+-		printf("\n");
++	  if ((aa = getline()) == NULL)
++	    err("btex section does not end");
++
+ 	if (getbta(aa) && *tt == 'e') {
+-	    s = tt - 1;
+-	    while (s >= bb && (*s == ' ' || *s == '\t'))
+-		s--;
+-	    s++;
++     	    s = tt;
+ 	} else {
+ 	    if (*tt == 'b')
+ 		err("btex in TeX mode");
+@@ -326,9 +315,31 @@
+ 	}
+ 	c = *s;
+ 	*s = 0;
+-	printf("%s", bb);
++	if (res==NULL) {
++	  res = malloc(strlen(bb)+2);
++	  if (res==NULL)
++	    err("memory allocation failure");
++	  res = strncpy(res,bb,(strlen(bb)+1));
++	} else {
++	  res = realloc(res,strlen(res)+strlen(bb)+2);
++	  if (res==NULL)
++	    err("memory allocation failure");
++	  res = strncat(res,bb, strlen(bb));
++	}
++	if (c == '\0')
++	    res = strncat(res, "\n", 1);
+ 	*s = c;
+     } while (*tt != 'e');
++    /* whitespace at the end */
++    for (s = res + strlen(res) - 1;
++	 s >= res && (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'); s--);
++    *(++s) = '\0';
++    /* whitespace at the start */
++    for (s = res;
++	 s < (res + strlen(res)) && (*s == ' ' || *s == '\t' || *s == '\r'
++				     || *s == '\n'); s++);
++    printf("%s%%",s);
++    free(res);
+ }
+ 
+ 
+@@ -386,7 +397,7 @@
+ 	exit(0);
+     } else if (argc > 1 && (strcmp(argv[1], "--version") == 0
+ 			    || strcmp(argv[1], "-version") == 0)) {
+-	printf("mpto 0.992\n\
++	printf("mpto 1.002\n\
+ This program is in the public domain.\n\
+ Primary author of mpto: John Hobby.\n\
+ Current maintainer: Taco Hoekwater.\n");
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/newer.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/mpware/newer.c	2007-11-29 13:49:54.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/mpware/newer.c	2007-11-29 13:50:22.000000000 +0100
+@@ -87,7 +87,7 @@
+ 	} else if (strcmp(argv[1], "-version") == 0 ||
+ 		   strcmp(argv[1], "--version") == 0) {
+ 
+-	    fputs("newer 0.992\n\
++	    fputs("newer 1.002\n\
+ This program is in the public domain.\n\
+ Primary author of newer: John Hobby.\n\
+ Current maintainer: Taco Hoekwater.\n", stdout);
--- texlive-bin-2007.dfsg.2.orig/debian/patches/12b_fix_a2ping_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/12b_fix_a2ping_invocation
@@ -0,0 +1,29 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 12b_fix_a2ping_invocation.dpatch  <preining@logic.at>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix invocation of a2ping to get rid of magic
+
+@DPATCH@
+---
+ build/source/texk/tetex/a2ping |   10 ++--------
+ 1 file changed, 2 insertions(+), 8 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/tetex/a2ping
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/tetex/a2ping	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/tetex/a2ping	2007-01-26 03:58:02.000000000 +0100
+@@ -1,11 +1,5 @@
+-#! /bin/sh
+-eval '(exit $?0)' && eval 'PERL_BADLANG=x;export PERL_BADLANG;: \
+-;exec perl -x -S -- "$0" ${1+"$@"};#'if 0;
+-eval 'setenv PERL_BADLANG x;exec perl -x -S -- "$0" $argv:q;#'.q+
+-#!perl -w
+-package Htex::a2ping;  $0=~/(.*)/s;unshift@INC,'.';do($1);die$@if$@;__END__+if !1;
+-# This Perl script was generated by JustLib2 at Wed Apr 23 09:14:13 2003.
+-# Don't touch/remove any lines above; http://www.inf.bme.hu/~pts/justlib
++#! /usr/bin/perl -w
++package Htex::a2ping;
+ #
+ # This program is free software, licensed under the GNU GPL, >=2.0.
+ # This software comes with absolutely NO WARRANTY. Use at your own risk!
--- texlive-bin-2007.dfsg.2.orig/debian/patches/51_fmtutil_keep_failedlog
+++ texlive-bin-2007.dfsg.2/debian/patches/51_fmtutil_keep_failedlog
@@ -0,0 +1,29 @@
+---
+ build/source/texk/tetex/fmtutil |    7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/fmtutil
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/fmtutil	2007-04-13 14:04:31.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/fmtutil	2007-04-13 14:09:48.000000000 +0200
+@@ -696,9 +696,7 @@
+   if test -f $fmtfile; then
+     grep '^! ' $format.log >/dev/null 2>&1 &&
+       log_failure "\`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' possibly failed."
+-    rm -f "$fulldestdir/$format.log"
+-    # We don't want user-interaction for the following "mv" commands:
+-    mv "$format.log" "$fulldestdir/$format.log" </dev/null
++    # We don't want user-interaction for the following "mv" command:
+     if mv "$fmtfile" "$fulldestdir/$fmtfile" </dev/null; then
+       verboseMsg "$progname: $fulldestdir/$fmtfile installed."
+       #
+@@ -710,6 +708,9 @@
+   else
+     log_failure "\`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' failed"
+   fi
++  rm -f "$fulldestdir/$format.log"
++  # We don't want user-interaction for the following "mv" command:
++  mv "$format.log" "$fulldestdir/$format.log" </dev/null
+ }
+ 
+ ###############################################################################
--- texlive-bin-2007.dfsg.2.orig/debian/patches/fix-ovp2ovf-segfault
+++ texlive-bin-2007.dfsg.2/debian/patches/fix-ovp2ovf-segfault
@@ -0,0 +1,19 @@
+fix-ovp2ovf-segfault
+fix a segfault under stange circumstances, from upstream
+---
+ build/source/texk/web2c/omegafonts/font_routines.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/omegafonts/font_routines.c
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/omegafonts/font_routines.c	2008-03-20 15:11:43.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/omegafonts/font_routines.c	2008-03-20 15:12:15.000000000 +0100
+@@ -57,7 +57,7 @@
+ void
+ font_no_incr(void)
+ {
+-    if (no_fonts == font_table_size) {
++    if (no_fonts * BLOCK == font_table_size) {
+        font_table_size += BLOCK;
+        font_table = (font *) xrealloc(font_table, font_table_size);
+     }
--- texlive-bin-2007.dfsg.2.orig/debian/patches/23_use_xdvi.bin
+++ texlive-bin-2007.dfsg.2/debian/patches/23_use_xdvi.bin
@@ -0,0 +1,22 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 23_use_xdvi.bin.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: use xdvi.bin as xdvi binary, which is handled via alternatives
+## DP: and not xdvi-xaw.real. The alternatives setting updates xdvi.bin
+## DP: to xdvi-xaw.real
+
+@DPATCH@
+ build/source/texk/xdvik/xdvi-sh.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/xdvik/xdvi-sh.in
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/xdvik/xdvi-sh.in	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/xdvik/xdvi-sh.in	2007-01-26 04:00:27.000000000 +0100
+@@ -43,4 +43,4 @@
+   XFILESEARCHPATH="$xdviapppath:${XFILESEARCHPATH-%D}"; export XFILESEARCHPATH
+ fi
+ 
+-exec @final_exec_name@ $NAMEOPT ${1+"$@"}
++exec xdvi.bin $NAMEOPT ${1+"$@"}
--- texlive-bin-2007.dfsg.2.orig/debian/patches/config.ps-update
+++ texlive-bin-2007.dfsg.2/debian/patches/config.ps-update
@@ -0,0 +1,635 @@
+Update config.ps from TeX Live 2007.
+This fixes some bugs with setting the right page size in created pdf
+documents.
+---
+ texmf/dvips/config/config.ps |  525 ++++++++++++++++++++++++++++++++++++-------
+ 1 file changed, 443 insertions(+), 82 deletions(-)
+
+Index: texlive-bin-2007/texmf/dvips/config/config.ps
+===================================================================
+--- texlive-bin-2007.orig/texmf/dvips/config/config.ps	2007-07-02 07:42:08.000000000 +0200
++++ texlive-bin-2007/texmf/dvips/config/config.ps	2007-07-02 07:42:26.000000000 +0200
+@@ -1,4 +1,5 @@
+-% teTeX's config.ps. Thomas Esser, 1998, public domain.
++% config.ps - configuration file for dvips.
++% Tomas Rokicki, Thomas Esser, Karl Berry, et al., 1986ff, public domain.
+ 
+ % Memory available. Download the three-line PostScript file:
+ %   %! Hey, we're PostScript
+@@ -11,7 +12,7 @@
+ % `\special' and config files (via the `E' option) and opening of any
+ % absolute filenames.  z1, the default, forbids shell escapes but
+ % allows absolute filenames.  z0 allows both.  The corresponding
+-% commandline options are -R0|-R1|-R2
++% command line options are -R0|-R1|-R2
+ z1
+ 
+ % How to print, maybe with lp instead lpr, etc. If commented-out, output
+@@ -43,167 +44,527 @@
+ 
+ % Partially download Type 1 fonts by default.  Only reason not to do
+ % this is if you encounter bugs.  (Please report them to
+-% @email{tex-k@@mail.tug.org} if you do.)
++% @email{tex-k@tug.org} if you do.)
+ j
+ 
+ % This shows how to add your own map file.
+ % Remove the comment and adjust the name:
+ % p +myfonts.map
+ 
+-% 0 0 595 842 is the right bounding box that most applications expect
+-% for A4.  Since dvips always rounds up, choose something slightly smaller.
++% If we have setpagedevice, use that.
++% else if we have the a4 resp. letter operator, use that.
++% else do nothing to set the page size.
++% 
++% In the past, the a4size and letterSize definitions did not set the
++% page size, but we want to set it if we can so that ps2pdf can work
++% properly.  Here, a4 and a4size, and letter and letterSize, are
++% identical, and we prefer the a4/letter names -- texconfig uses them.
++ 
++% 0 0 595 842 is the right bounding box that applications expect
++% for A4.  Since dvips always rounds up, choose something slightly
++% smaller for our paper size.
+ 
+-@ A4size 594.99bp 841.99bp
++@ a4 210mm 297mm
+ @+ ! %%DocumentPaperSizes: a4
+-@+ %%PaperSize: A4
++@+ %%BeginPaperSize: a4
++@+ /setpagedevice where
++@+  { pop << /PageSize [595 842] >> setpagedevice }
++@+  { /a4 where { pop a4 } if }
++@+ ifelse
++@+ %%EndPaperSize
+ 
+-@ letterSize 8.5in 11in
++@ letter 8.5in 11in
+ @+ ! %%DocumentPaperSizes: Letter
++@+ %%BeginPaperSize: Letter
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 792] >> setpagedevice }
++@+  { /letter where { pop letter } if }
++@+ ifelse
++@+ %%EndPaperSize
+ 
+-@ letter 8.5in 11in
++@ a4size 210mm 297mm
++@+ ! %%DocumentPaperSizes: a4
++@+ %%BeginPaperSize: a4
++@+ /setpagedevice where
++@+  { pop << /PageSize [595 842] >> setpagedevice }
++@+  { /a4 where { pop a4 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ letterSize 8.5in 11in
+ @+ ! %%DocumentPaperSizes: Letter
+ @+ %%BeginPaperSize: Letter
+-@+ letter
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 792] >> setpagedevice }
++@+  { /letter where { pop letter } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ halfexecutive 133mm 184mm
++@+ ! %%DocumentPaperSizes: halfexecutive
++@+ %%BeginPaperSize: halfexecutive
++@+ /setpagedevice where
++@+  { pop << /PageSize [378 522] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ halfletter 140mm 216mm
++@+ ! %%DocumentPaperSizes: halfletter
++@+ %%BeginPaperSize: halfletter
++@+ /setpagedevice where
++@+  { pop << /PageSize [396 612] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ statement 140mm 216mm
++@+ ! %%DocumentPaperSizes: statement
++@+ %%BeginPaperSize: statement
++@+ /setpagedevice where
++@+  { pop << /PageSize [396 612] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ executive 184mm 267mm
++@+ ! %%DocumentPaperSizes: executive
++@+ %%BeginPaperSize: executive
++@+ /setpagedevice where
++@+  { pop << /PageSize [522 756] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++% for powerdot
++@ screen 8.25in 11in
++@+ ! %%DocumentPaperSizes: Screen
++@+ %%BeginPaperSize: Screen
++@+ /setpagedevice where
++@+  { pop << /PageSize [594 792] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++% a common size for printers (in north america).
++@ sixbynine 6in 9in
++@+ ! %%DocumentPaperSizes: SixByNine
++@+ %%BeginPaperSize: SixByNine
++@+ /setpagedevice where
++@+  { pop << /PageSize [432 648] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ quarto 215mm 275mm
++@+ ! %%DocumentPaperSizes: quarto
++@+ %%BeginPaperSize: quarto
++@+ /setpagedevice where
++@+  { pop << /PageSize [610 780] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ note 216mm 279mm
++@+ ! %%DocumentPaperSizes: note
++@+ %%BeginPaperSize: note
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 792] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ folio 216mm 330mm
++@+ ! %%DocumentPaperSizes: folio
++@+ %%BeginPaperSize: folio
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 936] >> setpagedevice }
++@+ if
+ @+ %%EndPaperSize
+ 
+ @ legal 8.5in 14in
+ @+ ! %%DocumentPaperSizes: Legal
+ @+ %%BeginPaperSize: Legal
+-@+ legal
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 1008] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ 10x14 10in 14in
++@+ ! %%DocumentPaperSizes: 10x14
++@+ %%BeginPaperSize: 10x14
++@+ /setpagedevice where
++@+  { pop << /PageSize [720 1008] >> setpagedevice }
++@+ if
+ @+ %%EndPaperSize
+ 
+ @ ledger 17in 11in
+ @+ ! %%DocumentPaperSizes: Ledger
+ @+ %%BeginPaperSize: Ledger
+-@+ ledger
++@+ /setpagedevice where
++@+  { pop << /PageSize [1224 792] >> setpagedevice }
++@+ if
+ @+ %%EndPaperSize
+ 
+ @ tabloid 11in 17in
+ @+ ! %%DocumentPaperSizes: Tabloid
+ @+ %%BeginPaperSize: Tabloid
+-@+ 11x17
+-@+ %%EndPaperSize
+-
+-@ a6 105mm 148mm
+-@+ ! %%DocumentPaperSizes: a6
+-@+ %%BeginPaperSize: a6
+-@+ a6
+-@+ %%EndPaperSize
+-
+-@ a5 148mm 210mm
+-@+ ! %%DocumentPaperSizes: a5
+-@+ %%BeginPaperSize: a5
+-@+ a5
++@+ /setpagedevice where
++@+  { pop << /PageSize [792 1224] >> setpagedevice }
++@+ if
+ @+ %%EndPaperSize
+ 
+-@ a4 594.99bp 841.99bp
+-@+ ! %%DocumentPaperSizes: a4
+-@+ %%BeginPaperSize: a4
+-@+ a4
++@ 11x17 11in 17in
++@+ ! %%DocumentPaperSizes: 11x17
++@+ %%BeginPaperSize: 11x17
++@+ /setpagedevice where
++@+  { pop << /PageSize [792 1224] >> setpagedevice }
++@+ if
+ @+ %%EndPaperSize
+ 
+-@ a3 297mm 420mm
+-@+ ! %%DocumentPaperSizes: a3
+-@+ %%BeginPaperSize: a3
+-@+ a3
+-@+ %%EndPaperSize
+-
+-@ a2 420mm 595mm
+-@+ ! %%DocumentPaperSizes: a2
+-@+ %%BeginPaperSize: a2
+-@+ a2
++@ a0 841mm 1189mm
++@+ ! %%DocumentPaperSizes: a0
++@+ %%BeginPaperSize: a0
++@+ /setpagedevice where
++@+  { pop << /PageSize [2384 3370] >> setpagedevice }
++@+  { /a0 where { pop a0 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+-@ a1 595mm 841mm
++@ a1 594mm 841mm
+ @+ ! %%DocumentPaperSizes: a1
+ @+ %%BeginPaperSize: a1
+-@+ a1
++@+ /setpagedevice where
++@+  { pop << /PageSize [1684 2384] >> setpagedevice }
++@+  { /a1 where { pop a1 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+-@ a0 841mm 1189mm
+-@+ ! %%DocumentPaperSizes: a0
+-@+ %%BeginPaperSize: a0
+-@+ a0
+-@+ %%EndPaperSize
+-
+-@ b6 125mm 176mm
+-@+ ! %%DocumentPaperSizes: b6
+-@+ %%BeginPaperSize: b6
+-@+ b6
++@ a2 420mm 594mm
++@+ ! %%DocumentPaperSizes: a2
++@+ %%BeginPaperSize: a2
++@+ /setpagedevice where
++@+  { pop << /PageSize [1191 1684] >> setpagedevice }
++@+  { /a2 where { pop a2 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+-@ b5 176mm 250mm
+-@+ ! %%DocumentPaperSizes: b5
+-@+ %%BeginPaperSize: b5
+-@+ b5
++@ a3 297mm 420mm
++@+ ! %%DocumentPaperSizes: a3
++@+ %%BeginPaperSize: a3
++@+ /setpagedevice where
++@+  { pop << /PageSize [842 1191] >> setpagedevice }
++@+  { /a3 where { pop a3 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+-@ b4 250mm 353mm
+-@+ ! %%DocumentPaperSizes: b4
+-@+ %%BeginPaperSize: b4
+-@+ b4
++@ a5 148mm 210mm
++@+ ! %%DocumentPaperSizes: a5
++@+ %%BeginPaperSize: a5
++@+ /setpagedevice where
++@+  { pop << /PageSize [420 595] >> setpagedevice }
++@+  { /a5 where { pop a5 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+-@ b3 353mm 500mm
+-@+ ! %%DocumentPaperSizes: b3
+-@+ %%BeginPaperSize: b3
+-@+ b3
++@ a6 105mm 148mm
++@+ ! %%DocumentPaperSizes: a6
++@+ %%BeginPaperSize: a6
++@+ /setpagedevice where
++@+  { pop << /PageSize [298 420] >> setpagedevice }
++@+  { /a6 where { pop a6 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ a7 74mm 105mm
++@+ ! %%DocumentPaperSizes: a7
++@+ %%BeginPaperSize: a7
++@+ /setpagedevice where
++@+  { pop << /PageSize [210 298] >> setpagedevice }
++@+  { /a7 where { pop a7 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ a8 52mm 74mm
++@+ ! %%DocumentPaperSizes: a8
++@+ %%BeginPaperSize: a8
++@+ /setpagedevice where
++@+  { pop << /PageSize [147 210] >> setpagedevice }
++@+  { /a8 where { pop a8 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ a9 37mm 52mm
++@+ ! %%DocumentPaperSizes: a9
++@+ %%BeginPaperSize: a9
++@+ /setpagedevice where
++@+  { pop << /PageSize [105 147] >> setpagedevice }
++@+  { /a9 where { pop a9 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ a10 26mm 37mm
++@+ ! %%DocumentPaperSizes: a10
++@+ %%BeginPaperSize: a10
++@+ /setpagedevice where
++@+  { pop << /PageSize [74 105] >> setpagedevice }
++@+  { /a10 where { pop a10 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb0 1030mm 1456mm
+ @+ ! %%DocumentPaperSizes: jisb0
+ @+ %%BeginPaperSize: jisb0
+-@+ jisb0
++@+ /setpagedevice where
++@+  { pop << /PageSize [2920 4127] >> setpagedevice }
++@+  { /jisb0 where { pop jisb0 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb1 728mm 1030mm
+ @+ ! %%DocumentPaperSizes: jisb1
+ @+ %%BeginPaperSize: jisb1
+-@+ jisb1
++@+ /setpagedevice where
++@+  { pop << /PageSize [2064 2920] >> setpagedevice }
++@+  { /jisb1 where { pop jisb1 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb2 515mm 728mm
+ @+ ! %%DocumentPaperSizes: jisb2
+ @+ %%BeginPaperSize: jisb2
+-@+ jisb2
++@+ /setpagedevice where
++@+  { pop << /PageSize [1460 2064] >> setpagedevice }
++@+  { /jisb2 where { pop jisb2 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb3 364mm 515mm
+ @+ ! %%DocumentPaperSizes: jisb3
+ @+ %%BeginPaperSize: jisb3
+-@+ jisb3
++@+ /setpagedevice where
++@+  { pop << /PageSize [1032 1460] >> setpagedevice }
++@+  { /jisb3 where { pop jisb3 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb4 257mm 364mm
+ @+ ! %%DocumentPaperSizes: jisb4
+ @+ %%BeginPaperSize: jisb4
+-@+ jisb4
++@+ /setpagedevice where
++@+  { pop << /PageSize [729 1032] >> setpagedevice }
++@+  { /jisb4 where { pop jisb4 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb5 182mm 257mm
+ @+ ! %%DocumentPaperSizes: jisb5
+ @+ %%BeginPaperSize: jisb5
+-@+ jisb5
++@+ /setpagedevice where
++@+  { pop << /PageSize [516 729] >> setpagedevice }
++@+  { /jisb5 where { pop jisb5 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+ @ jisb6 128mm 182mm
+ @+ ! %%DocumentPaperSizes: jisb6
+ @+ %%BeginPaperSize: jisb6
+-@+ jisb6
++@+ /setpagedevice where
++@+  { pop << /PageSize [363 516] >> setpagedevice }
++@+  { /jisb6 where { pop jisb6 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ jisb7 91mm 128mm
++@+ ! %%DocumentPaperSizes: jisb7
++@+ %%BeginPaperSize: jisb7
++@+ /setpagedevice where
++@+  { pop << /PageSize [258 363] >> setpagedevice }
++@+  { /jisb7 where { pop jisb7 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ jisb8 64mm 91mm
++@+ ! %%DocumentPaperSizes: jisb8
++@+ %%BeginPaperSize: jisb8
++@+ /setpagedevice where
++@+  { pop << /PageSize [181 258] >> setpagedevice }
++@+  { /jisb8 where { pop jisb8 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ b0 1000mm 1414mm
++@+ ! %%DocumentPaperSizes: b0
++@+ %%BeginPaperSize: b0
++@+ /setpagedevice where
++@+  { pop << /PageSize [2835 4008] >> setpagedevice }
++@+  { /b0 where { pop b0 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ b1 707mm 1000mm
++@+ ! %%DocumentPaperSizes: b1
++@+ %%BeginPaperSize: b1
++@+ /setpagedevice where
++@+  { pop << /PageSize [2004 2835] >> setpagedevice }
++@+  { /b1 where { pop b1 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ b2 500mm 707mm
++@+ ! %%DocumentPaperSizes: b2
++@+ %%BeginPaperSize: b2
++@+ /setpagedevice where
++@+  { pop << /PageSize [1417 2004] >> setpagedevice }
++@+  { /b2 where { pop b2 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ b3 353mm 500mm
++@+ ! %%DocumentPaperSizes: b3
++@+ %%BeginPaperSize: b3
++@+ /setpagedevice where
++@+  { pop << /PageSize [1001 1417] >> setpagedevice }
++@+  { /b3 where { pop b3 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ b4 250mm 353mm
++@+ ! %%DocumentPaperSizes: b4
++@+ %%BeginPaperSize: b4
++@+ /setpagedevice where
++@+  { pop << /PageSize [709 1001] >> setpagedevice }
++@+  { /b4 where { pop b4 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ b5 176mm 250mm
++@+ ! %%DocumentPaperSizes: b5
++@+ %%BeginPaperSize: b5
++@+ /setpagedevice where
++@+  { pop << /PageSize [499 709] >> setpagedevice }
++@+  { /b5 where { pop b5 } if }
++@+ ifelse
+ @+ %%EndPaperSize
+ 
+-% not defined in Ghostscript, per Akira.
+-% @ jisb7 91mm 128mm
+-% @+ ! %%DocumentPaperSizes: jisb7
+-% @+ %%BeginPaperSize: jisb7
+-% @+ jisb7
+-% @+ %%EndPaperSize
+-%
+-% @ jisb8 64mm 91mm
+-% @+ ! %%DocumentPaperSizes: jisb8
+-% @+ %%BeginPaperSize: jisb8
+-% @+ jisb8
+-% @+ %%EndPaperSize
++@ b6 125mm 176mm
++@+ ! %%DocumentPaperSizes: b6
++@+ %%BeginPaperSize: b6
++@+ /setpagedevice where
++@+  { pop << /PageSize [354 499] >> setpagedevice }
++@+  { /b6 where { pop b6 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ c5 162mm 229mm
++@+ ! %%DocumentPaperSizes: c5
++@+ %%BeginPaperSize: c5
++@+ /setpagedevice where
++@+  { pop << /PageSize [459 649] >> setpagedevice }
++@+  { /c5 where { pop c5 } if }
++@+ ifelse
++@+ %%EndPaperSize
++
++@ DL 110mm 220mm
++@+ ! %%DocumentPaperSizes: DL
++@+ %%BeginPaperSize: DL
++@+ /setpagedevice where
++@+  { pop << /PageSize [312 624] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ Comm10 105mm 241mm
++@+ ! %%DocumentPaperSizes: Comm10
++@+ %%BeginPaperSize: Comm10
++@+ /setpagedevice where
++@+  { pop << /PageSize [297 684] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ Monarch 98.4mm 190.5mm
++@+ ! %%DocumentPaperSizes: Monarch
++@+ %%BeginPaperSize: Monarch
++@+ /setpagedevice where
++@+  { pop << /PageSize [279 540] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ archE 36in 48in
++@+ ! %%DocumentPaperSizes: archE
++@+ %%BeginPaperSize: archE
++@+ /setpagedevice where
++@+  { pop << /PageSize [2592 3456] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ archD 24in 36in
++@+ ! %%DocumentPaperSizes: archD
++@+ %%BeginPaperSize: archD
++@+ /setpagedevice where
++@+  { pop << /PageSize [1728 2592] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ archC 18in 24in
++@+ ! %%DocumentPaperSizes: archC
++@+ %%BeginPaperSize: archC
++@+ /setpagedevice where
++@+  { pop << /PageSize [1296 1728] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ archB 12in 18in
++@+ ! %%DocumentPaperSizes: archB
++@+ %%BeginPaperSize: archB
++@+ /setpagedevice where
++@+  { pop << /PageSize [864 1296] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ archA 9in 12in
++@+ ! %%DocumentPaperSizes: archA
++@+ %%BeginPaperSize: archA
++@+ /setpagedevice where
++@+  { pop << /PageSize [648 864] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ flsa 216mm 330.2mm
++@+ ! %%DocumentPaperSizes: flsa
++@+ %%BeginPaperSize: flsa
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 936] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ flse 216mm 330.2mm
++@+ ! %%DocumentPaperSizes: flse
++@+ %%BeginPaperSize: flse
++@+ /setpagedevice where
++@+  { pop << /PageSize [612 936] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ csheet 431.8mm 558.8mm
++@+ ! %%DocumentPaperSizes: csheet
++@+ %%BeginPaperSize: csheet
++@+ /setpagedevice where
++@+  { pop << /PageSize [1224 1584] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ dsheet 558.8mm 863.6mm
++@+ ! %%DocumentPaperSizes: dsheet
++@+ %%BeginPaperSize: dsheet
++@+ /setpagedevice where
++@+  { pop << /PageSize [1584 2448] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ esheet 863.6mm 1117.6mm
++@+ ! %%DocumentPaperSizes: esheet
++@+ %%BeginPaperSize: esheet
++@+ /setpagedevice where
++@+  { pop << /PageSize [2448 3168] >> setpagedevice }
++@+ if
++@+ %%EndPaperSize
++
++@ unknown 0in 0in
++@+ statusdict /setpageparams known { hsize vsize 0 1 statusdict begin {
++@+ setpageparams } stopped end } { true } ifelse { statusdict /setpage known
++@+ { hsize vsize 1 statusdict begin { setpage } stopped pop end } if } if
+ 
+ @ unknown 0in 0in
+ @+ statusdict /setpageparams known { hsize vsize 0 1 statusdict begin {
--- texlive-bin-2007.dfsg.2.orig/debian/patches/62_dvips_absolutepath_doc
+++ texlive-bin-2007.dfsg.2/debian/patches/62_dvips_absolutepath_doc
@@ -0,0 +1,59 @@
+---
+ texmf/doc/man/man1/dvips.1   |   25 +++++++++++++++----------
+ texmf/dvips/config/config.ps |    7 +++++--
+ 2 files changed, 20 insertions(+), 12 deletions(-)
+
+Index: texlive-bin-2007/texmf/dvips/config/config.ps
+===================================================================
+--- texlive-bin-2007.orig/texmf/dvips/config/config.ps	2007-04-22 08:21:53.000000000 +0200
++++ texlive-bin-2007/texmf/dvips/config/config.ps	2007-04-22 08:33:28.000000000 +0200
+@@ -7,8 +7,11 @@
+ % to determine this number. (It will be the only thing printed.)
+ m 3500000
+ 
+-% z1 is "secure", i.e., inhibits execution of `shell commands` in
+-% \specials.  Dvips allows this by default.
++% Run securely.  z2 disables both shell command execution in
++% `\special' and config files (via the `E' option) and opening of any
++% absolute filenames.  z1, the default, forbids shell escapes but
++% allows absolute filenames.  z0 allows both.  The corresponding
++% commandline options are -R0|-R1|-R2
+ z1
+ 
+ % How to print, maybe with lp instead lpr, etc. If commented-out, output
+Index: texlive-bin-2007/texmf/doc/man/man1/dvips.1
+===================================================================
+--- texlive-bin-2007.orig/texmf/doc/man/man1/dvips.1	2007-04-22 08:23:32.000000000 +0200
++++ texlive-bin-2007/texmf/doc/man/man1/dvips.1	2007-04-22 08:32:57.000000000 +0200
+@@ -360,16 +360,21 @@
+ .B -r
+ Stack pages in reverse order.  Normally, page 1 will be printed first.
+ .TP
+-.B -R
+-Run in secure mode. This means that ``backtick'' commands from a
+-.I \especial{}
+-or
+-.I \epsffile{}
+-macro in the (La)TeX source like
+-.I \especial{psfile="`zcat foo.ps.Z"}
+-or
+-.I \epsffile[72 72 540 720]{"`zcat screendump.ps.gz"}
+-are not executed.
++.B -R[0|1|2]
++Run securely.
++.BR -R2
++disables both shell command execution in
++.I \especial'{}
++(via backticks
++.BR `
++) and config files (via the
++.I E
++option), and opening of any absolute filenames.
++.BR -R1
++, the default, forbids shell escapes but allows absolute filenames.
++.BR -R0
++allows both.  The config file option is
++.I z
+ .TP
+ .B -s
+ Causes the entire global output to be enclosed in a save/restore pair.
--- texlive-bin-2007.dfsg.2.orig/debian/patches/32_dvips_fontbug_fix_upstream
+++ texlive-bin-2007.dfsg.2/debian/patches/32_dvips_fontbug_fix_upstream
@@ -0,0 +1,896 @@
+---
+ build/source/texk/dvipsk/ChangeLog     |   36 +++++++++++++++++++
+ build/source/texk/dvipsk/Makefile.in   |    2 -
+ build/source/texk/dvipsk/afm2tfm.c     |    6 +--
+ build/source/texk/dvipsk/afm2tfm.rc    |   34 ------------------
+ build/source/texk/dvipsk/bbox.c        |    2 -
+ build/source/texk/dvipsk/config.h      |    2 -
+ build/source/texk/dvipsk/crop.lpro     |    2 -
+ build/source/texk/dvipsk/debug.h       |    2 -
+ build/source/texk/dvipsk/download.c    |   25 +++++++++----
+ build/source/texk/dvipsk/dpicheck.c    |    6 +--
+ build/source/texk/dvipsk/dvips.1       |   25 ++++++++-----
+ build/source/texk/dvipsk/dvips.c       |   61 +++++++++++++++++++++++++++------
+ build/source/texk/dvipsk/dvips.h       |   14 ++-----
+ build/source/texk/dvipsk/emspecial.c   |   15 ++++++--
+ build/source/texk/dvipsk/finclude.c    |   11 +++++
+ build/source/texk/dvipsk/finclude.lpro |    1 
+ build/source/texk/dvipsk/flib.c        |    2 -
+ build/source/texk/dvipsk/header.c      |    4 +-
+ build/source/texk/dvipsk/hps.c         |    4 +-
+ build/source/texk/dvipsk/hps.lpro      |    5 +-
+ build/source/texk/dvipsk/loadfont.c    |   11 +++++
+ build/source/texk/dvipsk/makefont.c    |    6 +--
+ build/source/texk/dvipsk/output.c      |   11 +++++
+ build/source/texk/dvipsk/papersiz.c    |    2 -
+ build/source/texk/dvipsk/paths.h       |    2 -
+ build/source/texk/dvipsk/psfonts.map   |    1 
+ build/source/texk/dvipsk/resident.c    |   24 +++++++++++-
+ build/source/texk/dvipsk/special.lpro  |    5 +-
+ build/source/texk/dvipsk/squeeze.c     |    5 --
+ build/source/texk/dvipsk/tex.lpro      |    2 +
+ build/source/texk/dvipsk/texc.script   |    2 -
+ build/source/texk/dvipsk/texps.lpro    |    2 -
+ 32 files changed, 220 insertions(+), 112 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/dvipsk/ChangeLog
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/ChangeLog	2007-05-07 01:17:36.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/ChangeLog	2007-05-07 01:38:37.000000000 +0200
+@@ -1,3 +1,39 @@
++2007-05-06  Karl Berry  <karl@tug.org>
++
++	* finclude.c, dvips.c: keep track of last-unused psname (Akira).
++	* dvips.c (DEFRES): move down.
++	* dvips.c (--help): just mention Tom R.
++
++2007-05-05  Karl Berry  <karl@tug.org>
++
++	* dvips.h (DOWNLOADEDPSSIZE): new constant.
++	* dvips.c (downloadedpsname): new global array.
++	* finclude.c: set it up as we download.
++	* download.c: use it to avoid downloading fonts as both header
++	and font.  (From Akira.)
++
++2007-05-04  Karl Berry  <karl@tug.org>
++
++	* dvips.h (BANNER): change to 5.96dev to distinguish from the release.
++
++	* header.c (add_name, add_header): cast result of
++	add_header_general to int and return it.  From Akira.
++
++2007-03-23  Karl Berry  <karl@tug.org>
++
++	* dvips.texi: document it.
++	* dvips.c, loadfont.c, resident.c: also report map files
++	and config files, if the envvar DVIPSDEBUG is set.  From Akira.
++
++2007-03-20  Karl Berry  <karl@tug.org>
++
++	* download.c, output.c, emspecial.c: report full pathnames,
++	to help debugging and for consistency with TeX.  From Akira.
++
++2007-03-19  Karl Berry  <karl@tug.org>
++
++	* config.ps (screen): add this, 8.25x11, for powerdot.  (From Akira.)
++
+ 2006-12-09  Karl Berry  <karl@tug.org>
+ 
+ 	* dvips.texi (Config file paper sizes): best match now.  (From Akira.)
+Index: texlive-bin-2007/build/source/texk/dvipsk/Makefile.in
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/Makefile.in	2007-05-07 01:38:11.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/Makefile.in	2007-05-07 01:38:37.000000000 +0200
+@@ -1,5 +1,5 @@
+ # Makefile for dvipsk -- kb@mail.tug.org. Public domain.
+-version = 5.96
++version = 5.96.1
+ 
+ # Add -DDEFRES=dpi to DEFS to change the default resolution from 600.
+ # Add -DSECURE if you will install dvips with special privileges.
+Index: texlive-bin-2007/build/source/texk/dvipsk/afm2tfm.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/afm2tfm.c	2007-05-07 01:17:54.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/afm2tfm.c	2007-05-07 01:38:37.000000000 +0200
+@@ -1489,15 +1489,15 @@
+ void version P1C(FILE *, f)
+ {
+   extern KPSEDLL char *kpathsea_version_string;
+-  fputs ("afm2tfm(k) (dvips(k) 5.96) 8.1\n", f);
++  fputs ("afm2tfm(k) (dvips(k) 5.96.1) 8.1\n", f);
+   fprintf (f, "%s\n", kpathsea_version_string);
+-  fputs ("Copyright (C) 2005 Radical Eye Software.\n\
++  fputs ("Copyright (C) 2007 Radical Eye Software.\n\
+ There is NO warranty.  You may redistribute this software\n\
+ under the terms of the GNU General Public License\n\
+ and the Dvips copyright.\n\
+ For more information about these matters, see the files\n\
+ named COPYING and afm2tfm.c.\n\
+-Primary author of afm2tfm: T. Rokicki; -k maintainer: K. Berry.\n", f);
++Original author of afm2tfm: T. Rokicki.\n", f);
+ }
+ 
+ #define USAGE "\
+Index: texlive-bin-2007/build/source/texk/dvipsk/afm2tfm.rc
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/afm2tfm.rc	2007-05-07 01:38:11.000000000 +0200
++++ /dev/null	1970-01-01 00:00:00.000000000 +0000
+@@ -1,34 +0,0 @@
+-/* afm2tfm.rc: afm2tfm resources			-*- C++ -*-
+-
+-   Copyright (C) 1996-2003 Fabrice Popineau <fabrice.popineau@supelec.fr>
+-
+-   This file is free software; you can redistribute it and/or modify
+-   it under the terms of the GNU General Public License as published
+-   by the Free Software Foundation; either version 2, or (at your
+-   option) any later version.
+-
+-   This file is distributed in the hope that it will be useful, but
+-   WITHOUT ANY WARRANTY; without even the implied warranty of
+-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-   General Public License for more details.
+-
+-   You should have received a copy of the GNU General Public License
+-   along with this file; if not, write to the Free Software
+-   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+-   USA. */
+-
+-#include <texlive-version.h>
+-
+-#define VER_FILEVERSION TEXLIVE_MAJOR_VERSION,TEXLIVE_MINOR_VERSION,TEXLIVE_BETA_NUMBER,TEXLIVE_ALPHA_NUMBER
+-#define VER_FILEVERSION_STR TEXLIVE_PRODUCTVERSION_STR " afm2tfm(k) (dvips(k) 5.94b) 8.1"
+-
+-#define VER_INTERNALNAME_STR "afm2tfm"
+-#define VER_ORIGINALFILENAME_STR "afm2tfm.exe"
+-
+-#define VER_LEGALCOPYRIGHT_STR "Copyright (C) 1990-2004 Radical Eye Software"
+-
+-#define VER_FILEDESCRIPTION_STR "Adobe Font Metric to TeX Font Metric file converter"
+-
+-#include <texlive.version>
+-
+-/* afm2tfm.rc ends here */
+Index: texlive-bin-2007/build/source/texk/dvipsk/bbox.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/bbox.c	2007-05-07 01:38:11.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/bbox.c	2007-05-07 01:38:37.000000000 +0200
+@@ -6,7 +6,7 @@
+  *   If you request an EPSF file and specify -a, you may end up
+  *   processing a single page four times!
+  */
+-#include "dvips.h"
++#include "dvips.h" /* The copyright notice in that file is included too! */
+ #include <math.h>
+ #include "protos.h"
+ 
+Index: texlive-bin-2007/build/source/texk/dvipsk/config.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/config.h	2007-05-07 01:38:11.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/config.h	2007-05-07 01:38:37.000000000 +0200
+@@ -1,5 +1,5 @@
+ /* config.h: master configuration file, included first by all compilable
+-   source files (not headers).  */
++   source files (not headers).  This file is public domain.  */
+ 
+ #ifndef CONFIG_H
+ #define CONFIG_H
+Index: texlive-bin-2007/build/source/texk/dvipsk/crop.lpro
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/crop.lpro	2007-05-07 01:38:11.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/crop.lpro	2007-05-07 01:38:37.000000000 +0200
+@@ -1,5 +1,5 @@
+ %!
+-%   This file is for crop marks.
++%   This file is for crop marks.  This file is public domain.
+ %
+ %   First, we translate and draw the marks.  You can change the way the
+ %   marks are drawn, but the quarter inch border around the page is fixed.
+Index: texlive-bin-2007/build/source/texk/dvipsk/debug.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/debug.h	2007-05-07 01:38:11.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/debug.h	2007-05-07 01:38:37.000000000 +0200
+@@ -1,5 +1,5 @@
+ /* 
+- * Here's some stuff for debugging dvips.
++ * Here's some stuff for debugging dvips.  See dvips.h for copyright.
+  */
+ 
+ #ifdef DEBUG
+Index: texlive-bin-2007/build/source/texk/dvipsk/download.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/download.c	2007-05-07 01:17:43.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/download.c	2007-05-07 01:38:37.000000000 +0200
+@@ -433,6 +433,9 @@
+  *   Download a PostScript font, using partial font downloading if
+  *   necessary.
+  */
++extern char *downloadedpsnames[];
++extern int unused_top_of_psnames;
++
+ void downpsfont P2C(charusetype *, p, charusetype *, all)
+ {
+ #ifdef DOWNLOAD_USING_PDFTEX
+@@ -444,6 +447,8 @@
+     register chardesctype *c ;
+     struct resfont *rf ;
+     int cc;
++    extern char *realnameoffile ;
++    int j;
+ 
+     curfnt = p->fd ;
+     rf = curfnt->resfont ;
+@@ -457,6 +462,10 @@
+        return ;
+     if (rf->sent == 2) /* sent as header, from a PS file */
+        return ;
++    for (j=0; downloadedpsnames[j] && j < unused_top_of_psnames; j++) {
++       if (strcmp (downloadedpsnames[j], rf->PSname) == 0)
++          return;
++    }
+     if (all->fd == 0)
+        error("! internal error in downpsfont") ;
+     if (!partialdownload) {
+@@ -514,14 +523,6 @@
+         }
+     }
+     if(GridCount!=0 || extraGlyphs) {
+-        if (!quiet) {
+-           if (strlen(rf->Fontfile) + prettycolumn > STDOUTSIZE) {
+-              fprintf(stderr, "\n") ;
+-              prettycolumn = 0 ;
+-           }
+-           (void)fprintf(stderr, "<%s>", rf->Fontfile);
+-	   prettycolumn += strlen(rf->Fontfile) + 2 ;
+-	}
+         newline() ;
+         if (! disablecomments)
+            (void)fprintf(bitfile, "%%%%BeginFont: %s\n",  rf->PSname);
+@@ -531,6 +532,14 @@
+         if(FontPart(bitfile, rf->Fontfile, rf->Vectfile) < 0)
+ #endif
+             exit(1);
++        if (!quiet) {
++           if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) {
++              fprintf(stderr, "\n") ;
++              prettycolumn = 0 ;
++           }
++           (void)fprintf(stderr, "<%s>", realnameoffile);
++	   prettycolumn += strlen(realnameoffile) + 2 ;
++	}
+         if (! disablecomments)
+            (void)fprintf(bitfile, "%%%%EndFont \n");
+    }
+Index: texlive-bin-2007/build/source/texk/dvipsk/dpicheck.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/dpicheck.c	2007-05-07 01:38:11.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/dpicheck.c	2007-05-07 01:38:37.000000000 +0200
+@@ -1,12 +1,10 @@
+ /*
+- *   This software is Copyright 1988 by Radical Eye Software.
+- */
+-/*
+  *   dpicheck of dvips.c.  Checks the dots per inch to make sure
+  *   it exists.  The fonts which exist are DPI at the appropriate
+  *   magnifications.
+  */
+-#include "dvips.h"
++#include "dvips.h" /* The copyright notice in that file is included too! */
++
+ extern int actualdpi ;
+ static integer existsizes[30] = { 0 , 99999999 } ;
+ static int checkdpi ;
+Index: texlive-bin-2007/build/source/texk/dvipsk/dvips.1
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/dvips.1	2007-05-07 01:18:03.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/dvips.1	2007-05-07 01:38:37.000000000 +0200
+@@ -360,16 +360,21 @@
+ .B -r
+ Stack pages in reverse order.  Normally, page 1 will be printed first.
+ .TP
+-.B -R
+-Run in secure mode. This means that ``backtick'' commands from a
+-.I \especial{}
+-or
+-.I \epsffile{}
+-macro in the (La)TeX source like
+-.I \especial{psfile="`zcat foo.ps.Z"}
+-or
+-.I \epsffile[72 72 540 720]{"`zcat screendump.ps.gz"}
+-are not executed.
++.B -R[0|1|2]
++Run securely.
++.BR -R2
++disables both shell command execution in
++.I \especial'{}
++(via backticks
++.BR `
++) and config files (via the
++.I E
++option), and opening of any absolute filenames.
++.BR -R1
++, the default, forbids shell escapes but allows absolute filenames.
++.BR -R0
++allows both.  The config file option is
++.I z
+ .TP
+ .B -s
+ Causes the entire global output to be enclosed in a save/restore pair.
+Index: texlive-bin-2007/build/source/texk/dvipsk/dvips.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/dvips.c	2007-05-07 01:18:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/dvips.c	2007-05-07 01:38:37.000000000 +0200
+@@ -1,10 +1,6 @@
+ /*
+  *   This is the main routine.
+  */
+-#ifndef DEFRES
+-#define DEFRES (600)
+-#endif
+-
+ #include "dvips.h" /* The copyright notice there is included too! */
+ #ifdef KPATHSEA
+ #include <kpathsea/c-pathch.h>
+@@ -44,12 +40,22 @@
+ #include descrip
+ #endif
+ #endif
++
++#ifndef DEFRES
++#define DEFRES (600)
++#endif
++
+ /*
+  *   First we define some globals.
+  */
+ #ifdef VMS
+     static char ofnme[252],infnme[252],pap[40],thh[20];
+ #endif
++
++/* PS fonts fully downloaded as headers */ 
++char *downloadedpsnames[DOWNLOADEDPSSIZE];  
++
++int unused_top_of_psnames ;   /* unused top number of downloadedpsnames[#] */
+ fontdesctype *fonthead ;      /* list of all fonts mentioned so far */
+ fontdesctype *curfnt ;        /* the currently selected font */
+ sectiontype *sections ;       /* sections to process document in */
+@@ -159,6 +165,7 @@
+ int quiet ;                   /* should we only print errors to stderr? */
+ int filter ;                  /* act as filter default output to stdout,
+                                                default input to stdin? */
++int dvips_debug_flag ;        /* output config and map files to stderr if 1 */
+ int prettycolumn ;            /* the column we are at when running pretty */
+ int gargc ;                   /* global argument count */
+ char **gargv ;                /* global argument vector */
+@@ -306,6 +313,16 @@
+    fputs (kpse_bug_address, f);
+ #endif
+ }
++
++void
++freememforpsnames(void)
++{
++   int i;
++
++   for (i = 0; i < unused_top_of_psnames && downloadedpsnames[i]; i++)
++      free (downloadedpsnames[i]);
++}
++
+ /*
+  *   This error routine prints an error message; if the first
+  *   character is !, it aborts the job.
+@@ -328,6 +345,7 @@
+    }
+    
+    if (*s=='!') {
++      freememforpsnames() ;
+       if (bitfile != NULL) {
+          cleanprinter() ;
+       }
+@@ -440,6 +458,8 @@
+    i = 10;
+    for (s="abcdef"; *s!=0; s++)
+       xdig[(int)*s] = i++;
++   for(i=0 ; i < DOWNLOADEDPSSIZE; i++)
++      downloadedpsnames[i] = NULL;
+    morestrings() ;
+    maxpages = 100000 ;
+    numcopies = 1 ;
+@@ -552,7 +572,7 @@
+ #ifdef MVSXA
+    int firstext = -1 ;
+ #endif
+-   register sectiontype *sects ;
++   sectiontype *sects ;
+ 
+ #ifdef KPATHSEA
+    kpse_set_program_name (argv[0], "dvips");
+@@ -607,15 +627,15 @@
+         exit (0);
+       } else if (strcmp (argv[1], "--version") == 0) {
+         extern KPSEDLL char *kpathsea_version_string;
+-        puts ("dvips(k) 5.96");
++        puts ("dvips(k) 5.96.1");
+         puts (kpathsea_version_string);
+-        puts ("Copyright (C) 2005 Radical Eye Software.\n\
++        puts ("Copyright (C) 2007 Radical Eye Software.\n\
+ There is NO warranty.  You may redistribute this software\n\
+ under the terms of the GNU General Public License\n\
+ and the Dvips copyright.\n\
+ For more information about these matters, see the files\n\
+ named COPYING and dvips.h.\n\
+-Primary author of Dvips: T. Rokicki; -k maintainer: T. Kacvinsky/ S. Rahtz.");
++Primary author of Dvips: T. Rokicki.");
+         exit (0);
+       }
+       if (argc == 2 && strncmp(argv[1], "-?", 2) == 0) {
+@@ -630,6 +650,20 @@
+    }
+ #endif
+ #endif
++   dvips_debug_flag = 0 ;
++   { /* for compilers incompatible with c99 */
++      char *s = (char *)getenv ("DVIPSDEBUG") ;
++      if (s) {
++         dvips_debug_flag = 1 ;
++         free (s) ;
++      } else {
++         s = (char *) getenv ("KPATHSEA_DEBUG") ;
++         if (s) {
++           dvips_debug_flag = 1 ;
++           free (s) ;
++         }
++      }
++   }
+    initialize() ;
+    checkenv(0) ;
+    getdefaults(CONFIGFILE) ;
+@@ -1116,8 +1150,14 @@
+    revpslists() ;
+    getpsinfo((char *)NULL) ;
+    revpslists() ;
+-   if (!quiet)
+-      (void)fprintf(stderr, "%s %s\n", banner, banner2) ;
++   if (dvips_debug_flag) {
++      if (!quiet)
++         (void)fprintf(stderr, "\n%s %s\n", banner, banner2) ;
++      prettycolumn = 0 ;
++   } else {
++      if (!quiet)
++         (void)fprintf(stderr, "%s %s\n", banner, banner2) ;
++   }
+    if (*iname) {
+       dvifile = fopen(iname, READBIN) ;
+ /*
+@@ -1367,6 +1407,7 @@
+ 	 }
+       }
+    }
++   freememforpsnames() ;
+    if (! sepfiles) {
+ #ifdef HPS
+       if (HPS_FLAG)
+Index: texlive-bin-2007/build/source/texk/dvipsk/dvips.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/dvips.h	2007-05-07 01:18:25.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/dvips.h	2007-05-07 01:38:37.000000000 +0200
+@@ -1,19 +1,14 @@
+ /*
+  *   This is dvips, a freely redistributable PostScript driver
+- *   for dvi files.  It is (C) Copyright 1986-2004 by Tomas Rokicki.
+- *   You may modify and use this program to your heart's content,
+- *   so long as you send modifications to Tomas Rokicki.  It can
+- *   be included in any distribution, commercial or otherwise, so
+- *   long as the banner string defined below is not modified (except
+- *   for the version number) and this banner is printed on program
+- *   invocation, or can be printed on program invocation with the -? option.
++ *   for dvi files.  It is (C) Copyright 1986-2007 by Tomas Rokicki.
++ *   You may modify and use this program to your heart's content.
+  */
+ 
+ /*   This file is the header for dvips's global data structures. */
+ 
+ #define CREATIONDATE
+ #define BANNER \
+-"This is dvips(k) 5.96 Copyright 2005 Radical Eye Software"
++"This is dvips(k) 5.96.1 Copyright 2007 Radical Eye Software"
+ #define BANNER2 "(www.radicaleye.com)"
+ #ifdef KPATHSEA
+ #include "config.h"
+@@ -58,13 +53,14 @@
+  *   of a string that can be handled in specials, so it should not be
+  *   set too small.
+  */
+-#define STRINGSIZE (200000)  /* maximum total chars in strings in program */
++#define STRINGSIZE (200000) /* maximum total chars in strings in program */
+ #define RASTERCHUNK (8192)  /* size of chunk of raster */
+ #define MINCHUNK (240)      /* minimum size char to get own raster */
+ #define STACKSIZE (350)     /* maximum stack size for dvi files */
+ #define MAXFRAME (10)       /* maximum depth of virtual font recursion */
+ #define MAXFONTHD (100)     /* number of unique names of included fonts */
+ #define STDOUTSIZE (75)     /* width of a standard output line */
++#define DOWNLOADEDPSSIZE (1000)  /* max number of downloaded fonts to check */
+ /*
+  *   Other constants, which define printer-dependent stuff.
+  */
+Index: texlive-bin-2007/build/source/texk/dvipsk/emspecial.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/emspecial.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/emspecial.c	2007-05-07 01:38:37.000000000 +0200
+@@ -659,14 +659,23 @@
+ void imagehead P5C(char *, filename, int, wide, int, high, 
+ 		   float, emwidth, float, emheight)
+ {
++	char *fullname = NULL, *name ;
+ 	if (!quiet) {
+-	    if (strlen(filename) + prettycolumn > STDOUTSIZE) {
++#ifdef KPATHSEA
++	    fullname = (char *)kpse_find_file (filename, pictpath, 0) ;
++#endif
++	    if (!fullname)
++		name = filename ;
++	    else
++		name = fullname ;
++	    if (strlen(name) + prettycolumn > STDOUTSIZE) {
+ 		fprintf(stderr,"\n");
+ 		prettycolumn = 0;
+ 	    }
+-	    (void)fprintf(stderr,"<%s",filename);
++	    (void)fprintf(stderr,"<%s",name);
+ 	    (void)fflush(stderr);
+-	    prettycolumn += 2+strlen(filename);
++	    prettycolumn += 2+strlen(name);
++	    if (fullname) free (fullname);
+ 	}
+ 	hvpos();
+ 	nlcmdout("@beginspecial @setspecial") ;
+Index: texlive-bin-2007/build/source/texk/dvipsk/finclude.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/finclude.c	2007-05-07 01:17:29.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/finclude.c	2007-05-07 01:38:37.000000000 +0200
+@@ -57,6 +57,9 @@
+ extern integer debug_flag;
+ #endif  /* DEBUG */
+ 
++extern char *downloadedpsnames[];
++extern int unused_top_of_psnames;
++
+ /*
+  * Create a font descriptor for a font included in a psfile.  There will be
+  * no fontmaptype node for the resulting font descriptor until this font is
+@@ -252,6 +255,10 @@
+   char *p,*pe;
+   struct resfont *re;
+   int i;
++  int j = 0;
++
++  while (downloadedpsnames[j] != NULL && j < DOWNLOADEDPSSIZE)
++    j++;
+ 
+   /* Turn all newlines, CRs, and tabs into spaces. */
+   p = str;
+@@ -312,6 +319,10 @@
+ 	    infont = 0 ;
+           }
+           re->sent = 2 ;
++          if (unused_top_of_psnames < DOWNLOADEDPSSIZE) {
++             downloadedpsnames[unused_top_of_psnames] = xstrdup (re->PSname);
++             unused_top_of_psnames++;
++          }
+         } else {
+           char eb[1000];
+           sprintf(eb,"Font %s used in file %s is not in the mapping file.",
+Index: texlive-bin-2007/build/source/texk/dvipsk/finclude.lpro
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/finclude.lpro	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/finclude.lpro	2007-05-07 01:38:37.000000000 +0200
+@@ -1,4 +1,5 @@
+ %!
++% finclude.lpro - public domain.
+ % Define tfm-name to be a dictionary of included fonts indexed by size:
+ % /tfm-name  scaled-size1 /font-select1 ... scsize_k /fselect_k  k  fstore  -
+ /fstore
+Index: texlive-bin-2007/build/source/texk/dvipsk/flib.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/flib.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/flib.c	2007-05-07 01:38:37.000000000 +0200
+@@ -4,7 +4,7 @@
+  *   Tomas Rokicki or Radical Eye Software; use at your own risk.
+  */
+ #ifdef FONTLIB
+-#include "dvips.h"
++#include "dvips.h" /* The copyright notice in that file is included too! */
+ #include "paths.h"
+ #include "protos.h"
+ extern int debug_flag ;
+Index: texlive-bin-2007/build/source/texk/dvipsk/header.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/header.c	2007-05-07 01:18:19.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/header.c	2007-05-07 01:38:37.000000000 +0200
+@@ -35,7 +35,7 @@
+ int
+ add_name P2C(char *, s, struct header_list **, what)
+ {
+-  add_name_general (s, what, NULL, NULL);
++  return (int) add_name_general (s, what, NULL, NULL);
+ }
+ 
+ /*
+@@ -122,7 +122,7 @@
+ int
+ add_header P1C(char *, s)
+ {
+-  add_header_general (s, NULL, NULL);
++  return (int) add_header_general (s, NULL, NULL);
+ }
+ 
+ int
+Index: texlive-bin-2007/build/source/texk/dvipsk/hps.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/hps.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/hps.c	2007-05-07 01:38:37.000000000 +0200
+@@ -1,8 +1,8 @@
+ /* This is the main file for hacking dvips to do HyperPostScript
+  * Written by Mark D. Doyle 11/94. It is (C) Copyright 1994 by Mark D. Doyle
+  * and the University of California. You may modify and use this program to
+- * your heart's content, so long as you send modifications to Mark Doyle and
+- * abide by the rest of the dvips copyrights. 
++ * your heart's content.  Mark Doyle requests that you send him
++ * any modifications.
+  */
+ #include "dvips.h"
+ #ifdef HPS
+Index: texlive-bin-2007/build/source/texk/dvipsk/hps.lpro
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/hps.lpro	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/hps.lpro	2007-05-07 01:38:37.000000000 +0200
+@@ -5,8 +5,9 @@
+ % Written by Tanmoy Bhattacharya and Mark D. Doyle 11/94. 
+ % It is (C) Copyright 1994 by Tanmoy Bhattacharya, Mark D. Doyle
+ % and the University of California. You may modify and use this program to
+-% your heart's content, so long as you send modifications to Tanmoy
+-% Bhattacharya and/or Mark Doyle.
++% your heart's content. Tanmoy Bhattacharya and Mark Doyle request that
++% you send either or both them any modifications.
++% 
+ % Version number info
+ %   1 0 Probably first release
+ %   1 1 Added external handler to let ghostview work
+Index: texlive-bin-2007/build/source/texk/dvipsk/loadfont.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/loadfont.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/loadfont.c	2007-05-07 01:38:37.000000000 +0200
+@@ -333,6 +333,9 @@
+    register chardesctype *cd = 0 ;
+    int maxcc = 0 ;
+    int munged = 0 ;
++   extern int prettycolumn ;
++   extern int quiet ;
++   extern char *realnameoffile ;
+ /*
+  *   We clear out some pointers:
+  */
+@@ -358,6 +361,14 @@
+       tfmload(curfnt) ;
+       return ;
+    }
++   if (!quiet) {
++      if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) {
++         fprintf(stderr, "\n") ;
++         prettycolumn = 0 ;
++      }
++      (void)fprintf(stderr, "<%s>", realnameoffile);
++      prettycolumn += strlen(realnameoffile) + 2 ;
++   }
+ #ifdef DEBUG
+    if (dd(D_FONTS))
+       (void)fprintf(stderr,"Loading pk font %s at %.1fpt\n",
+Index: texlive-bin-2007/build/source/texk/dvipsk/makefont.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/makefont.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/makefont.c	2007-05-07 01:38:37.000000000 +0200
+@@ -1,7 +1,5 @@
+-/*
+- *   This software is Copyright 1988 by Radical Eye Software.
+- */
+-#include "dvips.h"
++/* makefont.c */
++#include "dvips.h" /* The copyright notice in that file is included too! */
+ #include <math.h>
+ #include "protos.h"
+ extern int quiet ;
+Index: texlive-bin-2007/build/source/texk/dvipsk/output.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/output.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/output.c	2007-05-07 01:38:37.000000000 +0200
+@@ -113,6 +113,7 @@
+ void
+ copyfile_general P2C(char *, s, struct header_list *, cur_header)
+ {
++   extern char *realnameoffile ;
+    FILE *f = NULL ;
+    int c, prevc = '\n' ;
+    long len ;
+@@ -205,7 +206,11 @@
+       error(errbuf) ;
+    else {
+       if (! quiet) {
++#if defined(VMCMS) || defined (MVSXA)
+          if (strlen(s) + prettycolumn > STDOUTSIZE) {
++#else
++         if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) {
++#endif
+             fprintf(stderr, "\n") ;
+             prettycolumn = 0 ;
+          }
+@@ -215,11 +220,15 @@
+ #ifdef MVSXA
+          (void)fprintf(stderr, "<%s>", trunc_s) ;
+ #else
+-         (void)fprintf(stderr, "<%s>", s) ;
++         (void)fprintf(stderr, "<%s>", realnameoffile) ;
+ #endif
+ #endif
+          (void)fflush(stderr) ;
++#if defined(VMCMS) || defined (MVSXA)
+          prettycolumn += 2 + strlen(s) ;
++#else
++         prettycolumn += 2 + strlen(realnameoffile) ;
++#endif
+       }
+       if (linepos != 0)
+          (void)putc('\n', bitfile) ;
+Index: texlive-bin-2007/build/source/texk/dvipsk/papersiz.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/papersiz.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/papersiz.c	2007-05-07 01:38:37.000000000 +0200
+@@ -11,7 +11,7 @@
+  *      0 <= num < den <= 20000
+  *      0 <= whole
+  */
+-#include "dvips.h"
++#include "dvips.h" /* The copyright notice in that file is included too! */
+ #include "protos.h"
+ static long scale P4C(long, whole, long, num, long, den, long, sf)
+ {
+Index: texlive-bin-2007/build/source/texk/dvipsk/paths.h
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/paths.h	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/paths.h	2007-05-07 01:38:37.000000000 +0200
+@@ -1,4 +1,4 @@
+-/*
++/*   paths.h - public domain.
+  *   OUTPATH is where to send the output.  If you want a .ps file to
+  *   be created by default, set this to "".  If you want to automatically
+  *   invoke a pipe (as in lpr), make the first character an exclamation
+Index: texlive-bin-2007/build/source/texk/dvipsk/psfonts.map
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/psfonts.map	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/psfonts.map	2007-05-07 01:38:37.000000000 +0200
+@@ -1,4 +1,5 @@
+ % original psfonts.map -- match TFM filenames to PostScript FontNames.
++% This file is public domain.
+ % (If you change or delete `original' on the previous line, dvips won't
+ % install its psfonts.map over this file.)
+ % 
+Index: texlive-bin-2007/build/source/texk/dvipsk/resident.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/resident.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/resident.c	2007-05-07 01:38:37.000000000 +0200
+@@ -32,6 +32,8 @@
+  *   These are the external variables we use.
+  */
+ extern char *realnameoffile ;
++extern int prettycolumn ;
++extern int dvips_debug_flag ;
+ #ifdef DEBUG
+ extern integer debug_flag;
+ #endif  /* DEBUG */
+@@ -441,6 +443,14 @@
+ #else
+    if ((deffile=search(d,PSname,READ))!=NULL) {
+ #endif
++   if (dvips_debug_flag && !quiet) {
++      if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) {
++         fprintf(stderr, "\n") ;
++         prettycolumn = 0 ;
++      }
++      (void)fprintf(stderr, "{%s}", realnameoffile);
++      prettycolumn += strlen(realnameoffile) + 2 ;
++   }
+ #ifdef DEBUG
+      if (dd (D_CONFIG)) {
+        fprintf (stderr, "Reading dvips config file `%s':\n", realnameoffile);
+@@ -845,9 +855,9 @@
+ */
+ void getpsinfo P1C(char *, name)
+ {
+-    FILE *deffile ;
+-    register char *p ;
+-    char *specinfo, *downloadinfo ;
++   FILE *deffile ;
++   register char *p ;
++   char *specinfo, *downloadinfo ;
+    char downbuf[500] ;
+    char specbuf[500] ;
+    int slen ;
+@@ -855,6 +865,14 @@
+    if (name == 0)
+       name = psmapfile ;
+    if ((deffile=search(mappath, name, READ))!=NULL) {
++      if (dvips_debug_flag && !quiet) {
++         if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) {
++            fprintf(stderr, "\n") ;
++            prettycolumn = 0 ;
++         }
++         (void)fprintf(stderr, "{%s}", realnameoffile);
++         prettycolumn += strlen(realnameoffile) + 2 ;
++      }
+       while (fgets(was_inline, INLINE_SIZE, deffile)!=NULL) {
+          p = was_inline ;
+          if (*p > ' ' && *p != '*' && *p != '#' && *p != ';' && *p != '%') {
+Index: texlive-bin-2007/build/source/texk/dvipsk/special.lpro
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/special.lpro	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/special.lpro	2007-05-07 01:38:37.000000000 +0200
+@@ -1,6 +1,5 @@
+-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-%%     header for the \special command
+-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
++% special.lpro - public domain.
++%     header for the \special command
+ %   The structure of the PostScript produced by dvips for \special is:
+ %         @beginspecial
+ %           - any number of @hsize, @hoffset, @hscale, etc., commands
+Index: texlive-bin-2007/build/source/texk/dvipsk/squeeze.c
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/squeeze.c	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/squeeze.c	2007-05-07 01:38:37.000000000 +0200
+@@ -1,7 +1,4 @@
+ /*
+- *   This software is Copyright 1988 by Radical Eye Software.
+- */
+-/*
+  *   This routine squeezes a PostScript file down to its
+  *   minimum.  We parse and then output it.
+  */
+@@ -14,7 +11,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include "dvips.h"
++#include "dvips.h" /* The copyright notice in that file is included too! */
+ #endif
+ #ifdef fopen
+ #undef fopen
+Index: texlive-bin-2007/build/source/texk/dvipsk/tex.lpro
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/tex.lpro	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/tex.lpro	2007-05-07 01:38:37.000000000 +0200
+@@ -1,3 +1,5 @@
++% tex.lpro - public domain.
++% 
+ % The following defines procedures assumed and used by program "dvips"
+ % and must be downloaded or sent as a header file for all TeX jobs.
+ % Originated by Neal Holtz, Carleton University, Ottawa, Canada
+Index: texlive-bin-2007/build/source/texk/dvipsk/texc.script
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/texc.script	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/texc.script	2007-05-07 01:38:37.000000000 +0200
+@@ -1,5 +1,5 @@
+ #! /bin/sh
+-# A shell script to convert tex.lpro to texc.lpro
++# A shell script to convert tex.lpro to texc.lpro.  Public domain.
+ #
+ # To use it, say
+ #       texc.script tex.lpro texc.lpro
+Index: texlive-bin-2007/build/source/texk/dvipsk/texps.lpro
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/dvipsk/texps.lpro	2007-05-07 01:38:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/dvipsk/texps.lpro	2007-05-07 01:38:37.000000000 +0200
+@@ -1,5 +1,5 @@
+ % Thanks for some changes to:
+-%+ This is TEXPS.LPRO as modified by Rob Hutchings 1992Apr02
++%+ This is TEXPS.LPRO as modified by Rob Hutchings 1992Apr02.  Public domain.
+ %+ My comments are marked as %+ 
+ % PostScript prolog for using resident fonts.
+ %+ Provision is made to change the encoding scheme in special instructions. 
--- texlive-bin-2007.dfsg.2.orig/debian/patches/12c_fix_pdfcrop_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/12c_fix_pdfcrop_invocation
@@ -0,0 +1,19 @@
+12c_fix_pdfcrop_invocation.dpatch  <preining@logic.at>
+Fix invocation of pdfcrop to get rid of magic
+---
+ build/source/texk/tetex/pdfcrop |    4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/tetex/pdfcrop
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/tetex/pdfcrop	2006-01-03 00:53:39.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/tetex/pdfcrop	2007-01-26 03:58:07.000000000 +0100
+@@ -1,7 +1,5 @@
+-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
+-  if 0;
++#!/usr/bin/perl -w
+ use strict;
+-$^W=1; # turn warning on
+ #
+ # pdfcrop.pl
+ #
--- texlive-bin-2007.dfsg.2.orig/debian/patches/10_mktexlsr_fixes
+++ texlive-bin-2007.dfsg.2/debian/patches/10_mktexlsr_fixes
@@ -0,0 +1,94 @@
+10_mktexlsr_fixes by  <frank@debian.org> etc etc
+
+Fixes wrong paths in various scripts to make lintian shut up.
+Fix creation of ls-R in root's homedir
+Fix skipping of all trees with empty $HOME (env -)
+Also add a note to the man page of mktexlsr about the above fix
+
+ build/source/texk/kpathsea/mktexlsr |   28 ++++++++++++++++------------
+ texmf/doc/man/man1/mktexlsr.1       |    9 +++++++++
+ 2 files changed, 25 insertions(+), 12 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/kpathsea/mktexlsr
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/kpathsea/mktexlsr	2006-12-25 19:44:43.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/source/texk/kpathsea/mktexlsr	2008-04-20 19:59:48.000000000 +0200
+@@ -82,10 +82,21 @@
+ '
+   set x `kpsewhich --show-path=ls-R | tr : '
+ ' | sort | uniq`; shift
++  if test "`id -u`" -eq 0; then
++    NOROOTHOME=true
++  fi
+   IFS=$OIFS
+ }
+ 
+ for TEXMFLS_R in "$@"; do
++  if [ "z$HOME" != 'z' ]; then
++    case "$TEXMFLS_R" in
++    $HOME/*) if test -n "$NOROOTHOME"; then
++  		tty -s && echo "$progname: Skipping $TEXMFLS_R" >&2
++		continue
++	   fi ;;
++    esac
++  fi
+   # Prepend cwd if the directory was relative.
+   case "$TEXMFLS_R" in
+   "") continue ;;  # Strictly speaking, it is an error if this case is taken.
+@@ -112,9 +123,9 @@
+   db_dir=`echo "$db_file" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
+ 
+   test -d "$db_dir" || continue
+-  test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
+ 
+   if test ! -f "$db_file"; then
++    test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
+     cp /dev/null "$db_file"
+     # Use same permissions as parent directory, minus x,s, or t bits.
+     chmod `kpsestat -xst "$db_dir"` "$db_file"
+@@ -128,11 +139,8 @@
+   # Skip if we cannot write the file:
+   kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission. Skipping..." >&2; continue; }
+ 
+-  db_dir_tmp="$db_dir/lsR$$.tmp"
+-  (umask 077 && mkdir "$db_dir_tmp" ) \
+-    || { echo "$progname: could not create directory '$db_dir_tmp'. Skipping..." >&2; continue; }
+-  db_file_tmp="$db_dir_tmp/lsR$$.tmp"
+-  rm -f "$db_file_tmp"
++  db_file_tmp=`mktemp -t ls-R.XXXXXXXXXX` \
++    || { echo "$progname: could not create temporary file for '$db_file'. Skipping..." >&2; continue; }
+ 
+   $verbose && echo "$progname: Updating $db_file... " >&2
+   echo "$ls_R_magic" >"$db_file_tmp"
+@@ -152,12 +160,8 @@
+    | sed -e '/\.svn.*:$/,/^$/d' \
+    >>"$db_file_tmp"
+ 
+-  # To be really safe, a loop.
+-  until PERMS=`kpsestat = "$db_file"`; do sleep 1; done
+-  chmod $PERMS "$db_file_tmp"
+-  rm -f "$db_file"
+-  mv "$db_file_tmp" "$db_file"
+-  rm -rf "$db_dir_tmp"
++  cat "$db_file_tmp" > "$db_file"
++  rm -f "$db_file_tmp"
+ done
+ $verbose && echo "$progname: Done." >&2
+ exit 0
+Index: texlive-bin-2007.dfsg.1/texmf/doc/man/man1/mktexlsr.1
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/texmf/doc/man/man1/mktexlsr.1	2007-01-14 19:01:06.000000000 +0100
++++ texlive-bin-2007.dfsg.1/texmf/doc/man/man1/mktexlsr.1	2008-04-20 19:58:53.000000000 +0200
+@@ -44,3 +44,12 @@
+ .B --version
+ .rb
+ Print version information and exit.
++.\"=====================================================================
++.SH NOTES
++When called by root with no arguments, \fBmktexlsr\fP in Debian ignores
++TEXMF trees under \fI$HOME\fP. This is to avoid creating undesirable files
++such as \fI/root/texmf/ls-R\fP when doing usual maintainance (it is generally
++a bad idea to work with TeX as root, therefore having a file such as
++\fI/root/texmf/ls-R\fP in the first place is rather pointless). If you really
++want to update the ls-R databases for such TEXMF trees, simply list them
++explicitely on the command-line.
--- texlive-bin-2007.dfsg.2.orig/debian/patches/unused51_fmtutil_tempdir_in_texinputs
+++ texlive-bin-2007.dfsg.2/debian/patches/unused51_fmtutil_tempdir_in_texinputs
@@ -0,0 +1,33 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50_fmtutil_tempdir_in_texinputs.dpatch by Frank Küster
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: add the tempdir to the texinputs path
+
+@DPATCH@
+ build/TeX/texk/tetex/fmtutil |    5 +++++
+ 1 files changed, 5 insertions(+)
+
+Index: texlive-bin-2007.dfsg.1/build/TeX/texk/tetex/fmtutil
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/TeX/texk/tetex/fmtutil	2007-01-22 13:08:31.000000000 +0100
++++ texlive-bin-2007.dfsg.1/build/TeX/texk/tetex/fmtutil	2007-01-22 13:09:29.000000000 +0100
+@@ -34,6 +34,7 @@
+ ###############################################################################
+ ###############################################################################
+ # program history:
++#   Do Mar 02 10:42:31 CET 2006 add tmpdir to TEXFORMATS
+ #   Fr Apr  8 19:15:05 CEST 2005 cleanup now has an argument for the return code
+ #   So MĂ¤r 27 18:52:06 CEST 2005 honor $TMPDIR, $TEMP and $TMP, not just $TMP
+ #   Sa Jan 15 18:13:46 CET 2005 avoid multiple variable assignments in one statement
+@@ -562,6 +563,10 @@
+   # due to KPSE_DOT, we don't search the current directory, so include
+   # it explicitly for formats that \write and later on \read
+   TEXINPUTS="$tmpdir:$TEXINPUTS"; export TEXINPUTS
++  # for formats that load other formats (e.g. jadetex loads latex.fmt),
++  # add the current directory to TEXFORMATS, too.  We could do the same for
++  # MFBASES and MPMEMS, but it doesn't seem to be necessary currently.
++  TEXFORMATS="$tmpdir:$TEXFORMATS"; export TEXFORMATS
+ 
+   setupTmpDir
+   cd "$tmpdir" || cleanup 1
--- texlive-bin-2007.dfsg.2.orig/debian/patches/11_fix_pkfix_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/11_fix_pkfix_invocation
@@ -0,0 +1,23 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 11_fix_pkfix_invocation.dpatch  <preining@logic.at>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix invocation of pkfix to get rid of magic
+
+@DPATCH@
+ build/source/texk/texlive/pkfix |    5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/texlive/pkfix
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/texlive/pkfix	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/texlive/pkfix	2007-01-26 03:56:42.000000000 +0100
+@@ -1,7 +1,4 @@
+-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
+-  if 0;
+-use strict;
+-$^W=1; # turn warning on
++#!/usr/bin/perl -w
+ #
+ # pkfix.pl
+ #
--- texlive-bin-2007.dfsg.2.orig/debian/patches/icu-powerpc-buildfix-patch
+++ texlive-bin-2007.dfsg.2/debian/patches/icu-powerpc-buildfix-patch
@@ -0,0 +1,139 @@
+Fix building on hurd-i386. From Samuel Thibault <samuel.thibault@ens-lyon.org>
+> texlive-bin currently FTBFS on hurd-i386 because of the copy of icu that
+> it embeds. Here is the patch that already got applied to the icu package
+> and is being forwarded icu upstream.
+
+> There was also a problem with xxx.l which uses the NOFILE macro which is
+> linux-only.
+---
+ build/source/libs/icu-xetex/aclocal.m4    |    1 
+ build/source/libs/icu-xetex/config/mh-gnu |   81 ++++++++++++++++++++++++++++++
+ build/source/libs/icu-xetex/configure     |    1 
+ build/source/texk/detex/detex.l           |    4 +
+ 4 files changed, 87 insertions(+)
+
+Index: texlive-bin-2007/build/source/libs/icu-xetex/aclocal.m4
+===================================================================
+--- texlive-bin-2007.orig/build/source/libs/icu-xetex/aclocal.m4	2007-08-16 11:12:26.000000000 +0200
++++ texlive-bin-2007/build/source/libs/icu-xetex/aclocal.m4	2007-08-16 11:16:36.000000000 +0200
+@@ -31,6 +31,7 @@
+ 	  	icu_cv_host_frag=mh-linux-va
+ 	fi ;;
+ *-*-linux*) icu_cv_host_frag=mh-linux ;;
++*-*-gnu*) icu_cv_host_frag=mh-gnu ;;
+ *-*-cygwin)
+ 	if test "$GCC" = yes; then
+ 	  	icu_cv_host_frag=mh-cygwin
+Index: texlive-bin-2007/build/source/libs/icu-xetex/config/mh-gnu
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ texlive-bin-2007/build/source/libs/icu-xetex/config/mh-gnu	2007-08-16 11:16:36.000000000 +0200
+@@ -0,0 +1,81 @@
++## -*-makefile-*-
++## GNU-specific setup
++## Copyright (c) 1999-2004, International Business Machines Corporation and
++## others. All Rights Reserved.
++
++## Commands to generate dependency files
++GEN_DEPS.c=  $(CC) -E -MM $(DEFS) $(CPPFLAGS)
++GEN_DEPS.cc= $(CXX) -E -MM $(DEFS) $(CPPFLAGS)
++
++## Flags for position independent code
++SHAREDLIBCFLAGS = -fPIC
++SHAREDLIBCXXFLAGS = -fPIC
++SHAREDLIBCPPFLAGS = -DPIC
++
++## Additional flags when building libraries and with threads
++LIBCPPFLAGS = -D_REENTRANT
++THREADSCPPFLAGS = -D_REENTRANT
++
++## Compiler switch to embed a runtime search path
++LD_RPATH=	
++LD_RPATH_PRE = -Wl,-rpath,
++
++## These are the library specific LDFLAGS
++LDFLAGSICUDT=-nodefaultlibs -nostdlib
++
++## Compiler switch to embed a library name
++# The initial tab in the next line is to prevent icu-config from reading it.
++	LD_SONAME = -Wl,-soname -Wl,$(notdir $(MIDDLE_SO_TARGET))
++#SH# # We can't depend on MIDDLE_SO_TARGET being set.
++#SH# LD_SONAME=
++
++## Shared object suffix
++SO = so
++## Non-shared intermediate object suffix
++STATIC_O = ao
++
++## Compilation rules
++%.$(STATIC_O): $(srcdir)/%.c
++	$(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $<
++%.o: $(srcdir)/%.c
++	$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $<
++
++%.$(STATIC_O): $(srcdir)/%.cpp
++	$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $<
++%.o: $(srcdir)/%.cpp
++	$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<
++
++
++## Dependency rules
++%.d: $(srcdir)/%.c
++	@echo "generating dependency information for $<"
++	@$(SHELL) -ec '$(GEN_DEPS.c) $< \
++		| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
++		[ -s $@ ] || rm -f $@'
++
++%.d: $(srcdir)/%.cpp
++	@echo "generating dependency information for $<"
++	@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
++		| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
++		[ -s $@ ] || rm -f $@'
++
++## Versioned libraries rules
++
++%.$(SO).$(SO_TARGET_VERSION_MAJOR): %.$(SO).$(SO_TARGET_VERSION)
++	$(RM) $@ && ln -s ${<F} $@
++%.$(SO): %.$(SO).$(SO_TARGET_VERSION_MAJOR)
++	$(RM) $@ && ln -s ${*F}.$(SO).$(SO_TARGET_VERSION) $@
++
++##  Bind internal references
++
++# LDflags that pkgdata will use
++BIR_LDFLAGS= -Wl,-Bsymbolic
++
++# CPPflags for genccode/gencmn
++BIR_CPPFLAGS= -DU_HAVE_BIND_INTERNAL_REFERENCES
++
++# Dependencies [i.e. map files] for the final library
++BIR_DEPS=
++
++## End Linux-specific setup
++
+Index: texlive-bin-2007/build/source/libs/icu-xetex/configure
+===================================================================
+--- texlive-bin-2007.orig/build/source/libs/icu-xetex/configure	2007-08-16 11:12:53.000000000 +0200
++++ texlive-bin-2007/build/source/libs/icu-xetex/configure	2007-08-16 11:16:36.000000000 +0200
+@@ -3270,6 +3270,7 @@
+ 	  	icu_cv_host_frag=mh-linux-va
+ 	fi ;;
+ *-*-linux*) icu_cv_host_frag=mh-linux ;;
++*-*-gnu*) icu_cv_host_frag=mh-gnu ;;
+ *-*-cygwin)
+ 	if test "$GCC" = yes; then
+ 	  	icu_cv_host_frag=mh-cygwin
+Index: texlive-bin-2007/build/source/texk/detex/detex.l
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/detex/detex.l	2007-08-16 11:16:12.000000000 +0200
++++ texlive-bin-2007/build/source/texk/detex/detex.l	2007-08-16 11:16:43.000000000 +0200
+@@ -59,6 +59,10 @@
+ 
+ #endif
+ 
++#ifndef NOFILE
++#define NOFILE 256
++#endif
++
+ extern void SetEnvIgnore(char *sbEnvList);
+ extern int BeginEnv(char *sbEnv);
+ extern int EndEnv(char *sbEnv);
--- texlive-bin-2007.dfsg.2.orig/debian/patches/63_texmf.cnf_for_comparison_temp
+++ texlive-bin-2007.dfsg.2/debian/patches/63_texmf.cnf_for_comparison_temp
@@ -0,0 +1,168 @@
+---
+ texmf/web2c/texmf.cnf |  121 ++++++++++++++++----------------------------------
+ 1 file changed, 40 insertions(+), 81 deletions(-)
+
+Index: texlive-bin-2007/texmf/web2c/texmf.cnf
+===================================================================
+--- texlive-bin-2007.orig/texmf/web2c/texmf.cnf	2007-04-22 19:05:16.000000000 +0200
++++ texlive-bin-2007/texmf/web2c/texmf.cnf	2007-04-22 19:05:29.000000000 +0200
+@@ -248,10 +248,27 @@
+ % Earlier entries override later ones, so put this last.
+ TEXINPUTS               = .;$TEXMF/tex/{$progname,generic,}//
+ 
++% extra format definitions for TeX Live
++
++TEXINPUTS.elambda       = .;$TEXMF/tex/{lambda,latex,generic,}//
++TEXINPUTS.eomega        = .;$TEXMF/tex/{plain,generic,}//
++TEXINPUTS.pdfxmex       = .;$TEXMF/tex/{mex,plain,generic,}//
++TEXINPUTS.frpdflatex    = .;$TEXMF/tex/{french,latex,generic,}//
++TEXINPUTS.frpdftex      = .;$TEXMF/tex/{french,plain,generic,}//
++TEXINPUTS.xmltex        = .;$TEXMF/tex/{xmltex,latex,generic,}//
++TEXINPUTS.pdfxmltex     = .;$TEXMF/tex/{xmltex,latex,generic,}//
++
++TTF2TFMINPUTS =                 .;$TEXMF/ttf2pk//
++
+ % Metafont, MetaPost inputs.
+ MFINPUTS = .;$TEXMF/metafont//;{$TEXMF/fonts,$VARTEXFONTS}/source//
+ MPINPUTS = .;$TEXMF/metapost//
+ 
++% allow for compressed files, and various extenions
++TEXDOCSSUFFIX   = ;.pdf;.ps;.dvi;.html;.txt;.tex
++TEXDOCSCOMPRESS = ;.gz;.bz2;.zip;.Z
++TEXDOCEXT       = {$TEXDOCSSUFFIX}{$TEXDOCSCOMPRESS}
++
+ % Dump files (fmt/base/mem) for vir{tex,mf,mp} to read (see web2c/INSTALL),
+ % and string pools (.pool) for ini{tex,mf,mp}.  It is silly that we have six
+ % paths and directories here (they all resolve to a single place by default),
+@@ -298,6 +315,9 @@
+ % BibTeX bibliographies and style files.
+ BIBINPUTS = .;$TEXMF/bibtex/bib//
+ BSTINPUTS = .;$TEXMF/bibtex/{bst,csf}//
++% For bibtex8. Do we really need to repeat the BIBINPUTS setting?
++BIBINPUTS.bibtex8 =             .;$TEXMF/bibtex/{bib,}//
++BSTINPUTS.bibtex8 =             .;$TEXMF/bibtex/{bst,csf,}//
+ 
+ % MFT style files.
+ MFTINPUTS = .;$TEXMF/mft//
+@@ -392,9 +412,23 @@
+ % search formats, you'll want to add their variables here as well.
+ T4HTINPUTS   = .;$TEXMF/tex4ht//
+ 
++%% t4ht utility, sharing files with TeX4ht
++TEX4HTFONTSET=alias,iso8859,unicode
++TEX4HTINPUTS = .;$TEXMF/tex4ht/base//;$TEXMF/tex4ht/ht-fonts/{$TEX4HTFONTSET}//
++
++% Part for scripts that are distributed/installed in the texmf tree.
++
+ % Architecture independent executables.
+ TEXMFSCRIPTS = $TEXMF/scripts/{$engine,$progname,}//
+ 
++% Perl, Python, Ruby, Java scripts
++JAVAINPUTS   = .;$TEXMF/scripts/{$progname,$engine,}/java//
++LUAINPUTS    = .;$TEXMF/scripts/{$progname,$engine,}/lua//
++PERLINPUTS   = .;$TEXMF/scripts/{$progname,$engine,}/perl//
++PYTHONINPUTS = .;$TEXMF/scripts/{$progname,$engine,}/python//
++RUBYINPUTS   = .;$TEXMF/scripts/{$progname,$engine,}/ruby//
++
++
+ %% The mktex* scripts rely on KPSE_DOT. Do not set it in the environment.
+ % KPSE_DOT = .
+ 
+@@ -446,6 +480,12 @@
+ openout_any = p
+ openin_any = a
+ 
++% Disable search on multiple suffixes filenames. In many case, when `foo.bar'
++% is looked for, you do not want to look for `foo.bar.tex' before. This flag
++% disables searching for standard suffixes if the file name has already an
++% extension of 3 characters. Default value is true (old behaviour).
++allow_multiple_suffixes =                       f
++
+ % Allow TeX, MF, and MP to parse the first line of an input file for
+ % the %&format construct.
+ parse_first_line = t
+@@ -582,84 +622,3 @@
+ half_error_line = 50
+ max_print_line = 79
+ 
+-
+-%  Part 4: extra format definitions for TeX Live
+-
+-TEXINPUTS.elambda       = .;$TEXMF/tex/{lambda,latex,generic,}//
+-TEXINPUTS.eomega        = .;$TEXMF/tex/{plain,generic,}//
+-TEXINPUTS.pdfxmex       = .;$TEXMF/tex/{mex,plain,generic,}//
+-TEXINPUTS.frpdflatex    = .;$TEXMF/tex/{french,latex,generic,}//
+-TEXINPUTS.frpdftex      = .;$TEXMF/tex/{french,plain,generic,}//
+-TEXINPUTS.xmltex        = .;$TEXMF/tex/{xmltex,latex,generic,}//
+-TEXINPUTS.pdfxmltex     = .;$TEXMF/tex/{xmltex,latex,generic,}//
+-
+-TTF2TFMINPUTS =                 .;$TEXMF/ttf2pk//
+-
+-% For bibtex8. Do we really need to repeat the BIBINPUTS setting?
+-BIBINPUTS.bibtex8 =             .;$TEXMF/bibtex/{bib,}//
+-BSTINPUTS.bibtex8 =             .;$TEXMF/bibtex/{bst,csf,}//
+-
+-% allow for compressed files, and various extenions
+-TEXDOCSSUFFIX   = ;.pdf;.ps;.dvi;.html;.txt;.tex
+-TEXDOCSCOMPRESS = ;.gz;.bz2;.zip;.Z
+-TEXDOCEXT       = {$TEXDOCSSUFFIX}{$TEXDOCSCOMPRESS}
+-
+-%% t4ht utility, sharing files with TeX4ht
+-TEX4HTFONTSET=alias,iso8859,unicode
+-TEX4HTINPUTS = .;$TEXMF/tex4ht/base//;$TEXMF/tex4ht/ht-fonts/{$TEX4HTFONTSET}//
+-
+-% Part for scripts that are distributed/installed in the texmf tree.
+-
+-% Perl, Python, Ruby, Java scripts (Win32 only)
+-% This is used by the irun.exe program which simulates a symlink
+-% but also makes use of kpathsea to retrieve the target
+-JAVAINPUTS   = .;$TEXMF/scripts/{$progname,$engine,}/java//
+-LUAINPUTS    = .;$TEXMF/scripts/{$progname,$engine,}/lua//
+-PERLINPUTS   = .;$TEXMF/scripts/{$progname,$engine,}/perl//
+-PYTHONINPUTS = .;$TEXMF/scripts/{$progname,$engine,}/python//
+-RUBYINPUTS   = .;$TEXMF/scripts/{$progname,$engine,}/ruby//
+-
+-% Suggestions for editor settings under Windows. Uncomment your
+-% preferred option. The corresponding MFEDIT can also be set for use with
+-% Metafont.
+-%
+-% Winedt:
+-%  TEXEDIT=C:\WinEdt\WinEdt.exe "[Open('%s');SelLine(%d,7)]
+-% Textpad:
+-%  TEXEDIT =                    c:\Progra~1\TextPad\System\Ddeopn32 TextPad %s(%d)
+-% UltraEdit (newer Win32 versions):
+-%  TEXEDIT =                    uedit32 %s/%d/1
+-% WinTeXShell32:
+-%  TEXEDIT =                    texshell.exe /l=%d %s
+-% vi, vim, gvim. here we show Windows gvim.exe:
+-%  TEXEDIT =                    gvim.exe %s +%d
+-% PFE:
+-%  TEXEDIT=pfe32/g%d  %s
+-% MED:
+-%  TEXEDIT=med.exe "%s" %d
+-% TSE:
+-%  TEXEDIT=e32.exe "%s" -n%d
+-% Epsilon (Lugaru)            http://www.lugaru.com/
+-%  TEXEDIT="c:\Program Files\eps90\bin\e32.exe" +%d %s
+-% WinShell
+-% TEXEDIT=C:\Progra~1\WinShell\WinShell.exe -c %s -l %d
+-% notepad
+-% TEXEDIT = notepad %s
+-
+-% For unix
+-%
+-% vi, vim, NEdit, (X)Emacs, pico, jed
+-% TEXEDIT =                     vi     +%d %s
+-% TEXEDIT =                     vim    +%d %s
+-% TEXEDIT =                     nedit  +%d %s
+-% TEXEDIT =                     xemacs +%d %s
+-% TEXEDIT =                     emacs +%d %s
+-
+-%(x)fte:
+-% TEXEDIT =                     xfte   -l%d %s
+-
+-% Disable search on multiple suffixes filenames. In many case, when `foo.bar'
+-% is looked for, you do not want to look for `foo.bar.tex' before. This flag
+-% disables searching for standard suffixes if the file name has already an
+-% extension of 3 characters. Default value is true (old behaviour).
+-allow_multiple_suffixes =                       f
--- texlive-bin-2007.dfsg.2.orig/debian/patches/disable-character-shifting
+++ texlive-bin-2007.dfsg.2/debian/patches/disable-character-shifting
@@ -0,0 +1,23 @@
+Disable character shifting for pdftex (option G) as it breaks in 
+combination with lmodern fonts.
+---
+ texmf/dvips/tetex/config.pdf |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+Index: texlive-bin-2007/texmf/dvips/tetex/config.pdf
+===================================================================
+--- texlive-bin-2007.orig/texmf/dvips/tetex/config.pdf	2007-09-04 16:35:11.000000000 +0200
++++ texlive-bin-2007/texmf/dvips/tetex/config.pdf	2007-09-04 16:36:04.000000000 +0200
+@@ -43,8 +43,10 @@
+ % It remaps certain ``control character'' positions to an another range
+ % where these characters are repeated. This character shifting works wround
+ % bugs in some tools such as older versions of the Acrobat Reader.
+-
+-G
++%
++% Since this is doing more harm than good, it is disabled by default.
++%
++% G
+ 
+ % Switching algorithm for drawing rules. texc.pro is loaded by default,
+ % but the h tex.pro is need so that it comes before the patch. See
--- texlive-bin-2007.dfsg.2.orig/debian/patches/12_fix_epstopdf_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/12_fix_epstopdf_invocation
@@ -0,0 +1,21 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 12_fix_epstopdf_invocation.dpatch  <preining@logic.at>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Fix invocation of epstopdf to get rid of magic
+
+@DPATCH@
+ build/source/texk/tetex/epstopdf |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/tetex/epstopdf
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/tetex/epstopdf	2006-12-17 20:58:20.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/tetex/epstopdf	2007-01-26 03:57:16.000000000 +0100
+@@ -1,5 +1,4 @@
+-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
+-  if 0;
++#!/usr/bin/perl
+ use strict;
+ 
+ # Change by Thomas Esser, Sept. 1998: The above lines allows us to find
--- texlive-bin-2007.dfsg.2.orig/debian/patches/55_texconfig_stuff
+++ texlive-bin-2007.dfsg.2/debian/patches/55_texconfig_stuff
@@ -0,0 +1,563 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 55_texconfig_stuff.dpatch by Frank Küster
+##
+## DP: expand texconfig man page, some random texconfig fixes
+
+@DPATCH@
+ build/source/texk/tetex/texconfig     |   19 +-
+ build/source/texk/tetex/texconfig.man |  224 ++++++++++++++++++++++++++++++++--
+ texmf/doc/man/man1/texconfig.1        |  224 ++++++++++++++++++++++++++++++++--
+ 3 files changed, 445 insertions(+), 22 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/texconfig
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/texconfig	2007-06-14 10:24:46.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/texconfig	2007-06-18 10:23:02.000000000 +0200
+@@ -919,8 +919,8 @@
+ 
+     faq)
+       setupTexmfmain
+-      if test -f $MT_TEXMFMAIN/doc/tetex/teTeX-FAQ; then
+-        <$MT_TEXMFMAIN/doc/tetex/teTeX-FAQ eval ${PAGER-more}
++      if test -f $MT_TEXMFDIST/doc/tetex/teTeX-FAQ.gz; then
++        <$MT_TEXMFDIST/doc/tetex/teTeX-FAQ.gz eval zcat | ${PAGER-sensible-pager}
+       else
+         echo "$progname: faq not found (usually in \$TEXMFMAIN/doc/tetex/teTeX-FAQ)" >&2
+         rc=1
+@@ -955,16 +955,19 @@
+               ;;
+             *)
+               tcBatchFontVardir=$3
+-              tfc=`kpsewhich texmf.cnf`
++	      tfcs=$(grep -l '^[[:space:]]*VARTEXFONTS[[:space:]]*=' /etc/texmf/texmf.d/*.cnf)
++	      # last match wins
++	      for file in $tfcs; do tfc=$file; done
+               if test -n "$tfc"; then
+                 if test -w "$tfc"; then
+                   configReplace "$tfc" '^VARTEXFONTS' "VARTEXFONTS  = $tcBatchFontVardir"
++		  update-texmf
+                 else
+                   echo "$progname: setting up vardir failed. Reason: no permission to write file \`$tfc'" >&2
+                   rc=1
+                 fi
+               else
+-                echo "$progname: setting up vardir failed. Reason: failed to find file texmf.cnf" >&2
++                echo "$progname: setting up vardir failed. Reason: failed to find file \`$tfc'" >&2
+                 rc=1
+               fi
+               ;;
+@@ -1076,6 +1079,11 @@
+                 rc=1
+                 return
+                 ;;
++	      /var/lib/texmf/*)
++		echo "$progname: The hyphenation file for $tcBatchHyphenFormat is a generated file in Debian"
++		echo "You cannot use this texconfig command, use \`update-language(1)' instead."
++		echo "Please read its manual page or /usr/share/tex-common/TeX-on-Debian*"
++		;;
+             esac
+ 
+             getRelDir "$tcBatchHyphenFile"
+@@ -1103,7 +1111,7 @@
+                 fi
+                 ;;
+             esac
+-            ${VISUAL-${EDITOR-vi}} "$tcBatchHFEdit"
++            ${VISUAL:-${EDITOR:-sensible-editor}} "$tcBatchHFEdit"
+             if cmp "$tcBatchHFEdit" "$tcBatchHFOrig" >/dev/null 2>&1; then
+               echo "$progname: configuration unchanged." >&2
+             else
+@@ -1145,7 +1153,6 @@
+       case $2 in
+         "")
+           if fmtutil --all \
+-             && texlinks --multiplatform \
+              && updmap; then
+             :
+           else
+Index: texlive-bin-2007/build/source/texk/tetex/texconfig.man
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/texconfig.man	2007-06-14 10:24:46.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/texconfig.man	2007-06-18 09:53:55.000000000 +0200
+@@ -6,22 +6,230 @@
+ .SH SYNOPSIS
+ .B texconfig
+ .LP
++.B texconfig
++[\fB commands\fR ...]
++.LP
+ .B texconfig-sys
+ .SH DESCRIPTION
+ .I texconfig
+-allows to configure and maintain
++allows one to configure and maintain
++.I teTeX
++in an easy and convenient manner, offering a series of dialog boxes to
++the user. After choosing settings or options, the appropriate files
++are changed automatically and the new settings are applied for the
++user.  If needed, copies of files in
++.I TEXMFDIST
++or
++.I TEXMFMAIN
++will be made in the user's
++.I TEXMFCONFIG
++tree.
++.PP
++.I texconfig
++uses either the
++.IR whiptail (1)
++or
++.IR dialog (1)
++program to communicate with the user, so must be run in a terminal.
++.PP
++For making system-wide changes, which will apply to all users of
+ .I teTeX
+-in an easy and convenient manner. It uses the
+-.I dialog
+-program to draw nice input boxes. After answering the dialoges, the
+-appropriate files are changed automatically and all necessary
+-steps are involved to apply the new settings.
++(for example, default paper size and so on), run
++.I texconfig-sys
++instead.  Changed or generated files will be placed in
++.I TEXMFSYSCONFIG.
++(You may need ot be root to do this.)
++.PP
++Note that on a Debian system, changes to formats, font setup,
++hyphenation for different languages, etc. should not be done with
++texconfig, because
++.B fmtutil.cnf(5), updmap.cfg(5), texmf.cnf
++and
++.B language.dat
++are generated files in Debian.  See
++.I TeX-on-Debian.pdf, TeX-on-Debian.txt.gz
++or
++.I TeX-on-Debian.hmlt/index.html
++in
++.I /usr/share/doc/tex-common/
++for alternatives.
++.PP
++.I texconfig
++also offers a non-interactive batch mode which can be accessed with
++the following commands
++.SH COMMANDS
++Commands that accept further options usually display available options
++if called without them.  For example,
++.B texconfig dvipdfm paper
++will inform about valid paper settings.
++.PP
++.B
++.IP conf
++Display the system configuration.  Note that some of the files listed
++as configuration files are generated files on a Debian system.
++.PP
++.TP
++.B dvipdfm paper [letter|legal|ledger|tabloid|a4|a3]
++Set up dvipdfm to use papersize PAPER by default.
++.TP
++.B dvips add PRINTERNAME
++Create a new (empty) configuration file
++.I TEXMFCONFIG/dvips/config/config.PRINTERNAME.
++This file can later be filled with the
++.B mode, offset
++or
++.B printcmd
++options
++.TP
++.B dvips del PRINTERNAME
++Remove
++.I config.PRINTERNAME
++.TP
++.B dvips mode
++List available MetaFont modes.
++.TP
++.B dvips [-P PRINTER] mode MODE
++Change the MetaFont mode to
++.I MODE
++for
++.I PRINTER
++or for all output files
++.I (config.ps),
++if no
++.B -P
++option is given.
++.TP
++.B dvips [-P PRINTER] offset x-OFFSET,y-OFFSET
++Set printer offset for
++.I PRINTER
++or for all output files
++.I (config.ps),
++if no
++.B -P
++option is given.  Offsets must be given with units, e.g.
++.I 0pt,10pt
++You can use testpage.tex from the LaTeX distribution to find these
++numbers.
++.TP
++.B dvips [-P PRINTER] printcmd CMD
++Set the printing command for
++.I PRINTER
++or for all output files
++.I (config.ps),
++if no
++.B -P
++option is given.  Commands might be
++.B lp
++or
++.B lpr.
++See the description of the
++.I o
++option in
++.B info dvips
++or the
++.I -O
++option in
++.B dvips(1).
++.TP
++.B faq
++Display the list of Frequently Asked Questions about
++.B teTeX
++(and their answers).
++.TP
++.B font vardir DIR, font ro, font ro
++These options should not be used on a Debian system unless you really
++know what you are doing.  For details, look at the output of
++.B texconfig fonts
++and read section 2.5, font caching, in the TeX-on-Debian documentation
++in
++.I /usr/share/doc/tex-common/.
++.TP
++.B formats
++This command allows to edit
++.B fmtutil.cnf(5)
++and (re)creates any new or changed formats afterwards.  It should not
++be used on Debian systems, unless you want to temporarily create and
++test a specific format, because
++.B fmtutil.cnf(5)
++is a generated file in Debian, and changes will be overwritten.  See
++.B update-fmtutil
++for details.
++.TP
++.B hyphen FORMAT
++This command allows to edit the hyphenation configuration file for
++formats that support this, and recreates the formats afterwards to
++enable the new languages.  Available formats are shown when no
++.I FORMAT
++is given.
++.IP
++Note that for formats that use LaTeX's
++.I language.dat,
++ e.g.
++.I (pdf)jadetex
++and
++.I latex
++itself, this change is not persistent, since this file is a generated
++file.  You should not use this command in these cases, read
++.B update-language(1)
++for alternatives.
++.TP
++.B init [format]
++Recreate
++.I format
++or all formats if none is given, and the font information.  This is
++the same as calling
++.B fmtutil --byfmt format
++or
++.B fmtutil --all,
++respectively, followed by
++.B updmap.
++.TP
++.B mode-list
++List available printer modes, together with the printers they were
++developed for, and their DPI resolution
++.TP
++.B mode MODE
++Set the default printer mode in
++.I /etc/texmf/web2c/mktex.cnf
++or the respective user file in
++.I $TEXMFCONFIG/web2c
++to
++.B MODE.
++.TP
++.B paper [a4|letter]
++Set the default papersize for
++.B dvips, dvipdfm, pdftex
++and
++.B xdvi.
++The set is restricted because not all programs understand all sizes.
++.TP
++.B pdftex paper [a4|letter]
++Set the default paper size for
++.B pdftex.
++.TP
++.B rehash
++Call
++.B mktexlsr.
++.TP
++.B xdvi paper PAPER
++Set the default paper size for
++.B xdvi.
++The (long) list is available with
++.B texconfig xdvi paper.
++
++.SH ENVIRONMENT
++To let you change files,
++.B texconfig
++will open the editor specified in the VISUAL or EDITOR variables, or
++.B sensible-editor
++if both are unset.
+ .SH "SEE ALSO"
++.IR whiptail (1),
+ .IR dialog (1),
+-.IR initex (1),
++.IR tex (1),
+ .IR mf (1),
+ .IR vi (1),
+ .IR EDITOR
+-environment-variable.
++environment variable.
+ .SH AUTHOR
+ Thomas Esser <te@dbs.uni-hannover.de>
+Index: texlive-bin-2007/texmf/doc/man/man1/texconfig.1
+===================================================================
+--- texlive-bin-2007.orig/texmf/doc/man/man1/texconfig.1	2007-06-14 10:24:46.000000000 +0200
++++ texlive-bin-2007/texmf/doc/man/man1/texconfig.1	2007-06-18 09:53:55.000000000 +0200
+@@ -6,22 +6,230 @@
+ .SH SYNOPSIS
+ .B texconfig
+ .LP
++.B texconfig
++[\fB commands\fR ...]
++.LP
+ .B texconfig-sys
+ .SH DESCRIPTION
+ .I texconfig
+-allows to configure and maintain
++allows one to configure and maintain
++.I teTeX
++in an easy and convenient manner, offering a series of dialog boxes to
++the user. After choosing settings or options, the appropriate files
++are changed automatically and the new settings are applied for the
++user.  If needed, copies of files in
++.I TEXMFDIST
++or
++.I TEXMFMAIN
++will be made in the user's
++.I TEXMFCONFIG
++tree.
++.PP
++.I texconfig
++uses either the
++.IR whiptail (1)
++or
++.IR dialog (1)
++program to communicate with the user, so must be run in a terminal.
++.PP
++For making system-wide changes, which will apply to all users of
+ .I teTeX
+-in an easy and convenient manner. It uses the
+-.I dialog
+-program to draw nice input boxes. After answering the dialoges, the
+-appropriate files are changed automatically and all necessary
+-steps are involved to apply the new settings.
++(for example, default paper size and so on), run
++.I texconfig-sys
++instead.  Changed or generated files will be placed in
++.I TEXMFSYSCONFIG.
++(You may need ot be root to do this.)
++.PP
++Note that on a Debian system, changes to formats, font setup,
++hyphenation for different languages, etc. should not be done with
++texconfig, because
++.B fmtutil.cnf(5), updmap.cfg(5), texmf.cnf
++and
++.B language.dat
++are generated files in Debian.  See
++.I TeX-on-Debian.pdf, TeX-on-Debian.txt.gz
++or
++.I TeX-on-Debian.hmlt/index.html
++in
++.I /usr/share/doc/tex-common/
++for alternatives.
++.PP
++.I texconfig
++also offers a non-interactive batch mode which can be accessed with
++the following commands
++.SH COMMANDS
++Commands that accept further options usually display available options
++if called without them.  For example,
++.B texconfig dvipdfm paper
++will inform about valid paper settings.
++.PP
++.B
++.IP conf
++Display the system configuration.  Note that some of the files listed
++as configuration files are generated files on a Debian system.
++.PP
++.TP
++.B dvipdfm paper [letter|legal|ledger|tabloid|a4|a3]
++Set up dvipdfm to use papersize PAPER by default.
++.TP
++.B dvips add PRINTERNAME
++Create a new (empty) configuration file
++.I TEXMFCONFIG/dvips/config/config.PRINTERNAME.
++This file can later be filled with the
++.B mode, offset
++or
++.B printcmd
++options
++.TP
++.B dvips del PRINTERNAME
++Remove
++.I config.PRINTERNAME
++.TP
++.B dvips mode
++List available MetaFont modes.
++.TP
++.B dvips [-P PRINTER] mode MODE
++Change the MetaFont mode to
++.I MODE
++for
++.I PRINTER
++or for all output files
++.I (config.ps),
++if no
++.B -P
++option is given.
++.TP
++.B dvips [-P PRINTER] offset x-OFFSET,y-OFFSET
++Set printer offset for
++.I PRINTER
++or for all output files
++.I (config.ps),
++if no
++.B -P
++option is given.  Offsets must be given with units, e.g.
++.I 0pt,10pt
++You can use testpage.tex from the LaTeX distribution to find these
++numbers.
++.TP
++.B dvips [-P PRINTER] printcmd CMD
++Set the printing command for
++.I PRINTER
++or for all output files
++.I (config.ps),
++if no
++.B -P
++option is given.  Commands might be
++.B lp
++or
++.B lpr.
++See the description of the
++.I o
++option in
++.B info dvips
++or the
++.I -O
++option in
++.B dvips(1).
++.TP
++.B faq
++Display the list of Frequently Asked Questions about
++.B teTeX
++(and their answers).
++.TP
++.B font vardir DIR, font ro, font ro
++These options should not be used on a Debian system unless you really
++know what you are doing.  For details, look at the output of
++.B texconfig fonts
++and read section 2.5, font caching, in the TeX-on-Debian documentation
++in
++.I /usr/share/doc/tex-common/.
++.TP
++.B formats
++This command allows to edit
++.B fmtutil.cnf(5)
++and (re)creates any new or changed formats afterwards.  It should not
++be used on Debian systems, unless you want to temporarily create and
++test a specific format, because
++.B fmtutil.cnf(5)
++is a generated file in Debian, and changes will be overwritten.  See
++.B update-fmtutil
++for details.
++.TP
++.B hyphen FORMAT
++This command allows to edit the hyphenation configuration file for
++formats that support this, and recreates the formats afterwards to
++enable the new languages.  Available formats are shown when no
++.I FORMAT
++is given.
++.IP
++Note that for formats that use LaTeX's
++.I language.dat,
++ e.g.
++.I (pdf)jadetex
++and
++.I latex
++itself, this change is not persistent, since this file is a generated
++file.  You should not use this command in these cases, read
++.B update-language(1)
++for alternatives.
++.TP
++.B init [format]
++Recreate
++.I format
++or all formats if none is given, and the font information.  This is
++the same as calling
++.B fmtutil --byfmt format
++or
++.B fmtutil --all,
++respectively, followed by
++.B updmap.
++.TP
++.B mode-list
++List available printer modes, together with the printers they were
++developed for, and their DPI resolution
++.TP
++.B mode MODE
++Set the default printer mode in
++.I /etc/texmf/web2c/mktex.cnf
++or the respective user file in
++.I $TEXMFCONFIG/web2c
++to
++.B MODE.
++.TP
++.B paper [a4|letter]
++Set the default papersize for
++.B dvips, dvipdfm, pdftex
++and
++.B xdvi.
++The set is restricted because not all programs understand all sizes.
++.TP
++.B pdftex paper [a4|letter]
++Set the default paper size for
++.B pdftex.
++.TP
++.B rehash
++Call
++.B mktexlsr.
++.TP
++.B xdvi paper PAPER
++Set the default paper size for
++.B xdvi.
++The (long) list is available with
++.B texconfig xdvi paper.
++
++.SH ENVIRONMENT
++To let you change files,
++.B texconfig
++will open the editor specified in the VISUAL or EDITOR variables, or
++.B sensible-editor
++if both are unset.
+ .SH "SEE ALSO"
++.IR whiptail (1),
+ .IR dialog (1),
+-.IR initex (1),
++.IR tex (1),
+ .IR mf (1),
+ .IR vi (1),
+ .IR EDITOR
+-environment-variable.
++environment variable.
+ .SH AUTHOR
+ Thomas Esser <te@dbs.uni-hannover.de>
--- texlive-bin-2007.dfsg.2.orig/debian/patches/xetex-sinhala-support
+++ texlive-bin-2007.dfsg.2/debian/patches/xetex-sinhala-support
@@ -0,0 +1,230 @@
+---
+ build/source/libs/icu-xetex/layout/IndicClassTables.cpp  |   19 +++++++
+ build/source/libs/icu-xetex/layout/IndicReordering.cpp   |   38 ++++++++++++---
+ build/source/libs/icu-xetex/layout/LEFontInstance.cpp    |    2 
+ build/source/libs/icu-xetex/layout/LayoutEngine.cpp      |    2 
+ build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp |    2 
+ 5 files changed, 55 insertions(+), 8 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/IndicClassTables.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/libs/icu-xetex/layout/IndicClassTables.cpp	2008-04-20 20:07:44.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/IndicClassTables.cpp	2008-04-20 20:08:36.000000000 +0200
+@@ -186,6 +186,18 @@
+     _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx  // 0D60 - 0D6F
+ };
+ 
++static const IndicClassTable::CharClass sinhCharClasses[] =
++{
++    _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, // 0D80 - 0D8F
++    _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _ct, _ct, // 0D90 - 0D9F
++    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0DA0 - 0DAF
++    _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _xx, _xx, // 0DB0 - 0DBF
++    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _vr, _xx, _xx, _xx, _xx, _dr, // 0DC0 - 0DCF
++    _dr, _dr, _da, _da, _db, _xx, _db, _xx, _dr, _dl, _s1, _dl, _s2, _s3, _s4, _dr, // 0DD0 - 0DDF
++    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0DE0 - 0DEF
++    _xx, _xx, _dr, _dr, _xx                                                         // 0DF0 - 0DF4
++};
++
+ //
+ // Split matra tables
+ //
+@@ -202,6 +214,8 @@
+ 
+ static const SplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}};
+ 
++static const SplitMatra sinhSplitTable[] = {{0x0DD9, 0x0DCA}, {0x0DD9, 0x0DCF}, {0x0DD9, 0x0DCF, 0x0DCA}, {0x0DD9, 0x0DDF}};
++
+ //
+ // Script Flags
+ //
+@@ -218,6 +232,7 @@
+ #define TELU_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3)
+ #define KNDA_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3)
+ #define MLYM_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT)
++#define SINH_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT)
+ 
+ //
+ // Indic Class Tables
+@@ -240,6 +255,8 @@
+ 
+ static const IndicClassTable mlymClassTable = {0x0D00, 0x0D6F, 3, MLYM_SCRIPT_FLAGS, mlymCharClasses, mlymSplitTable};
+ 
++static const IndicClassTable sinhClassTable = {0x0D80, 0x0DF4, 4, SINH_SCRIPT_FLAGS, sinhCharClasses, sinhSplitTable};
++
+ //
+ // IndicClassTable addresses
+ //
+@@ -277,7 +294,7 @@
+     NULL,            /* 'ital' (OLD-ITALIC) */
+     &oryaClassTable, /* 'orya' (ORIYA) */
+     NULL,            /* 'runr' (RUNIC) */
+-    NULL,            /* 'sinh' (SINHALA) */
++    &sinhClassTable, /* 'sinh' (SINHALA) */
+     NULL,            /* 'syrc' (SYRIAC) */
+     &tamlClassTable, /* 'taml' (TAMIL) */
+     &teluClassTable, /* 'telu' (TELUGU) */
+Index: texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/IndicReordering.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/libs/icu-xetex/layout/IndicReordering.cpp	2008-04-20 20:07:52.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/IndicReordering.cpp	2008-04-20 20:08:36.000000000 +0200
+@@ -35,6 +35,9 @@
+     LEUnicode fLengthMark;
+     le_int32  fLengthMarkIndex;
+ 
++    LEUnicode fAlLakuna;
++    le_int32  fAlLakunaIndex;
++
+     const LETag *fMatraTags;
+     
+     le_int32 fMPreOutIndex;
+@@ -56,6 +59,9 @@
+         if (IndicClassTable::isLengthMark(matraClass)) {
+             fLengthMark = matra;
+             fLengthMarkIndex = matraIndex;
++        } else if (IndicClassTable::isVirama(matraClass)) {
++            fAlLakuna = matra;
++            fAlLakunaIndex = matraIndex;
+         } else {
+             switch (matraClass & CF_POS_MASK) {
+             case CF_POS_BEFORE:
+@@ -89,8 +95,9 @@
+     ReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage, MPreFixups *mpreFixups)
+         : fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage),
+           fMpre(0), fMpreIndex(0), fMbelow(0), fMbelowIndex(0), fMabove(0), fMaboveIndex(0),
+-          fMpost(0), fMpostIndex(0), fLengthMark(0), fLengthMarkIndex(0), fMatraTags(NULL),
+-          fMPreOutIndex(-1), fMPreFixups(mpreFixups),
++          fMpost(0), fMpostIndex(0), fLengthMark(0), fLengthMarkIndex(0),
++          fAlLakuna(0), fAlLakunaIndex(0),
++          fMatraTags(NULL), fMPreOutIndex(-1), fMPreFixups(mpreFixups),
+           fVMabove(0), fVMpost(0), fVMIndex(0), fVMTags(NULL),
+           fSMabove(0), fSMbelow(0), fSMIndex(0), fSMTags(NULL)
+     {
+@@ -104,7 +111,7 @@
+ 
+     void reset()
+     {
+-        fMpre = fMbelow = fMabove = fMpost = fLengthMark = 0;
++        fMpre = fMbelow = fMabove = fMpost = fLengthMark = fAlLakuna = 0;
+         fMPreOutIndex = -1;
+         
+         fVMabove = fVMpost  = 0;
+@@ -205,6 +212,19 @@
+         }
+     }
+ 
++    int alLakunaExists()
++    {
++        return (fAlLakuna != 0);
++    }
++
++    // Handles Al-Lakuna in Sinhala split vowels.
++    void writeAlLakuna()
++    {
++        if (fAlLakuna != 0) {
++            writeChar(fAlLakuna, fAlLakunaIndex, fMatraTags);
++        }
++    }
++
+     void writeMpre()
+     {
+         if (fMpre != 0) {
+@@ -326,14 +346,15 @@
+     { 1,  1,  1,  5,  8,  3,  2,  1,  5,  9,  5,  1,  1,  1}, //  0 - ground state
+     {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //  1 - exit state
+     {-1,  6,  1, -1, -1, -1, -1, -1,  5,  9,  5,  5,  4, -1}, //  2 - consonant with nukta
+-    {-1,  6,  1, -1, -1, -1, -1,  2,  5,  9,  5,  5,  4, -1}, //  3 - consonant
++    {-1,  6,  1, -1, -1, -1, -1,  2,  5,  9,  5,  5,  4, 11}, //  3 - consonant
+     {-1, -1, -1, -1, -1,  3,  2, -1, -1, -1, -1, -1, -1,  7}, //  4 - consonant virama
+     {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //  5 - dependent vowels
+     {-1, -1,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //  6 - vowel mark
+     {-1, -1, -1, -1, -1,  3,  2, -1, -1, -1, -1, -1, -1, -1}, //  7 - ZWJ, ZWNJ
+     {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  4, -1}, //  8 - independent vowels that can take a virama
+     {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, 10,  5, -1, -1}, //  9 - first part of split vowel
+-    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1,  5, -1, -1}  // 10 - second part of split vowel
++    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1,  5, -1, -1}, // 10 - second part of split vowel
++    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  7, -1}  // 11 - <ct> <zwj>
+ 
+ };
+ 
+@@ -420,7 +441,10 @@
+         case CC_SPLIT_VOWEL_PIECE_3:
+         case CC_VOWEL_MODIFIER:
+         case CC_STRESS_MARK:
+-            output.writeMpre();
++            // A lone <U+0DDD> crashes ooffice without this workaround.
++            if (!output.alLakunaExists()) {
++                output.writeMpre();
++            }
+ 
+             output.writeChar(C_DOTTED_CIRCLE, prev, &tagArray[1]);
+ 
+@@ -442,6 +466,7 @@
+             }
+ 
+             output.writeLengthMark();
++            output.writeAlLakuna();
+ 
+             if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
+                 output.writeVMabove();
+@@ -632,6 +657,7 @@
+             }
+ 
+             output.writeLengthMark();
++            output.writeAlLakuna();
+ 
+             // write reph
+             if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
+Index: texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/LEFontInstance.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/libs/icu-xetex/layout/LEFontInstance.cpp	2008-04-20 20:08:00.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/LEFontInstance.cpp	2008-04-20 20:08:36.000000000 +0200
+@@ -75,7 +75,7 @@
+         return 0xFFFF;
+     }
+ 
+-    if (mappedChar == 0x200C || mappedChar == 0x200D) {
++    if (mappedChar == 0x200C) {
+         return 1;
+     }
+ 
+Index: texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/LayoutEngine.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/libs/icu-xetex/layout/LayoutEngine.cpp	2008-04-20 20:08:08.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/libs/icu-xetex/layout/LayoutEngine.cpp	2008-04-20 20:08:36.000000000 +0200
+@@ -483,6 +483,7 @@
+         case guruScriptCode:
+         case tamlScriptCode:
+         case teluScriptCode:
++        case sinhScriptCode:
+             result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
+             break;
+ 
+@@ -537,6 +538,7 @@
+             case guruScriptCode:
+             case tamlScriptCode:
+             case teluScriptCode:
++            case sinhScriptCode:
+             {
+                 result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
+                 break;
+Index: texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp	2008-04-20 20:08:16.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/web2c/xetexdir/XeTeXOTLayoutEngine.cpp	2008-04-20 20:08:36.000000000 +0200
+@@ -85,6 +85,7 @@
+         case guruScriptCode:
+         case tamlScriptCode:
+         case teluScriptCode:
++        case sinhScriptCode:
+ //            result = new XeTeXIndicLayoutEngine(fontInstance, scriptTag, languageTag, gsubTable, addFeatures, removeFeatures);
+             result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
+             break;
+@@ -125,6 +126,7 @@
+ 		case guruScriptCode:
+ 		case tamlScriptCode:
+ 		case teluScriptCode:
++		case sinhScriptCode:
+ 			result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
+ 			break;
+ 
--- texlive-bin-2007.dfsg.2.orig/debian/patches/22_xdvi
+++ texlive-bin-2007.dfsg.2/debian/patches/22_xdvi
@@ -0,0 +1,43 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 22_xdvi.dpatch
+##
+## DP: force input focus for the text input
+## DP: field that appears after hitting Ctrl-F (string search).
+## DP: thanks Florent, taken from tetex.
+## DP: fix segfault when hitting g with -nogrey, upstream fix from Stefan Ulrich
+
+@DPATCH@
+ build/source/texk/xdvik/dvi-draw.c          |    3 +++
+ build/source/texk/xdvik/gui/search-dialog.c |    5 +++++
+ 2 files changed, 8 insertions(+)
+
+Index: texlive-bin-2006.svn3816/build/source/texk/xdvik/gui/search-dialog.c
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/xdvik/gui/search-dialog.c	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/xdvik/gui/search-dialog.c	2007-01-26 04:00:04.000000000 +0100
+@@ -694,6 +694,11 @@
+ #ifdef MOTIF
+     XtAddCallback(searchbox_input, XmNactivateCallback, cb_search_get_term, settings);
+ #endif
++
++    /* Fix for #1499566: Force input focus for text input field */
++#ifndef MOTIF
++    XtSetKeyboardFocus(find_paned, searchbox_input);
++#endif
+     
+     /*
+      * form for left row of options checkbuttons
+Index: texlive-bin-2006.svn3816/build/source/texk/xdvik/dvi-draw.c
+===================================================================
+--- texlive-bin-2006.svn3816.orig/build/source/texk/xdvik/dvi-draw.c	2006-01-17 22:41:51.000000000 +0100
++++ texlive-bin-2006.svn3816/build/source/texk/xdvik/dvi-draw.c	2007-01-26 04:00:04.000000000 +0100
+@@ -1255,6 +1255,9 @@
+ 	do_color_change();
+     }
+ #endif
++    if (pixeltbl == NULL) {
++        do_color_change();
++    }
+ 
+     /* TODO: rounding errors causing color fringing (see HACK comment below):
+        
--- texlive-bin-2007.dfsg.2.orig/debian/patches/12a_fix_thumbpdf_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/12a_fix_thumbpdf_invocation
@@ -0,0 +1,19 @@
+12a_fix_thumbpdf_invocation.dpatch  <preining@logic.at>
+Fix invocation of thumbpdf to get rid of magic
+---
+ build/source/texk/tetex/thumbpdf |    5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+Index: texlive-bin-2007/build/source/texk/tetex/thumbpdf
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/tetex/thumbpdf	2005-07-06 13:03:00.000000000 +0200
++++ texlive-bin-2007/build/source/texk/tetex/thumbpdf	2007-05-19 16:30:21.000000000 +0200
+@@ -1,7 +1,4 @@
+-eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
+-  if 0;
+-use strict;
+-$^W=1; # turn warning on
++#!/usr/bin/perl -w
+ #
+ # thumbpdf.pl
+ #
--- texlive-bin-2007.dfsg.2.orig/debian/patches/mktexlsr-ignore-more-vcs
+++ texlive-bin-2007.dfsg.2/debian/patches/mktexlsr-ignore-more-vcs
@@ -0,0 +1,48 @@
+ignore more than only .svn
+patch taken from upstream, based on the original from Michael Schutte
+---
+ build/source/texk/kpathsea/mktexlsr |   21 +++++++++++----------
+ 1 file changed, 11 insertions(+), 10 deletions(-)
+
+Index: texlive-bin-2007.dfsg.1/build/source/texk/kpathsea/mktexlsr
+===================================================================
+--- texlive-bin-2007.dfsg.1.orig/build/source/texk/kpathsea/mktexlsr	2008-05-19 07:19:26.000000000 +0200
++++ texlive-bin-2007.dfsg.1/build/source/texk/kpathsea/mktexlsr	2008-05-19 07:23:44.000000000 +0200
+@@ -13,7 +13,7 @@
+ # <te@dbs.uni-hannover.de>, Okt., 1994.
+ # Public domain.
+ 
+-version='$Id: mktexlsr,v 1.46 2005/06/21 14:32:26 olaf Exp $'
++version='$Id$'
+ progname=`echo $0 | sed 's%.*/%%'`
+ usage="Usage: $progname [DIR]...
+ 
+@@ -146,18 +146,19 @@
+   echo "$ls_R_magic" >"$db_file_tmp"
+ 
+   # The main task. We put ./: in the output, so top-level files can be
+-  # found via ls-R. Probably irrelevant in practice.
+-  # The sed command inserts the leading ./ for directory names, and
+-  # removes ., .., and .svn entries from the list.  Also omit contents
+-  # of any .svn directories; sed apparently requires that we do that
+-  # operation in a separate invocation.
+-  # We do not try to support colons in directory names.
++  # found via ls-R. Probably irrelevant in practice.  The sed command
++  # inserts the leading ./ for directory names, and removes ., .., and
++  # version control entries from the list.  Also omit contents of any
++  # the version directories; sed apparently requires that we do that
++  # operation in a separate invocation.  We do not try to support colons
++  # in directory names.
+   # 
+   echo "./:" >>"$db_file_tmp"
++  vc_dirs='\.\(bzr\|git\|hg\|svn\)\|CVS\|RCS\|_darcs'
+   (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) \
+-   | sed -e '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^\.svn$/d;' \
+-        -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d' \
+-   | sed -e '/\.svn.*:$/,/^$/d' \
++   | sed -e '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^'$vc_dirs'$/d;' \
++         -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d' \
++   | sed -e /$vc_dirs'.*:$/,/^$/d' \
+    >>"$db_file_tmp"
+ 
+   cat "$db_file_tmp" > "$db_file"
--- texlive-bin-2007.dfsg.2.orig/debian/patches/12d_fix_ebong_invocation
+++ texlive-bin-2007.dfsg.2/debian/patches/12d_fix_ebong_invocation
@@ -0,0 +1,13 @@
+---
+ build/source/texk/texlive/ebong |    1 +
+ 1 file changed, 1 insertion(+)
+
+Index: texlive-bin-2007/build/source/texk/texlive/ebong
+===================================================================
+--- texlive-bin-2007.orig/build/source/texk/texlive/ebong	2007-05-15 14:44:43.000000000 +0200
++++ texlive-bin-2007/build/source/texk/texlive/ebong	2007-05-15 14:44:52.000000000 +0200
+@@ -1,3 +1,4 @@
++#!/usr/bin/python
+ # look in newbong
+ import sre
+ A='A'
--- texlive-bin-2007.dfsg.2.orig/debian/libkpathsea4.install
+++ texlive-bin-2007.dfsg.2/debian/libkpathsea4.install
@@ -0,0 +1,3 @@
+build/source/inst/lib/libkpathsea.so.4.0.0 usr/lib/
+build/source/inst/lib/libkpathsea.so.4 usr/lib/
+build/source/texk/kpathsea/ChangeLog usr/share/doc/libkpathsea4
--- texlive-bin-2007.dfsg.2.orig/debian/tpm2liclines
+++ texlive-bin-2007.dfsg.2/debian/tpm2liclines
@@ -0,0 +1,1318 @@
+12many: not-in-catalogue
+a0poster: lppl (verification data:1.22b:1.22b:2006-02-08:norbusan:)
+aastex: lppl (verification data:5.2:5.2:2006-02-08:norbusan:)
+abbr: pd (unverified)
+abc: lppl (unverified)
+abstract: lppl (verification data:1.1:1.1:2006-02-08:norbusan:)
+abstyles: not-in-catalogue
+accfonts: gpl (unverified)
+achemso: lppl (unverified)
+acmconf: lppl (unverified)
+acmtrans: unknown (unverified)
+acronym: lppl (verification data:1.26:1.17:2006-03-07:frank:header)
+active-conf: lppl (unverified)
+adobeuro: not-in-catalogue
+adrconv: lppl (verification data:1.2c:1.2b:2006-03-07:frank:header)
+adrlist: unknown (unverified)
+ae: lppl (verification data:1.4:1.4:2007-05-29:frank:README)
+aeguill: lppl (unverified)
+aguplus: lppl (unverified)
+ai: not-in-catalogue
+aiaa: lppl (unverified)
+akletter: lppl (verification data:1.5i:1.5i:2006-02-08:norbusan:)
+alatex: gpl (unverified)
+albertus: not-in-catalogue
+aleph: unknown (unverified)
+alg: lppl (verification data:2001-03-13:2001-03-13:2006-02-08:norbusan:)
+algorithm2e: lppl (verification data:3.9:3.9:2006-02-08:norbusan:)
+algorithmicx: lppl (verification data:::2006-10-12:norbusan:algorithmicx.pdf)
+algorithms: lgpl (verification data::2005-07-05:2006-02-08:norbusan:)
+allrunes: lppl (unverified)
+alnumsec: lppl (verification data:v0.02:v0.02:2006-02-08:norbusan:)
+altfont: gpl (unverified)
+ams: not-in-catalogue
+amscls: lppl (unverified)
+amsfonts: lppl (unverified)
+amsltx2: not-in-catalogue
+amsmath: lppl (unverified)
+amsrefs: lppl (unverified)
+amstex: lppl (unverified)
+answers: unknown (unverified)
+antiqua: not-in-catalogue
+antomega: lppl (unverified)
+antp: pd (unverified)
+antt: gfsl (unverified)
+anysize: pd (unverified)
+apa: lppl (unverified)
+apacite: lppl (unverified)
+apl: unknown (unverified)
+appendix: lppl (verification data:1.2:1.2a:2006-07-24:frank:README)
+ar: dfsg (unverified)
+arabi: lppl (unverified)
+arabtex: lppl (unverified)
+archaic: lppl (unverified)
+arcs: lppl (verification data:1:1:2006-10-12:norbusan:arcs.dtx)
+arev: lppl (unverified)
+armenian: not-in-catalogue
+arphic: other-free (unverified)
+arrayjob: lppl (unverified)
+arydshln: lppl (verification data:1.71:1.71:2006-10-12:norbusan:arydshln.dtx)
+asaetr: pd (unverified)
+ascelike: lppl (verification data:1999-06-25:1999-06-25:2006-02-08:norbusan:)
+ascii: lppl (verification data:2.0::2006/06/19:auth:graham:)
+assignment: lppl (verification data:::2006-10-12:norbusan:README)
+astro: unknown (unverified)
+atqolive: not-in-catalogue
+attachfile: lppl (verification data:v1.3:1.2a:2006-10-12:norbusan:README)
+augie: lppl (verification data::2000-10-19:2006-02-08:norbusan:)
+aurical: lppl (verification data:1.4:2004-04-16:2006-02-08:norbusan:)
+aurora: nocommercial (unverified)
+authorindex: lppl (unverified)
+auto-pst-pdf: lppl (unverified)
+autotab: unknown (unverified)
+avantgar: gpl (unverified)
+babel: lppl (verification data:3.8h:3.8h:2006-04-28:frank:legal.bbl)
+babelbib: lppl (unverified)
+backgammon: other-free (unverified)
+bangtex: lppl (unverified)
+barcode2: not-in-catalogue
+barcodes: lppl (unverified)
+bardiag: lppl (unverified)
+barr: not-in-catalogue
+bayer: gpl (unverified)
+bbding: lppl (unverified)
+bbm: unknown (unverified)
+bbold: bsd (verification data:1.01:1.01:2006-03-14:frank:bbold.dtx,INSTALL)
+beamer: gpl (verification data:3.07:3.06:2006-01-29:graham:)
+beebe: not-in-catalogue
+begriff: gpl (verification data:1.6:1.6:2006-10-17:norbusan:header)
+belleek: pd (unverified)
+bengali: not-in-catalogue
+bera: nosell (unverified)
+betababel: lppl (unverified)
+beton: lppl (verification data::1.3:2006-07-24:frank:legal.txt)
+bez123: lppl1.3 (unverified)
+bezos: lppl (verification data::n/a:2006-07-24:frank:header)
+bghyphen: lppl (unverified)
+bibarts: gpl (unverified)
+bibhtml: gpl (unverified)
+bibleref: lppl (unverified)
+biblist: unknown (unverified)
+bibtex: dfsg (unverified)
+bibtopic: gpl (verification data:1.1a:1.1a:2006-10-17:norbusan:header)
+bibunits: lppl (verification data:2.2:2.4:2006-07-31::header)
+bigfoot: gpl (unverified)
+binomexp: lppl (unverified)
+biocon: gpl (unverified)
+bitfield: lppl (unverified)
+bizcard: gpl (unverified)
+blacklettert1: dfsg (unverified)
+blindtext: lppl (unverified)
+boites: gpl (unverified)
+bookhands: lppl (unverified)
+booklet: lppl (unverified)
+bookman: gpl (unverified)
+booktabs: gpl (verification data:1.61803:1.618:2006-07-31:frank:header)
+bophook: lppl (unverified)
+borceux: unknown (unverified)
+boxhandler: lppl (unverified)
+bpchem: lppl (unverified)
+braille: lppl (unverified)
+breakurl: lppl (unverified)
+breqn: unknown (unverified)
+bridge: unknown (unverified)
+brushscr: pd (unverified)
+burmese: lppl (unverified)
+bussproofs: lppl1.3 (verification data:1.0:1.0:2006-11-02:norbusan:header)
+bytefield: lppl (unverified)
+c-pascal: pd (unverified)
+c90enc: not-in-catalogue
+calendar: nosell (unverified)
+calligra: unknown (unverified)
+calrsfs: unknown (unverified)
+calxxxx: pd (unverified)
+camel: unknown (unverified)
+captcont: lppl (unverified)
+caption: lppl (verification data:3.0q:3.0c,3.1:2006-03-15:frank:header)
+carlisle: lppl (unverified)
+casyl: unknown (unverified)
+cb: lppl (unverified)
+cbcoptic: lppl (unverified)
+cc-pl: pd (unverified)
+ccaption: lppl (verification data:3.2a:3.2a:2006-11-09:norbusan:README)
+ccfonts: lppl (verification data:1.1:1.1:2006-03-14:frank:readme)
+cchess: unknown (unverified)
+cd-cover: gpl (unverified)
+cd: unknown (unverified)
+cdpbundl: lppl (verification data:0.34:0.34:2006-11-09:norbusan:manifest.txt)
+cellspace: lppl (unverified)
+cellular: unknown (unverified)
+changebar: lppl (verification data:3.5c:3.4g:2006-08-21:frank:changebar.dtx)
+chappg: lppl (unverified)
+chapterfolder: lppl (unverified)
+charter: other (verification data:::2006-05-03:frank:readme.charter)
+chem-journal: gpl (unverified)
+chemarrow: unknown (unverified)
+chemcompounds: lppl (unverified)
+chemcono: lppl (unverified)
+cheq: nosell (unverified)
+cherokee: unknown (unverified)
+chess: pd (unverified)
+china2e: unknown (unverified)
+circ: gpl (unverified)
+cirth: unknown (unverified)
+cite: dfsg (unverified)
+citeref: lppl (unverified)
+cjhebrew: lppl (unverified)
+CJK: gpl (unverified)
+cjw: unknown (unverified)
+clarendo: not-in-catalogue
+clefval: lppl (verification data:::2006-11-09:norbusan:header)
+clock: dfsg (unverified)
+clrscode: lppl (unverified)
+cm-lgc: gpl (unverified)
+cm-super: gpl (unverified)
+cm: knuth (unverified)
+cmap: lppl (unverified)
+cmarrows: lppl (unverified)
+cmastro: unknown (unverified)
+cmbright: lppl (verification data:8.1:7.1,8.1:2006-03-15:frank:README)
+cmcyr: pd (unverified)
+cmcyralt: not-in-catalogue
+cmdtrack: dfsg (unverified)
+cmex: not-in-catalogue
+cmextra: not-in-catalogue
+cmll: lppl (unverified)
+cmpica: unknown (unverified)
+cmsd: lppl (unverified)
+cns: not-in-catalogue
+codepage: unknown (unverified)
+colorinfo: lppl (unverified)
+colorsep: pd (unverified)
+colortab: unknown (unverified)
+colortbl: lppl (unverified)
+combine: lppl (unverified)
+commath: lppl (unverified)
+comment: gpl (unverified)
+compactbib: lppl (unverified)
+complexity: lppl (unverified)
+computational-complexity: lppl (unverified)
+concmath: lppl (verification data:1999/03/18:1999/03/18:2006-03-30:frank:README)
+concprog: gpl (unverified)
+concrete: knuth (unverified)
+context: nocommercial (unverified)
+contour: lppl (unverified)
+cooking: gpl (unverified)
+cool: lgpl (unverified)
+coollist: lgpl (unverified)
+coolstr: lgpl (unverified)
+cooltooltips: lppl (unverified)
+coordsys: lppl (verification data:1.4:1.4:2006-11-09:norbusan:README)
+coronet: not-in-catalogue
+count1to: lppl (unverified)
+courier-scaled: lppl (unverified)
+courier: gpl (unverified)
+courseoutline: unknown (unverified)
+coursepaper: unknown (unverified)
+coverpage: lppl (unverified)
+covington: pd (unverified)
+croatian: unknown (unverified)
+crop: lppl (unverified)
+crossreference: lppl (unverified)
+crosswrd: unknown (unverified)
+cryst: dfsg (unverified)
+cs: gpl (unverified)
+cslatex: gpl (unverified)
+csplain: other (unverified)
+csquotes: lppl (unverified)
+csvtools: lppl (unverified)
+ctable: lppl (unverified)
+ctib: gpl (unverified)
+cuisine: lppl (unverified)
+currvita: gpl (unverified)
+cursor: unknown (unverified)
+curve: lppl (unverified)
+curve2e: lppl (unverified)
+curves: lppl (verification data:1.50:1.50:2006-03-15:frank:header)
+custom-bib: lppl (verification data:4.20:4.14:2006-03-15:frank:header)
+cv: gpl (unverified)
+cweb: knuth (unverified)
+cwpuzzle: not-in-catalogue
+cyrillic: lppl (verification data:::2006-03-15:frank:00readme.txt,header)
+cyrplain: lppl (unverified)
+dancers: unknown (unverified)
+dashbox: lppl (unverified)
+dashrule: lppl (unverified)
+dateiliste: lppl (unverified)
+datenumber: lppl (unverified)
+datetime: lppl (unverified)
+dcpic: gpl (unverified)
+decimal: lppl (unverified)
+deleq: nosell (unverified)
+diagnose: gpl (unverified)
+dialogl: unknown (unverified)
+dice: lppl (unverified)
+dichokey: pd (unverified)
+dictsym: lppl (unverified)
+digiconfigs: lppl (unverified)
+dinat: pd (unverified)
+dinbrief: lppl (unverified)
+dingbat: lppl (verification data:1.0:1.0:2006-11-09:norbusan:README)
+directory: lppl (unverified)
+dk-bib: dfsg (unverified)
+dnaseq: lppl (unverified)
+docmfp: lppl (unverified)
+doipubmed: lppl (unverified)
+dotseqn: unknown (unverified)
+dottex: gpl (unverified)
+doublestroke: dfsg (unverified)
+dpfloat: lppl (verification data::2006-10-05:2006-11-09:norbusan:dpfloat.sty)
+draftcopy: lppl (unverified)
+draftwatermark: lppl (unverified)
+dramatist: gpl (verification data:1.2d:1.2d:2006-11-09:norbusan:dramatist.dtx)
+dratex: lppl (unverified)
+dropping: nosell (unverified)
+dtk: not-in-catalogue
+duerer: unknown (unverified)
+dvdcoll: lppl (verification data:v1.1:0.6a:2006-11-02:norbusan:README)
+dvips: gpl (unverified)
+dvipsconfig: gpl (unverified)
+dyntree: lgpl (unverified)
+ean: gpl (unverified)
+easy: lppl (unverified)
+ebezier: lppl (unverified)
+ebong: pd (unverified)
+ebsthesis: lppl (verification data:1.0:0.9i:2006-11-09:norbusan:LICENSE)
+ec: lppl (unverified)
+eCards: lppl (unverified)
+ecc: lppl (unverified)
+ecltree: lppl (unverified)
+eco: gpl (unverified)
+economic: lppl (unverified)
+edmac: lppl (unverified)
+ednotes: lppl (unverified)
+eemeir: lppl (unverified)
+eepic: dfsg (unverified)
+egameps: lppl (unverified)
+egplot: gpl (verification data:1.02a:1.02a:2006-11-09:norbusan:README)
+eiad: unknown (unverified)
+eijkhout: unknown (unverified)
+ellipsis: lppl (unverified)
+elmath: lppl (unverified)
+elpres: lppl (unverified)
+elsevier-bib: lppl (unverified)
+elsevier: lppl (unverified)
+elvish: dfsg (unverified)
+em: not-in-catalogue
+emp: gpl (unverified)
+empheq: lppl (unverified)
+emulateapj: lppl (unverified)
+enctex: gpl (unverified)
+endfloat: gpl (verification data:2.4i:2.4i:2006-03-31:frank:readme.enf)
+endheads: lppl (unverified)
+engpron: lppl (unverified)
+engrec: lppl (unverified)
+enumitem: dfsg (unverified)
+envbig: unknown (unverified)
+envlab: lppl (unverified)
+epigraph: lppl (unverified)
+epiolmec: lppl (unverified)
+eplain: dfsg (unverified)
+epsdice: lppl (unverified)
+epsf: pd (unverified)
+eqlist: unknown (unverified)
+eqname: unknown (unverified)
+eqnarray: unknown (unverified)
+eqparbox: lppl (unverified)
+esdiff: unknown (unverified)
+ESIEEcv: lppl (unverified)
+esint-type1: pd (unverified)
+esint: pd (unverified)
+eskd: lppl (unverified)
+eskdx: lppl1.3 (verification data:0.97:0.96:2006-11-05:norbusan:README)
+eso-pic: lppl (unverified)
+esvect: gpl (unverified)
+etaremune: lppl (unverified)
+etex: other (unverified)
+ethiop-t1: gpl (unverified)
+ethiop: gpl (unverified)
+euenc: lppl (unverified)
+euler: lppl (unverified)
+eulervm: lppl (verification data:4.0:4.0:2006-03-28:frank:README.eulervm)
+euro-ce: not-in-catalogue
+euro: lppl (unverified)
+eurofont: other (unverified)
+europecv: lppl (unverified)
+eurosans: lppl (unverified)
+eurosym: other (unverified)
+euxm: not-in-catalogue
+everypage: lppl (unverified)
+everysel: lppl (unverified)
+everyshi: lppl (unverified)
+exam: lppl (unverified)
+examdesign: lppl (unverified)
+examplep: gpl (unverified)
+exercise: gpl (unverified)
+expdlist: lppl (unverified)
+expl3: lppl (unverified)
+export: lppl (unverified)
+expressg: lppl (unverified)
+extarrows: lgpl (unverified)
+exteps: gpl (unverified)
+extpfeil: lppl (unverified)
+extract: lppl (verification data:1.8:1.8:2006-11-09:norbusan:README)
+extsizes: lppl (unverified)
+facsimile: lppl (unverified)
+faktor: lppl (unverified)
+fancybox: artistic (unverified)
+fancyhdr: lppl (verification data:3.1:3.1:2006-03-31:frank:README)
+fancynum: dfsg (unverified)
+fancyref: gpl (unverified)
+fancyvrb: artistic (verification data:1998/07/17:1998/07/17:2006-03-31:frank:fancyvrb.dtx,contrib/fvrb-ex.dtx)
+fax: unknown (unverified)
+fc: gpl (unverified)
+featpost: gpl (unverified)
+feyn: gpl (unverified)
+feynmf: gpl (unverified)
+figbib: lppl (unverified)
+figsize: lppl (unverified)
+filecontents: lppl (verification data:1.1a:1.1a:2006-11-09:norbusan:README)
+finbib: not-in-catalogue
+fink: lppl (unverified)
+fixfoot: lppl (unverified)
+fixme: lppl (unverified)
+fixpdfmag: pd (unverified)
+flabels: lppl (unverified)
+flagderiv: gpl (unverified)
+flashcards: gpl (unverified)
+flippdf: lppl (unverified)
+float: lppl (unverified)
+floatflt: nosell (unverified)
+floatrow: lppl (unverified)
+flowfram: lppl (unverified)
+fltpoint: dfsg (unverified)
+fmp: lppl (unverified)
+fmtcount: lppl (unverified)
+fnbreak: lppl (unverified)
+fncychap: dfsg (unverified)
+foekfont: gpl (unverified)
+foilhtml: lppl (unverified)
+fontch: lppl (unverified)
+fontinst: lppl (verification data:1.928:1.928:2006-02-23:frank:header)
+fontname: gpl (unverified)
+fontspec: lppl (unverified)
+footbib: lppl (verification data:2.0.4:2.0.4:2006-11-09:norbusan:footbib.dtx)
+footmisc: lppl (unverified)
+footnpag: gpl (unverified)
+forloop: lgpl (unverified)
+formlett: unknown (unverified)
+formula: gpl (unverified)
+formular: lppl (unverified)
+fourier: lppl (unverified)
+fp: lppl (unverified)
+fpl: gpl (verification data:1.002:1.002:2006-05-04:frank:README)
+frcursive: gpl (unverified)
+frenchle: lppl (unverified)
+fribrief: unknown (unverified)
+fullblck: unknown (unverified)
+fullpict: unknown (unverified)
+functan: lppl (unverified)
+fundus: unknown (unverified)
+futhark: unknown (unverified)
+g-brief: lppl (unverified)
+galley: not-in-catalogue
+galois: lppl (unverified)
+garamond: not-in-catalogue
+garuda: not-in-catalogue
+gastex: lppl (unverified)
+gatech-thesis: gpl (unverified)
+gauss: lppl (unverified)
+genealogy: lppl (unverified)
+genmisc: not-in-catalogue
+genmpage: lppl (unverified)
+geometry: lppl (unverified)
+geomsty: unknown (unverified)
+german: lppl (unverified)
+germbib: unknown (unverified)
+ginpenc: lppl (unverified)
+gloss: lppl (unverified)
+glossary: lppl (unverified)
+glyphlist: not-in-catalogue
+gmdoc: lppl (unverified)
+gmiflink: lppl (unverified)
+gmutils: lppl (unverified)
+gmverb: lppl (unverified)
+gnuplottex: gpl (verification data:0.2:0.2:2006-11-02:norbusan:header)
+go: pd (unverified)
+gost: lppl (unverified)
+gothic: unknown (unverified)
+graphics: lppl (unverified)
+graphicx-psmin: lppl (unverified)
+greek: not-in-catalogue
+greektex: pd (unverified)
+greenpoint: gpl (unverified)
+grfpaste: lppl (unverified)
+grnumalt: unknown (unverified)
+groff: not-in-catalogue
+grotesq: not-in-catalogue
+grtimes: unknown (unverified)
+grverb: not-in-catalogue
+GuIT: not-in-catalogue
+guitar: unknown (unverified)
+gustlib: pd (unverified)
+HA-prosper: lppl (unverified)
+hands: unknown (unverified)
+hanging: lppl (unverified)
+harpoon: unknown (unverified)
+harvard: unknown (unverified)
+harvmac: unknown (unverified)
+hatching: pd (unverified)
+hc: dfsg (unverified)
+helvetic: gpl (unverified)
+hepparticles: lppl (unverified)
+hepthesis: lppl (unverified)
+hepunits: lppl (unverified)
+hfbright: lppl (unverified)
+hfoldsty: gpl (unverified)
+hhtensor: lppl (unverified)
+hieroglf: lppl (unverified)
+hilowres: unknown (unverified)
+histogr: lppl1.3 (verification data:1.01:1.01:2006-11-09:norbusan:histogr.dtx)
+hitec: unknown (unverified)
+hpsdiss: gpl (unverified)
+hrlatex: lppl (unverified)
+hvfloat: lppl (unverified)
+hvmath: lppl (unverified)
+hyper: lppl (unverified)
+hyperref: lppl (unverified)
+hyperxmp: lppl (unverified)
+hyphenat: lppl (unverified)
+hyplain: pd (unverified)
+ibycus-babel: lppl (unverified)
+ibycus: gpl (unverified)
+ibygrk: gpl (unverified)
+icsv: lppl (unverified)
+IEEEconf: lppl (unverified)
+ieeepes: lppl (unverified)
+IEEEtran: lppl (unverified)
+ifacmtg: other (unverified)
+ifmslide: dfsg (unverified)
+ifsym: dfsg (unverified)
+ifxetex: lppl (unverified)
+ijqc: lppl (unverified)
+imac: gpl (unverified)
+index: dfsg (unverified)
+inlinebib: lppl (unverified)
+insbox: pd (unverified)
+interactiveworkbook: lppl (unverified)
+invoice: dfsg (unverified)
+iopart-num: lppl (unverified)
+ipa: unknown (unverified)
+iso: not-in-catalogue
+iso10303: not-in-catalogue
+isodate: lppl (unverified)
+isorot: lppl (unverified)
+isotope: lppl (unverified)
+itrans: not-in-catalogue
+iwona: gfsl (unverified)
+jadetex: dfsg (unverified)
+jhep: unknown (unverified)
+jknapltx: gpl (unverified)
+jmn: not-in-catalogue
+jneurosci: lppl (unverified)
+jpsj: lppl (unverified)
+jsmisc: not-in-catalogue
+jura: gpl (unverified)
+juraabbrev: gpl (unverified)
+jurabib: gpl (verification data:0.6:0.6:2006-11-09:norbusan:jurabib.dtx)
+juramisc: lppl (unverified)
+jurarsp: gpl (unverified)
+kalender: unknown (unverified)
+karnaugh: lppl (unverified)
+kastrup: dfsg (unverified)
+kdgreek: unknown (unverified)
+kerkis: lppl (unverified)
+kerntest: lppl (unverified)
+keystroke: gpl (unverified)
+kixfont: not-in-catalogue
+kluwer: not-in-catalogue
+knuthotherfonts: not-in-catalogue
+koma-script: lppl (unverified)
+labbook: lppl (unverified)
+labelcas: lppl (unverified)
+labels: lppl (unverified)
+lambda: not-in-catalogue
+lastpage: gpl (unverified)
+latex-fonts: lppl (unverified)
+latex-tds: lppl (unverified)
+latex: lppl (verification data::2e:2006-04-25:frank:legal.txt)
+latexconfig: not-in-catalogue
+latexmp: pd (unverified)
+layouts: lppl (unverified)
+lazylist: lppl (unverified)
+lcd: lppl (verification data:0.3:0.3:2006-11-09:norbusan:00readme)
+lcg: lppl (unverified)
+leaflet: lppl (unverified)
+ledmac: lppl (unverified)
+leftidx: lppl (unverified)
+lettre: lppl (unverified)
+lettrgth: not-in-catalogue
+lettrine: lppl (unverified)
+levy: not-in-catalogue
+lewis: pd (unverified)
+lexikon: lppl (unverified)
+lfb: lppl (unverified)
+lgreek: unknown (unverified)
+lh: lppl (unverified)
+lhcyr: other (unverified)
+lhelp: gpl (unverified)
+limap: lppl (unverified)
+linearA: not-in-catalogue
+lineno: lppl (unverified)
+linguex: lppl (unverified)
+lipsum: lppl (unverified)
+listbib: gpl (unverified)
+listings: lppl (verification data:1.4:1.4:2007-03-02:frank:README)
+listliketab: lppl (unverified)
+listofsymbols: lppl (unverified)
+literat: not-in-catalogue
+lkproof: gpl (unverified)
+lm: gfsl (unverified)
+lmextra: not-in-catalogue
+localloc: dfsg (unverified)
+logic: unknown (unverified)
+logpap: lppl (unverified)
+lsc: lppl (unverified)
+ltablex: unknown (unverified)
+ltabptch: lppl (unverified)
+ltxindex: gpl (unverified)
+ltxmisc: unknown (unverified)
+ly1: unknown (unverified)
+mafr: gpl (unverified)
+magyar: lppl (unverified)
+mailing: lppl (unverified)
+makebox: lppl (unverified)
+makecell: lppl (unverified)
+makecirc: lppl (unverified)
+makecmds: lppl (unverified)
+makedtx: lppl (unverified)
+makeglos: gpl (unverified)
+makeindex: dfsg (unverified)
+makeplot: lppl (unverified)
+malayalam: not-in-catalogue
+manfnt: lppl (unverified)
+manjutex: gpl (unverified)
+manuscript: lppl (unverified)
+mapcodes: other (unverified)
+maple: unknown (unverified)
+marginnote: lppl (unverified)
+marigold: not-in-catalogue
+marvosym: gpl (unverified)
+mathcomp: lppl (unverified)
+mathdesign: gpl (unverified)
+mathdots: lppl (unverified)
+mathpazo: gpl (unverified)
+maybemath: lppl (verification data:::2006-11-09:norbusan:README)
+mcaption: lppl (unverified)
+mceinleger: gpl (unverified)
+mcite: gpl (unverified)
+mdwtools: gpl (unverified)
+memoir: lppl (unverified)
+mentis: lppl (unverified)
+menu: unknown (unverified)
+metafont: not-in-catalogue
+metaobj: lppl (verification data:0.83:0.83:2006-11-09:norbusan:README)
+metaplot: lppl (verification data:0.91:0.91:2006-11-09:norbusan:README)
+metapost: unknown (unverified)
+metatex: gpl (unverified)
+metauml: gpl (unverified)
+method: lppl (unverified)
+metre: lppl (unverified)
+mex: pd (unverified)
+mff: unknown (unverified)
+mflogo: lppl (unverified)
+mfnfss: lppl (unverified)
+mfpic: lppl (unverified)
+mft: not-in-catalogue
+mftinc: lppl (unverified)
+mftoeps: not-in-catalogue
+mh: lppl (unverified)
+mhchem: lppl (unverified)
+mhequ: dfsg (unverified)
+mhs: other (unverified)
+microtype: lppl (unverified)
+midnight: unknown (unverified)
+miller: lppl (unverified)
+minipage-marginpar: lppl (unverified)
+miniplot: lppl (unverified)
+minitoc: lppl (unverified)
+minutes: dfsg (unverified)
+misc: not-in-catalogue
+misc209: not-in-catalogue
+mkind-english: not-in-catalogue
+mkind-german: not-in-catalogue
+mla-paper: bsd (unverified)
+mltex: unknown (unverified)
+mnras: nosell (unverified)
+moderncv: lppl (unverified)
+modroman: lppl (unverified)
+montex: gpl (unverified)
+morehelp: other (unverified)
+moresize: lppl (unverified)
+moreverb: lppl (unverified)
+morse: nosell (unverified)
+movie15: lppl (verification data::2006-10-12:2006-11-02:norbusan:README)
+mp3d: not-in-catalogue
+mparhack: gpl (unverified)
+mpattern: pd (unverified)
+msc: lppl (unverified)
+msg: lppl (unverified)
+mslapa: unknown (unverified)
+mtgreek: lppl (unverified)
+multenum: unknown (unverified)
+multi: not-in-catalogue
+multibbl: lppl (unverified)
+multibib: lppl (unverified)
+multicap: lppl (unverified)
+multido: lppl (unverified)
+multirow: lppl (unverified)
+multitoc: lppl (unverified)
+munich: lppl (unverified)
+musictex: unknown (unverified)
+musixlyr: unknown (unverified)
+musixps: not-in-catalogue
+musixtex: gpl (unverified)
+muthesis: lppl (unverified)
+mwcls: lppl (verification data:0.65:0.65:2006-11-09:norbusan:README)
+mwrite: other (unverified)
+mxd: unknown (unverified)
+mxedruli: unknown (unverified)
+nag: lppl (unverified)
+namespc: lppl (unverified)
+natbib: lppl (unverified)
+nath: gpl (unverified)
+nature: unknown (unverified)
+ncclatex: lppl (unverified)
+ncctools: lppl (unverified)
+ncntrsbk: not-in-catalogue
+newalg: unknown (unverified)
+newfile: lppl (unverified)
+newlfm: lppl (unverified)
+newsletr: other-free (unverified)
+newthm: unknown (unverified)
+newvbtm: lppl (unverified)
+niceframe: unknown (unverified)
+nih: lppl (unverified)
+nkarta: unknown (unverified)
+noitcrul: lppl (unverified)
+nomencl: lppl (unverified)
+nomentbl: lppl (unverified)
+nonfloat: pd (unverified)
+norasi: not-in-catalogue
+notes: lppl (unverified)
+nrc: lppl (unverified)
+ntabbing: dfsg (unverified)
+ntgclass: lppl (unverified)
+ntheorem: lppl (unverified)
+numline: unknown (unverified)
+numprint: lppl (unverified)
+oberdiek: lppl (verification data:::2006-11-03:norbusan:)
+objectz: lppl (unverified)
+oca: unknown (unverified)
+ocherokee: lppl (unverified)
+ocr-a: nosell (unverified)
+ocr-latex: gpl (unverified)
+octavo: lppl (unverified)
+oesch: unknown (unverified)
+ofs: knuth (unverified)
+ogham: unknown (unverified)
+ogonek: other (unverified)
+oinuit: lppl (unverified)
+oldstyle: lppl (unverified)
+omega-devanagari: unknown (unverified)
+omega: gpl (unverified)
+onlyamsmath: lppl (unverified)
+opcit: lppl (unverified)
+optima: not-in-catalogue
+ordinalpt: lppl (unverified)
+osa: unknown (unverified)
+osmanian: unknown (unverified)
+ot2cyr: unknown (unverified)
+othello: gpl (unverified)
+otibet: not-in-catalogue
+outline: unknown (unverified)
+outliner: gpl (unverified)
+overpic: lppl (unverified)
+oxford: nosell (unverified)
+pacioli: lppl (unverified)
+pageno: other (unverified)
+pagenote: lppl (unverified)
+palatino: gpl (unverified)
+paper: unknown (unverified)
+papercdcase: lppl (unverified)
+papertex: lppl (unverified)
+paralist: lppl (unverified)
+parallel: lppl (unverified)
+paresse: lppl (unverified)
+parrun: lppl (unverified)
+passivetex: dfsg (unverified)
+patch: lppl (unverified)
+patchcmd: pd (unverified)
+pauldoc: lppl (unverified)
+pawpict: gpl (unverified)
+pb-diagram: dfsg (unverified)
+pbox: gpl (unverified)
+pbsheet: lppl (unverified)
+pclnfss: unknown (unverified)
+pdcmac: gpl (unverified)
+pdf-trans: pd (unverified)
+pdfcprot: lppl (unverified)
+pdfpages: lppl (unverified)
+pdfscreen: lppl (verification data:1.5:1.5:2006-11-09:norbusan:header)
+pdfslide: lppl (unverified)
+pdfsync: lppl (unverified)
+pdftex-def: lppl (unverified)
+pdftricks: gpl (unverified)
+pdfwin: not-in-catalogue
+pecha: gpl (unverified)
+perception: lppl (unverified)
+perltex: lppl (unverified)
+permute: lppl (unverified)
+petri-nets: gpl (unverified)
+pgf: lppl1.3 (verification data:1.10:1.10:2006-11-02:norbusan:LICENSE)
+phaistos: lppl (unverified)
+philokalia: lppl (unverified)
+phonetic: unknown (unverified)
+photo: lppl (unverified)
+physe: unknown (unverified)
+phyzzx: unknown (unverified)
+picinpar: gpl (unverified)
+pict2e: lppl (unverified)
+pictex: unknown (unverified)
+pictex2: lppl (unverified)
+piechartmp: lppl (unverified)
+pittetd: unknown (unverified)
+pl: unknown (unverified)
+placeins: pd (unverified)
+plain: knuth (unverified)
+plari: gpl (unverified)
+plates: lppl (unverified)
+platex: lppl (unverified)
+play: lppl (unverified)
+plgraph: not-in-catalogue
+plnfss: lppl (unverified)
+plweb: not-in-catalogue
+pmgraph: unknown (unverified)
+poemscol: lppl (unverified)
+polyglot: not-in-catalogue
+polynom: lppl (unverified)
+polytable: lppl (verification data:0.8.2:0.8.2:2006-11-09:norbusan:README)
+postcards: lppl (unverified)
+powerdot: lppl (unverified)
+ppower4: gpl (unverified)
+ppr-prv: lppl (unverified)
+pracjourn: gpl (unverified)
+prelim2e: lppl (unverified)
+preprint: lppl (unverified)
+prettyref: unknown (unverified)
+preview: gpl (verification data:11.84:11.81:2006-04-21:frank:header)
+probsoln: lppl (unverified)
+procIAGssymp: lppl (verification data:::2006-11-09:norbusan:procIAGssymp.sty)
+progkeys: unknown (unverified)
+program: gpl (unverified)
+progress: lppl (unverified)
+prosper: lppl (unverified)
+protocol: lppl1.3 (verification data:1.9:1.9:2006-11-03:norbusan:readme)
+psafm: not-in-catalogue
+pseudocode: lppl (unverified)
+psfig: nosell (unverified)
+psfrag: dfsg (unverified)
+psfragx: lppl (unverified)
+psgo: lppl (unverified)
+psizzl: lppl (unverified)
+pslatex: lppl (unverified)
+psnfss: lppl (verification data:9.2a:9.2:2006-05-02:frank:psfonts.dtx)
+psnfssx: lppl (unverified)
+pspicture: lppl (unverified)
+pst-3d: lppl (verification data:1.0:1.0:2003-03-28:frank:header)
+pst-3dplot: lppl (unverified)
+pst-bar: lppl (verification data:::2006-11-09:norbusan:LICENSE)
+pst-barcode: lppl (unverified)
+pst-blur: lppl (unverified)
+pst-circ: lppl (unverified)
+pst-coil: lppl (unverified)
+pst-dbicons: lppl (unverified)
+pst-eps: lppl (unverified)
+pst-eucl: lppl (unverified)
+pst-fill: lppl (unverified)
+pst-fr3d: lppl (unverified)
+pst-func: lppl (unverified)
+pst-geo: lppl (unverified)
+pst-ghsb: not-in-catalogue
+pst-gr3d: lppl (unverified)
+pst-grad: lppl (unverified)
+pst-infixplot: lppl (unverified)
+pst-jtree: lppl (unverified)
+pst-labo: lppl (verification data:2.03:2.03:2006-11-02:norbusan:header)
+pst-lens: lppl (unverified)
+pst-light3d: lppl (unverified)
+pst-math: lppl (unverified)
+pst-optic: dfsg (unverified)
+pst-osci: lppl (unverified)
+pst-pdf: lppl (unverified)
+pst-pdgr: lppl (unverified)
+pst-poly: lppl (verification data:1.60:1.60:2006-03-27:frank:header)
+pst-slpe: lppl (unverified)
+pst-text: lppl (unverified)
+pst-uml: lppl (unverified)
+pst-vue3d: lppl (unverified)
+pstricks-add: lppl (unverified)
+pstricks: lppl (unverified)
+ptptex: unknown (unverified)
+punk: knuth (unverified)
+pxfonts: gpl (unverified)
+qcm: lppl (unverified)
+qfonts: gpl (unverified)
+qobitree: unknown (unverified)
+qpxqtx: not-in-catalogue
+qsymbols: gpl (unverified)
+qtree: lppl (unverified)
+quotchap: lppl (unverified)
+r-und-s: dfsg (unverified)
+ragged2e: lppl (unverified)
+randbild: lppl (unverified)
+randtext: lppl (unverified)
+rccol: dfsg (unverified)
+rcs: gpl (unverified)
+rcsinfo: lppl (unverified)
+realcalc: nosell (unverified)
+rectopma: lppl (unverified)
+refcheck: gpl (unverified)
+refman: lppl (unverified)
+refstyle: lppl (unverified)
+regcount: lppl (verification data:1.0:1.0:2006-11-09:norbusan:regcount.dtx)
+register: lppl (verification data:1.5:1.4:2006-11-09:norbusan:register.dtx)
+relenc: unknown (unverified)
+repeatindex: lppl (unverified)
+resume: lppl (unverified)
+revtex: lppl (unverified)
+rlepsf: lppl (unverified)
+rmpage: unknown (unverified)
+robustcommand: lppl (unverified)
+robustindex: lppl (unverified)
+roex: not-in-catalogue
+romannum: lppl (unverified)
+rotating: lppl (unverified)
+rotfloat: lppl (unverified)
+rotpages: lppl (unverified)
+rsc: gpl (verification data:1.1:2006-10-30:2006-11-09:norbusan:header)
+rsfs: lppl (unverified)
+rst: nocommercial (unverified)
+rtkinenc: lppl (verification data:1.0:1.0:2006-11-05:norbusan:rtkinenc.ins)
+rtklage: not-in-catalogue
+ruhyphen: lppl (unverified)
+sae: nosell (unverified)
+sanskrit: lppl (unverified)
+sauerj: lppl (unverified)
+sauter: unknown (unverified)
+sauterfonts: gpl (verification data:::2006-11-05:norbusan:sauterfonts.fdd)
+savefnmark: gpl (verification data:1.0:1.0:2006-11-05:norbusan:savefnmark.dtx)
+savesym: lppl (verification data:1.1:1.1:2006-11-05:norbusan:header)
+savetrees: lppl (verification data:1.2:1.1:2006-11-05:norbusan:README)
+scale: gpl (verification data:1.1.2:1.1.2:2006-11-05:norbusan:README)
+scalebar: lppl (verification data:1.0:1.0:2006-11-05:norbusan:header)
+schedule: unknown (unverified)
+scientificpaper: lppl (unverified)
+sciposter: lppl (unverified)
+sciwordconv: lppl (unverified)
+screenplay: gpl (verification data:1.535:1.518:2006-11-03:norbusan:header)
+script: unknown (unverified)
+sectionbox: lppl (unverified)
+sectsty: lppl (unverified)
+semantic: lppl (unverified)
+semaphor: gpl (verification data:::2006-11-05:norbusan:README)
+seminar: lppl (unverified)
+semioneside: lppl (unverified)
+seqsplit: lppl (verification data:0.1:0.1:2006-11-05:norbusan:README)
+setspace: pd (unverified)
+sf298: lppl (unverified)
+sffms: lppl (verification data:2.0:2.0:2006-11-05:norbusan:header)
+sgame: lppl (unverified)
+shadbox: other (unverified)
+shadethm: lppl (unverified)
+shapepar: nocommercial (unverified)
+shortlst: unknown (unverified)
+shorttoc: lppl (verification data:1.3:1.3:2006-11-05:norbusan:header)
+showdim: unknown (unverified)
+showexpl: lppl (unverified)
+showlabels: gpl (verification data:1.6:1.6:2006-11-05:norbusan:README)
+sidecap: lppl (verification data:1.6f:1.6f:2006-11-05:norbusan:header)
+sides: gpl (unverified)
+siggraph: other (unverified)
+simpsons: unknown (unverified)
+SIstyle: lppl (unverified)
+SIunits: lppl (unverified)
+skak: lppl (unverified)
+skaknew: lppl (unverified)
+skull: gpl (verification data:0.1:0.1:2006-11-05:norbusan:header)
+slantsc: lppl (unverified)
+slashbox: unknown (unverified)
+slidenotes: unknown (unverified)
+slideshow: other (unverified)
+smalltableof: lppl (verification data:::2006-11-05:norbusan:README)
+smartref: lppl (verification data:1.9:1.9:2006-11-05:norbusan:header)
+smflatex: unknown (unverified)
+snapshot: lppl (unverified)
+songbook: lgpl-2.1 (unverified)
+sort-by-letters: lppl (unverified)
+soul: lppl (verification data:2.4:2.4:2006-11-05:norbusan:soul.txt)
+soyombo: unknown (unverified)
+sparklines: lppl (unverified)
+spie: lppl (unverified)
+splines: lppl1.3 (verification data:0.2:0.2:2006-11-05:norbusan:README)
+splitbib: lppl (unverified)
+splitindex: dfsg (unverified)
+spotcolor: lppl (unverified)
+sprite: unknown (unverified)
+srcltx: pd (verification data:1.6:1.5:2006-11-05:norbusan:header)
+sseq: lppl (verification data:1.03:1.03:2006-11-05:norbusan:sseq.dtx)
+ssqquote: dfsg (unverified)
+stack: lppl (verification data:1.00:1.00:2006-11-05:norbusan:stack.dtx)
+stage: lppl1.3 (verification data:::2006-11-05:norbusan:header)
+startex: unknown (unverified)
+statistik: gpl (unverified)
+stdclsdv: lppl (verification data:1.1:1.1:2006-11-05:norbusan:README)
+stdpage: lppl1.2 (verification data:0.6:0.6:2006-11-05:norbusan:header)
+stellenbosch: lppl (unverified)
+stmaryrd: lppl (unverified)
+struktex: lppl (unverified)
+sttools: lppl (unverified)
+subeqn: lppl (verification data:2.0b:2.0b:2006-11-05:norbusan:header)
+subeqnarray: lppl (verification data:2.1c:2.1c:2006-11-05:norbusan:header)
+subfig: lppl (unverified)
+subfigure: lppl (unverified)
+subfloat: lppl (verification data:2.14:2.14:2006-11-05:norbusan:README)
+substr: lppl (verification data:1.1:1.1:2006-11-05:norbusan:README)
+sudoku: lppl (unverified)
+sudokubundle: lppl (unverified)
+sugconf: lppl (unverified)
+supertabular: lppl (unverified)
+svgcolor: lppl (unverified)
+svn-multi: dfsg (unverified)
+svn: lppl (unverified)
+svninfo: lppl (unverified)
+swebib: lppl1.2 (verification data:::2006-11-05:norbusan:header)
+swimgraf: lppl (unverified)
+symbol: gpl (unverified)
+syntax: gpl (verification data:::2006-11-05:norbusan:README)
+syntrace: lppl (unverified)
+synttree: lppl (unverified)
+t-angles: gpl (unverified)
+t2: lppl (unverified)
+Tabbing: lppl (unverified)
+tableaux: unknown (unverified)
+tabto-ltx: lppl (unverified)
+tabulary: lppl (unverified)
+tabvar: lppl (unverified)
+talk: lppl (unverified)
+tap: pd (unverified)
+tapir: gpl (unverified)
+taupin: not-in-catalogue
+tcldoc: not-in-catalogue
+technics: lppl (unverified)
+template: not-in-catalogue
+tengwarscript: lppl (unverified)
+tensor: lppl (verification data:2.1:2.1:2006-11-02:norbusan:header)
+teubner: lppl (verification data:2.2c:2.2b:2006-11-02:norbusan:teubner.txt)
+tex-gyre: gfsl (unverified)
+tex-ps: pd (unverified)
+tex4ht: lppl (unverified)
+texdraw: dfsg (unverified)
+texinfo: gpl (verification data:2007-05-04.09:4.8:2006-04-25:frank:header)
+texlogos: lppl (unverified)
+texmate: lppl (unverified)
+texpower: gpl (unverified)
+texshade: gpl (unverified)
+texsis: lppl (unverified)
+textcase: lppl (unverified)
+textfit: dfsg (unverified)
+textmerg: lppl (unverified)
+textopo: gpl (verification data:1.4:1.4:2006-11-02:norbusan:textopo.txt)
+textpath: lppl (unverified)
+textpos: gpl (unverified)
+thesis-titlepage-fhac: lppl (unverified)
+thumb: gpl (verification data:1.0:1.0:2006-11-02:norbusan:README)
+thumbpdf: lppl (unverified)
+ticket: lppl (unverified)
+times: gpl (unverified)
+timescyr: not-in-catalogue
+timesht: not-in-catalogue
+timesnew: not-in-catalogue
+timing: unknown (unverified)
+tipa: unknown (unverified)
+titlefoot: lppl (verification data::1999/03/02:2006-11-02:norbusan:header)
+titlesec: lppl (unverified)
+titling: lppl (verification data:2.1c:2.1c:2006-11-02:norbusan:README)
+tmmath: lppl (unverified)
+tocbibind: lppl (verification data:1.5g:1.5g:2006-11-02:norbusan:README)
+tocloft: lppl1.3 (verification data:2.3c:2.3c:2006-11-02:norbusan:README)
+tocvsec2: lppl1.3 (verification data:1.2:1.2:2006-11-02:norbusan:README)
+todo: lppl (verification data:1.1:1.1:2006-11-02:norbusan:header)
+tokenizer: lppl (unverified)
+toolbox: lppl (unverified)
+tools: lppl (verification data:::2006-05-02:frank:readme.txt)
+topfloat: gpl (unverified)
+totpages: lppl (unverified)
+tpslifonts: gpl (unverified)
+tracking: unknown (unverified)
+trajan: lppl (unverified)
+tree-dvips: unknown (unverified)
+treetex: not-in-catalogue
+trfsigns: gpl (unverified)
+trsym: lppl1.2 (verification data:1.0:1.0:2006-11-02:norbusan:)
+tugboat: lppl (unverified)
+twoup: not-in-catalogue
+txfonts: gpl (unverified)
+type1cm: lppl (unverified)
+typedref: unknown (unverified)
+typespec: unknown (unverified)
+typogrid: lppl (verification data:0.10:0.10:2006-11-02:norbusan:README)
+uaclasses: unknown (unverified)
+ucs: not-in-catalogue
+ucthesis: lppl (verification data:3.2:3.2:2006-10-17:norbusan:)
+uhc: not-in-catalogue
+uhrzeit: unknown (unverified)
+uiucthesis: lppl (unverified)
+ukrhyph: lppl (unverified)
+ulsy: unknown (unverified)
+umich-thesis: lppl (verification data:1.20:1.20:2006-10-17:norbusan:)
+uml: lppl (unverified)
+umlaute: lppl (unverified)
+umoline: lppl (unverified)
+umrand: unknown (unverified)
+underlin: lppl (unverified)
+undertilde: unknown (unverified)
+units: gpl (verification data:0.9b:0.9b:2006-10-17:norbusan:)
+unitsdef: lppl (unverified)
+univers: not-in-catalogue
+universa: gpl (unverified)
+upquote: lppl (verification data:v1.1:v1.1:2006-10-17:norbusan:)
+urlbst: gpl (unverified)
+ushort: dfsg (unverified)
+utf8mex: not-in-catalogue
+utopia: dfsg (unverified)
+uwthesis: lppl (unverified)
+vancouver: gpl (unverified)
+variations: gpl (unverified)
+varindex: dfsg (unverified)
+vector: unknown (unverified)
+velthuis: not-in-catalogue
+venn: lppl (unverified)
+verse: lppl (unverified)
+versions: lppl (verification data:0.55:0.55::norbusan:)
+vertex: unknown (unverified)
+vhistory: lppl (unverified)
+vita: unknown (unverified)
+vmargin: lppl (verification data:2.5:2.5::norbusan:)
+vntex: lppl (unverified)
+volumes: lppl (unverified)
+vpe: lppl (unverified)
+vrb: unknown (unverified)
+vrsion: lppl (unverified)
+vtex: not-in-catalogue
+wadalab: unknown (unverified)
+wallpaper: lppl (unverified)
+warning: lppl (verification data:0.01:0.01::norbusan:)
+warpcol: unknown (unverified)
+was: lppl (unverified)
+wasy: dfsg (unverified)
+wasysym: lppl (verification data:2.0:2.0:2006-03-06:frank:header)
+webeq: not-in-catalogue
+williams: unknown (unverified)
+wnri: gpl (unverified)
+wntamil: other (unverified)
+wordcount: dfsg (unverified)
+wordlike: lppl (unverified)
+wrapfig: dfsg (unverified)
+wsuipa: unknown (unverified)
+xbmc: not-in-catalogue
+xcolor: lppl (verification data:2.11:2.09:2004-06-25:frank:header)
+xdoc: lppl (unverified)
+xetex: not-in-catalogue
+xetexconfig: not-in-catalogue
+xetexurl: not-in-catalogue
+xfrac: lppl (unverified)
+xifthen: lppl (unverified)
+xinitials: not-in-catalogue
+xkeyval: lppl (verification data:2.5f:2.0,2.5e:2006-03-06:frank:README)
+xltxtra: lppl (unverified)
+xmlplay: pd (unverified)
+xmltex: lppl (unverified)
+xmpincl: gpl (unverified)
+xor: not-in-catalogue
+xparse: not-in-catalogue
+xq: lppl (unverified)
+xtab: lppl (verification data:2.3a:2.3a:2006-10-17:norbusan:README)
+xtcapts: unknown (unverified)
+xtheorem: not-in-catalogue
+xu-hyphen: not-in-catalogue
+xunicode: not-in-catalogue
+xyling: lppl (verification data:1.1:1.1:2006-10-17:norbusan:header)
+xypic: dfsg (unverified)
+xytree: lppl (unverified)
+yafoot: lppl (unverified)
+yannisgr: unknown (unverified)
+yfonts: lppl (unverified)
+yhmath: lppl (unverified)
+yi4latex: unknown (unverified)
+york-thesis: lppl (unverified)
+youngtab: lppl (unverified)
+yplan: lppl (unverified)
+ytex: unknown (unverified)
+zapfchan: gpl (unverified)
+zapfding: gpl (unverified)
+zed-csp: other (unverified)
+zefonts: unknown (unverified)
+amslatex-primer: unknown (unverified)
+amsldoc-it: not-in-catalogue
+amsldoc-vn: not-in-catalogue
+amsmath-it: not-in-catalogue
+amsthdoc-it: not-in-catalogue
+beamer-tut-pt: gpl (unverified)
+catalogue: lppl (unverified)
+components-of-TeX: not-in-catalogue
+comprehensive: lppl (unverified)
+cursolatex: gpl (unverified)
+dtxtut: lppl (unverified)
+epslatex-fr: not-in-catalogue
+es-tex-faq: not-in-catalogue
+fancyhdr-it: not-in-catalogue
+FAQ-en: not-in-catalogue
+FAQ-fr: not-in-catalogue
+FAQ-ge: not-in-catalogue
+firststeps: not-in-catalogue
+free-math-font-survey: dfsg (unverified)
+gentle-gr: not-in-catalogue
+gentle: unknown (unverified)
+guide-to-latex: not-in-catalogue
+guides-pl: not-in-catalogue
+help: not-in-catalogue
+impatient-fr: not-in-catalogue
+impatient: fdl (unverified)
+knuth: not-in-catalogue
+kopka: not-in-catalogue
+l2picfaq: fdl (unverified)
+l2tabu-english: gpl (unverified)
+l2tabu-french: gpl (unverified)
+l2tabu-it: not-in-catalogue
+l2tabu: gpl (unverified)
+latex-graphics-companion: not-in-catalogue
+latex-tipps-und-tricks: not-in-catalogue
+latex-web-companion: not-in-catalogue
+latex2e-html: not-in-catalogue
+lkort: unknown (unverified)
+lshort-bulgarian: pd (unverified)
+lshort-dutch: gpl (unverified)
+lshort-english: dfsg (unverified)
+lshort-finnish: unknown (unverified)
+lshort-french: unknown (unverified)
+lshort-german: dfsg (unverified)
+lshort-italian: gpl (unverified)
+lshort-japanese: gpl (unverified)
+lshort-korean: unknown (unverified)
+lshort-mongolian: unknown (unverified)
+lshort-polish: pd (unverified)
+lshort-portuguese: pd (unverified)
+lshort-russian: gpl (unverified)
+lshort-slovak: lppl (unverified)
+lshort-spanish: unknown (unverified)
+lshort-thai: pd (unverified)
+lshort-turkish: pd (unverified)
+lshort-ukrainian: not-in-catalogue
+lshort-vietnamese: lppl (unverified)
+make-tex-work: not-in-catalogue
+math-into-latex: not-in-catalogue
+mathmode: not-in-catalogue
+MemoirChapStyles: not-in-catalogue
+metafont-for-beginners: not-in-catalogue
+metafp: lppl (unverified)
+metapost-examples: dfsg (unverified)
+ntg: dfsg (unverified)
+ntheorem-vn: not-in-catalogue
+pstricks-tutorial: not-in-catalogue
+tamethebeast: lppl (unverified)
+tds: unknown (unverified)
+tex-refs: not-in-catalogue
+tex-virtual-academy-pl: not-in-catalogue
+texlive-common: not-in-catalogue
+texlive-cz: not-in-catalogue
+texlive-en: not-in-catalogue
+texlive-fr: not-in-catalogue
+texlive-ge: not-in-catalogue
+texlive-pl: not-in-catalogue
+texlive-ru: not-in-catalogue
+texlive-zh-cn: not-in-catalogue
+tlc2: not-in-catalogue
+truetype: not-in-catalogue
+Type1fonts: not-in-catalogue
+visualfaq: lppl (unverified)
+voss-de: not-in-catalogue
+webguide: dfsg (unverified)
+wp-conv: unknown (unverified)
+xypic-tut-pt: gpl (unverified)
+hyphen-arabic: not-in-catalogue
+hyphen-base: not-in-catalogue
+hyphen-basque: not-in-catalogue
+hyphen-bulgarian: not-in-catalogue
+hyphen-coptic: not-in-catalogue
+hyphen-croatian: not-in-catalogue
+hyphen-czechslovak: not-in-catalogue
+hyphen-danish: not-in-catalogue
+hyphen-dutch: not-in-catalogue
+hyphen-esperanto: not-in-catalogue
+hyphen-estonian: not-in-catalogue
+hyphen-finnish: not-in-catalogue
+hyphen-french: not-in-catalogue
+hyphen-german: not-in-catalogue
+hyphen-greek: not-in-catalogue
+hyphen-hungarian: not-in-catalogue
+hyphen-ibycus: not-in-catalogue
+hyphen-icelandic: not-in-catalogue
+hyphen-indonesian: not-in-catalogue
+hyphen-interlingua: not-in-catalogue
+hyphen-italian: not-in-catalogue
+hyphen-latin: not-in-catalogue
+hyphen-mongolian: not-in-catalogue
+hyphen-norwegian: not-in-catalogue
+hyphen-pinyin: not-in-catalogue
+hyphen-polish: not-in-catalogue
+hyphen-portuguese: not-in-catalogue
+hyphen-romanian: not-in-catalogue
+hyphen-russian: not-in-catalogue
+hyphen-serbian: not-in-catalogue
+hyphen-slovene: not-in-catalogue
+hyphen-spanish: not-in-catalogue
+hyphen-swedish: not-in-catalogue
+hyphen-turkish: not-in-catalogue
+hyphen-ukenglish: not-in-catalogue
+hyphen-ukrainian: not-in-catalogue
+hyphen-usorbian: not-in-catalogue
+hyphen-welsh: not-in-catalogue
+lib-freetype2: not-in-catalogue
+lib-geturl: not-in-catalogue
+lib-gnu: not-in-catalogue
+lib-md5: not-in-catalogue
+lib-regex: not-in-catalogue
+lib-texmfmp: not-in-catalogue
+lib-zlib: not-in-catalogue
+scheme-basic: not-in-catalogue
+scheme-context: not-in-catalogue
+scheme-full: not-in-catalogue
+scheme-gust: not-in-catalogue
+scheme-gutenberg: not-in-catalogue
+scheme-mactex: not-in-catalogue
+scheme-medium: not-in-catalogue
+scheme-minimal: not-in-catalogue
+scheme-omega: not-in-catalogue
+scheme-tetex: not-in-catalogue
+scheme-xml: not-in-catalogue
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-base-bin.mime
+++ texlive-bin-2007.dfsg.2/debian/texlive-base-bin.mime
@@ -0,0 +1 @@
+application/x-dvi; /usr/bin/xdvi %s; description=TeX DVI; test=test -n "$DISPLAY"; nametemplate=%s.dvi; priority=5
--- texlive-bin-2007.dfsg.2.orig/debian/README.Debian
+++ texlive-bin-2007.dfsg.2/debian/README.Debian
@@ -0,0 +1,48 @@
+README TeX live for Debian
+==========================
+
+First of all, if you need help with TeX on Debian, ie with respect to 
+file placement, configuration options, etc, please see the document
+	TeX-on-Debian
+in the tex-common package, which can be found in 
+	/usr/share/doc/tex-common/
+in the pdf, txt, and html format.
+
+This file contains additional information specific to TeX live.
+
+
+Differences to TeX live (upstream)
+----------------------------------
+
+Several parts of TeX Live have not been included into the Debian packages,
+mostly due to licensing issues (e.g., XyMTeX, which is not redistributable,
+or ppower4 which needs a jar file where sources are not provided).
+
+Some collection are not packaged, as the packages they contain are already
+in Debian, or should be packaged separately. Furthermore, some TeX packages
+are excluded from the debian packages out of the same reasons:
+already in Debian (incomplete list):
+	cm-super, texinfo, preview, lcdf-typetools, passivetex, tex4ht,
+	jadetex, xmltex, tipa, t1utils, prosper, tpslifonts
+	CJK, arphic, c90enc, cns, garuda, norasi, uhc, wadalab,
+	beamer, pgf, xcolor, lacheck, dvipdfmx, lm, dvi2tty, sanskrit
+	musixps, musixtex, musixflx, musixlyr, texpower, tpslifonts
+should be packages independently
+	collection-psutils, collection-ttfutils, collection-graphicstools
+collections gone because the containing TeX packages are in Debian
+	collection-langarab (would have been texlive-lang-arab)
+		replaced by arabtex
+	collection-htmlxml (would have been texlive-htmlxml)
+		replaced by xmltex, jadetex, passivetex, tex4ht
+	collection-langcjk (would have been texlive-lang-cjk)
+		replaced by latex-cjk-all
+
+If a package is removed from a collection/Debian package due to the
+existence of an equivalent package in Debian, the collection/Debian package
+depends on the other package, so no functionality is lost.
+
+For disappearing whole collections this is not possible, but the metapackage
+`texlive-full' depends on all the necessary items.
+
+
+$Id: README.Debian 3104 2007-09-25 11:05:08Z preining $
--- texlive-bin-2007.dfsg.2.orig/debian/lintian.override
+++ texlive-bin-2007.dfsg.2/debian/lintian.override
@@ -0,0 +1,26 @@
+zero-byte-file-in-doc-directory
+extra-license-file
+script-not-executable
+wrong-name-for-upstream-changelog
+texlive-lang-german: spelling-error-in-description german German
+texlive-fonts-recommended: unusual-interpreter ./usr/share/texmf-texlive/source/fonts/fpl/fpl/TeXPalladioL-BoldItalicOsF.pe #!fontforge
+texlive-fonts-recommended: unusual-interpreter ./usr/share/texmf-texlive/source/fonts/fpl/fpl/TeXPalladioL-BoldOsF.pe #!fontforge
+texlive-fonts-recommended: unusual-interpreter ./usr/share/texmf-texlive/source/fonts/fpl/fpl/TeXPalladioL-ItalicOsF.pe #!fontforge
+texlive-fonts-recommended: unusual-interpreter ./usr/share/texmf-texlive/source/fonts/fpl/fpl/TeXPalladioL-SC.pe #!fontforge
+texlive-fonts-recommended: unusual-interpreter ./usr/share/texmf-texlive/source/fonts/hfbright/simplify-rename.pe #!pfaedit
+texlive-base source: maintainer-script-lacks-debhelper-token debian/common.functions.preinst
+texlive-base source: maintainer-script-lacks-debhelper-token debian/common.functions.postinst
+texlive-base source: maintainer-script-lacks-debhelper-token debian/common.functions.postrm
+texlive-bin source: maintainer-script-lacks-debhelper-token debian/common.functions.preinst
+texlive-bin source: maintainer-script-lacks-debhelper-token debian/common.functions.postinst
+texlive-bin source: maintainer-script-lacks-debhelper-token debian/common.functions.postrm
+texlive-lang source: maintainer-script-lacks-debhelper-token debian/common.functions.preinst
+texlive-lang source: maintainer-script-lacks-debhelper-token debian/common.functions.postinst
+texlive-lang source: maintainer-script-lacks-debhelper-token debian/common.functions.postrm
+texlive-extra source: maintainer-script-lacks-debhelper-token debian/common.functions.preinst
+texlive-extra source: maintainer-script-lacks-debhelper-token debian/common.functions.postinst
+texlive-extra source: maintainer-script-lacks-debhelper-token debian/common.functions.postrm
+texlive-doc source: maintainer-script-lacks-debhelper-token debian/common.functions.preinst
+texlive-doc source: maintainer-script-lacks-debhelper-token debian/common.functions.postinst
+texlive-doc source: maintainer-script-lacks-debhelper-token debian/common.functions.postrm
+tetex-base: maintainer-script-needs-depends-on-ucf postinst
--- texlive-bin-2007.dfsg.2.orig/debian/tpm2debcommon2008.pm
+++ texlive-bin-2007.dfsg.2/debian/tpm2debcommon2008.pm
@@ -0,0 +1,948 @@
+#!/usr/bin/perl
+#
+# tpm2deb-common.pl
+# machinery to create debian packages from TeX Live depot
+# (c) 2005, 2006 Norbert Preining
+#
+# $Id: tpm2debcommon.pm 3270 2008-02-03 18:18:57Z frank $
+#
+# configuration is done via the file tpm2deb.cfg
+#
+#
+# please see the README file in the pkg-texlive svn repository of the
+# debian-tex project on alioth.debian.org
+
+package tpm2debcommon2008;
+use Exporter ();
+@ISA = qw( Exporter );
+@EXPORT_OK = qw (
+    
+    %TeXLive 
+
+	build_data_hash load_collection_tpm_data check_consistency
+	initialize_config_file_data is_blacklisted get_all_files 
+	get_all_executes myopen mycopy ismember populate_TpmData_from_dump
+    dump_tpm_data store_tpm
+);
+@EXPORT = @EXPORT_OK;
+
+# keys(%TeXLive{$package}) = extra_format, uploaders, section,
+#       standards, build_dep_indep, build_dep, priority, description, title,
+#       license, remotefiles, sourcefiles, runfiles, docfiles, binfiles,
+#       realtype, type, replaces, provides, recommends, suggests,
+#       conflicts, depends, includedpackages, executes
+#
+# keys(%Config) = 
+#                 add_execute, title, description, depends, conflicts,
+#                 suggests, recommends provides, maintainer
+
+use strict;
+no strict 'refs';
+use warnings;
+no warnings 'uninitialized';
+
+
+#use Strict;
+use Getopt::Long;
+use File::Basename;
+use File::Copy;
+use File::Path;
+use File::Temp qw/ tempfile tempdir /;
+use Storable;
+## not needed, atm we are calling eperl binary 
+# use Parse::ePerl;
+#use XML::DOM;
+use Cwd;
+#use FileUtils qw(canon_dir cleandir make_link newpath member
+#		 normalize substitute_var_val dirname diff_list remove_list
+#		 rec_rmdir sync_dir walk_dir start_redirection stop_redirection);
+use Tpm;
+
+# for debuging
+# use Data::Dumper;
+
+#
+
+our (%TeXLive);
+our (%Config,%TpmData);
+our %TexmfTreeOfType = ( "TLCore" => "texmf",
+ 						"Documentation" => "texmf-doc",
+ 						"Package" => "texmf-dist");
+our @TpmCategories = keys %TexmfTreeOfType;
+our %TypeOfTexmfTree = reverse %TexmfTreeOfType;
+
+# pre set $opt_master to ./LocalTPM which contains also the Tools dir
+# this is set in the main script, and changed with commandline option.
+# should it maybe be deleted here?
+
+my $opt_debug;
+my $opt_onlyscripts;
+my $Master;
+sub use_global_vars {
+  $opt_debug = $main::opt_debug;
+  $opt_onlyscripts = $main::opt_onlyscripts;
+  $Master = $main::Master;
+}
+
+
+sub populate_TpmData_from_dump {
+  my $datafile = $_[0];
+  my $tpmdataref = retrieve($datafile);
+  %TpmData = %{$tpmdataref};
+}
+
+sub build_data_hash {
+	# local functions
+	sub get_type {
+		my ($type_slash_tpmname) = @_;
+		$type_slash_tpmname =~ m#^(.*)/#;
+		return($1);
+	}
+	sub get_name {
+		my ($type_slash_tpmname) = @_;
+		$type_slash_tpmname =~ m#/(.*)$#;
+		return($1);
+	}
+	sub tpm2debname {
+		my @list_of_debnames =();
+		foreach my $tpm_spec (@_) {
+			my $tpm_name = get_name($tpm_spec);
+			my $tpm_type = get_type($tpm_spec);
+# 			my $realtype = $subtype;
+			if (defined($Config{'name_mapping'}{$tpm_name})) {
+				push @list_of_debnames, $Config{'name_mapping'}{$tpm_name};
+			} else {
+				push @list_of_debnames, $tpm_name;
+			};
+		}
+		return(@list_of_debnames);
+	}
+	# start real work
+	print "Building data hash ...\n";
+	#
+	# we now build the information used for building the packages
+	# this should merge the tpm data and the config file data
+	# after this we check on consistency
+	#
+	# The data will be stored in %TeXLive{'binary'}{$package}{'item'}
+	# where item is in: depend, suggest, conflict, execute, description
+	# title, packages, docfiles, binfiles, runfiles, sourcefiles,
+	# remotefiles, tltype, license for binary packages, and in
+	# %TeXLive{'source'}{$package}{'item'} .... for source packages.
+	#
+	# Note that the keys in %TeXLive are *different* package names than
+	# the collection names!
+	#
+	# First the binary part
+	foreach my $tl_type ('TLCore', 'Documentation', 'Package') {
+		foreach my $coll (keys %{$TpmData{$tl_type}}) {
+			if (is_blacklisted($coll,"")) { next; }
+			my ($bin_pkg) = tpm2debname("$tl_type/$coll");
+			my $realtype = $tl_type;
+			if ($tl_type eq "TLCore") {
+				if ($coll =~ /^bin-(.*)$/) { $realtype = "Package"; }
+				if ($coll =~ /^hyphen-(.*)$/) { $realtype = "Package"; }
+				if ($coll =~ /^lib-(.*)$/) { $realtype = "Package"; }
+			}
+			$TeXLive{'binary'}{$bin_pkg}{'type'}        = $realtype;
+			$TeXLive{'binary'}{$bin_pkg}{'realtype'}    = $tl_type;
+			if ($tl_type eq "Documentation") { $TeXLive{'binary'}{$bin_pkg}{'type'} = "Package"; }
+			$TeXLive{'binary'}{$bin_pkg}{'binfiles'}    = $TpmData{$tl_type}{$coll}{'BinFiles'};
+			$TeXLive{'binary'}{$bin_pkg}{'docfiles'}    = $TpmData{$tl_type}{$coll}{'DocFiles'};
+			$TeXLive{'binary'}{$bin_pkg}{'runfiles'}    = $TpmData{$tl_type}{$coll}{'RunFiles'};
+			$TeXLive{'binary'}{$bin_pkg}{'sourcefiles'} = $TpmData{$tl_type}{$coll}{'SourceFiles'};
+			$TeXLive{'binary'}{$bin_pkg}{'remotefiles'} = $TpmData{$tl_type}{$coll}{'RemoteFiles'};
+			$TeXLive{'binary'}{$bin_pkg}{'license'}     = $TpmData{$tl_type}{$coll}{'License'};
+			# items that can be overwritten by the configuration file
+			$TeXLive{'binary'}{$bin_pkg}{'title'} =
+				$Config{'title'}{$bin_pkg} ? 
+					$Config{'title'}{$bin_pkg} : 
+					$TpmData{$tl_type}{$coll}{'Title'};
+			$TeXLive{'binary'}{$bin_pkg}{'description'} =
+				$Config{'description'}{$bin_pkg} ?
+					$Config{'description'}{$bin_pkg} : 
+					$TpmData{$tl_type}{$coll}{'Description'};
+			#
+			# executes
+			#
+			my @installation = @{$TpmData{$tl_type}{$coll}{'Installation'}};
+			my @executes = ();
+			if (@installation) {
+				for (my $i = 0; $i <= $#installation; $i++) {
+					my %execute = %{$installation[$i]};
+					my $execute = "";
+					foreach my $attr (sort keys %execute) {
+						$execute .= "$attr=$execute{$attr} ";
+					}
+					if (grep(/$execute/,@executes) == 0) {
+						push (@executes, $execute);
+					}
+				}
+			}
+			if (defined($Config{'add_execute'}{$bin_pkg})) {
+				foreach my $e (@{$Config{'add_execute'}{$bin_pkg}}) {
+					if (grep(/$e/,@executes) == 0) {
+						push (@executes, $e);
+					}
+				}
+			}
+			$TeXLive{'binary'}{$bin_pkg}{'executes'} = \@executes;
+			#
+			# included packages
+			#
+			my @requires = @{$TpmData{$tl_type}{$coll}{'Package'}};
+			my @packs = ();
+			foreach my $required_tpm (@requires) {
+# 				my $st = get_type($required_tpm);
+				my $tpm_name = get_name($required_tpm);
+				#
+				# if the package is moved somewhere else, ignore it
+				if (defined($Config{'moved_to'}{$tpm_name})) { 
+					next; 
+				}
+				if (!is_blacklisted($tpm_name,$bin_pkg)) { push @packs, $tpm_name; } 
+			}
+			if (defined($Config{'extra_packages'}{$bin_pkg})) {
+				push @packs, @{$Config{'extra_packages'}{$bin_pkg}};
+			}
+			$TeXLive{'binary'}{$bin_pkg}{'includedpackages'} = \@packs;
+			#
+			# depends
+			#
+			# we have to collect the depends from the config file and the 
+			# direct tpm dependencies
+			my @depends = tpm2debname(@{$TpmData{$tl_type}{$coll}{'TLCore'}});
+			if ($bin_pkg ne "texlive-common") {
+				push @depends, "texlive-common (>= $TeXLive{'all'}{'tl_common_version'})";
+			}
+			#
+			if (defined($Config{'depends'}{$bin_pkg})) {
+				push @depends, @{$Config{'depends'}{$bin_pkg}};
+			}
+			# what about ${shlibs:Depends}
+			$TeXLive{'binary'}{$bin_pkg}{'depends'} = \@depends;
+			#
+			# other relations
+			#
+			if (defined($Config{'conflicts'}{$bin_pkg})) {
+				$TeXLive{'binary'}{$bin_pkg}{'conflicts'} = [ @{$Config{'conflicts'}{$bin_pkg}} ];
+			}
+			if (defined($Config{'suggests'}{$bin_pkg})) {
+				$TeXLive{'binary'}{$bin_pkg}{'suggests'} = [ @{$Config{'suggests'}{$bin_pkg}} ];
+			}
+			if (defined($Config{'recommends'}{$bin_pkg})) {
+				$TeXLive{'binary'}{$bin_pkg}{'recommends'} = [ @{$Config{'recommends'}{$bin_pkg}} ];
+			}
+			if (defined($Config{'provides'}{$bin_pkg})) {
+				$TeXLive{'binary'}{$bin_pkg}{'provides'} = [ @{$Config{'provides'}{$bin_pkg}} ];
+			}
+			if (defined($Config{'replaces'}{$bin_pkg})) {
+				$TeXLive{'binary'}{$bin_pkg}{'replaces'} = [ @{$Config{'replaces'}{$bin_pkg}} ];
+			}
+			if (defined($Config{'bin-section'}{$bin_pkg})) {
+				$TeXLive{'binary'}{$bin_pkg}{'section'} = $Config{'bin-section'}{$bin_pkg};
+			}
+		}
+	}
+	# we do the doc splitting now
+	foreach my $coll (keys %{$TpmData{'TLCore'}}) {
+		if (is_blacklisted($coll,"")) { next; }
+		my ($bin_pkg) = tpm2debname("TLCore/$coll");
+		if (defined($Config{'docsplitting'}{$bin_pkg})) {
+			my $doc_pkg = "$bin_pkg-doc";
+			# first creat new bin package and add doc files
+
+			$TeXLive{'binary'}{$doc_pkg}{'section'} = "doc" ; 
+			$TeXLive{'binary'}{$doc_pkg}{'type'}        = 'TLCore';
+			$TeXLive{'binary'}{$doc_pkg}{'realtype'}    = 'TLCore';
+			# we don't want to move man pages!!!
+			my @p = ();
+			my @pd = ();
+			foreach my $f (@{$TeXLive{'binary'}{$bin_pkg}{'docfiles'}}) {
+				# the following is a hack but necessary
+				# we do move some files from doc dirs to non doc dirs using
+				# mapping;orig;move;target
+				# but these files are listed as doc-files we DONT want to move!
+				# In fact we should check for a pair
+				# 	$f:xxxx
+				# in @{$TeXLive{'all'}{'filemappings'}} and check that xxxx is 
+				# NOT a doc file ... but who cares ...
+				if (defined($TeXLive{'all'}{'file_map_actions'}{$f}) && 
+							($TeXLive{'all'}{'file_map_actions'}{$f} eq "move")) {
+					push @p, $f;
+				} else {
+					if ($f =~ m;texmf[^/]*/doc/man/man.*/.*;) {
+						push @p, $f;
+					} else {
+						push @pd, $f;
+					}
+				}
+			}
+			$TeXLive{'binary'}{$doc_pkg}{'docfiles'}    = [ @pd ];
+			$TeXLive{'binary'}{$bin_pkg}{'docfiles'} = [ @p ];
+			$TeXLive{'binary'}{$doc_pkg}{'license'}     = $TpmData{'TLCore'}{$coll}{'License'};
+			$TeXLive{'binary'}{$doc_pkg}{'title'} = "Documentation files for $bin_pkg";
+			$TeXLive{'binary'}{$doc_pkg}{'description'} = "This package provides the documentation for $bin_pkg";
+			# what else do we have to set here ????
+			#
+			# the doc package needs to depend on texlive-common, it
+			# doesn't get this dependency as ordinary packages do
+			$TeXLive{'binary'}{$doc_pkg}{'depends'} = 
+				[ @{$TeXLive{'binary'}{$doc_pkg}{'depends'}}, 
+				  "texlive-common (>= $TeXLive{'all'}{'tl_common_version'})" 
+				];
+			# add a recommends for the normal package on the doc pkg.
+			$TeXLive{'binary'}{$bin_pkg}{'recommends'} = [ @{$TeXLive{'binary'}{$bin_pkg}{'recommends'}}, "$bin_pkg-doc" ];
+			# add source mapping
+			my $srcpkg = $TeXLive{'binary'}{$bin_pkg}{'source_package'};
+			$TeXLive{'source'}{$srcpkg}{'binary_packages'} = [ @{$TeXLive{'source'}{$srcpkg}{'binary_packages'}}, $doc_pkg ];
+			#
+			# necessary relations from the config file
+			#
+			# we need texlive-common (for tex-common)
+			push @{$TeXLive{'binary'}{$doc_pkg}{'depends'}}, "texlive-common (>= $TeXLive{'all'}{'tl_common_version'})";
+			if (defined($Config{'depends'}{$doc_pkg})) {
+				$TeXLive{'binary'}{$doc_pkg}{'depends'} = [ @{$Config{'depends'}{$doc_pkg}} ];
+			}
+			if (defined($Config{'conflicts'}{$doc_pkg})) {
+				$TeXLive{'binary'}{$doc_pkg}{'conflicts'} = [ @{$Config{'conflicts'}{$doc_pkg}} ];
+			}
+			if (defined($Config{'suggests'}{$doc_pkg})) {
+				$TeXLive{'binary'}{$doc_pkg}{'suggests'} = [ @{$Config{'suggests'}{$doc_pkg}} ];
+			}
+			if (defined($Config{'recommends'}{$doc_pkg})) {
+				$TeXLive{'binary'}{$doc_pkg}{'recommends'} = [ @{$Config{'recommends'}{$doc_pkg}} ];
+			}
+			if (defined($Config{'provides'}{$doc_pkg})) {
+				$TeXLive{'binary'}{$doc_pkg}{'provides'} = [ @{$Config{'provides'}{$doc_pkg}} ];
+			}
+			if (defined($Config{'replaces'}{$doc_pkg})) {
+				$TeXLive{'binary'}{$doc_pkg}{'replaces'} = [ @{$Config{'replaces'}{$doc_pkg}} ];
+			}
+			#
+			# now we have to move all the DocFiles of all INCLUDED
+			# package/tpms into $bin_pkg and remove them from the original
+			# packages
+			#
+			# For an explanation of the code see above!
+			foreach my $incpkg (@{$TeXLive{'binary'}{$bin_pkg}{'includedpackages'}}) {
+				my @p = ();
+				my @pd = ();
+				foreach my $f (@{$TeXLive{'binary'}{$incpkg}{'docfiles'}}) {
+					if (defined($TeXLive{'all'}{'file_map_actions'}{$f}) && 
+								($TeXLive{'all'}{'file_map_actions'}{$f} eq "move")) {
+						push @p, $f;
+					} else {
+						if ($f =~ m;texmf[^/]*/doc/man/man.*/.*;) {
+							push @p, $f;
+						} else {
+							push @pd, $f;
+						}
+					}
+				}
+				$TeXLive{'binary'}{$doc_pkg}{'docfiles'}    = [ @{$TeXLive{'binary'}{$doc_pkg}{'docfiles'}}, @pd ];
+				$TeXLive{'binary'}{$incpkg}{'docfiles'} = [ @p ];
+			}
+		}
+	}
+	#
+	# Now for the source part
+	#
+	for my $srcpkg (@{$TeXLive{'all'}{'sources'}}) {
+		$TeXLive{'source'}{$srcpkg}{'uploaders'}   = 
+			$Config{'uploaders'}{$srcpkg}     ? 
+				$Config{'uploaders'}{$srcpkg} : $TeXLive{'all'}{'uploaders'};
+		$TeXLive{'source'}{$srcpkg}{'maintainer'}  = 
+			$Config{'maintainer'}{$srcpkg}    ? 
+				$Config{'maintainer'}{$srcpkg} : $TeXLive{'all'}{'maintainer'};
+		$TeXLive{'source'}{$srcpkg}{'priority'} = 
+			$Config{'priority'}{$srcpkg};
+		$TeXLive{'source'}{$srcpkg}{'build_dep'} = 
+			$Config{'build_dep'}{$srcpkg};
+		$TeXLive{'source'}{$srcpkg}{'build_dep_indep'} =
+			$Config{'build_dep_indep'}{$srcpkg};
+		$TeXLive{'source'}{$srcpkg}{'standards'} =
+			$Config{'standards'}{$srcpkg};
+ 		$TeXLive{'source'}{$srcpkg}{'section'} =
+			$Config{'section'}{$srcpkg};
+	}
+	# we let texlive-common CONFLICT with all texlive packages << then the 
+	# values set in latest-version
+	my @conflictpkgs = ();
+	foreach my $source_package (@{$TeXLive{'all'}{'sources'}}) {
+		foreach my $bin_pkg (@{$TeXLive{'source'}{$source_package}{'binary_packages'}}) {
+			push @conflictpkgs, "$bin_pkg (<< $TeXLive{'source'}{$source_package}{'latest_version'})";
+		}
+	}
+	# finally we let the package "texlive-full" depend on all texlive-* packages
+	my @allpkgs = ();
+	foreach my $source_package (@{$TeXLive{'all'}{'sources'}}) {
+		foreach my $bin_pkg (@{$TeXLive{'source'}{$source_package}{'binary_packages'}}) {
+			my $addthis = 1;
+			foreach my $depends_not (@{$Config{'depends_not'}{'texlive-full'}}) {
+				$addthis = 0 if ($bin_pkg eq $depends_not);
+			};
+# 			next if ($bin_pkg eq "texlive-full");
+# 			next if ($bin_pkg eq "texlive");
+# 			next if ($bin_pkg eq "texlive-lang-all");
+# 			next if ($bin_pkg eq "tetex-bin");
+# 			next if ($bin_pkg eq "tetex-base");
+# 			next if ($bin_pkg eq "tetex-extra");
+			$addthis && push @allpkgs, "$bin_pkg (>= $TeXLive{'source'}{$source_package}{'latest_version'})";
+		}
+	}
+
+	# Additional (meta)packages
+	$TeXLive{'all'}{'meta_packages'} = [ @{$Config{'add_packages'}} ];
+	foreach my $meta_package (@{$Config{'add_packages'}}) {
+		$TeXLive{'binary'}{$meta_package}{'type'} = "TLCore" ;
+
+		# Dependencies
+		if ($meta_package eq "texlive-full") {
+			$TeXLive{'binary'}{$meta_package}{'depends'}   = [ @{$Config{'depends'}{$meta_package}}, @allpkgs ];
+		} elsif ($meta_package eq "texlive-lang-all") {
+			my @foo = ();
+			foreach my $a (@allpkgs) {
+				if ($a =~ /^texlive-lang-/) { push @foo, $a; }
+			}
+			$TeXLive{'binary'}{$meta_package}{'depends'}   = [ @{$Config{'depends'}{$meta_package}}, @foo ];
+		} else {
+			$TeXLive{'binary'}{$meta_package}{'depends'}   = [ @{$Config{'depends'}{$meta_package}} ];
+		};
+		$opt_debug && print STDERR "metapackage: $meta_package, Depends: @{$TeXLive{'binary'}{$meta_package}{'depends'}}\n";
+		$TeXLive{'binary'}{$meta_package}{'suggests'}    = [ @{$Config{'suggests'}{$meta_package}} ];
+		$TeXLive{'binary'}{$meta_package}{'recommends'}  = [ @{$Config{'recommends'}{$meta_package}} ];
+		$TeXLive{'binary'}{$meta_package}{'replaces'}    = [ @{$Config{'replaces'}{$meta_package}} ];
+		if ($meta_package eq "texlive-common") {
+			$TeXLive{'binary'}{$meta_package}{'conflicts'}   = [ @{$Config{'conflicts'}{$meta_package}}, @conflictpkgs ];
+		} else {
+			$TeXLive{'binary'}{$meta_package}{'conflicts'}   = [ @{$Config{'conflicts'}{$meta_package}} ];
+		}
+	  
+		# Short and long description
+		$TeXLive{'binary'}{$meta_package}{'title'}       = $Config{'title'}{$meta_package};
+		$TeXLive{'binary'}{$meta_package}{'description'} = $Config{'description'}{$meta_package};
+		if (defined($Config{'bin-section'}{$meta_package})) {
+			$TeXLive{'binary'}{$meta_package}{'section'} = $Config{'bin-section'}{$meta_package};
+		}
+	}
+}
+
+sub load_collection_tpm_data {
+	# local functions
+	sub get_requires {
+		my ($tpm,$type) = @_;
+		my @tlcorereqlist = (); 
+		my @packagereqlist = ();
+		if ($type eq '') { 
+			$type = "all";
+		}
+		my $k = $tpm->category;
+		foreach my $e ($tpm->depends) {
+			if ($e =~ m/^(.*)\.ARCH$/) {
+				$e = "$1.i386-linux";
+			}
+			my $depcat = $::tlpdb->get_package($e)->category;
+			if ($k eq "Collection") {
+				if ($depcat eq "Collection") {
+					push @tlcorereqlist, $e;
+				} else {
+					push @packagereqlist, $e;
+				}
+			} else {
+				push @packagereqlist, $e;
+			}
+		}
+		if ($type eq '' || $type eq 'all') {
+			my %foo;
+			$foo{'TLCore'} = \@tlcorereqlist;
+			$foo{'Package'} = \@packagereqlist;
+			return(\%foo);
+		} elsif ($type eq 'TLCore') {
+			return(@tlcorereqlist);
+		} elsif ($type eq 'Package') {
+			return(@packagereqlist);
+		} else {
+			die("Don't know this type: $type!\n");
+		}
+	}
+	# start of real function
+	use_global_vars();
+	$::tlpdb = TeXLive::TLPDB->new ("root" => "$Master");
+	die("Cannot read tlpdb from $Master") unless $::tlpdb;
+	foreach my $p ($::tlpdb->list_packages) {
+		next if ($p =~ m/^00texlive/);
+		my $pkg = $::tlpdb->get_package($p);
+		die ("Cannot find $pkg in tlpdb, strange") unless $pkg;
+		my $shortn = $pkg->name;
+		my $t = $pkg->category;
+		if (($t eq 'TLCore') && ($shortn =~ m/^scheme-/)) { next ; }
+		$TpmData{$t}{$shortn}{'BinFiles'} = [ @{${$pkg->binfiles}{'i386-linux'}} ];
+		$TpmData{$t}{$shortn}{'DocFiles'} = [ $pkg->docfiles ];
+		$TpmData{$t}{$shortn}{'RunFiles'} = [ $pkg->runfiles ];
+		$TpmData{$t}{$shortn}{'SourceFiles'} = [ $pkg->srcfiles ];
+		$TpmData{$t}{$shortn}{'Title'} = $pkg->shortdesc;
+		# print "got title $TpmData{$t}{$shortn}{'Title'}\n";
+		$TpmData{$t}{$shortn}{'Description'} = $pkg->longdesc;
+		$TpmData{$t}{$shortn}{'License'} = $pkg->cataloguedata->{'license'};
+		my @foo = $pkg->executes;
+		$TpmData{$t}{$shortn}{'Installation'} = \@foo ;
+		my $alldeps = get_requires($pkg,'all');
+		my @incs = @{$alldeps->{'Package'}};
+		my @deps = @{$alldeps->{'TLCore'}};
+		$TpmData{$t}{$shortn}{'Package'} = \@incs;
+		$TpmData{$t}{$shortn}{'TLCore'} = \@deps;
+	}
+}
+
+sub check_consistency {
+	my %UsedPackages;
+	my $raiseerror = 0;
+	my @allincludedpkgs = ();
+	my %PackageToCollection;
+
+	print "Checking consistency ... \n";
+	#
+	# first go through all the collections and collect all included
+	# packages and check on double inclusion of packages
+	#
+	my %TLB = %{$TeXLive{'binary'}};
+	foreach my $collection (keys %TLB) {
+		if ($TLB{$collection}{'type'} ne "TLCore") { next; }
+		foreach my $tpm (@{$TLB{$collection}{'includedpackages'}}) {
+			$PackageToCollection{$tpm} = $collection;
+			push @allincludedpkgs, $tpm;
+			push (@{$UsedPackages{$tpm}},$collection);
+		}
+	}
+	my @badpacks = ();
+	foreach my $k (keys %UsedPackages) {
+		if (@{$UsedPackages{$k}} > 1) {
+			print STDERR "Double inclusion of $k:\n";
+			print STDERR "@{$UsedPackages{$k}}:\n";
+			push @badpacks, $k;
+		}
+	}
+	if ($#badpacks >= 0) {
+		#
+		# ujjeeee, a package is included more than once, STOP!!!
+		#
+		print ("ERROR double-inclusion @badpacks\n");
+		$raiseerror = 1;
+	}
+	#
+	# check for not included packages
+	#
+	my $binary_package;
+	foreach $binary_package (keys %TLB) {
+		if ($TLB{$binary_package}{'type'} ne "Package") { next; }
+		if (grep(/$binary_package/,@allincludedpkgs) == 0) {
+			print STDERR "ERROR not-covered $binary_package\n";
+			$raiseerror = 1;
+		}
+	}
+	#
+	# check for packages in packages which are not included or depended on
+	#
+	foreach my $c (keys %TLB) {
+		if ($TLB{$binary_package}{'type'} ne "TLCore") { next; }
+		foreach $binary_package (@{$TLB{$c}{'includedpackages'}}) {
+			foreach my $subdep (@{$TLB{$binary_package}{'includedpackages'}}) {
+				# $binary_package depends on $subdep, we have to check wether
+				# either $subdep is also included in $c
+				# or $c depends on the collection $subdep is in
+				my $subdepcoll = $PackageToCollection{$subdep};
+				# the package is included in the parent collection, ok
+				if ($subdepcoll eq $c) { next ; }
+				# the parent collection depends on the collection
+				# including the subdep by tpm depends
+				if ($subdepcoll eq "texlive-base-bin") { next; }
+				if (ismember($subdepcoll,@{$TLB{$c}{'depends'}})) { next; }
+				# ujeee, cross wise inclusion does not work
+				print STDERR "ERROR diamond\n";
+				print STDERR "There is a problem here:\n";
+				print STDERR "$c includes $binary_package\n";
+				print STDERR "\t$binary_package depends on $subdep\n";
+				print STDERR "\t$subdep is NOT included in $c\n";
+				print STDERR "$subdep is included in $subdepcoll\n";
+				print STDERR "$c does NOT depend on $subdepcoll\n";
+				print STDERR "Please fix this problem!\n";
+				$raiseerror = 1;
+			}
+		}
+	}
+	if ($raiseerror) { exit 1; }
+	print " ... tpm files and config file are consistent, good!\n";
+}
+
+
+sub initialize_config_file_data {
+	my ($cfgfile) = @_;
+	use_global_vars();
+	print "Start loading config file ...\n";
+	open(CFGFILE,"<$cfgfile") or die "Cannot open $cfgfile\n";
+	while (<CFGFILE>) {
+		if (m/^#/) { 
+			next ; 
+		}
+		chomp;
+		my @foo;
+		my ($type, $a, @rest) = split ";";
+		$opt_debug && print STDERR  "type=$type, a=$a, ";
+		if ($type eq "depends") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'depends'}{$a} = [ @{$Config{'depends'}{$a}}, split(/[ \t]*,[ \t]*/,$b) ];
+			next;
+		}
+		if ($type eq "recommends") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'recommends'}{$a} = [ @{$Config{'recommends'}{$a}}, split(/[ \t]*,[ \t]*/,$b) ];
+			next;
+		}
+		if ($type eq "provides") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'provides'}{$a} = [ @{$Config{'provides'}{$a}}, split(/[ \t]*,[ \t]*/,$b) ];
+			next;
+		}
+		if ($type eq "suggests") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'suggests'}{$a} = [ @{$Config{'suggests'}{$a}}, split(/[ \t]*,[ \t]*/,$b) ];
+			next;
+		}
+		if ($type eq "conflicts") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'conflicts'}{$a} = [ @{$Config{'conflicts'}{$a}}, split(/[ \t]*,[ \t]*/,$b) ];
+			next;
+		}
+		if ($type eq "replaces") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'replaces'}{$a} = [ @{$Config{'replaces'}{$a}}, split(/[ \t]*,[ \t]*/,$b) ];
+			next;
+		}
+		if ($type eq "execute") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'add_execute'}{$a} = [ @{$Config{'add_execute'}{$a}}, "$b" ];
+			next;
+		}
+		if ($type eq "mapping") {
+			my ($b,$c) = @rest;
+			$opt_debug && print STDERR  "b=$b, c=$c.\n";
+			push @{$TeXLive{'all'}{'filemappings'}}, "$a:$c";
+			$TeXLive{'all'}{'file_map_actions'}{$a} = $b;
+			if (($b eq "config-link") || ($b eq "config-remap")) {
+				push @{$TeXLive{'all'}{'config-files'}}, $c;
+			}
+			if ($b eq "config-copy") {
+				$a =~ s#texmf-dist#texmf#;
+				$a =~ s#texmf-doc#texmf#;
+				$a =~ s#texmf/##;
+				push @{$TeXLive{'all'}{'config-files'}}, "$c/$a";
+			}
+			next;
+		}
+		if ($type eq "blacklist") {
+			if ($a eq "file") {
+				my ($b) = @rest;
+				$opt_debug && print STDERR  "b=$b.\n";
+				push @{$TeXLive{'all'}{'file_blacklist'}}, $b;
+			} elsif ($a eq "tpm") {
+				my ($b,$c) = @rest;
+				$opt_debug && print STDERR  "b=$b, c=$c.\n";
+				$Config{'package_blacklist'}{$b} = "$c";
+			} else {
+				print STDERR "tpm2deb.cfg: Unknown directive: $_. Exiting!\n";
+				exit 1;
+			}
+			next;
+		}
+		if ($type eq "source") {
+			push @{$TeXLive{'all'}{'sources'}}, $a;
+			next;
+		}
+		if ($type eq "move") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			# move tpm $a to binary package $b
+			$Config{'moved_to'}{$a} = $b;
+			$Config{'extra_packages'}{$b} = [ @{$Config{'extra_packages'}{$b}}, $a ];
+			next;
+		}
+		if ($type eq "extra") {
+			my ($b,$c,$d) = @rest;
+			if ($a ne "format") {
+				print STDERR "tpm2deb.cfg: Unknown directive: $_. Exiting!\n";
+				exit 1;
+			}
+			$opt_debug && print STDERR  "b=$b, c=$c, d=$d.\n";
+			$TeXLive{'binary'}{$c}{'extra_format'}{$b} = $d;
+			next;
+		}
+		if ($type eq "arch") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$TeXLive{'source'}{$a}{'architecture'} = $b;
+			next;
+		}
+		if ($type eq "name") {
+			my ($b,$c) = @rest;
+			$opt_debug && print STDERR  "b=$b, c=$c.\n";
+			$Config{'name_mapping'}{$a} = $b;
+			$TeXLive{'binary'}{$b}{'source_package'} = $c;
+			$TeXLive{'source'}{$c}{'binary_packages'} = [ @{$TeXLive{'source'}{$c}{'binary_packages'}}, $b ];
+			next;
+		}
+		if ($type eq "special") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			push @{$TeXLive{'all'}{'special_actions_config'}}, "$a:$b";
+			next;
+		}
+		if ($type eq "description") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			# push the next line into the description string, but
+			# avoid to get a "use of uninitialized value in concat..."
+			$Config{'description'}{$a} = 
+				($Config{'description'}{$a} ? $Config{'description'}{$a} : "") 
+				. "$b\n";
+			next;
+		}
+		if ($type eq "title") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'title'}{$a} = "$b";
+			next;
+		}
+		if ($type eq "docsplitting") {
+			$opt_debug && print STDERR  "\n";
+			$Config{'docsplitting'}{$a} = 1;
+			next;
+		}
+		if ($type eq "build-dep") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'build_dep'}{$a} = "$b";
+			next;
+		}
+		if ($type eq "build-dep-indep") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'build_dep_indep'}{$a} = "$b";
+			next;
+		}
+		if ($type eq "texlive-common-version") {
+			$TeXLive{'all'}{'tl_common_version'} = "$a";
+			next;
+		}
+		if ($type eq "latest-version") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$TeXLive{'source'}{$a}{'latest_version'} = "$b";
+			next;
+		}
+		if ($type eq "maintainer") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			if ("$a" eq "*") {
+				$TeXLive{'all'}{'maintainer'} = "$b";
+			} else {
+				$Config{'maintainer'}{$a} = "$b";
+			}
+			next;
+		}
+		if ($type eq "priority") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			if ("$a" eq "*") {
+				$TeXLive{'all'}{'priority'} = "$b";
+			} else {
+				$Config{'priority'}{$a} = "$b";
+			}
+			next;
+		}
+		if ($type eq "uploaders") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			if ("$a" eq "*") {
+				$TeXLive{'all'}{'uploaders'} = "$b";
+			} else {
+				$Config{'uploaders'}{$a} = "$b";
+			}
+			next;
+		}
+		if ($type eq "section") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			if ("$a" eq "*") {
+				$TeXLive{'all'}{'section'} = "$b";
+			} else {
+				$Config{'section'}{$a} = "$b";
+			}
+			next;
+		}
+		if ($type eq "bin-section") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			$Config{'bin-section'}{$a} = "$b";;
+			next;
+		}
+		if ($type eq "standards") {
+			my ($b) = @rest;
+			$opt_debug && print STDERR  "b=$b.\n";
+			if ("$a" eq "*") {
+				$TeXLive{'all'}{'standards'} = "$b";
+			} else {
+				$Config{'standards'}{$a} = "$b";
+			}
+			next;
+		}
+		if ($type eq "addpackages") {
+			@{$Config{'add_packages'}} = @rest;
+			$opt_debug && print STDERR "\nAdditional packages: @{$Config{'add_packages'}}\n";
+			next;
+		}
+		if ($type eq "dependsnot") {
+			@{$Config{'depends_not'}{$a}} = @rest;
+			$opt_debug && print STDERR "Dropped depends of $a on @{$Config{'depends_not'}{$a}}\n";
+			next;
+		}
+		print STDERR "tpm2deb.cfg: Unknown directive: $type. Exiting!\n"; 
+		exit 1;
+	}
+	close(CFGFILE);
+	print " ... done\n";
+}
+
+
+sub is_blacklisted {
+	my ($tpm,$coll) = @_;
+	# blacklist check
+	# either there is no blacklist entry, then it is ok
+	# if there is a blacklist entry and it is *, blacklist it
+	# if it is not *, and the $coll is not "", then match it
+	if (defined($Config{'package_blacklist'}{$tpm}) &&
+			(($Config{'package_blacklist'}{$tpm} eq "*") ||
+			 (($coll ne "") && ($Config{'package_blacklist'}{$tpm} =~ m/$coll/)))) {
+		return(1);
+	} else {
+		return(0);
+	}
+}
+
+sub get_all_files {
+	my ($entry,$reclevel) = @_;
+	my @requires = @{$TeXLive{'binary'}{$entry}{'includedpackages'}};
+	my %files;
+	#
+	$files{'BinFiles'} = \@{$TeXLive{'binary'}{$entry}{'binfiles'}};
+	$files{'DocFiles'} = \@{$TeXLive{'binary'}{$entry}{'docfiles'}};
+	$files{'RunFiles'} = \@{$TeXLive{'binary'}{$entry}{'runfiles'}};
+	$files{'SourceFiles'} = \@{$TeXLive{'binary'}{$entry}{'sourcefiles'}};
+	$files{'RemoteFiles'} = \@{$TeXLive{'binary'}{$entry}{'remotefiles'}};
+	if ($reclevel > 0) {
+		foreach my $r (@requires) {
+			$opt_debug && print STDERR  "  package " . $r . "\n";
+			my %foo = %{&get_all_files($r,$reclevel-1)};
+			push @{$files{'BinFiles'}}, @{$foo{'BinFiles'}};
+			push @{$files{'DocFiles'}}, @{$foo{'DocFiles'}};
+			push @{$files{'RunFiles'}}, @{$foo{'RunFiles'}};
+			push @{$files{'SourceFiles'}}, @{$foo{'SourceFiles'}};
+			push @{$files{'RemoteFiles'}}, @{$foo{'RemoteFiles'}};
+		}
+	}
+	return(\%files);
+}
+
+sub get_all_executes {
+	my ($entry,$reclevel) = @_;
+	my @requires = @{$TeXLive{'binary'}{$entry}{'includedpackages'}};
+	my %bar;
+	my @executes;
+	#
+	@executes = @{$TeXLive{'binary'}{$entry}{'executes'}};
+	if ($reclevel > 0) {
+		foreach my $r (@requires) {
+			$opt_debug && print STDERR  "  package " . $r . "\n";
+			my @foo = get_all_executes($r,$reclevel-1);
+			push @executes, @foo;
+		}
+	}
+	foreach (@executes) {
+		$bar{$_} = 1;
+	}
+	return(keys %bar);
+}
+ 
+sub myopen {
+	my ($a, $fn) = @_;
+	open($a, $fn) or die "Cannot open $fn: $!\n";
+}
+
+sub mycopy {
+	my ($src,$dest) = @_;
+	&mkpath(dirname($dest));
+# 	system("/bin/cp -a $src $dest 2>/dev/null") == 0
+	my $cp_cmdline = "/bin/cp -a $src $dest" . ( $opt_debug ? "" : " 2>/dev/null");
+	if ($opt_onlyscripts == 0) {
+		system($cp_cmdline) == 0
+			or do {
+				print STDERR "$cp_cmdline\n";
+				die ("missing: $src\n");
+		};
+	};
+}
+
+sub ismember {
+	my ($a, @rest) = @_;
+	foreach my $i (@rest) {
+		if ($a eq $i) { return 1; }
+	}
+	return 0;
+}
+
+#####################################
+sub dump_tpm_data {
+	print "Dumping TpmData\n\n";
+	foreach my $t ('Collection', 'TLCore', 'Documentation', 'Package') {
+		print "Dumping $t:\n";
+		my %foo = %{$TpmData{$t}};
+		foreach my $p (keys %foo) {
+			print "$p:\n";
+			print "\tbinfiles: @{$TpmData{$t}{$p}{'BinFiles'}}<<<\n";
+			print "\trunfiles: @{$TpmData{$t}{$p}{'RunFiles'}}<<<\n";
+			print "\tdocfiles: @{$TpmData{$t}{$p}{'DocFiles'}}<<<\n";
+			print "\tsourcefiles: @{$TpmData{$t}{$p}{'SourceFiles'}}<<<\n";
+			print "\tremotefiles: @{$TpmData{$t}{$p}{'RemoteFiles'}}<<<\n";
+			print "\ttitle: $TpmData{$t}{$p}{'Title'}\n";
+			print "\tDescription: $TpmData{$t}{$p}{'Description'}\n";
+			print "\tLicense: $TpmData{$t}{$p}{'License'}\n";
+			print "\tInstallation: @{$TpmData{$t}{$p}{'Installation'}}\n";
+			print "\tDep-Package: @{$TpmData{$t}{$p}{'Package'}}\n";
+			print "\tDep-TLCore: @{$TpmData{$t}{$p}{'TLCore'}}\n";
+		}
+	}
+}
+
+sub store_tpm {
+	my ($fn) = @_;
+	print "Storing TpmData into $fn ...\n";
+	store(\%TpmData, $fn) or die "Can't store TpmData in $fn!\n";
+	print "  ...done\n";
+}
+
+
+1;
+
+### Local Variables:
+### perl-indent-level: 4
+### tab-width: 4
+### indent-tabs-mode: t
+### End:
+# vim:set tabstop=4: #
--- texlive-bin-2007.dfsg.2.orig/debian/libkpathsea-dev.README
+++ texlive-bin-2007.dfsg.2/debian/libkpathsea-dev.README
@@ -0,0 +1,24 @@
+Why a new soname of libkpathsea in teTeX 3.0?
+---------------------------------------------
+
+We're just quoting Olaf Weber, the author of web2c. The full message can be
+found on:
+http://lists.debian.org/debian-tetex-maint/2004/03/msg00181.html
+
+"libkpathsea moved from using klibtool (a web2c-specific libtool-like hack)
+to libtool. As a result it acquired a new soname.
+libkpathsea was not designed to work well as a shared library, and has
+numerous flaws in that area -- in particular, too many internals are
+exposed, and too much is hard-coded."
+
+Olaf does not expect too many changes in the API of the libkpathsea between
+teTeX 2.0.2 and 3.0 so just relinking the programs should be sufficient.
+However that is not really predictable.
+
+"So at present my advice is that it's better to be safe than sorry, and
+enforce that the version of libkpathsea matches the program's version."
+
+A new redesigned libkpathsea, which is really a shared lib, is on his TODO
+list, but he can't say when it will be released.
+
+ -- Frank Küster <frank@debian.org>, Wed Aug 24 12:54:11 2005
--- texlive-bin-2007.dfsg.2.orig/debian/CHANGES.packaging
+++ texlive-bin-2007.dfsg.2/debian/CHANGES.packaging
@@ -0,0 +1,1985 @@
+#
+# ChangeLog for tpm2deb.pl and relatives
+#
+# $Id: CHANGES.packaging 3445 2008-06-26 21:15:29Z preining $
+#
+
+release texlive-doc 2007.dfsg.1-1
+release texlive-bin 2007.dfsg.2-3
+
+2008-06-26
+
+  * [bin] add roadmap.fig to fontinst (patch add-missing-fontinst-source)
+    (Closes: #482915) (urgency medium, RC bug) [np]
+
+release texlive-base 2007.dfsg.1-2
+release texlive-bin 2007.dfsg.2-2
+
+2008-06-25
+
+  * [doc] blacklist catalogue.tpm, the source is not present and in addition
+    not completely free. So we drop the Catalogue, as it is also dropped
+    upstream for TL2008. (Closes: #487149) [np]
+  * [base] fix texlive-base.postinst(.pre) to actually add the comment and not
+    echo it to stderr, thanks Julien Cristau for the patch (Closes: #487947)
+  * [bin] do not install fmtutil.cnf in texmf-texlive/web2c (Closes: #488035)
+  * [bin] use the local keyword in a policy-compliant way (rebuild packages
+    with fix from 2008-06-23) (Closes: #488023)
+
+release texlive-base 2007.dfsg.1-1
+
+2008-06-23
+  * [common.functions.preinst] use the local keyword in a policy-compliant
+    way [fk]
+
+2008-06-23
+  * [extra] add texlive-pstricks recommends texlive-extra-utils for pdfcrop
+    (recommends because pdf is getting more and more over)
+    (Closes Ubuntu Bug 145407) [np]
+  * [base] tetex-extra depends on texlive now, not on tetex-bin, lintian
+    error
+  * [base] fix spelling in descriptions of the metapackages
+
+release texlive-bin 2007.dfsg.2-1
+
+2008-06-12
+  * [base] activate eps-inclusion code in xetex.def (Closes: #485071) [np]
+  * [all] add Homepage field to the control file [np]
+  * [all] rename README.Debian-source to README.source, and add change the
+    information therein to refer to the trunk/README file and the quilt
+    README.source. [np]
+  * [all] bump policy to 3.8.0 [np]
+  * [all] add a patch target to rules.in [np]
+  * [all] add dversionmangle to debian/watch file to ignore the .dfsg.NN suffix
+    and add pasv option
+
+2008-06-11
+  * [base] blacklist proba.sty in texlive-latex-base (Closes: #483282) [np]
+  * [extra] add the new proba package (src, doc, run files) from CTAN.
+    This is done to comply with what has been done upstream by adding 
+    the proba package to collection-mathextra. [np]
+  * [bin] include sfd files necessary for other packages, but removed from
+    the archive with the imminent removal of freetype1-tools. That needs
+    a new .orig.tar.gz [np]
+  * [base] add EPS support for xelatex by including an updated xetex.def
+    (patch added, not activated, would close the bug #485071, waiting
+    for Jonathans remark) [np]
+
+2008-06-07
+  * [common.functions.preinst] make $package a local variable in the
+    check_move shell function (fixes one half of #483833) [fk]
+  * [bin] correct invocation of dpkg_md5sum in tl-base-bin.preinst.pre,
+    fixes the second half of #484833 [fk]
+  * [bin] Add Replaces: texlive-context for tl-metapost (supp-mis.tex
+    moved) [fk]
+
+release texlive-bin 2007.dfsg.1-4
+
+2008-06-01
+  * [bin] use gcc/g++-4.2 on armel to fix FTBFS (closes: #483939) [np]
+    that adds aditional build-dep for texlive-bin and adds code to rules.in
+
+2008-05-28
+  * [bin] add a missing line to the tl2007.2 xetex patch,
+    taken from upstream [np]
+  * [bin] add a patch to xdvipdfmx to re-allow inclusion of tagged pdf images
+    (Closes: #483019) (big thanks to Jonathan Kew for tracking all this down)
+  * [bin] do not install xdvizilla(.1) (Closes: #477160) [np]
+
+2008-05-19
+  * [bin] add mktexlsr-ignore-more-vcs patch that makes mktexlsr ignore not
+    only .svn, but also other VCS directories. Patch taken from upstream
+    (Closes: #481371) [np]
+
+2008-05-13
+  * [extra] let texlive-pstricks recommend texlive-extra-utils and ps2eps 
+    since the included pdftricks packages needs them (Closes: #473791) [np]
+
+release texlive-extra 2007.dfsg.2-1
+
+2008-05-09
+  * [extra] blacklist tpm/camel as it is nosell, thus we need a new
+    .orig.tar.gz (Closes: #479832)
+  * [extra] add a license statement from Robert Gilles about the bbm fonts to
+    Licenses file (Closes: #479097)
+  * [extra] add a license statement from Michael NĂĽsken about the
+    computational-complexity packages to the Licenses file (Closes: #477152)
+  * [base] blacklist documentation files for eepic since license statement
+    is missing. That closes another part of bug #356853.
+    This makes a new .orig.tar.gz necessary
+
+release texlive-bin 2007.dfsg.1-3
+release texlive-base 2007-14
+release texlive-extra 2007.dfsg.1-2
+release texlive-lang 2007.dfsg.3-2
+release texlive-doc 2007-4
+
+2008-04-25
+  * [extra] update everypage from CTAN to fix serious error (Closes: #477794)
+
+2008-04-20
+  * [bin] texlive-extra-utils now recommends ghostscript (Closes: #476954) [np]
+  * [bin] fix skipping of all trees in mktexlsr with empty $HOME
+    (Closes: #473548)
+  * [bin] add a patch for Sinhala support by Anuradha Ratnaweera 
+    <anuradha@taprobane.org>, but keep it disabled until Jonathan gives me
+    the ok. This would close the bug #476957.
+
+2008-04-19
+  * [all] include the lppl.txt literally in the copyright file
+    (greating to all those who enjoy reading a LONG copyright file)
+
+2008-04-18
+  * [bin] add dviconcat.1 and dviselect.1 to texlive-bin/texmf/doc/man/man1,
+    they were blacklisted when building the .orig.tar.gz and we include
+    these bin/man now [np]
+  * [all] fix some lintian errors, many more to do.
+  * [bin] TeX Live 2007.2 release incorporation: fixes for xetex and xdvipdfmx,
+    new patches tl2007.2-xetex and tl2007.2-xdvipdfmx
+    (adapted from Jonathan Kew's original patches to work with poppler) [np]
+
+2008-03-20
+  * [bin] fix perl warning in thumbpdf (patch: fix-thumbpdf-perlwarning)
+    (Closes: #469294) [np]
+  * [bin] * fix a segfault in ovp2ovf (patch: fix-ovp2ovf-segfault)
+    (Closes: #470433)
+  * [all] Clarify the location of lppl.txt (Closes: #470479)
+  * [doc] fix the spelling of the gentle description (Closes: #469931)
+
+2008-02-21
+  * [bin] add copies of supp-pdf.tex and supp-mis.tex from context 2008-01-28
+    to texlive-metapost so inclusion of metapost images in pdf(la)tex does
+    work without installation of context (Closes: #465107) [np]
+
+2008-02-20
+  * [base] add a fancyheadings placeholder calling fancyhdr (Closes Ubuntu 
+    bug 132399) [np]
+
+2008-02-09
+  * [extra] let -formats-extra replace -latex-base (<= 2007-10) to make
+    smooth upgrades in Ubuntu (gutsy->hardy) possible (Closes Ubuntu 
+    bug 188910) [np]
+
+2008-02-08
+  * [extra] add pbox.pdf to texlive-latex-extra-doc (Closes: #464219) [np]
+  * [lang] texlive-lang-cyrillic suggests scalable-cyrfonts-tex
+    (email from Ralf) (Closes: #459539) [np]
+
+2008-02-03
+  * [all] add a dependeny for all splitted docpks on texlive-common
+    ($version) (closes: #457270) [fk]
+
+2008-01-26
+  * [bin] texlive-xetex depends on texlive-latex-base (Closes: #462610)
+
+2008-01-22
+  * [base] add a patch fix-txfonts-precapprox to switch the symbols 
+    \precapprox and \succapprox in txfonts.sty (Closes Ubuntu bug 184065) [np]
+
+2008-01-16
+  * [base] fix a small bug in booktabs.sty by updating it to the version
+    on CTAN (Closes: #460878) [np]
+
+2008-01-15
+  * [bin] include dviconcat and dviutils (orphaned package dviutils/seetex)
+    and provide/replace/conflict with dviutils (extra-utils) [np]
+
+2007-12-31
+  * [base] make texlive-latex-recommended provide latex-ucs-uninames,
+    latex-ucs, latex-ucs-contrib as these Debian packages have been given
+    up for adoption [np]
+
+2007-12-21
+  * [all] bump standards version to 3.7.3, no changes needed [np]
+  * [all] add texlive-common dependency to the -doc splitted packages,
+    otherwise configuration can fail due to missing update-updmap etc
+    (Closes: #457270) (Closes Ubuntu bug: 177674) [np]
+
+2007-12-05
+  * [base,extra] replace gs-* alternatives with ghostscript [np]
+
+2007-11-29
+  * [bin] add a patch for metapost 1.02 (from upstream svn), but leave it
+    deactivated [np]
+  * (really?) fix the watch file (Closes: #449621), thanks Raphael Geissert
+
+2007-11-28
+  * [base] improve the comments about english hyphenation/language0 in 
+    language.dat, from DEK on tex-k [np]
+      
+2007-11-26
+  * [bin] improve manpage of patgen (Closes: #450875) [np]
+
+release texlive-bin 2007.dfsg.1-2 unstable
+
+2007-11-17
+  * [bin] switch to libpoppler >= 0.5.9 since unstable has now 0.6.2
+    (Closes: #451588) [np] (also adjust build deps)
+  * [base] do not install tex/latex/jknapltx/ubbold.fd, it break the bbold
+    fonts (Closes: #449221). Thanks and sorry Ralf for ignoring you so long!
+
+2007-11-15
+  * [base] close the latin.ldf bug (Closes: #451295) [np]
+
+2007-11-13
+  * [extra] update via.cls from CTAN to fix misbehaviour (Closes: #429150) [np]
+  * [all] add instructions how to generate .orig.tar.gz files to
+    all/debian/README.Debian-source, and extend the trunk/README file [np]
+  * change watch file to use the tug.org ftp server
+  * [extra] fix skak.sty for usage with skaknew's uskak.fd (the only one
+    present) (Closes: #439709) [np]
+
+2007-11-11
+  * [extra] include simplecv to make lyx happy (Closes: #449983) [np]
+
+2007-11-07
+  * [all] change watch file to point to cstug server, update changelogs
+    closing respective bugs
+
+2007-10-30
+  * [base] fix latin.ldf with the version from CTAN 
+    (closes Ubuntu bug #157709) [np]
+
+release texlive-bin 2007.dfsg.1-1 unstable
+release texlive-base 2007-13 unstable
+release texlive-extra 2007-4 unstable
+
+2007-10-24
+  * recode the NEWS files to utf8
+
+2007-10-22
+  * [bin] fix segfault of dvips -z on amd64 (patch applied upstream), thanks
+    to Bastien Roucaries for finding and providing a patch (Closes: #447081)
+
+2007-10-04
+  * [bin] add a patch for metapost 1.0, but do not activate it [np]
+
+2007-09-27
+  * [extra] blacklist tableaux.tpm, new orig.tar.gz
+
+2007-09-25
+  * remove most stuff from the README.Debian file
+
+2007-09-24
+  * implement doc splitting, so that we can build separate -doc packages
+    for every collection we want to [np]
+    splitting is done for: (texlive-base) latex-base, latex-recommended, 
+    fonts-recommended, pictures 
+    (texlive-extra) latex-extra (Closes: #420574), pstricks (Closes: #442052), 
+    publishers, humanities, science
+    (texlive-bin) metapost
+  * add patch gcc43-compile-fix to compilation of teckit with newer
+    gcc compilers (Closes: #441605) (patch taken from 007-12ubuntu3,
+    thanks Matthias Klose)
+
+2007-09-15
+  * put DEBHELPER tag before the post parts [fk from htmlxml]
+  * return (with 0) if we don't have to create a new tarball [fk from htmlxml]
+
+release texlive-lang 2007.dfsg.3-1 unstable
+
+2007-09-09
+  * texlive-lang: reinclude csplain, the license has been fixed.
+  * add a dir orig.tar.gz-addons to the svn repository for orig.tar.gz
+    building
+
+release texlive-lang 2007.dfsg.2-1 unstable
+
+2007-09-05
+  * only blacklist the five files covered by Petr's special licence,
+    not the whole csplain.tpm, since it contains t1code.tex which
+    is essential
+  * build new orig.tar for texlive-bin and texlive-lang
+  * include the change from htmlxml branch for setting the INC path
+    to /usr/share/tex-common in tpm2deb-bin.pl
+  * add a NEWS file for texlive-lang-czechslovak announcing the
+    removal of csplain
+  * fix the syntax error for blacklisting literat and csplain stuff
+
+2007-09-04
+  * texlive-bin: disable pdftex character shifting (option G) in config.pdf
+    (Closes: #434891) [np]
+  * all: retitle all those dreadful "Macro package for TeX" title 
+    (Closes: #436729)
+  * texlive-extra: fix an occurrence of the @ in pubform.bib (Closes: #430438)
+  * spell the path of mllatex.ini the right way, both in the tpm2deb.cfg
+    and in the texlive-latex-extra.root (Closes: #430969)
+
+release texlive-base 2007-12 unstable
+release texlive-bin 2007-14 unstable
+
+2007-09-01
+  * rework the preinst resurrect code so that it is executed *only* for
+    upgrades from >= 2007. Furthermore, the special code for config.ps
+    is executed only for 2007-12.
+  * texlive-bin: blacklist latexmp.pdf since no source is present
+    (Closes: #436965)
+
+2007-08-25
+  * set LANG=C for the update-alternatives grepping, thanks Andreas Degert
+    (Closes: #438551) [np]
+  * blacklist literat (texlive-lang-cyrillic) (Closes: #439028) [np]
+  * Add missing quotes around the sed script in
+    texlive-base-bin.postinst(.pre) (Closes parts of #439205) [np]
+
+2007-08-23
+  * only try to resurrect conffiles when there is a template file present,
+    i.e., only for versions of 2007 in the archive (Closes: #439205) [np]
+
+2007-08-16
+  * fix FTBFS on hurd-i386, adding patch icu-powerpc-buildfix-patch from
+    Samuel Thibault (Closes: #437949) [np]
+
+2007-08-15
+  * Really move Philokalia-Regular.otf to a fonts directory [fk]
+
+release texlive-base 2007-11 unstable
+release texlive-bin 2007-13 unstable
+
+2007-08-13
+  * run the resurrect code *also* in the postinst scripts for the cases 
+    where a package is in rc state with removed conf files. [np]
+  * adapt the menu items to new menu policy [np]
+
+2007-08-11
+  * adjust latest-version for texlive-base to -11 and -bin to -13 so that
+    we get a good combination of packages ;-) [np]
+  * fix removal of old tetex files in language.d (Closes: #435812) [np]
+  * use see in texdoc for displaying of all types of files (Closes: #432037) 
+    [np]
+  * run the resurrect code only at upgrade, not install time. At clean install
+    time there is no file in /u/s/texlive-{bin,base}/... [np]
+
+2007-08-07
+  * move the code to recreate missing conffiles from postinst to preinst:
+    texlive-base: modes.mf
+    texlive-base-bin: pdftexconfig.tex, config.ps
+    texlive-latex-base: color/graphics.cfg
+    (Closes: #425803, #435156, #435081, #433889, #436235, #435719, #435081,
+    #433889) [np]
+    unfortunately version 2007-12 of texlive-bin ships a config.ps in
+    /u/s/texlive-bin which is NOT equal to /e/texmf/dvips/config/config.ps
+    in the same version. We fix this by applying a sed command that transforms
+    the /u/s/texlive-bin/config.ps into the /e/texmf/d/c/config.ps of -12
+    in the preinst of -13. After -13 is in testing we should remove this
+    code.
+
+2007-07-27
+  * Move Philokalia-Regular.otf to a fonts directory [fk]
+
+2007-07-24
+  * copy over explanations in copyright from tetex-base's copyright.header
+    [fk]
+  * bump versioned dep of tl-common on tex-common [fk]
+  
+2007-07-03
+  * [texlive-bin] add another libpoppler patch for libpoppler >= 0.5.9
+    (needs control update, too). Thanks go to 
+    Martin Pitt <martin.pitt@ubuntu.com> for creating this patch. Rename the
+    libpoppler patches to have the respective version in the name. [np]
+  * [texlive-bin] include the fixes to dvilj(k) which are included in the 
+    TeX Live security branch, this adds a patch dviljk-security-fixes [np]
+
+2007-07-02
+  * [texlive-bin] update config.ps from svn (Closes: #431338) [np]
+  * add lost texlive-extra-utils recommends dvidvi (thanks Lionel for
+    spotting this) [np]
+
+2007-06-29
+  * [texlive-bin] update a2ping script and it's man page (Closes: #412107) [np]
+
+2007-06-27
+  * update patch for xetex from texlive svn release texlive 2007.1
+    this also fixes some bugs with OTF inclusion
+    actually use this patch
+
+2007-06-25
+  * fix multiple inclusion of hyphen patterns [np]
+  * let texlive-xetex depend on dvipdfmx (Closes: #430373)
+
+2007-06-22
+  * include a patch for xetex from Jonathan Kew which fixes problems
+    on 64bit archs, and incorrect output in certain (obscure)
+    situations. The patch is NOT activated by now! [np]
+    (version patch1a from 23 Jun 2007, texlive ML
+    msg id <D1EBC1B5-2ADD-4972-8198-9EBE4AFA7249@sil.org>, see
+    http://tug.org/pipermail/tex-live/2007-June/014110.html)
+
+2007-06-21
+  * change common.functions.preinst to use new dpkg_md5sum which
+    does not grep the status file but uses dpkg_query [np]
+
+release texlive-base 2007-10 unstable
+release texlive-bin 2007-12 unstable
+release texlive-lang 2007.dfsg.1-3 unstable
+
+2007-06-20
+  * many changes and fixes by Frank (thanks!)
+
+2007-06-13
+  * Change mapping directive config-copy-move to copy-move and don't
+    register it as a conffile: This is only for *moved* conffiles [fk]
+  * Add a remark to trunk/README about what "config file" actually means
+    for mapping. [fk]
+  
+2007-06-11
+  * Add debianize-fmtutil in /usr/share/texlive-bin, and source it in
+    fmtutil. [fk]
+  * Bring fmtutil(1) closer to reality in TeXLive 2007 [fk]
+
+2007-06-10
+  * Let tetex-base conflict with tetex-bin (<< 2007) to prevent its
+    isolated upgrade on mixed systems (closes: #427859) [fk]
+
+2007-06-05
+  * [base] activate mathpple.map (closes: #426790) [np]
+  * [extra] fix g-brief redefinition of \Telefon (closes: #423919)
+  * [extra] fix g-brief empty unterschrift bug (closes: #154266, #407968)
+  * [base] don't call dh_installtex for meta packages (closes: #427169)
+      - make a distinction between meta packages and normal packages
+        in rules.in
+
+2007-06-02
+  * beautify the config.ps installation [np] (see merge-dist-tree!):
+    - remove the code in rules.in
+    - move config.ps from texlive-bin/debian/ to 
+      texlive-bin/debian/texlive-base-bin.root/usr/share/texlive-bin
+  * strip the ./debian/$pkg part in debian/all/generate-license-file [np]
+
+2007-05-31
+  * Remove the version check from the "resurrect conffile" code; purging
+    tetex-base may happen any time.
+  
+release texlive-base 2007-8 unstable  
+release texlive-bin 2007-10 unstable  
+  
+2007-05-30
+  * IMPORTANT: Move the #DEBHELPER# string after the $maintscript.post
+    snippet.  "post" now signifies that it is after the usual,
+    tpm2deb-bin.pl-generated config file handling, not that it is after
+    the debhelper stuff.  I need some code at this special place, and
+    furthermore I think it's usually a bug in tex-common if something is
+    not handled in a dh_installtex snippet, but cannot be done before it.
+  * Fix the copying of conffiles to /usr/share/$sourcepkg: New directive
+    "config-copy-move".
+  * Add missing dep of libkpathsea-dev on libkpathsea4
+
+2007-05-29
+  * Ship modes.mf and pdftexconfig.tex in /usr/share/$sourcepackagename,
+    and install it into /etc/texmf in postinst.  For the time being, do
+    that without debconf messages and unconditionally (configure would
+    fail without them, anyway). [fk]
+  * Recreate tpm2liclines
+  * tex-common package-status in bug.control, since "report-with" doesn't
+    supply that information
+
+2007-05-26
+  * texlive-bin: don't install libkpathsea.la (Closes: #426006) [np]
+  * all/texlive-bin: do not actually carry out the "preserve deleted
+    conffile" due to the tetex bug and too many busted installations.
+    We warn the admin to delete the file if he really wants to.
+    (Closes: #425781 in texlive-bin and #425803 in texlive-base) [np]
+
+release texlive-bin 2007-9 unstable
+
+2007-05-24
+  * Use --enable-shared=default in order to not try it in the
+    subdirectories for static-only libraries, in particular xetex's
+    teckit. [fk]
+
+2007-05-23
+  * libkapthsea4 is of section libs, libkpathsea-dev of libdevel, add
+    infrastructure to override single bin package sections (bin-section) [np]
+
+release texlive-base 2007-7 unstable
+release texlive-bin 2007-8 unstable
+release texlive-lang 2007.dfsg.1-2 unstable
+
+2007-05-23
+  * Let tl-generic-recommended declare Replaces: tl-base because of
+    cmyk-hax.tex [fk]
+  
+2007-05-22
+  * in the abort-upgrade case in texlive-base-bin's postrm, we cannot
+    assume that xdvi.cfg does exist at the new place: Make code
+    conditional [fk]
+
+2007-05-22
+  * add texlive-base-bin replaces texlive-pdfetex
+
+2007-05-21
+  * texlive-common conflicts with all package revisions of all packages 
+    << latest-revision as set in tpm2deb.cfg.
+  * big format move:
+    - move (partly fixed) format.{tex,pdftex,etex,metafont} to texlive-base
+      and edit format.latex.cnf in texlive-base. Fixes done:
+      . add pdfetex to format.etex.cnf
+      . add latex to format.latex.cnf
+      . remove those two from format.pdftex.cnf
+      . take unchanged format.tex.cnf
+    - BuildFormat executes moves:
+      . remove call in texlive-bin/bin-{tex,pdftex,etex,metafont}.tpm
+      . add call {tex,pdftex,etex} to plain.tpm (and thus to texlive-base)
+      . add call metafont to metafont.tpm (and thus to texlive-base)
+    - missing: should we take over fmt.d/10texlive-base-bin.cnf? I prefer
+      to leave it there and don't do anything. After we have this version
+      without a conf file we can add code for the upgrade from 2005.
+  * as a consequence of the format move some cleaning actions:
+    - remove /usr/bin/mf -> mf-nowin as generated from dh_installtex in
+      texlive-base rules, mf is shipped by texlive-base-bin
+    - remove also /usr/bin/{pdf,}etex in texlive-base rules, and create
+      them via dh_link in texlive-base-bin
+
+2007-05-20
+  * texlive-base: rename (and not remove) old obsolete config files from tetex
+    (Closes: #425256)
+  * texlive-base: don't call tetex-bin-upgrade (Closes: #425270)
+  * texlive-bin: update 64_fix_makempx_installation to upstream fix
+  * texlive-extra: move bigfoot from tl-humanities to tl-latex-extra 
+    (upstream move, too) (Closes: #420394)
+  * common.functions.preinst: rework the xdvi conf file handling code
+    to not "preserve removal" when upgrading from older texlive versions
+    (Closes: #425272)
+
+2007-05-19
+  * add stricter dependencies to all packages: if in the final shipout
+    dep on a texlive package there is no version given, the value of
+    latest-version (from tpm2deb.cfg) of the source package is taken.
+    (texlive-bin: Closes: #421969) (texlive-lang: Closes: #423143)
+  * texlive-bin: remove cruft from control files (cweb, ctie, texdoctk)
+    (Closes: #241089, #249085)
+  * don't leave copies of conffiles in TEXMFDIST (Closes: #420139)
+  * texlive-bin: add poppler to the pdftex banner (Closes: #420971)
+  * texlive-bin: texlive-lang-indic needs depends on python
+  * update/add some patches for the invocation fixes, they patched the
+    wrong files
+  * add lintian source override for 
+    maintainer-script-lacks-debhelper-token debian/common.functions.*
+  * add lintian override for
+    tetex-base: maintainer-script-needs-depends-on-ucf postinst
+    we check with -x /usr/bin/ucf
+  * texlive-bin: add build-dep on chrpath, and remove the rpath entry
+    in the binaries
+  * texlive-bin: remove link /u/s/d/libkpathsea-dev -> libkpathsea4
+    as shipped in packages <= 3.something
+  * texlive-bin: add patch 64_fix_makempx_installation to fix the installation
+    of makempx script instead of the binary (thanks Sanjoy Mahajan)
+
+2007-05-18
+  * Output the list of files in /etc/texmf/web2c in the bug.script
+
+2007-05-17
+  * shlibs magic, thanks Florent
+  * add new poppler patch: 30_libpoppler_new, the old is still present
+    for backports, this also adds a versioned build dep for
+    libpoppler-dev (>= 0.5.4) to texlive-bin
+  * texlive-extra-utils suggests gs-* for epstopdf (Closes: #423988)
+
+2007-05-16
+  * texlive-bin: dpkg_md5sum in common-functions.preinst returns now
+    the empty string in case of an unknown conffile (could have been
+    created by touch). This should fix Ubuntu bug 111654. [np]
+    Serious testing whether nothing else is broken should be done.
+  * merge manually the changes from the libkpathsea branch back [np,fk]
+    - change rules.in to build libkpathsea4 and -dev, and add the necessary
+      control files [fk]
+    - add texlive-bin/debian/libkpathsea4.install, 
+      texlive-bin/debian/libkpathsea-dev.README.Debian, and
+      texlive-bin/debian/libkpathsea-dev.install
+    - adjust tpm2deb.cfg to build the new packages from texlive-bin
+  * Change the code that drops meta- and transitional packages from
+    texlive-full's dependencies so that the list of unwanted packages is
+    in the config file [fk]
+  * Consistently output error messages of perl scripts to STDERR [fk]
+  * move bin-thumbpdf to texlive-base-bin (upstream done, too) 
+    (Closes: #424658) [np]
+
+2007-05-15
+  * texlive-bin: move bangfont.tex from doc to run files (Closes: #424031)
+  * texlive-bin: add missing python header to ebong script (Closes: #423990)
+
+2007-05-14
+  * texlive-base: texlive-full should not depend on tetex-base 
+    (Closes: #424023) [np] (We should move the code from tpm2debcommon.pm
+    to the config file... but I am too lazy for now)
+
+release texlive-base 2007-6 unstable
+release texlive-doc 2007-3 unstable
+
+2007-05-14
+  * texlive-base: make the conflict with ivritex versioned (Closes: #423718)
+  * tetex-base replaces tetex-extra << 2007, since teTeX3-extra ships a
+    lintian override file for tetex-base (Closes: #423520) [np]
+  * texlive-doc-zh replaces/conflicts texlive-doc-ch ...
+
+release texlive-bin 2007-7 unstable
+
+2007-05-07
+  * rename texlive-doc-cn to texlive-doc-zh, sorry all for the chaos [np]
+    (needs new texlive-base and -lang packages)
+  * fix typo in postinst scripts update-alternative(s) (Closes: #422929)
+
+release texlive-bin 2007-6 unstable
+
+2007-05-03
+  * texlive-bin: add a "changed by debianize-updmap" comment to
+    syncWithTrees' definition, and divert "--edit" [fk]
+
+2007-05-03
+  * texlive-bin: move the debianize-updmap call in updmap after the
+    syncWithTrees function so that this function is also debianized.
+    (Closes: #421184)
+  * texlive-bin: apply teTeX texdoctk.defaults patch to get texdoctk
+    to use the right programs (Closes: #421633)
+  * all: add call to dh_installmenu to rules.in
+  * texlive-bin: add menu entry of xdvi, texdoctk, texconfig (Closes: #421634)
+  * all: update README.Debian-source to point to the svn repository and
+    the contained README file
+  * [base] blacklist intermediate files in mathpazo doc (Closes: #421620)
+  * all: fix bug.script
+  * lang: add jerus10 to tl-lang-herbrew to fix hebrew typesetting
+  * base: backport koma-script r288 to fix the use of \usekomafont in all
+    koma-script classes (Closes: #421079)
+  * doc: rename texlive-doc-ch to texlive-doc-cn, stupid me [np]
+
+2007-04-28
+  * texlive-bin: patch updmap so that the help text at map file not found
+    error does not mention --syncwithtree etc, but refers to updmap.d
+    and update-updmap
+
+2007-04-25
+  * texlive-bin: reworked alternative code for removal of old tetex 
+    settings [np]
+  * create tetex-base
+
+release texlive-bin 2007-5 unstable
+
+2007-04-17
+  * fix config file handling (Closes: #419826) [np]
+    - fix a bug in tpm2deb-bin.pl which prevented any config file handling
+    - fix another bug in tpm2deb-bin.pl which didn't install the config
+      file handling in the postrm script
+
+release texlive-bin 2007-4 unstable
+release texlive-base 2007-4 unstable
+release texlive-lang 2007.dfsg.1-1 unstable
+
+2007-04-16
+  * Add patch 31_pdftex_gcc_ICE-on-alpha to work around a bug in newer
+    gcc, thanks to Falk Hueffner <falk@debian.org> (closes: #419434) [fk]
+  * create meta packages texlive-lang-all in texlive-lang, thanks to
+    Frans Pop for the suggestion. [np]
+  * texlive does not longer depend on context [np]
+  * we build texlive-lang-arab, this needs a new .orig.tar.gz as we have
+    to include the respective files there. [np]
+  * Since we take over xdvi from tetex-bin, we remove its xdvi alternative
+    in case it is present (closes: #419381) [fk]
+  * Remove any format or log files in /var/lib/texmf/web2c, they must be
+    in $engine subdirs now.  teTeX does not properly remove them, and
+    they cause strange failures with context (see #419059 and #418976) [fk]
+  * add code to the bug.script to give the md5sums of all the files in
+    /etc/texmf/texmf.d [np]
+  * add update tests from etch in tests/etch-test-*
+  * [tl-bin] Add patch 62_dvips_absolutepath_doc to document the change in
+    dvips' file inclusion behavior in config.ps (closes: #418788)
+
+release texlive-bin 2007-3 unstable
+release texlive-base 2007-3 unstable
+release texlive-extra 2007-3 unstable
+release texlive-lang 2007-3 unstable
+
+2007-04-14
+  * undo the fix of friday 13, thanks to debhelper bug #419060, this fixes
+    several texlive bugs
+  * bump tex-common build-deps to 1.7
+
+2007-04-13
+  * fix the ordering of auto scripts:
+    - bump build-dep on tex-common to 1.6 for fixed auto scripts
+    - bump build-dep on debhelper to >= 5.0.44 for the 
+    (thanks to LoĂŻc Minier for the hint!)
+
+2007-04-12
+  * disable the texmf.cnf check which was run by default, this can only be
+    done manually (because each upload of tex-common with changed files
+    would make tl-bin FTBFS) [fk]
+  
+release texlive-bin 2007-2 unstable
+release texlive-base 2007-2 unstable
+release texlive-extra 2007-2 unstable
+release texlive-doc 2007-2 unstable
+release texlive-lang 2007-2 unstable
+
+2007-04-10
+  * texlive-bin: Fix missing build dependency on tex-common >= 1.3, thanks
+    to Yannick Roehlly for spotting this.
+  * call dh_compress with -X.pdf so that pdf files are not compressed
+
+2007-04-06
+  * texlive-bin: drop updated collection-binextra.tpm and bin-dvipos.tpm
+    into the source package to solve the missing dvipos problem.
+
+2007-04-05
+  * texlive-bin: replace links of odvicopy.1 and odvitype.1 to the respective
+    man pages without o with a minimal manpage (Closes: #417274) [np]
+
+  * fix installation of info pages, we should believe perl if it tells us
+    Variable "@SpecialActions" will not stay shared at 
+    debian/tpm2deb-bin.pl line 343. [np]
+
+  * big do_remap_and_copy restructuring: the final component now is 
+    unified for all mapping directives: either relative file names (in this
+    case /usr/share/texmf-texlive is prepended), or absolute file names.
+    Needs loads of testing. Furthermore, the sub-directives names have
+    changed (remap -> move). Proper documentation added in trunk/README [np]
+
+2007-03-23
+  * texlive-bin: fix config file move logic for xdvi.cfg (Closes: #415906) [np]
+  * really move nag.sty [np]
+
+release texlive-bin 2007-1
+release texlive-base 2007-1
+release texlive-extra 2007-1
+release texlive-doc 2007-1
+release texlive-lang 2007-1
+
+2007-03-21
+  * final changelog editing
+
+2007-03-15
+  * move nag.sty to a TEXINPUTS tree [fk] 
+  * modularize the make_deb function in tpm2deb-bin.pl (ongoing work) [fk]
+
+2007-03-14
+  * Add code to take over changes from fmt.d/10texlive-pdfetex in
+    texlive-base-bin. 
+
+2007-03-12
+  * Let tl-bin Build-Depend on tex-common (>= 1.2) for the handling of
+    fmtutil-sys in postrm [FK]
+  * Fix the "when to run" logic for conffile moves, and write them in a
+    way that I actually understand them myself
+
+2007-03-09
+  * Fix conffile upgrade code: Only act with correct versions, actually
+    pass the action parameter to the function, and respect conffile
+    removals [FK]
+
+2007-03-08
+  * Add error-unwind code for the conffile renames [FK]
+
+2007-03-02
+  * upgrade path replaces:
+    - texlive-latex-base -> texlive-base-bin << 2007 since 
+      /usr/bin/pdflatex has moved
+    - texlive-base-bin -> tetex-bin (<< 2007)
+    - texlive-metapost -> tetex-bin (<< 2007)
+  * fix forgotten config files handling
+
+2007-03-01
+  * introduce a new map sub-directive config-remap
+  * remap instead of copy various files into /etc/texmf (dvips/config/config.*
+    texdoctk, xdvi)
+  * texdoctk.dat is not a configfile anymore
+  * fix fmtutil patches referring to pdfetex as engine
+
+2007-02-28
+  * use old teTeX's xdvi perl script, add a dependency base-bin -> perl [NP]
+  * create links via dh_installtex and remove the links.dist entries [NP]
+  * depend on tex-common >= 1.1 to get dh_installtex with link creation [NP]
+
+2007-02-18
+  * add common.functions.preinst and include common.functions.$type in
+    the make_maintainer call. We don't want to have the preinst code
+    hanging around in all other maintainer scripts.
+  * use dh_installtex in the rules files, thus cleaning the 
+    maintainer scripts:
+    - rules.in: use dh_installtex
+    - tpm2deb.cfg: bump tex-common deps to >> 1.0 for the flavor
+      format:build_all
+    - tpm2deb-bin.pl: rewrite make_maintainer()
+    - remove empty common.functions as all the functionality is taken from
+      dh_installtex
+  * as an interim solution, add format links to the respective binary
+    packages' dh_link files [FK]
+
+
+2007-02-17
+  * add patch 01_tmp_configure_without_installextra which allows to skip
+    running updmap-sys, fmtutil-sys, mktexlsr and most importantly
+    texlinks with a configure option; add that option [FK]
+  * Add explicit real packages to the build-dependencies, in addition to
+    the alternative virtual packages [FK]
+
+2007-02-16
+  * fixes from the first test round
+    - really blacklist ttf2pk, this is a perl regexp, not a shell wildcard,
+      so we have to use .* instead of * (should be done in texlive-old!, too)
+    - missing (upstream) dependency
+      texlive-humanities -> texlive-latex-base
+      texlive-science -> texlive-latex-base
+    - add conflict texlive-common <-> texlive-chemistry as this is gone
+    - mathpazo hack
+      mathpazo was in math-extra <= 2005-2, in latex-recommended << 2007,
+      and now in fonts-recommended, thus:
+      texlive-fonts-recommended replaces texlive-math-extra (<= 2005-2)
+      texlive-fonts-recommended replaces texlive-latex-recommended (<< 2007)
+    - HA-prosper was moved from latex-extra to latex-recommended, thus
+      add a versioned replace
+    - all/debian/preinst.pre code: upgrading to tetex-bin 2007 does not 
+      work as the "upgrade from experimental versions" breakage kicks in.
+      check for upgrade from version 2005 <= version <= 2005-2
+      so that tetex-bin 3.0-something is not hit
+
+2007-02-15
+  * update dvipdfm patch [NP]
+
+2007-02-14
+  * Another mapping directive "copy" which is like config-copy (see
+    below) but does not create any maintainer scripts entries. [NP]
+  * Adapt tpm2deb.cfg that new config files are just "config" [NP]
+  * add preliminary config file handling, no unroll treatment by now [NP]
+  * fix texlive-bin build breakage, we patch the Build script now [NP]
+
+2007-02-13
+  * Expand infrastructure to allow automatic generation of preinst
+    code for config files. Config files are marked in the tpm2deb.cfg
+    via a mapping;origdist;config-{copy,link};dest directive and
+    in the preinst script of the respective package a line
+    	handle_config_file $configfile
+    is added. Currently prefixed with a :, as the function has to be
+    written [NP]
+  * define the files from Frank's list as config files [NP]
+
+2007-02-12
+  * Add Replaces: for file that were in tl-latex-extra in TL 2005 and
+    are now in individual collections [FK, probably earlier unnoted
+    changes by NP]
+  * Use separate configure and build targets in tl-bin's rules and
+    Build.debian, for easier work with the sources [FK]
+  
+2007-02-08
+  * add new remapping type "configfile" which is copied to the last
+    argument as base path and remains where it should be. [NP]
+  * conflict with texlive-pdfetex, and add necessary replaces
+
+2007-02-06
+  * TL2007 work [NP]
+    - collection-chemistry is gone, superseeded by collection-science
+      do not build texlive-chemistry and let tl-science replace tl-chemistry
+    - add replaces: texlive-humanities and tl-science -> tl-latex-extra
+
+2007-01-25
+  * more internal restructuring [NP]
+
+2007-01-22
+  * lots of internal changes to the Perl scripts, mainly cleanup, more
+    descriptive names, and debugging handling [FK]
+  * Add Tpm.pm and FileUtils.pm from TL 2007 [FK]
+  * Switch texlive-base and texlive-bin to quilt 
+  * Do not install rules.in in the binary package, it not used and hence
+    is confusing. 
+  * Switch texlive-lang, texlive-doc to quilt [NP]
+  * include quilt call only for packages with patches [NP]
+  * update tpm.data to the data of TL2007
+
+2007-01-11
+  * all: change the build infrastructure so that short and long
+	description of add-on packages can be specified in the
+	configuration file [FK]
+  * all: add a versioned build-dep on findutils, sarge's doesn't
+	understand the -wholename option.  Should be dropped when etch is
+	released, nobody is going to want to make backports for
+	oldstable. [FK}
+  * no texlive-context anymore, replace it with Debian context package
+	
+2007-01-11
+  * texlive-base: blacklist siam as it is non-free, thus new upstream 
+    (Closes: #406426) [NP]
+
+2007-01-08
+  * texlive-base: create transitional packages tetex-bin and tetex-extra [FK]
+
+release texlive-bin 2005.dfsg.2-10
+
+2007-01-11
+  * build -10 from the old repository layout. The old layout will continue
+    for etch support.
+
+release texlive-bin 2005.dfsg.2-9
+
+2007-01-04
+  * texlive-bin: Apply a patch by "Mark A. Wicks" <mwicks@kettering.edu> to 
+    fix a crash of dvipdfm in half-hour timezones (Closes: #403267)
+
+2007-01-02
+  * texlive-bin: Apply patch by Julian Gilbey <jdg@debian.org> to prevent 
+    mktexlsr from creating ls-R in root's home directory (closes: #402925)
+
+release texlive-bin 2005.dfsg.2-8
+release texlive-base 2005.dfsg.2-5
+release texlive-extra 2005.dfsg.2-4
+
+2006-12-28
+  * move to new repository layout, documentation has to be written for it
+ 
+2006-12-18
+  * texlive-bin: reinclude pslatex script and its manpage into
+    texlive-base-bin. [NP]
+
+2006-12-15
+  * all: move the dpatch stuff to addons-per-source/$package/debian/patches
+
+2006-12-14
+  * texlive-extra: remap infix-RPN.tex and .sty from the doc hieracy to 
+    texmf-texlive (Closes: #402987) (closes Ubuntu bug #69690)
+  * texlive-bin: move bin-ttfutils to tl-font-utils, blacklist everything
+    but ttf2afm, add bin-ttfutils.tpm and ttf2afm.1 to the source
+    package (Closes: #402983) (Closes ubuntu #75545)
+  * all: restructure the layout of addons-per-source, it is now one directory
+    per source plus one for all, which is cp -a to the source package
+    at source package build time. This way we can include files missing
+    in the .orig.tar.gz without making a new .orig.tar.gz. This was necessary
+    to fix the above as bin-ttfutils.tpm was missing.
+    Note that binary files are NOT dealt with ATM, so do NOT install
+    binary files into addons-per-source/ !!
+  * redo a bit of documentation in the README file
+
+release texlive-bin 2005.dfsg.2-7
+
+2006-12-12
+  * texlive-bin: fix the wrong texdoctk patch [NP]
+  * texlive-bin: include xdvi upstream fix for segfault on hitting g with
+    -nogrey (Closes: #369569)
+
+2006-12-09
+  * texlive-extra: downgrade the relation from fonts-extra to cm-super from
+    depends to suggests. Default would be recommends, but a suggests is
+    enough. (Closes: #399064) [NP]
+  * Add the ability to define additional execute statements in the config
+    file [NP]
+  * texlive-extra: add the missing dstroke.map, and add the addMap action
+    to the config file (Closes: #400780) [NP]
+  * tpm2deb.pl/texlive-base: Don't add mktexlsr calls to the postinst/postrm
+    script of texlive package, as it does not contain 'real' files
+    (Closes: #400369) [NP]
+  * texlive-bin: change shebang for getnonfreefonts to /bin/bash
+    (Closes: #398112) [NP]
+  * texlive-base: add an updated dcpic.sty to texlive-pictures (Closes: #388653)
+  * texlive-extra: activate ugq.map (Closes: #374351)
+
+2006-12-08
+  * texlive-bin: Final polish of changelog
+  
+release texlive-bin 2005.dfsg.2-6
+  
+2006-12-06
+  * texlive-bin: Apply patch (from teTeX) to allow texdoctk to work when 
+    both TEXMFDIST directories are populated (#400058) [FK]
+
+2006-12-02
+  * texlive-bin: Apply pdftex patch that allows to use large cjk fonts 
+    (see tetex's bug #399897) [FK]
+
+2006-12-01
+
+release texlive-bin 2005.dfsg.2-5
+  
+  * Add Conflicts of tl-omega on the aleph package (#400930) [FK]
+
+2006-11-28
+  * in addons-per-source/all.watch, change extension of CD image from bz2
+    to zip to match CTAN naming [FK]
+
+release texlive-bin 2005.dfsg.2-4
+    
+2006-11-28
+  * texlive-bin: Blacklist feynmf, the separate package will soon work
+    with texlive; instead let tl-metapost recommend feynmf and tl-full
+    depend on it [FK] (closes: #400657)
+
+release texlive-base 2005.dfsg.2-4
+release texlive-bin 2005.dfsg.2-3
+release texlive-extra 2005.dfsg.2-3
+release texlive-lang 2005.dfsg.2-2
+
+2006-11-09
+  * texlive-bin: don't provide dvipdfm, it messes up sbuild
+
+2006-11-08
+  * all: fix inclusion of packages descriptions when they are actually
+    blacklisted (thanks Frank) (Closes: #397589)
+
+2006-11-07
+  * all: fix a stupid error in the is_blacklist logic, which blacklisted
+    packages which aren't blacklisted at all (Closes: #397324)
+
+2006-11-04
+  * texlive-base: add the forgotten ltxtable.sty to texlive-latex-base 
+    (Closes: #396965) [NP]
+  * texlive-bin: extend texconfig man page and include some fixes from 
+    teTeX (Closes: #396904) [NP,FK]
+
+2006-10-30
+  * texlive-bin: include fixes for superficially linked in libs [NP]
+
+release texlive-base 2005.dfsg.2-3
+
+2006-10-26
+  * alternative dependencies for teTeX changed to tetex-bin to get
+    mktexlsr (Closes: #395270)
+  * texlive-base: upgrade prosper relation back to recommends in
+    tl-latex-recommended as we have an updated package now.
+  * adjust version numbers in the relation to jadetex, xmltex, passivetex
+
+2006-10-20
+  * Add a default for $opt_master in tpm2deb.pl setting it to ./LocalTPM,
+    this way we don't need a TeX Live 2005 Master when rebuilding only
+    a new Debian revision.
+  * Add a default for $oldsrcdir in tpm2deb.pl setting it to ./src, search
+    first for the .orig.tar.gz in ., then in $oldsrcdir.
+
+release texlive-base 2005.dfsg.2-2
+release texlive-bin 2005.dfsg.2-2
+release texlive-extra 2005.dfsg.2-2
+
+2006-10-19
+  * texlive-bin: include patch for pdfetex to support newer TTF fonts
+    (Closes: #394028) [NP]
+
+2006-10-18
+  * texlive-bin: adjust built-in search paths of libkpathsea to the 
+    Debian defaults (Closes: #392641) [NP]
+
+2006-10-16
+  * Fix the description of MetaFont, this should be done upstream, too -
+    but where is it taken from? [FK]
+  * texlive now only suggests texlive-doc-en, not depends (Closes: #392517)
+ 
+2006-10-14 NP
+  * texlive-base: add versioned dependencies on all texlive packages
+    for texlive-full. Latest version must be configure in tpm2deb.cfg.
+
+2006-10-13 NP
+  * texlive-bin: update the debian patch for updmap(.1) (Closes: #393189)
+
+2006-10-12 NP
+  * texlive-lang: Add a depends from tl-lang-spanish on tl-latex-base as
+    eshyph.tex loads cathyph.tex, which is not present in tetex packages.
+    (Closes: #392474)
+  * texlive-base: texlive-full now recommends 
+    latex-cjk-all >= 4.6.0+cvs20060714-2
+  * texlive-base: blacklist beamer, xcolor, pgf and depend on the 
+    respective Debian packages (Closes: #382870, #389467)
+
+2006-10-11 NP
+  * texlive-base: move the conflict texlive-latex-extra<->latex-beamer
+    to texlive-latex-recommended<->latex-beamer as the packages has
+    been moved.
+  * texlive-base: add a suggests texlive-latex-recommended -> tl-pictures
+    to get pgf for beamer (Closes: #382870)
+  * provide pgf, latex-beamer, latex-xcolor in the respective packages
+  * reorganize the tpm2deb.cfg file to make it easier to find something
+
+release texlive-base 2005.dfsg.2-1
+release texlive-bin 2005.dfsg.2-1
+release texlive-extra 2005.dfsg.2-1
+release texlive-lang 2005.dfsg.2-1
+release texlive-doc 2005.dfsg.2-1
+
+2006-10-09 NP
+  * texlive-bin: depend on tex-common >= 0.33 to get working debianize-updmap
+  * texlive-base: blacklist several non-free beamer exampler files
+    (Closes: #391946)
+
+2006-10-08 NP
+  * texlive-bin: Include the changes by Frank to debianize-updmap
+  * texlive-bin: move bin-texdoc to tl-base-bin (Closes: #391640)
+  * texlive-bin: include the already unpacked sources instead of the
+    source.tar.bz2. Changes to the clean target:
+    - don't remove unpack-stamp
+    - don't remove the whole build dir, only build/inst and build/Work
+    (Closes: #380227) (Thanks Frank for insisting!)
+  * texlive-bin: Use tex-common's (>= 0.32) debianize-updmap (Closes: #391348)
+  * texlive-base: call tetex-bin-upgrade from tex-common (>= 0.32) to allow
+    upgrades from sarge's tetex2 (Closes: #382861) (at least we hope)
+
+2006-10-07 FK
+  * Add a Depends on ed for texlive-base-bin, updmap uses it
+  
+2006-10-06 NP
+  * texlive-bin: use xdvi.bin in the xdvi shell script, and use alternatives
+    system to set xdvi.bin to xdvi-xaw.bin (Closes: #391437)
+  * extend the README in the svn repository to explain the inner workings
+    in more details
+  * all: extend the copyright file with statements for the copyright of
+    the Debian adaptions, uses GPLv2 (no higher).
+
+2006-10-05 NP
+  * texlive-lang: provide/replace/conflict texlive-lang-african - ethiop
+  * texlive-extra: add recommend texlive-latex-extra -> texlive-generic-extra
+    (Closes: #390896)
+  * all: move the definition of maintainers, section, uploaders, priority,
+    standards to the config file. Move some provides which were hard coded
+    in the perl file into the config file.
+  * all: create the rules file via an eperl script, add build-dep on eperl
+
+2006-10-03 NP
+  * texlive-lang: remove the conflict with octave-forge as they don't have
+    /usr/bin/mex anymore.
+
+2006-09-29 NP
+  * remove unnecessary conflicts (with blacklisting)
+    - texlive-bin: tl-extra-utils <-> dviutils
+      . blacklist dviconcat(.1) and dviselect(.1)
+      . recommend dviutils
+    - texlive-bin: tl-extra-utils <-> lacheck
+      . blacklist bin-lacheck.tpm
+      . recommend lacheck
+  * drop unnecessary conflicts (without blacklisting)
+    - texlive-extra: tl-latex-extra <-> lhs2tex
+      it concerns only two old files
+    - texlive-base: tl-latex-recommended <-> latex-ucs* (Closes: #388311)
+    - texlive-extra: tl-games <-> tex-skak, tex-chess
+  * texlive-base: change relation tl-latex-recommended/prosper from recommends
+    to suggests as we cannot recommend a not available package.
+    (Closes: #389195)
+
+2006-09-28 NP
+  * texlive-extra: blacklist latex/misc209/bar.sty as it has a bad license
+
+2006-09-08 NP
+  * texlive-lang: reinclude cs*, as it will be redistributable, and add
+    a comment.
+
+2006-09-06 NP
+  * Change my email address to preining@debian.org in the Uploaders field
+
+2006-09-05 NP
+  * blacklist various scripts in texmf-texlive/scripts which are unnecessary
+    as they are also in /usr/bin
+  * texlive-lang: blacklist (bin-)cslatex, (bin-)csplain, and 
+    hyphen-czechslovak as they contain undistributable parts (the former 4)
+    or depends on these parts (the last one). Also add a dpatch that
+    removes the lang initialisation from collection-langczechslovak.tpm
+
+2006-09-04 NP
+  * all: report bugs together with tex-common, and report status of the
+    tetex packages. Fix some small things in bug.scripts.
+  * texlive-lang: blacklist ntimes.sty (Closes: #366521)
+  * add SHELL=/bin/bash to debian/rules
+  * update tpm2licenses.txt
+
+2006-08-31 NP
+  * texlive-bin: remove magic header of a2ping, thumbpdf, and pdfcrop
+  * allow for comments in the source of the lintian.override file, and 
+    comment the override lines for a2ping, thumbpdf, and pdfcrop
+  * texlive-base: texlive-latex-extra recommend texlive-latex-recommended
+    (Closes: #385213)
+
+2006-08-10 NP
+  * add comment to the rules file that bins for all archs can be found in
+    bin/i386-linux as the tpm arch is set to i386-linux
+  * fix the title and description of texlive package
+
+version 2005.dfsg.1-1 unstable Wed, 09 Aug 2006 09:57:05 +0200
+	for texlive-bin, texlive-base, texlive-extra
+
+2006-08-04 NP
+  * texlive-bin: fix a typo in tpm2deb.cfg (font-util instead of font-utils)
+  * texlive-base: remap esbst.tex and romanidx.tex to really fix bug #365235
+  * texlive-extra: close the eulervm bug #361941 in the changelog file
+
+2006-08-03 NP
+  * texlive-bin: blacklist mktex.cnf as it conflicts with tex-common's.
+  * infra: change test scripts to work with cowbuilder
+  * infra: change test script to call aptitude upgrade instead of
+    install $package
+  * texlive-bin: rm -f the mktex.cnf file, it could already be gone.
+
+2006-08-01 NP
+  * texlive-bin: undo the undo from 22.07 to get back to 08.07.
+
+2006-07-22 NP
+  * texlive-bin: reinstall mktex.cnf conffile link, see bug #379089
+  * texlive-base: add dependency tl-context -> perl-tk, libxml-parser-perl 
+    for texshow to run (Closes: #378829)
+  * texlive-bin: Remove the dep from texlive-base-bin on tex-common >= 0.26.
+
+2006-07-15 NP
+  * all: move several tpm packages around, as done upstream
+  * all: get rid of update-link-files, it was unnecessary, dh_compress
+    is intelligent enough to adjust links
+  * all: get rid of some dpatches for moving tpm packages, as the move
+    directive in tpm2deb.cfg is enough.
+  * all: create links with script create-doc-links instead of using tpm2deb.pl
+    internal add_symlink function
+  * texlive-extra: add eulervm 4.0 to texlive-fonts-extra, replacing the old
+    version 3.0a with missing manifest (Closes: #361941)
+
+2006-07-13 NP
+  * all: change maintainer to debian-tex-maint@lists.debian.org
+  * all: first merge the dist-trees, than call the license stuff
+
+2006-07-08 NP
+  * texlive-base: move passivetex, jadetex, xmltex, latex-cjk from 
+    recommends to suggests of texlive-full (Closes: #377106)
+  * texlive-bin: remove fmtutil.cnf link (useless) and mktex.cnf 
+    (taken from tex-common). Add a dep from texlive-base-bin on
+    tex-common >= 0.26. (Closes: #376524)
+  * all: use tex-commons Tpm.pm and tpm2licenses, add build-dep on 
+    tex-common >= 0.23
+  * all: add lintian override for wrong-name-for-upstream-changelog
+
+2006-06-15 NP
+  * separate changelog files for all source packages in addons-per-source
+
+2006-06-13 NP
+  * include fixed supp-*.tex files into texlive-context
+  * include input focus fix for xdvi (upstream, tetex)
+  * include a patch for dvipdfm's config file that allows proper 
+    inclusion of really large Postscript files, as reported by Thomas 
+    Esser and Laurent Siebenmann  on the TeXLive list.
+
+2006-05-28 NP
+  * after discussion with Ralf Stubner move fpl and mathpazo from 
+    fonts-extra/math-extra to fonts-recommended (psnfss calls for), 
+    and move charter from fonts-extra to fonts-recommended.
+    Move some files in fpl.tpm from DocFiles to SourceFiles,
+    thanks Ralf and Frank for tracking this (Closes: #366035)
+    
+2006-05-27 NP
+  * reinstantiate texlive-lang-ukenglish, the un-freeness is not clear.
+  * add a patch by Ralf Stubner to mktexnam (accepted by TE and included
+    upstream) to create TEXMFVAR in mktexnam. First step to do another
+    /var/cache/fonts retry.
+  * fix texlive-bin build logic: patch-stamp: unpack-stamp
+  * allow for additional license entries at the beginning $Pkg.Licenses.add
+  * add the license statement from Donald Arseneau to relicense underscore.sty
+    under LPPL license (Closes: #368902)
+  * move the whole license generation stuff into the generate-license-file,
+    thus uncluttering the rules file
+  * make blacklist also work on the orig.tar.gz
+  * move esbst.tex and romanidx.tex in the babel.tpm file into the 
+    RunFiles section (Closes: #365235)
+  * move fpl into texlive-latex-base as it is required by PSNFSS, also
+    move some files which are actually SourceFiles into the respective
+    section, thanks Ralf and Frank (see 28.05.2006)
+    (also adapt the lintian.override file for new fpl overrides!)
+  * move lmodern from Depends to Recommends in texlive-base
+  * replace the relation directive with single directives for conflicts,
+    depends, recommends, suggests, and add the replaces directive.
+
+2006-05-24 NP
+  * don't build texlive-lang-ukenglish as it is non-free
+    we still have to build dfsg .orig.tar.gz files once!
+
+2006-05-23 NP
+  * texlive-extra-utils recommends perl-tk for texdoctk (Closes: #368659)
+
+version 2005-2 unstable Thu, 11 May 2006 00:12:10 +0200
+
+2006-05-11 NP
+  * another fix for tpm2licenses to not break if there is an empty
+    directory (or one only containing links!)
+  * Upload to unstable sponsored by Neil McGovern <maulkin@halon.org.uk>
+
+2006-05-10 NP
+  * Build-Dep on tex-common not necessary as we include tpm2licenses
+    and fixed Tpm.pm (can go away with next version when the fixes
+    are in tex-common)
+  * The build-dep day, finding what all is necessary for a clean build
+    with tpm2licenses: libappconfig-perl, libxml-dom-perl
+  * Really fix the ibycus4.map problem (Closes: #354652)
+  * adjust dvipdfmx recommend version to 1:20050831-1
+  * Install this file as CHANGES.packaging into texlive-common, and
+    create a streamlined and terse changelog.
+
+2006-05-09 NP
+  * create new package texlive-common:
+    - move the symlink /u/s/texmf-texlive/doc -> ../texlive-doc from
+      texlive-base-bin to texlive-common, and the installation of it
+      from tpm2deb.pl to texlive-common.links.dist (Closes: #364776)
+    - same as above for the /u/s/texmf-texlive/ls-R link
+    - let *all* packages depend on texlive-common (which allows the above
+      two changes!)
+    - add a all.preinst.pre snippet that ensures that all texlive
+      packages are *first* purged before the -2 version is installed.
+      We don't support upgrade path from experimental. Also add the
+      preinst handling which was missing.
+    - texlive-common depends on tex-common, the other packages do only
+      depend on texlive-common
+  * allow all.{post,pre}{inst,rm}.{post,pre} to be merged into all
+    maintainer scripts
+  * do not install SourceFiles into the binary package.
+  * install the README.?? files only into texlive-common
+  * update the tl4deb-dep diagram
+  * move endfloat.dvi from texlive-latex-recommended to texlive-latex-extra
+    (upstream fix necessary)
+
+2006-05-08 NP
+  * move the installation of debianize-updmap form tpm2deb.pl to the
+    texlive-base-bin.root 
+  * update tpm2liclines from catalogue
+  * allow installation of uuencoded files via the .root method, and move
+    tl4deb-deptree.pdf.uu into texlive-common.root, remove all references
+    to tl4deb-deptree in tpm2deb.pl (especially the rules files)
+  * remove all .svn directories at source package build time from debian
+  * bump standards version to 3.7.2, no changes necessary
+  * install mime entry for dvi in texlive-base-bin (thanks JĂ¶rg Sommer)
+  * move declaration of build-dependencies into the config file,
+    move dpatch into Build-Depends: as it is necessary for clean target.
+  * before writing out relation fields, uniq the entries.
+
+2006-05-06 NP
+  * blacklist musixtex, musixps, musixlyr, and let texlive-music depend
+    on the updated packages.
+  * add mllatex.ini to texlive-formats-extra and blacklist it in
+    texlive-latex-base
+
+2006-05-04 NP
+  * add man pages for pkfix, texconfig-dialog, aleph, lambda, otangle
+    (thus all binaries have man pages now, yippie)
+
+2006-05-03 NP
+  * add man page for pdfcrop (written by Frank, thanks)
+
+2006-05-02 NP
+  * texlive-lang-polish conflicts with octave-forge as both provide
+    /usr/bin/mex, this is preliminary, a better solution must be
+    sought (Closes: #364059)
+
+2006-05-01 NP
+  * add man pages for bibtex8, devnag, ps4pdf, musixflx (from Andreas Tille)
+    getnonfreefonts-sys (link to getnonfreefonts), perltex (pod2man)
+
+2006-04-30 NP
+  * add man page for simpdftex
+
+2006-04-29 NP
+  * add man page for pdfopen and pdfclose (thanks Frank)
+  * add man page for deprecated altpdf* scripts
+
+2006-04-25 NP
+  * extend license with a coverage check
+  * blacklist trig.dtx and xdoc from fontinst sources (thanks to Frank
+    for spotting this)
+  * extend the svn README (not installed) for config file syntax and
+    first write up on the build procedure
+
+2006-04-23 NP
+  * add support for arbitrary bin-package specific subtrees in addons-per-bin,
+    and install omfonts.1 into texlive-omega man directory.
+  * License support rehauled: We now give for (nearly) every file a license
+    statement generated from the TeX Catalogue. 
+
+2006-04-10 NP
+  * fix build_format_if_format_exists check, it was completely hosed
+  * let texlive-lang-cyrillic conflict with tetex due to /usr/bin/ru*
+
+2006-04-06 NP
+  * blacklist sanskrit.tpm, and recommend latex-sanskrit from
+    texlive-lang-indic.
+
+2006-04-03 NP
+  * Remove build-deps on | libxaw8-dev as it goes away with X7.
+
+2006-04-01 NP
+  * Remove non-free documentation and create a specific package
+    texlive-doc-nonfree. Currently only three context documents.
+  * change pdftex's version string to indicate that it uses libpoppler,
+    taken from the teTeX patch (thanks to Frank and Julian).
+
+2006-03-23 NP
+  * include the texdoc patch from tetex, which allows following of
+    symlinks for doc files, and fixes security concerns (Closes: #356390)
+  * As a consequence of the above patch let tl-extra-utils depend on 
+    mime-support.
+  * remove tetex-missing-magic-header workaround in test script.
+
+2006-03-20 NP
+  * add conflict ptex-bin vs texlive-lang-polish as both provide platex.
+  * add a fix to the tmpfile race in the example feynmf.pl script (thanks
+    to Kevin B. McCarty).
+
+2006-03-14 NP
+  * change shell for the reportbug script to bash (Closes: #356391)
+
+2006-03-12 NP
+  * Add lintian override for pdfcrop and thumbpdf executable-not-elf-or-script
+    because it is one of the magic header which can be called with sh or perl.
+
+2006-03-11 NP
+  * Blacklist /usr/bin/thumbpdf and /usr/bin/pdfcrop as it is a link to 
+    texexec, which is in texlive-context, while thumbpdf/pdfcrop is in 
+    texlive-pdfetex. Remap the thumbpdf and pdfcrop perl files from scripts to
+    /usr/bin. (Closes: #352092)
+
+2006-03-06 NP
+  * allow overriding of tpm and package titles and descriptions, improve
+    various descriptions (Closes: #354964)
+
+2006-03-04 NP
+  * add all update-* calls to the postinst scripts so that the config file do
+    not contain left-overs from tetex at switch time (Closes: #355266)
+
+2006-03-02 NP
+  * Add the temporary directory to TEXFORMATS in fmtutil, to allow
+    building formats based on latex.fmt without cluttering stdout
+    (patch taken from tetex by Frank KĂĽster, see bug #354604)
+
+2006-03-01 NP
+  * make all texlive-lang-* packages working with tetex3, but add a
+    README file explaining the situation for duplicate languages.
+  * only recommend dvipdfmx, so we can go for the upload
+  * make most depends on other Debian packages a recommends (tipa, texpower,
+    etc)
+
+2006-02-28 NP
+  * remap the ibycus4.map TeX/MF input file from the fonts/map location
+    to the fonts/source location (upstream cleanup necessary) (Closes: #354652)
+  * add packages specific README.Debian files
+  * allow various texlive-lang-* packages to work with tetex3
+
+2006-02-26 NP
+  * Fix dependency of texlive onto texlive-latex-base
+
+2006-02-25 NP
+  * Let texlive-base depend on the new NMU of dvipdfmx and blacklist it.
+  * Try to stop the build system to build dvipdfmx.
+  * Add Provides for virtual packages: dvipdfm, cweb, ctie, texdoctk
+
+2006-02-20 NP
+  * move all files to texmf-texlive, only a few essential stay in TEXMFMAIN
+  * add a new package texlive-full which takes the role of the previous
+    texlive package in pulling in all necessary components, while the
+    texlive package itself now consists of a selection of packages
+    (the -recommended ones, plus doc-en, but no -lang-*)
+
+2006-02-19 NP
+  * conflict: texlive-extra-utils with dviutils (superseeded, more utils)
+  * blacklist bin-dvi2tty, but let tl-extra-utils depend on dvi2tty
+  * fix problems when switching from teTeX (missing update-language call)
+    (all three thanks to Atsuhito Kohda)
+
+2006-02-18 NP
+  * The svn repository has moved to the debian-tex project at alioth,
+    thus the revisions now are shifted by ~500.
+
+2006-02-13 NP
+  * remove /var/lib/texmf/web2c/{latex,pdflatex}.{fmt,log} before
+    calling fmtutil-sys --all as jadetex (and other formats) with 
+    a fmtutil config line based on the latex format might use the
+    old latex format. (Closes: #351707)
+
+2006-02-12 NP
+  * blacklist /usr/bin/uniqleaf which is a link to texexec but no
+    corresponding perl file exists (but it is in tetex).
+  * Fix the Build-Depends-Indep vs Build-Depends stuff
+  * tipa NMU is in Debian, so depend on it
+  * fix for the link files fix
+  * cleanup of common.functions (backticks, printf instead of echo -n)
+
+2006-02-11 NP
+  * blacklist lm(odern), and depend on lmodern >= 0.99.3-1, this makes the
+    lmodern fonts again available for X (Closes: #351727)
+  * included fixes for errors in the depot:
+    - remove ltxdoc.cfg from tex/latex/subfig
+    - move pst-3d.tex from the doc directory to the proper place
+
+2006-02-06 NP
+  * add a special clause to bug script to see the texmf-texlive/ls-R file
+  * import debianize-updmap and other fixes for fmtutil from tetex 
+
+2006-01-31 NP
+  * fix installation of files from addons-per-bin
+  * link fixing: remove double call to dh_link, install pre-distributed
+    links files as package.links.dist, fix update-link-files to copy the
+    package.links.dist to package.links, and only append the links from
+    package.links.generated
+  * add some more man pages (links to pdfetex.1)
+
+2006-01-24 NP
+  * add a watch file to the sources
+  * add poppler/Link.h for building with poppler >= 0.5.0. Thanks to Martin
+    Pitt.
+  * texpower is updated, let texlive depend on it
+
+2006-01-15 NP
+  * expand reportbug script to include an ls -l of texmf.cnf, fmtutil.cnf
+    updmap.cfg, and language.dat
+
+version 2005-1 experimental Thu, 12 Jan 2006 17:30:22 +0100
+
+2006-01-12 NP
+  * switch to debhelper compat version 5, no changes necessary
+  * upload to experimental, based on scripts revision 293.
+  * Upload sponsored by Neil McGovern <maulkin@halon.org.uk>
+  * fix tetex-dependency/conflict check
+  * fix bug report script, install it into all packages
+
+2006-01-11 NP
+  * support for reportbug control and script, all packages but the
+    doc packages report together with texlive-base-bin, and texlive-base-bin
+    reports via the same script as does tetex-base.
+  * remove config.status file in pdcmac
+  * texlive-formats-extra conflicts with tetex-bin <= 3.0-13
+  * add missing build dependency texlive-bin -> ed
+  * test builds are done in a minimal pbuilder with only build-essential stuff
+
+2006-01-09 NP
+  * clean up poppler patch
+  * separate the writing of debian/rules into its own function
+  * clean up the whole direcory (shouldn't I do it for my life, too ;-)
+  * add a README file in the repository how everything is structured
+  * restructuring stuff:
+    - merge scripts/snippets/addons etc into two directories
+      addons-per-source and addons-per-bin
+    - simplify the make_deb_source functions as nearly all files
+      are now installed automatic via the addons-per-* stuff.
+
+2006-01-04 NP
+  * fix read_changelog program
+  * build sources only based on the configuration in tpm2deb.cfg, not
+    necessary to be specified in the Makefile
+  * test script cats all the error files /tmp/texlive.* to stdout if
+    one of the commands goes wrong
+  * fix check_consistency by blacklisting collection-binaries, actually
+    break out if there is an error raised in check_consistency
+
+2005-12-29 NP
+  * remove conflicts on thailatex, although it doesn't work with texlive
+    (and probably not with thailatex). Updates are necessary to thailatex.
+  * change dep on tex-common to >= 0.12
+
+2005-12-28 NP
+  * kill texlive-lang-cjk package:
+    - move yi4latex to texlive-latex-extra
+    - recommend latex-cjk-all (>= 4.6.0+cvs20051031-4)
+  * remove 40_hbf2gf.dpatch as it is not included into the package
+    anymore
+  * add libpoppler-dev to Build-Deps for texlive-bin
+
+2005-12-27 NP
+  * move unified doc dir to /usr/share/doc/texlive-doc as there is a 
+    package texlive, install all the README.?? etc also there
+  * include fixes from Werner Lemberg for hbf2gf and mktexmf
+       dpatch/texlive-bin/40_hbf2gf.dpatch and 41_maketexmf.dpatch
+       dpatch/texlive-base/30_depot_fixes.dpatch
+  * switch pdfetex from libxpdf to libpoppler, patch taken from tetex
+
+2005-12-26 NP
+  * add missing dependency of texlive-omega onto texlive-latex-base for
+    latex.ltx in lambda.ini (todo for depot)
+  * move mltex and bin-mltex to texlive-formats-extra (todo for depot)
+  * add missing dependency of texlive-formats-extra onto texlive-latex-base
+    for bplain.tex and mllatex (todo for depot)
+  * include diagram into texlive-doc-base package
+  * fix --noremove option to tpm2deb.pl
+  * add sharutils to build-deps of texlive-doc
+
+2005-12-23 NP
+  * created a diagram of dependencies
+  * implement automatic test system, testing all packages with install-
+    remove-install-purge cycle
+  * fix installation of eplain format, it has been moved to tl-plain-extra
+    instead of tl-formats-extra (todo for depot)
+  * for the texlive-doc-* packages call mktexlsr only if it is available
+    (these packages do not depend on texlive-base-bin)
+
+2005-12-21 NP
+  * call fmtutil-sys --all in tl-base and tl-base-bin postinst script
+  * move tex4ht from recommends to depends for the texlive package, as
+    it is already fixed in unstable to work with texlive and tetex.
+  * Include relation to teTeX in README.Debian
+
+2005-12-15 NP
+  * make texlive-math-extra and texlive-plain-extra conflict with tetex
+  * version dependency of cm-super >= 0.3.3-3 due to the name change
+  * include pdftex update to 1.30.5, bugfix release
+  * texlive-font-utils conflicts with tetex
+
+2005-12-14 NP
+  * tl-htmlxml completely replaced, removed conflict of tl-context vs tex4ht
+  * let texlive recommend tex4ht in locally updpkg version
+
+2005-12-13 NP
+  * make packages which are not texlive specific depend on either texlive
+    or tetex, and remove unnecessary conflicts with tetex, so that tetex
+    users can use the texlive packages, too.
+
+2005-12-12 NP
+  * Rename dependency from lcdftypetools to lcdf-typetools
+  * don't build texlive-htmlxml but recommend the respective debian pkgs
+  * move xmlplay from texlive-htmlxml (not build) to tl-latex-extra
+
+2005-12-11 NP
+  * remove texlive from the dependencies of the texlive packages
+  * include security fix xpdf-3.01pl1.patch (CAN-2005-3193)
+  * add bzip2 to build-dep
+  * fix installation of getnonfreefonts(-sys)
+
+2005-12-10 NP
+  * fix rules generation to first unpack and then patch
+  * add texdoctk patch warning if perl-tk is not installed (stolen from tetex)
+    and remap-link texdotk.{defaults,dat} to /etc/texmf/texlive/texdoctk
+  * add a texlive meta package that pulls in all sub packages and other
+    Debian packages resulting in a more or less complete TeX Live system.
+  * change orig.tar.gz layout to look exactely like the DVD (so we can
+    once put the debian dir into the DVD)
+
+2005-12-09 NP
+  * use source.tar.bz2 from Master/source (i.e. from the DVD)
+
+2005-12-03 NP
+  * blacklist euclide.tpm, as it is superseeded by pst-eucl (todo for depot)
+  * "give Debian what Debian is":
+    - do not build texlive-lang-arab as it is arabtex which is in Debian
+    - blacklist prosper and depend on prosper (fix for prosper needed)
+      recommend prosper
+    - blacklist texpower and tpslifonts as they are superseeded by the
+      Debian texpower package (fix for texpower needed), recommend texpower
+    - blacklist tipa as it is in Debian (fix for tipa send to maintainers)
+      recommend tipa
+  * switch field separator in cfg file to ; so that epoch specifications work
+
+2005-12-02 NP
+  * blacklisting xymtex as it is not distributable.
+  * blacklist (bin-)ppower4 as it depends on java and no sources
+    are provided within texlive (but you can get it from the author)
+  * save ChangeLog in utf8
+
+2005-12-01 NP
+  * add dependency tl-context -> tl-metapost (thanks Arne JĂ¸rgensen)
+    (todo for depot)
+
+2005-11-30 NP
+  * add symlink from texmf-texlive/ls-R to /var/lib/texmf/ls-R-TEXLIVE
+  * kill packages ttf-utils, ps-utils, graphics-tools, they should become
+    proper Debian packages
+
+2005-11-29 NP
+  * another round of package renaming, adaptions to the perl script
+  * move only the files from texmf-dist and texmf-doc to texmf-texlive, 
+    leave others in place (more work for teTeX cooperation has to be done)
+  * fix lintian generation for source packages
+
+2005-11-28 NP
+  * reduce number of source packages
+  * rename various packages
+
+2005-11-27 NP
+  * properly clean up debian subdir with target clean, ie remove the
+    generated maintainer scripts and the generated .link files.
+  * upgrade pgf in texlive-pictures to 1.01 for compatibility fixes
+
+2005-11-24 NP
+  * Close the ITP (Closes: #312897)
+  * add a dependency tl-htmlxml -> tl-latexrecommended because jadetex
+    needs the ecrm fonts.
+  * switch to texmf-texlive tree, which also makes a dependency on
+    tex-common >= 0.12 necessary.
+
+version 2005-0.2 UNRELEASED Tue, 22 Nov 2005 23:49:00 +0100
+
+2005-11-22 NP
+  * this release was uploaded as -1 to experimental but rejected. Thus
+    the release was renamed as -0.2 and a new -1 will be generated.
+  * re-add updmap-sys call to the postrm scripts
+  * make updmap-sys silent in postinst script
+  * make fmtutil-sys silent in postinst script
+  * make mktexlsr silent in postinst script
+  * change depend on tex-common to >= 0.11 for TEXMFSYSCONFIG change
+
+2005-11-21 NP
+  * fix lintian source override installation
+  * fix etex/pdfetex format generation problem
+  * remove the 04TeXlive hack as the change will go into tex-common 0.11
+    rather soon
+  * remap only a few config files (those for programs) to /etc/texmf/texlive
+  * try to fix the conundrum with format generation. This is a complete
+    upstream chaos (ok, also upstream I created the chaos ;-). Should be fixed
+    rather soon.
+
+2005-11-20 NP
+  * fix invocation of grep in common.functions to add || true, since grep
+    returns if no match found
+  * fix installation of TeXlive.cnf as 04TeXlive.cnf into /e/t/texmf.d
+  * add a overriding TEXMF variable to 04TeXlive.cnf which includes
+    TEXMFCONFIG without !! (Should actually be fixed in tex-common!)
+  * remove the long invocation of language.dat
+  * fix merging of common.functions into postrm and prerm
+  * fix regexp for installing lintian.override files
+
+2005-11-19 NP
+  * add common.functions and merge it into the maintainer scripts
+  * change check for the existence of a format from kpsewhich fmt.ini
+    to a fmtutil-sys --listcfg check (in common.functions)
+  * Leave the map files in TEXMFMAIN and do not remap them to /etc/texmf
+  * New configuration file handling, all the files are left in their
+    normal place and config files to shadow these files should be put 
+    into /etc/texmf
+  * Add override for TEXMFSYSCONFIG to /etc/texmf
+  * give the updmap.d, fmt.d, and language.d config snippets priority 10
+    and only the us language snippet the 09 priority.
+  * create a README.Debian
+  * lintian override for a2perl header problem
+
+2005-11-16 NP
+  * add a distribution entry to the ChangeLog file and make tpm2deb.pl
+    aware of it
+  * fix all remaining man page warnings of lintian
+  * load tpm data from a dump of the %TpmData using perl::Storable,
+    significantly speeding up the initialization time at source-deb
+    building time.
+  * add additional override for texlive-langgerman that german is correct
+
+2005-11-15 NP
+  * fix the man page errors (wrong char and ttf2pt1)
+
+version 2005-0.1 UNRELEASED Mon, 14 Nov 2005 20:11:34 +0100
+
+2005-11-14 NP
+  * remove build-dep on tex-common
+  * Rework maintainer script handling, separate out the creation of
+    maintainer scripts into a function, allow only to create the
+    maintainer scripts for checking.
+  * move the extra format configuration from the snippets/post scripts
+    to tpm2deb.cfg.
+  * Building a first prerelease version. The scripts used are from
+    svn revision 134.
+
+2005-11-11 NP
+  * Fix a failure in setting the executes, thus there were some map files
+    missing.
+
+2005-11-09 NP
+  * Don't forget dh_strip
+
+2005-11-08 NP
+  * Fixes for big cleanup part I.
+  * Create all rules file from tpm2deb.pl, make the rules subdir
+    unnecessary.
+
+2005-11-07 NP
+  * Big cleanup in the script, part I.
+    - make config file syntax more readable
+    - create infrastructure for all kind of tests by reading in all tpm
+      data and store it in a hash
+    - separation of functions handling with tpm data, config file reading
+      and hash creation from the debian functions
+    - work on more packages in one go is now possible, thus the tedious
+      reading of all the tpm files is not necessary anymore
+
+2005-11-05 NP
+  * TeX live 2005 is done. It includes everything up to perforce change #8640.
+  * Make a new set of tpm/licence files
+  * allow independent building of orig.tar.gz files
+  * do not create empty control files
+  * remove old fmt/log files in the postinst script prior to creating
+    them new to get rid of leftovers.
+  * include a lot of checks that dependencies are going right
+
+version 2004.05.10.13-1 UNRELEASED Thu, 13 Oct 2005 22:44:33 +0200
+
+2005-10-13 NP
+  * Include the list of all licenses of all packages into the package
+  * Rebuild packages from current depot including perforce change #8432
+  * move the format generation of etex and pdfetex from -basic to -pdfetex
+  * Install lintian overrides for zero-byte-file-in-doc-directory,
+    extra-license-file, and script-not-executable.
+  * add support for dh_link and create links for some man pages
+
+2005-10-11 NP
+  * Make blacklists collection specific. 
+  * Implement consistency checks:
+    - packages which are included in two collections
+    - packages which are not included at all
+      (missing for bin-* packages)
+  * Include antt and iwona only in texlive-fontsextra and not in 
+    texlive-langpolish.
+
+2005-10-06 NP
+  * change cm-super from Suggest to Depend, as it is now in Debian/sid
+
+2005-10-04 NP
+  * remove last traces of texlive-trees and replace it by Master
+  * Fix postrm scripts to take actions only on remove action, not
+    on purge
+
+2005-09-29 NP
+  * Move to svn://svn.debian.org/pkg-texlive/texlive/trunk/
+  * split tpm2deb from Master, include the Tools perl modules in orig.tar.gz
+
+2005-09-27 NP
+  * Add mktexlsr patch to generate ls-R via a /tmp file and cat into
+    the original one. This way permissions can be set for the ls-R files.
+    Taken from tetex-bin.
+
+2005-09-26 NP
+  * Changed cmd test to which from test -e, so that no actual paths
+    are used in the control scripts (Debian Policy)
+
+version 2004.05.09.25-1 UNRELEASED Sun, 25 Sep 2005 12:03:18 +0200
+
+2005-09-25 NP
+  * Change the test for fmtutil-sys --byhyphen to fmtutil-sys --listcfg
+    and grep for ^latex.
+  * Remove the chmod -x stuff, it breaks execution of various web2c/*
+    scripts (mktexupd, tcfmgr, ...)
+  * Switch to new numbering scheme (tlversion.yy.mm.dd) where tlversion
+    is the last *released* TeX live version and yy.mm.dd is the current
+    date. This way we can have regular releases 200N-debrelease and 
+    additional releases between official TeX live releases.
+  * Fix the order of ifs in postrm scripts so that first the existence of
+    fmtutil-sys is checked, and then wether the latex fmt is installed.
+  * Add myself to the Uploaders field.
+  * New source version, including up to perforce change #8177
+
+2005-09-24 NP
+  * Forget to remove the "all" from the generated rules file. It does
+    not hurt at build time, but I don't like it.
+  * add the fmtutil-sys --byhyphen calling check also to the postrm scripts
+  * remove x bit from all files under texlive-trees at source packages
+    built time
+
+2005-09-23 NP
+  * Fix the lang postinst scripts so that fmtutil-sys --byhyphen is only
+    called if language.dat is found. This is not the optimal method, but
+    the best I can think of ATM.
+  * Actually copy source and not source.development from the depot
+  * make the architecture parameter to tpm2deb unnecessary and put config
+    for this into the tpm2deb.cfg file. Update all the debian/rules files.
+  * Change Maintainer to: 
+    Debian TeX live Maintainers <pkg-texlive-maint@lists.alioth.debian.org>
+  * Added some documentation to tpm2deb.pl, and cleaned up the script
+
+version 2005.09.15-2 UNRELEASED Wed, 21 Sep 2005 16:59:23 +0200
+
+2005-09-20 NP
+  * Move the link /usr/share/texmf/fonts/map -> /etc/texmf/map from
+    texlive-basic to texlive-basicbin as in the later there are several
+    map files and updmap is also in basicbin
+  * Temporary fixes to the tpm files to make texlive-lang* with hyphen files
+    depend on texlive-latex and not only on texlive-basic.
+  * Add (unused) feature to build debian packages for single CTAN packages
+    as well
+
+version 2005.09.15-1 UNRELEASED Thu, 15 Sep 2005 16:14:10 +0200
+
+2005-09-15 NP
+  * New source version, including up to perforce change #8062
+  * fixed format generation problem
+  * make descriptions lines not longer than 80 chars
+
+2005-09-14 NP
+  * add -e to the /bin/sh shebang for error checking in the control scripts
+  * test for existence of various programs before trying to execute them
+    this is for the case when a package is removed but not purged, but
+    the tex-common package is removed, too.
+
+version 2005.08.27-1 UNRELEASED Sat, 27 Aug 2005 16:03:44 +0200
+
+2005-08-27 NP
+  * New source version, including up to perforce change #7870
+  * fix build dependency on libXaw7-dev | libXaw8-dev
+  * Fix generation of formats of texlive-basic. The actual fmt.d files
+    are in texlive-basicbin, but the .ini files are in texlive-basic,
+    so actually the call to fmtutil should be in the postinst of
+    texlive-basic. (Thanks to LUK ShunTim)
+
+2005-08-26 NP
+  * Do not include cm-super.tpm, but suggest the debian package cm-super,
+    which contains the full set of cm-super fonts. For now locally
+    available on tug.
+
+2005-08-25 NP
+  * Fix installation of README.Debian-source into all binary packages
+
+version 2005.08.24-1 UNRELEASED Wed, 24 Aug 2005 18:10:02 +0200
+
+2005-08-24 NP
+  * Everything is build with depot at change #7842
+  * Really fix the info problem: Now all the info files are converted at
+    install time to unix line endings. Thus also the strange ^M in the
+    postinst script install-info commands should be fixed.
+
+2005-08-23 NP
+  * New source version, including up to perforce change #7836
+    This includes fixed versions of pdftex, mpost, dvipdfmx, and as usual
+    several updates to  (La)TeX packages.
+  * fixes the dvips.info install problem
+  * lm is now included in texlive-basic, so changed conflicts in tpm2deb.cfg
+  * generation of /var/cache/font/* and various ls-R files has moved to
+    tex-common (>= 0.7), thus also the changed Depends
+  * Dependency on tex-common (>= 0.7) also fixes the lambda with all
+    languages problem in dumping the format file
+
+2005-08-22 NP
+  * Include the included packages and their title in the long description
+    of the control files, and generate the control files automatically.
+
+version 2005.08.21-1 UNRELEASED Sun, 21 Aug 2005 16:20:00 +0200
+
+2005-08-21 NP
+  * New source version, including up to perforce change #7781
+  * Fix missing dependencies in Depot, should make install/deinstall more
+    clean, and give a full install.
+  * Building the source packages does not need the file revision anymore,
+    all information are deduced from this ChangeLog file
+
+version 2005.08.18-2 UNRELEASED Sat, 20 Aug 2005 22:35:00 +0200
+
+2005-08-20 NP
+  * Fix installation of /var/cache/font etc
+  * Link verious config files into /etc/texmf
+  * remove generated formats in the postrm script
+  * dynamically generate ChangeLog file from the ChangeLog of tpm2deb
+
+version 2005.08.18-1 UNRELEASED Thu, 18 Aug 2005 22:00:00 +0200
+
+2005-08-18 NP
+  * Split out texinfo building into its own (source)package.
+  * More work on the doc disaster.
+
+2005-08-16 NP
+  * Fix info installation again. blacklist now really disables *all*
+    actions, also specials, while empty mappings allow special actions.
+    So the info files from info are blacklisted, all the others are
+    remapped to void and dh_installinfo-ed.
+
+2005-08-12 NP
+  * Fix syntax error in postrm when no actions are defined
+
+2005-08-11 NP
+  * Fix install-info installation
+  * Fix dh_installinfo/dh_compress order in rules, update rules files for
+    arch=all
+  * do not call updmap-sys, fmtutil-sys, update-XXXX in postrm upgrade
+    . /usr/share/doc/pkgname/...
+        contains the actual files
+    . /usr/share/doc/texmf/
+        contains some directories and some symlinks to directories in
+        /usr/share/doc/pkgname (as I said, hope this works, will
+        implement it now and see ;-)
+    . /usr/share/texmf/doc -> ../doc/texmf
+
+2005-08-10 NP
+  * Add support of info files with dh_installinfo
+  * do not install tpm files and fmtutil/* files into /usr/share/texmf
+  * put DocFiles back into /usr/share/texmf/doc, but make links of
+    every file to /usr/share/doc/debname/...
+    Hopefully texdoc is working now.
+
+version 2005.08.02-1 UNRELEASED Tue, 02 Aug 2005 20:00:00 +0200
+
+2005-08-02 NP
+  * Start of ChangeLog and first version
+
+EndOfChangeLog
+
+# vim:set termencoding=iso8859-15 encoding=utf-8 fileencoding=utf-8: #
+# Local Variables:
+# coding: utf-8
+# mode: debian-changelog
+# End:
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-base-bin.override
+++ texlive-bin-2007.dfsg.2/debian/texlive-base-bin.override
@@ -0,0 +1,4 @@
+texlive-base-bin: zero-byte-file-in-doc-directory
+texlive-base-bin: extra-license-file
+texlive-base-bin: script-not-executable
+texlive-base-bin: wrong-name-for-upstream-changelog
--- texlive-bin-2007.dfsg.2.orig/debian/libkpathsea4.override
+++ texlive-bin-2007.dfsg.2/debian/libkpathsea4.override
@@ -0,0 +1,4 @@
+libkpathsea4: zero-byte-file-in-doc-directory
+libkpathsea4: extra-license-file
+libkpathsea4: script-not-executable
+libkpathsea4: wrong-name-for-upstream-changelog
--- texlive-bin-2007.dfsg.2.orig/debian/rules
+++ texlive-bin-2007.dfsg.2/debian/rules
@@ -0,0 +1,157 @@
+#!/usr/bin/make -f
+# 
+# debian/rules file for texlive-bin
+# $Id: rules.in 3421 2008-06-12 16:07:04Z preining $
+
+PACKAGES=texlive-base-bin texlive-extra-utils texlive-font-utils texlive-metapost texlive-omega texlive-xetex texlive-music texlive-lang-indic texlive-metapost-doc texlive-base-bin-doc
+METAPACKAGES=libkpathsea4 libkpathsea-dev
+
+SHELL=/bin/bash
+
+# needed for quilt:
+export QUILT_PATCHES=./debian/patches
+
+
+build: build-stamp
+
+patch: patch-stamp
+
+
+# if we are compiling on armel we have to use gcc/g++ 4.2 to fix the 
+# build error due to upstream bug, see #483939
+DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+GCC_42_ARCHES := armel
+
+ifneq (,$(filter $(DEB_BUILD_ARCH),$(GCC_42_ARCHES)))
+    export CC=gcc-4.2
+    export CXX=g++-4.2
+endif
+
+# still statically links some libs, most notably icu-xetex.
+export TL_CONFIGURE_ARGS=--without-lcdf-typetools --without-dvipng --without-dvipdfmx \
+        --without-dvi2tty --without-texinfo --without-musixflx --without-texi2html \
+        --without-ps2eps --without-psutils --without-sam2p \
+	--without-t1utils --without-cjkutils --without-dvi2tty --without-dvidvi \
+	--without-lacheck --without-tex4htk --without-ttf2pk \
+	--with-system-ncurses --with-system-pnglib --with-system-zlib --with-system-gd \
+	--with-system-tifflib --with-system-wwwlib --with-system-t1lib \
+	--with-system-freetype --with-system-freetype2 \
+	--with-freetype2-include=/usr/include/freetype2 \
+	--with-x --with-xdvi-x-toolkit=xaw --with-mf-x-toolkit \
+	--enable-ipc --enable-shared=default \
+	--without-install-extra
+
+unpack-stamp:
+	mkdir -p build
+	cd build && tar -xjf ../source/source.tar.bz2
+	touch unpack-stamp
+
+configure-stamp: patch-stamp
+	cd build/source && ./Build configure
+	touch $@
+
+build-stamp: configure-stamp
+	cd build/source && ./Build --no-clean build
+	# we disable the extra stuff in the build process (mktexlsr, texlinks
+	# updmap-sys, fmtutil-sys, but we need the links, so we create them
+	# with texlinks now
+	# Is there a better way to find out where the files end up under
+	# inst/bin/ ?
+	# this is done by dh_installtex now
+	#PATH=`pwd`/`ls -d build/source/inst/bin/*`:$$PATH texlinks --cnffile `pwd`/texmf/web2c/fmtutil.cnf
+	# the following works also on non-i386 arch as the Tpm arch is set
+	# to i386-linux in the tpm2deb.pl file. So the build binaries (of any
+	# architecture) will be found in bin/i386-linux.
+	mkdir -p bin/i386-linux
+	cp -a build/source/inst/bin/*/* bin/i386-linux/
+	cp -a bin.special/* bin/i386-linux/
+	# remove wrongly created rpath entry
+	for i in bin/i386-linux/* ; do chrpath -d $$i 2>/dev/null || true ; done
+	for i in build/source/inst/texmf/web2c/*.pool ; do \
+		cp $$i texmf/web2c/ ; \
+	done
+	touch build-stamp
+
+patch-stamp: unpack-stamp
+
+patch-stamp: 
+	quilt push -a
+	touch $@
+	     
+unpatch:
+	# unapply patches, not giving an error when quilt says "No patch removed"
+	quilt pop -a || [ $$? = 2 ]
+	rm -f patch-stamp
+
+clean: unpatch
+	for i in $(PACKAGES) $(METAPACKAGES) ; do \
+	  rm -f debian/$$i.{README.Debian,links,links.generated} ; \
+	  rm -f debian/$$i.{postinst,postrm,preinst,prerm} ; \
+	  rm -f debian/$$i.{maps,languages,formats} ; \
+	done
+	rm -rf build/source/Work build/source/inst
+	rm -rf bin
+	rm -f texmf/web2c/*.pool
+	rm -f texmf-dist/source/plain/pdcmac/config.status
+	dh_clean
+	rm -f configure-stamp
+	rm -f build-stamp
+	rm -f install-stamp
+
+install: install-stamp
+
+install-stamp: build-stamp
+	perl debian/tpm2deb-bin.pl --nosource $(PACKAGES) $(METAPACKAGES)
+	for i in $(PACKAGES) $(METAPACKAGES) ; do \
+	  if [ -d debian/$$i.root ] ; then bash debian/merge-dist-tree debian/$$i.root debian/$$i ; fi ; \
+	  bash debian/generate-license-file $$i ; \
+	  rm -rf debian/$$i/usr/share/texmf-texlive/tpm ; \
+	  install -D --mode=644 debian/$$i.override debian/$$i/usr/share/lintian/overrides/$$i ; \
+	  install -D --mode=755 debian/bug.script debian/$$i/usr/share/bug/$$i/script ; \
+	  install -D --mode=644 debian/bug.control debian/$$i/usr/share/bug/$$i/control ; \
+	  bash debian/create-doc-links $$i texlive-doc > debian/$$i.links ; \
+	  if [ -r debian/$$i.links.dist ] ; then cat debian/$$i.links.dist >> debian/$$i.links ; fi ; \
+	  if [ -r debian/$$i.README ] ; then cat debian/$$i.README > debian/$$i.README.Debian ; fi ; \
+	  cat debian/README.Debian >> debian/$$i.README.Debian ; \
+	done
+	touch install-stamp
+
+binary-indep:
+
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_install
+	dh_installmenu
+	dh_installdocs -A debian/README.source
+	dh_installtex -Ntexlive-base-bin -Nlibkpathsea4	\
+		-Nlibkpathsea-dev -A --priority=10	\
+		texmftrees=/usr/share/texmf-texlive
+	dh_installtex -ptexlive-base-bin --priority=10	\
+		--flavor=format:build_all		\
+		texmftrees=/usr/share/texmf-texlive
+	dh_installchangelogs
+	bash debian/convert-info-files-to-unix.sh
+	bash debian/fix-manpages.sh
+	dh_installinfo
+	dh_installmime
+	dh_link
+	dh_compress -X.pdf
+	dh_fixperms
+	dh_makeshlibs -plibkpathsea4 -V 'libkpathsea4 (>= 2007)'
+	dh_strip
+	dh_shlibdeps -L libkpathsea4 -l debian/libkpathsea4/usr/lib
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+
+.PHONY: build clean binary-indep binary-arch binary install
+
+check_texmfcnf:
+	sh debian/compare-texmf.cnf.sh
+
+
+# eof
--- texlive-bin-2007.dfsg.2.orig/debian/watch
+++ texlive-bin-2007.dfsg.2/debian/watch
@@ -0,0 +1,2 @@
+version=3
+opts=pasv,dversionmangle=s/\.dfsg\.\d+$// ftp://ftp.tug.org/texlive/Images/texlive(....)-live-.*\.iso
--- texlive-bin-2007.dfsg.2.orig/debian/create-doc-links
+++ texlive-bin-2007.dfsg.2/debian/create-doc-links
@@ -0,0 +1,21 @@
+#
+# create-doc-links
+#
+# (c) 2006 Norbert Preining
+# $Id$
+# create links from every file under /usr/share/doc/$1/ to
+# /usr/share/doc/$2/
+#
+
+pref="./debian/$1"
+src="usr/share/doc/$1"
+dst="usr/share/doc/$2"
+
+mkdir -p "$dst"
+
+for f in $(cd "$pref/$src"; find . -mindepth 2 -type f) ; do
+  g=$(echo $f | cut -b 3-)
+  echo "$src/$g" "$dst/$g"
+done
+
+
--- texlive-bin-2007.dfsg.2.orig/debian/bug.script
+++ texlive-bin-2007.dfsg.2/debian/bug.script
@@ -0,0 +1,87 @@
+#!/bin/bash
+# $Id: bug.script 2906 2007-05-29 11:01:20Z frank $
+set -e
+
+cat <<EOF
+
+Please read and follow the instructions in the first lines below
+the text: "-- Package-specific info:".
+Thank you.
+
+Press ENTER to continue
+EOF
+
+getkey
+
+cat >&3 <<EOF
+If you report an error when running one of the TeX-related binaries 
+(latex, pdftex, metafont,...), or if the bug is related to bad or wrong
+output, please include a MINIMAL example input file that produces the
+error in your report. Don't forget to also include minimal examples of
+other files that are needed, e.g. bibtex databases. Often it also helps
+to include the logfile. Please, never send included pictures!
+
+If your example file isn't short or produces more than one page of
+output (except when multiple pages are needed to show the problem),
+you can probably minimize it further. Instructions on how to do that
+can be found at
+
+http://www.latex-einfuehrung.de/mini-en.html (english)
+
+or 
+
+http://www.latex-einfuehrung.de/mini.html (german)
+
+##################################
+minimal input file
+
+
+##################################
+other files
+
+EOF
+
+# unset error exit since those files might not be present...
+set +e
+for dir in $(kpsexpand '$TEXMF' | sed -e 's/,/ /g;s/[!{}]//g;'); do
+  ls_R_files="$ls_R_files $(ls $dir/ls-R 2>/dev/null)";
+done
+ls_R_files="$ls_R_files $(ls /usr/share/texmf-texlive/ls-R 2>/dev/null)"
+
+echo "######################################" >&3
+echo " List of ls-R files" >&3
+echo >&3
+for file in $ls_R_files; do
+  ls -l $file >&3
+#  echo >&3
+#  cat $file >&3
+#  echo "######################################" >&3
+done
+
+echo "######################################" >&3
+echo " Config files" >&3
+for i in texmf.cnf fmtutil.cnf updmap.cfg ; do
+  f=$(kpsewhich --format='web2c files' $i)
+  if [ -z "$f" ] ; then
+    echo "Warning: $i cannot be found with kpsewhich!" >&3
+  else
+    ls -l $f >&3
+  fi
+done
+for i in language.dat ; do
+  f=$(kpsewhich -progname=latex $i)
+  if [ -z "$f" ] ; then
+    echo "Warning: $i cannot be found with kpsewhich!" >&3
+  else
+    ls -l $f >&3
+  fi
+done
+
+echo "######################################" >&3
+echo " Files in /etc/texmf/web2c/" >&3
+ls -l /etc/texmf/web2c/ >&3
+
+echo "######################################" >&3
+echo " md5sums of texmf.d" >&3
+md5sum /etc/texmf/texmf.d/* >&3
+
--- texlive-bin-2007.dfsg.2.orig/debian/fix-manpages.sh
+++ texlive-bin-2007.dfsg.2/debian/fix-manpages.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+# $Id: fix-manpages.sh 2583 2007-03-15 20:12:56Z frank $
+# fix-manpages.sh
+#
+# Several manpages in TeX live have smaller or bigger flaws like:
+# - international characters from latin1 are not written in their
+#   encoded form (ä instead of \[:a])
+# - problems in the first line of the manpage defining wrong section
+#   or syntactical wrong files
+# We fix all these errors on the installed man pages, otherwise lintian
+# complains.
+#
+# Norbert Preining, 2005
+# GPL
+
+set -e
+
+tmpfile=`mktemp`
+
+for i in `find debian/ -wholename 'debian/texlive-*/usr/share/man/man?/*' -type f` ; do
+	bn=`basename $i`
+	case "$bn" in 
+	ttf2pt1.1)
+		# fix ttf2pt1.1 first line error
+		(echo '.TH "ttf2pt1" "1" "Nov 2005" "TeX live" "TeX live"' ; tail --lines=+2 $i ) > $tmpfile
+		cat $tmpfile > $i
+		;;
+	vlna.1)
+		# fix the NAZEV to NAME in vlna.1
+		cat $i | sed -e 's/^\.SH NAZEV/.SH NAME/' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	makeindex.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH MAKEINDEX 1L /.TH MAKEINDEX 1 /' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	detex.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH DETEX 1L /.TH DETEX 1 /' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	dvi2tty.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH DVI2TTY Local /.TH DVI2TTY 1 /' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	dvidvi.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH DVIDVI L /.TH DVIDVI 1 /' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	fmtutil.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH "fmtutil" "8"/.TH "fmtutil" "1"/' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	texlinks.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH "texlinks" "8"/.TH "texlinks" "1"/' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	tie.1)
+		# fix section
+		cat $i | sed -e 's/^\.TH TIE 1L /.TH TIE 1 /' > $tmpfile
+		cat $tmpfile > $i
+		;;
+	esac
+	cat $i | sed 	-e "s/ó/\\['o]/g" 		\
+			-e "s/é/\\['e]/g"		\
+			-e 's/ü/\\[:u]/g'		\
+			-e 's/ä/\\[:a]/g'		\
+			-e 's/ö/\\[:o]/g'		\
+			-e 's/©/\\[co]/g'		\
+				> $tmpfile
+	cat $tmpfile > $i
+done
+
+rm $tmpfile
+
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-base-bin.preinst.post
+++ texlive-bin-2007.dfsg.2/debian/texlive-base-bin.preinst.post
@@ -0,0 +1,31 @@
+# texlive-base-bin.preinst.post begin
+
+
+# unfortunately version 2007-12 of texlive-bin ships a config.ps in
+# /u/s/texlive-bin which is NOT equal to /e/texmf/dvips/config/config.ps
+# in the same version. 
+# We fix this by applying a magic sed command that transforms the one
+# shipped in /u/s/texlive-bin into the old config file
+case  "$1" in
+  upgrade)
+    if [ -n "$2" ] && dpkg --compare-versions "$2" eq 2007-12; then
+      if ! [ -f /etc/texmf/dvips/config/config.ps ] ; then
+        mkdir -p /etc/texmf/dvips/config
+        echo "Reinstalling deleted mandatory conffile config.ps" >&2
+        cat /usr/share/texlive-bin/config.ps | \
+           sed -e "s@% z1 is \"secure\", i.e., inhibits execution of \`shell commands\` in@% Run securely.  z2 disables both shell command execution in\n% \`\\\\special' and config files \(via the \`E\' option\) and opening of any\n% absolute filenames.  z1, the default, forbids shell escapes but@" | \
+           sed -e "s@% \\\\specials.  Dvips allows this by default.@% allows absolute filenames.  z0 allows both.  The corresponding\n% commandline options are -R0|-R1|-R2@" > /etc/texmf/dvips/config/config.ps
+      fi
+    fi
+    ;;
+  *)
+    ;;
+esac
+
+# Cleanup after Bug #420390 for sid users
+# For config.ps and upgrade from 2007-12 this is done as above, but
+# as soon as -12 has vanished we can delete the above code!
+resurrect_conffile_sid /etc/texmf/tex/generic/config/pdftexconfig.tex texlive-bin "$1" "$2"
+resurrect_conffile_sid /etc/texmf/dvips/config/config.ps texlive-bin "$1" "$2"
+
+# texlive-base-bin.preinst.post end
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-metapost.override
+++ texlive-bin-2007.dfsg.2/debian/texlive-metapost.override
@@ -0,0 +1,4 @@
+texlive-metapost: zero-byte-file-in-doc-directory
+texlive-metapost: extra-license-file
+texlive-metapost: script-not-executable
+texlive-metapost: wrong-name-for-upstream-changelog
--- texlive-bin-2007.dfsg.2.orig/debian/source.lintian-overrides
+++ texlive-bin-2007.dfsg.2/debian/source.lintian-overrides
@@ -0,0 +1,3 @@
+texlive-bin source: maintainer-script-lacks-debhelper-token debian/common.functions.preinst
+texlive-bin source: maintainer-script-lacks-debhelper-token debian/common.functions.postinst
+texlive-bin source: maintainer-script-lacks-debhelper-token debian/common.functions.postrm
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-base-bin.preinst.pre
+++ texlive-bin-2007.dfsg.2/debian/texlive-base-bin.preinst.pre
@@ -0,0 +1,53 @@
+#
+# texlive-base-bin.preinst.pre
+#
+# remove the /etc/texmf/texlive/mktex.cnf file from version <= 2005-2
+# remove the link /usr/share/texmf-texlive/web2c/mktex.cnf
+# new packages install the file in /usr/share/texmf-texlive/web2c/mktex.cnf
+# and this is overriden by tex-common's /usr/share/texmf/web2c/mktex.cnf
+#
+
+if [ $# -eq 2 ] && [ "$2" = "2005-2" ] && ( [ "$1" = "install" ] || [ "$1" = "upgrade" ] ); then
+	# remove the link in any case
+	rm -f /usr/share/texmf-texlive/web2c/mktex.cnf
+	# now for the conffile
+	oldfile=/etc/texmf/texlive/mktex.cnf
+	originalmd5sum=83c6f33da512a8b49f6e9d2c399bd69a
+	installedmd5sum=$(md5sum "$oldfile" |  cut -d ' ' -f 1)
+	if [ "$originalmd5sum" = "$installedmd5sum" ] ; then
+		echo "Removing obsolete, unchanged conffile $oldfile"
+		rm $oldfile
+	else
+		echo "
+Warning: you appear to have modified $oldfile. Please read the document
+	/usr/share/doc/tex-common/README.Debian
+The old file has been saved as /etc/texmf/texlive/mktex.cnf.old and will
+not be used."
+		mv $oldfile $oldfile.old
+	fi
+fi
+
+# take over 10texlive-pdfetex.cnf from version <2007
+# no need to rename, postinst can handle the old name well
+old_cfg=/etc/texmf/fmt.d/10texlive-pdfetex.cnf
+
+if [ -f $old_cfg ]; then
+  # we can use dpkg_md5sum which is in common.functions.preinst
+  mdorig=$(dpkg_md5sum $old_cfg texlive-pdfetex)
+  if [ $(md5sum "$old_cfg" | cut -f 1 -d ' ') = "$mdorig" ] ; then
+    rm -f $old_cfg
+  fi
+fi
+
+# remove any format or log files in /var/lib/texmf/web2c, they must be
+# in $engine subdirs now.  tetex does not properly remove them, and
+# they cause strange failures with context.
+for ext in fmt mem log base; do
+  rm -f /var/lib/texmf/web2c/*.$ext
+done
+
+
+# texlive-base-bin.preinst.pre end
+# Local Variables:
+# mode: shell-script
+# End:
--- texlive-bin-2007.dfsg.2.orig/debian/libkpathsea-dev.override
+++ texlive-bin-2007.dfsg.2/debian/libkpathsea-dev.override
@@ -0,0 +1,4 @@
+libkpathsea-dev: zero-byte-file-in-doc-directory
+libkpathsea-dev: extra-license-file
+libkpathsea-dev: script-not-executable
+libkpathsea-dev: wrong-name-for-upstream-changelog
--- texlive-bin-2007.dfsg.2.orig/debian/compat
+++ texlive-bin-2007.dfsg.2/debian/compat
@@ -0,0 +1 @@
+5
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-xetex.override
+++ texlive-bin-2007.dfsg.2/debian/texlive-xetex.override
@@ -0,0 +1,4 @@
+texlive-xetex: zero-byte-file-in-doc-directory
+texlive-xetex: extra-license-file
+texlive-xetex: script-not-executable
+texlive-xetex: wrong-name-for-upstream-changelog
--- texlive-bin-2007.dfsg.2.orig/debian/preinst.pre
+++ texlive-bin-2007.dfsg.2/debian/preinst.pre
@@ -0,0 +1,18 @@
+# preinst.pre
+# $Id: preinst.pre 2583 2007-03-15 20:12:56Z frank $
+# we want to be sure that experimental versions are purged before
+# the first unstable is installed
+# furthermore check that we are at least at version 2005 for the 
+# temporary tetex packages upgrades
+case "$1" in
+  upgrade|install)
+    old_version=$2
+    if [ -n "$old_version" ] && dpkg --compare-versions "$old_version" lt 2005-2 && dpkg --compare-versions "$old_version" gt 2005 ; then
+      echo "Upgrade from experimental versions are not supported!" >&2
+      echo "Please purge all texlive packages before installation." >&2
+      exit 1
+    fi
+    ;;
+esac
+
+# end preinst.pre
--- texlive-bin-2007.dfsg.2.orig/debian/merge-dist-tree
+++ texlive-bin-2007.dfsg.2/debian/merge-dist-tree
@@ -0,0 +1,38 @@
+#
+# merge-dist-tree
+# $Id: merge-dist-tree 2583 2007-03-15 20:12:56Z frank $
+# (c) 2006 Norbert Preining
+#
+# merge tree $1 into destination $2
+# files in tree $1 with extension .uu are uudecoded installed into $2
+#
+
+src="$1"
+dst="$2"
+
+if ! [ -d "$dst" ] ; then
+  echo "please first call debian/rules install!"
+  exit 1
+fi
+
+if ! [ -d "$src" ] ; then
+  echo "first argument must be a directory: $src"
+  exit 1
+fi
+
+for f in $(cd "$src"; find . -type f) ; do
+  bn=$(basename "$f")
+  dn=$(dirname "$f")
+  mkdir -p "$dst/$dn"
+  case "$f" in
+    *.uu)
+      bn=$(basename "$f" .uu)
+      uudecode -o "$dst/$dn/$bn" "$src/$f"
+      ;;
+    *)
+      cp -a "$src/$f" "$dst/$dn/"
+      ;;
+  esac
+done
+
+
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-metapost.root/usr/share/texmf-texlive/tex/context/base/supp-mis.tex
+++ texlive-bin-2007.dfsg.2/debian/texlive-metapost.root/usr/share/texmf-texlive/tex/context/base/supp-mis.tex
@@ -0,0 +1,711 @@
+%D \module
+%D   [       file=supp-mis,
+%D        version=2004.10.26, % 1997.01.04,
+%D          title=\CONTEXT\ Support Macros,
+%D       subtitle=Missing (For Generic Use),
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D I will clean up this module (a la supp-pdf.tex preamble).
+
+%D Some support modules are more or less independant. This
+%D module, which is not part of plain \CONTEXT, provides the
+%D missing macros and declarations of registers.
+
+\ifx \undefined \writestatus \else \expandafter \endinput \fi
+
+%D Because \LATEX\ has no safe package loading mechanism, we
+%D need to take care of possible interference.
+
+\def\StartLatexHack % replace this by the one in supp-pdf
+  {\edef\StopLatexHack
+     {\catcode\string`\noexpand/=\the\catcode\string`/
+      \catcode\string`\noexpand-=\the\catcode\string`-
+      \catcode\string`\noexpand:=\the\catcode\string`:
+      \catcode\string`\noexpand;=\the\catcode\string`;
+      \catcode\string`\noexpand"=\the\catcode\string`"
+      \catcode\string`\noexpand<=\the\catcode\string`<
+      \catcode\string`\noexpand>=\the\catcode\string`>
+      \catcode\string`\noexpand`=\the\catcode\string``}%
+  \catcode\string`/=12 \catcode\string`-=12
+  \catcode\string`:=12 \catcode\string`;=12
+  \catcode\string`"=12 \catcode\string`<=12
+  \catcode\string`>=12 \catcode\string``=12 }
+
+%D This hack is needed especially for \LATEX\ users who use
+%D the Babel package. The Germans have active \type {"}'s, the
+%D Poles have \type {/}, while the French have \type {:} and
+%D \type {;} defines as command (thanks to Daniel Flipo for
+%D pointing that out and testing). Potentially active \type
+%D {?}'s and \type {!}'s are less dangerous since they are
+%D handled by the \type {\protect} and \type {\unprotect}
+%D macros.
+
+\StartLatexHack
+
+%D \macros
+%D   {ifnocontextobject}
+%D
+%D First we take care of redundant defining. The next set of
+%D macros are a bit complicated by the fact that Plain
+%D \TEX\ defines the \type{\new}||macros as being outer.
+%D Furthermore nested \type{\if}'s can get us into
+%D trouble.
+
+\def\definecontextobject
+  {\iftrue}
+
+\def\gobblecontextobject
+  {\setbox0\hbox
+     \bgroup
+     \long\def\gobblecontextobject##1\fi{\egroup}%
+     \expandafter\gobblecontextobject\string}
+
+\long\def\ifnocontextobject#1\do
+  {\ifx#1\undefined
+     \expandafter\definecontextobject
+   \else
+     %\writestatus{system}{beware of conflicting \string#1}%
+     \expandafter\gobblecontextobject
+   \fi}
+
+%D \macros
+%D   {beginETEX,beginTEX}
+%D
+%D Outside \CONTEXT\ we will not be \ETEX||aware.
+
+\long\def\beginETEX #1\endETEX {}
+\long\def\beginOMEGA#1\endOMEGA{}
+
+\let\beginTEX\relax \let\endTEX\relax
+
+%D \macros
+%D   {writestatus}
+%D
+%D We start each module with a message. Normally the output is
+%D formatted, but here we keep things simple.
+
+\ifnocontextobject \writestatus \do
+
+  \def\writestatus#1#2%
+    {\immediate\write16{#1 : #2}}
+
+\fi
+
+%D Let's see if it works.
+
+\writestatus{loading}{Context Support Macros / Miscellaneous (2004.10.26)}
+
+%D \macros
+%D   {protect,unprotect}
+%D
+%D Next we present a poor mans alternative for \type{\protect}
+%D and \type{\unprotect}, two commands that enable us to use
+%D the characters \type{@}, \type{!} and \type{?} in macro
+%D names.
+
+\ifnocontextobject \protect \do
+
+  \let\protect\relax
+
+\fi
+
+\newcount\protectiondepth
+
+\ifnocontextobject \unprotect \do
+
+  \def\unprotect
+    {\advance\protectiondepth 1
+     \ifnum\protectiondepth=1
+       \let\normalprotect=\protect
+       \def\protect
+         {\ifnum\protectiondepth>0
+            \advance\protectiondepth -1
+            \ifnum\protectiondepth=0
+              \doprotect
+              \let\protect=\normalprotect
+            \fi
+          \fi}
+       \edef\doprotect
+         {\catcode`\noexpand @=\the\catcode`@\relax
+          \catcode`\noexpand !=\the\catcode`!\relax
+          \catcode`\noexpand ?=\the\catcode`?\relax}
+       \catcode`@=11
+       \catcode`!=11
+       \catcode`?=11
+     \fi}
+
+\fi
+
+%D We start using this one it at once.
+
+\unprotect
+
+%D \macros
+%D   {scratch...,if...,next...}
+%D
+%D We need some scratch registers. Users are free to use them,
+%D but can never be sure of their value once another macro is
+%D called. We only allocate things when they are yet
+%D undefined. This way we can't mess up other macro packages,
+%D but of course previous definitions can mess up our modules.
+
+\ifnocontextobject \donetrue \do \newif\ifdone \fi
+
+% no time now, will do a better test later (based on dimendef)
+
+\def\!!stringa{plain}       \ifx\!!stringa\fmtname \donetrue  \else
+\def\!!stringa{eplain}      \ifx\!!stringa\fmtname \donetrue  \else
+\def\!!stringa{babel-plain} \ifx\!!stringa\fmtname \donetrue  \else
+                                                   \donefalse \fi \fi \fi
+
+\ifdone
+  % plain defines some 15 dimens, so we need to define a few
+  % dummies in order to get out of the scratch area
+  \newdimen\scratchdimen % 16
+  \newdimen\scratchdimen % 17
+  \newdimen\scratchdimen % 18
+  \newdimen\scratchdimen % 19
+  \newdimen\scratchdimen % 20
+  \newdimen\scratchdimen % 21
+\fi
+
+\def\stripnewabove#1%
+  {\ifnum10<9#1 #1\else\expandafter\stripnewabove\fi}%
+
+\def\newabove\csname#1\endcsname#2% \dimen \name
+  {\csname#1\endcsname#2%
+   \ifnum\expandafter\stripnewabove\meaning#2>20\else
+     \newabove\csname#1\endcsname#2%
+   \fi}
+
+\ifnocontextobject \scratchcounter \do \newabove \csname  newcount\endcsname \scratchcounter \fi
+\ifnocontextobject \scratchtoks    \do \newabove \csname   newtoks\endcsname    \scratchtoks \fi
+\ifnocontextobject \scratchdimen   \do \newabove \csname  newdimen\endcsname   \scratchdimen \fi
+\ifnocontextobject \scratchskip    \do \newabove \csname   newskip\endcsname    \scratchskip \fi
+\ifnocontextobject \scratchmuskip  \do \newabove \csname newmuskip\endcsname  \scratchmuskip \fi
+\ifnocontextobject \scratchbox     \do           \csname    newbox\endcsname     \scratchbox \fi
+\ifnocontextobject \scratchread    \do           \csname   newread\endcsname    \scratchread \fi
+\ifnocontextobject \scratchwrite   \do           \csname   newwrite\endcsname  \scratchwrite \fi
+
+%D Watch out, in the past we ran into troubles with \type {\onepoint}
+%D (and others) mening something different in \LATEX\ then here. In
+%D such situations clashes are bound to happen. For this reason the
+%D assignments are no inside the test. We try to catch those situations
+%D but we cannot keep ahead of the future.
+
+\ifnocontextobject \zeropoint      \do \newdimen  \zeropoint      \zeropoint     =    0pt \fi % else problems with dimen12
+\ifnocontextobject \onepoint       \do \newdimen  \onepoint       \onepoint      =    1pt \fi
+\ifnocontextobject \onebasepoint   \do \newdimen  \onebasepoint   \onebasepoint  =    1bp \fi
+\ifnocontextobject \zerocount      \do \chardef   \zerocount                     =      0 \fi
+\ifnocontextobject \plusone        \do \chardef   \plusone                       =      1 \fi
+\ifnocontextobject \minusone       \do \newcount  \minusone       \minusone      =     -1 \fi
+\ifnocontextobject \thousandpoint  \do \newdimen  \thousandpoint  \thousandpoint = 1000pt \fi
+\ifnocontextobject \onerealpoint   \do \newdimen  \onerealpoint   \onerealpoint  =    1pt \fi % latex has a funny \onepoint
+
+\ifnocontextobject \emptytoks      \do \newtoks   \emptytoks \fi
+\ifnocontextobject \nextbox        \do \newbox    \nextbox   \fi
+\ifnocontextobject \nextdepth      \do \newdimen  \nextdepth \fi
+
+\ifnocontextobject \CONTEXTtrue            \do \newif\ifCONTEXT            \fi
+\ifnocontextobject \eightbitcharacterstrue \do \newif\ifeightbitcharacters \fi
+\ifnocontextobject \MPdrawingdonetrue      \do \newif\ifMPdrawingdone      \fi
+
+\ifnocontextobject \ifzeropt               \do \let\ifzeropt\ifcase        \fi
+
+%D \macros
+%D   {@@...}
+%D
+%D We use symbolic name for \CATCODES. They can only be used
+%D when we are in unprotected state.
+
+\ifnocontextobject \@@escape     \do \chardef\@@escape     =  0 \fi
+\ifnocontextobject \@@begingroup \do \chardef\@@begingroup =  1 \fi
+\ifnocontextobject \@@endgroup   \do \chardef\@@endgroup   =  2 \fi
+\ifnocontextobject \@@endofline  \do \chardef\@@endofline  =  5 \fi
+\ifnocontextobject \@@ignore     \do \chardef\@@ignore     =  9 \fi
+\ifnocontextobject \@@space      \do \chardef\@@space      = 10 \fi
+\ifnocontextobject \@@letter     \do \chardef\@@letter     = 11 \fi
+\ifnocontextobject \@@other      \do \chardef\@@other      = 12 \fi
+\ifnocontextobject \@@active     \do \chardef\@@active     = 13 \fi
+\ifnocontextobject \@@comment    \do \chardef\@@comment    = 14 \fi
+
+\def\s!sp{sp}
+\def\s!pt{pt}
+\def\s!bp{bp}
+
+%D \macros
+%D   {@EA,expanded,expandoneargafter,expandtwoargsafter}
+%D
+%D Also needed:
+
+\let\@EA=\expandafter \let\@@expanded\empty
+
+\def\expanded#1%
+  {\long\xdef\@@expanded{\noexpand#1}\@@expanded}
+
+\def\expandoneargafter#1#2%
+  {\@EA#1\@EA{#2}}
+
+\def\expandtwoargsafter#1#2#3%
+  {\@EA\@EA\@EA#1\@EA\@EA\@EA{\@EA#2\@EA}\@EA{#3}}
+
+\def\@EAEAEA{\@EA\@EA\@EA}
+
+%D \macros
+%D   {everyline,EveryLine,EveryPar}
+%D
+%D In \CONTEXT\ we use \type{\everypar} for special purposes
+%D and provide \type{\EveryPar} as an alternative. The same
+%D goes for \type{\everyline} and \type{\EveryLine}.
+
+\ifnocontextobject \everyline \do \newtoks\everyline        \fi
+\ifnocontextobject \EveryPar  \do \let\EveryPar =\everypar  \fi
+\ifnocontextobject \EveryLine \do \let\EveryLine=\everyline \fi
+
+%D \macros
+%D   {globallet}
+
+\def\globallet{\global\let}
+
+%D \macros
+%D   {!!...}
+%D
+%D We reserve ourselves some scratch strings (i.e. macros)
+%D and some more counters.
+
+\ifnocontextobject \!!stringa \do \def\!!stringa {} \fi
+\ifnocontextobject \!!stringb \do \def\!!stringb {} \fi
+\ifnocontextobject \!!stringc \do \def\!!stringc {} \fi
+\ifnocontextobject \!!stringd \do \def\!!stringd {} \fi
+
+\ifnocontextobject \!!counta \do \newcount\!!counta {} \fi
+\ifnocontextobject \!!countb \do \newcount\!!countb {} \fi
+
+%D \macros
+%D   {!!...}
+%D
+%D The next set of definitions speed up processing a bit.
+%D Furthermore it saves memory.
+
+\ifnocontextobject \!!zeropoint   \do \def\!!zeropoint   {0pt}    \fi
+\ifnocontextobject \!!zerocount   \do \def\!!zerocount   {0}      \fi
+\ifnocontextobject \!!tenthousand \do \def\!!tenthousand {10000}  \fi
+
+\ifnocontextobject \!!width       \do \def\!!width       {width}  \fi
+\ifnocontextobject \!!height      \do \def\!!height      {height} \fi
+\ifnocontextobject \!!depth       \do \def\!!depth       {depth}  \fi
+
+\ifnocontextobject \!!plus        \do \def\!!plus        {plus}   \fi
+\ifnocontextobject \!!minus       \do \def\!!minus       {minus}  \fi
+\ifnocontextobject \!!to          \do \def\!!to          {to}     \fi
+
+%D \macros
+%D   {smashbox}
+%D
+%D The system modules offer a range of smashing macros, of
+%D which we only copied \type{\smashbox}.
+
+\ifnocontextobject \smashbox \do
+
+  \def\smashbox#1%
+    {\wd#1\zeropoint
+     \ht#1\zeropoint
+     \dp#1\zeropoint}
+
+\fi
+
+%D \macros
+%D   {dowithnextbox}
+%D
+%D Also without further comment, we introduce a macro that
+%D gets the next box and does something usefull with it.
+%D Because the \type{\afterassignment} is executed inside the
+%D box, we have to use a \type{\aftergroup} too.
+
+\ifnocontextobject \dowithnextbox \do
+
+  \def\dowithnextbox#1%
+    {\def\dodowithnextbox{#1}%
+     \afterassignment\dododowithnextbox
+     \setbox\nextbox}
+
+  \def\dododowithnextbox%
+    {\aftergroup\dodowithnextbox}
+
+\fi
+
+%D \macros
+%D   {setvalue,setevalue,setxvalue,,setgvalue,
+%D    getvalue,
+%D    letvalue,letgvalue}
+%D
+%D The next two macros expand their argument to
+%D \type{\argument}. The first one is used to define macro's
+%D the second one executes them.
+
+\ifnocontextobject \setvalue \do
+
+  \def\setvalue #1{\expandafter\def\csname#1\endcsname}
+  \def\setevalue#1{\expandafter\edef\csname#1\endcsname}
+  \def\setgvalue#1{\expandafter\gdef\csname#1\endcsname}
+  \def\setxvalue#1{\expandafter\xdef\csname#1\endcsname}
+  \def\getvalue #1{\csname#1\endcsname}
+  \def\letvalue #1{\expandafter\let\csname#1\endcsname}
+  \def\letgvalue#1{\global\expandafter\let\csname#1\endcsname}
+\fi
+
+%D \macros
+%D   {unexpanded}
+%D
+%D The next command can be used as prefixed for commands that
+%D need protection during tests and writing to files. This
+%D is a very \CONTEXT\ specific one.
+
+\ifnocontextobject \unexpanded \do
+
+  \let\unexpanded\relax
+
+\fi
+
+%D \macros
+%D   {convertargument}
+%D
+%D The original one offers a bit more, like global assignment, the
+%D the next implementation is however a bit more byte saving.
+
+\ifnocontextobject \convertargument \do
+
+  \def\doconvertargument#1>{}
+
+  \long\def\convertargument#1\to#2%
+    {\long\def\@@convertedargument{#1}%
+     \edef#2{\expandafter\doconvertargument\meaning\@@convertedargument}}
+
+\fi
+
+%D \macros
+%D   {forgetall}
+%D
+%D Sometimes we have to disable interference of whatever kind
+%D of skips and mechanisms. The next macro resets some.
+
+\ifnocontextobject \forgetall \do
+
+  \def\forgetall
+    {\parskip\zeropoint
+     \leftskip\zeropoint
+     \parindent\zeropoint
+     \everypar{}}
+
+\fi
+
+%D \macros
+%D   {withoutpt,
+%D    ScaledPointsToBigPoints,ScaledPointsToWholeBigPoints}
+%D
+%D \TEX\ lacks some real datastructure. We can however use
+%D \DIMENSIONS. This kind of trickery is needed when we want
+%D \TEX\ to communicate with the outside world (by means of
+%D \type{\specials}).
+
+\ifnocontextobject \withoutpt \do
+
+  {\catcode`\.=\@@other
+   \catcode`\p=\@@other
+   \catcode`\t=\@@other
+   \gdef\WITHOUTPT#1pt{#1}}
+
+  \def\withoutpt#1%
+    {\expandafter\WITHOUTPT#1}
+
+  \def\ScaledPointsToBigPoints#1#2%
+    {\scratchdimen=#1sp\relax
+     \scratchdimen=.996264\scratchdimen
+     \edef#2{\withoutpt{\the\scratchdimen}}}
+
+  \def\ScaledPointsToWholeBigPoints#1#2%
+    {\scratchdimen=#1sp
+     \scratchdimen=.996264\scratchdimen
+     \scratchcounter=\scratchdimen
+     \advance\scratchcounter by 32768
+     \divide\scratchcounter by 65536
+     \edef#2{\the\scratchcounter}}
+
+\fi
+
+%D \macros
+%D   {doprocessfile}
+%D
+%D This macro takes three arguments: the file number, the
+%D filename and a macro that handles the content of a read
+%D line.
+
+\newif\iffileprocessed
+
+\ifnocontextobject \doprocessfile \do
+
+  \def\doprocessfile#1#2#3%
+    {\openin#1=#2\relax
+     \ifeof#1%
+       \fileprocessedfalse
+       \closein#1\relax
+     \else
+       \fileprocessedtrue
+       \gdef\dofinishfile%
+         {\closein#1\relax
+          \global\let\doprocessline\relax}%
+       \gdef\doprocessline%
+         {\ifeof#1%
+            \dofinishfile
+          \else
+            \global\read#1 to \fileline
+            #3\relax
+            \expandafter\doprocessline
+          \fi}%
+       \expandafter\doprocessline
+     \fi}
+
+\fi
+
+%D \macros
+%D   {uncatcodespecials}
+%D
+%D This one is taken from the \TEX\ book. The \CONTEXT\
+%D alternative is a bit different, but we hope this one works
+%D here.
+
+\ifx\dospecials\undefined
+
+  \def\dospecials
+    {\do\ \do\\\do\{\do\}\do\$%
+     \do\#\do\^\do\_\do\&\do\%%
+     \do\~\do\^^A\do\^^K}
+
+\fi
+
+\ifnocontextobject \uncatcodespecials \do
+
+  \def\uncatcodespecials
+    {\def\do##1{\catcode`##1=12 }\dospecials
+     \catcode`\   =\@@space
+     \catcode`\^^L=\@@ignore
+     \catcode`\^^M=\@@endofline
+     \catcode`\^^?=\@@ignore}
+
+\fi
+
+\ifnocontextobject \setnaturalcatcodes \do
+
+\def\setnaturalcatcodes
+  {\catcode`\!=\@@other \catcode`\?=\@@other \catcode`\@=\@@other
+   \catcode`\#=\@@other \catcode`\&=\@@other \catcode`\|=\@@other
+   \catcode`\$=\@@other \catcode`\^=\@@other \catcode`\_=\@@other
+   \catcode`\*=\@@other \catcode`\/=\@@other
+   \catcode`\-=\@@other \catcode`+=\@@other
+   \catcode`\==\@@other \catcode`\<=\@@other \catcode`\>=\@@other
+   \catcode`\"=\@@other \catcode`\'=\@@other \catcode`\`=\@@other
+   \catcode`\:=\@@other \catcode`\;=\@@other
+   \catcode`\,=\@@other \catcode`\.=\@@other \catcode`\~=\@@other
+   \catcode`\(=\@@other \catcode`\)=\@@other
+   \catcode`\{=\@@other \catcode`\}=\@@other
+   \catcode`\\=\@@other \catcode`\%=\@@other }
+
+\fi
+
+%D \macros
+%D   {doglobal}
+%D
+%D Some \CONTEXT\ low level macros can have a \type{\doglobal}
+%D prefix. Let's just forget about that here:
+
+\ifnocontextobject \doglobal \do \let\doglobal\relax  \fi
+
+%D The next obscure one is needed in the generic verbatim
+%D environment. When we end up with more of these, it's time
+%D to load the module \type{syst-gen}.
+
+\ifnocontextobject \doifincsnameelse \do
+
+  \def\dodoifincsnameelse#1#2%
+    {\def\dododoifincsnameelse##1#1##2##3\war%
+       {\csname\if##2@iffalse\else iftrue\fi\endcsname}%
+     \expandafter\dododoifincsnameelse#2#1@@\war}
+
+  \long\def\doifincsnameelse#1#2#3#4%
+    {\edef\@@instring{#1}%
+     \expandafter\dodoifincsnameelse\expandafter{\@@instring}{#2}%
+       #3%
+     \else
+       #4%
+     \fi}
+
+\fi
+
+%D \macros
+%D   {dostepwiserecurse, dorecurse, doloop, exitloop}
+%D
+%D The next loop macro is a real weak one, and does not offer
+%D the full \CONTEXT\ functionality, let alone nesting, but
+%D for simple purposes, its behaviour is acceptable.
+
+\newcount\recursecounter
+
+\def\dostepwiserecurse#1#2#3#4% very weak and rubishly version
+  {\ifnum#2<#1\relax\else\dodostepwiserecurse{#1}{#2}{#3}{#4}\fi}
+
+\def\dodostepwiserecurse#1#2#3#4% very weak and rubishly version
+  {\recursecounter=#1\relax
+   \loop
+     \edef\recurselevel{\the\recursecounter}%
+     #4\relax
+   \ifnum\recursecounter<#2\relax
+     \advance\recursecounter by #3\relax
+   \repeat}
+
+\def\dorecurse#1%
+  {\dostepwiserecurse{1}{#1}{1}}
+
+\def\doloop
+  {\dostepwiserecurse{1}{\maxdimen}{1}}
+
+\def\exitloop
+  {\recursecounter=\maxdimen}
+
+%D \macros
+%D   {ifundefined,doifdefined,doifundefined,
+%D    doifdefinedelse,doifundefinedelse}
+%D
+%D These alteratives are not robust but suitable for simple
+%D usage. The official ones are a bit faster.
+
+\ifnocontextobject \doifdefined \do
+
+  \def\ifundefined#1%
+    {\expandafter\ifx\csname#1\endcsname\relax}
+
+  \def\doifdefinedelse#1#2#3%
+    {\expandafter\ifx\csname#1\endcsname\relax#3\else#2\fi}
+
+  \def\doifundefinedelse#1#2#3%
+    {\expandafter\ifx\csname#1\endcsname\relax#2\else#3\fi}
+
+  \def\doifdefined#1#2%
+    {\expandafter\ifx\csname#1\endcsname\relax\else#2\fi}
+
+  \def\doifundefined#1#2%
+    {\expandafter\ifx\csname#1\endcsname\relax#2\fi}
+
+\fi
+
+%D \macros
+%D   {doifinstringelse}
+%D
+%D It seems like we end up with more and more macros here.
+%D Sigh.
+
+\ifnocontextobject \doifinstringelse \do
+
+  \def\p!doifinstringelse#1#2%
+    {\def\pp!doifinstringelse##1#1##2##3\war%
+       {\csname if\if##2@fals\else tru\fi e\endcsname}%
+     \expanded{\pp!doifinstringelse#2#1@@\noexpand\war}}
+
+  \long\def\doifinstringelse#1#2#3#4%
+    {\edef\@@@instring{#1}%
+     \@EA\p!doifinstringelse\@EA{\@@@instring}{#2}#3\else#4\fi}
+
+\fi
+
+%D \macros
+%D   {twodigitrounding}
+%D
+%D We don't support rounding outside \CONTEXT. Sorry.
+
+\def\twodigitrounding#1{#1}
+
+%D \macros
+%D   {lineheight}
+%D
+%D In \CONTEXT\ we have \type{\lineheight}, which in many
+%D cases matches \type {\baselineskip}.
+
+\ifnocontextobject \lineheight \do
+
+  \def\lineheight{\baselineskip}
+
+\fi
+
+%D \macros
+%D   {dohandletokens}
+%D
+%D The following macro is the simplified version, but good
+%D enough for day to day hacks.
+%D
+%D \starttyping
+%D \dohandletokens some text\with\somemacro
+%D \stoptyping
+
+\ifnocontextobject \dohandletokens \do
+
+\def\dodohandletokens
+  {\ifx\next\end \else
+     \docommand{\next}%
+     \expandafter\dohandletokens
+   \fi}
+
+\def\dohandletokens
+  {\afterassignment\dodohandletokens\let\next= }
+
+\long\def\handletokens#1\with#2%
+  {\let\docommand=#2%
+   \dohandletokens#1\end}
+
+\fi
+
+%D Very reduced:
+
+\long\def\appendtoks#1\to#2%
+  {\scratchtoks{#1}\expanded{#2{\the#2\the\scratchtoks}}}
+
+%D Well, also handy.
+
+\def\doiffileelse#1#2#3%
+  {\immediate\openin\scratchread=#1\relax
+   \ifeof\scratchread
+     \def\next{#3}%
+   \else
+     \def\next{#2}%
+   \fi
+   \immediate\closein\scratchread
+   \next}
+
+%D New.
+
+\let\donothing\empty
+
+%D Also new:
+
+\def\letempty             #1{\let#1\empty}
+\def\globalletempty#1{\global\let#1\empty}
+
+\def\letvalueempty        #1{\expandafter\let\csname#1\endcsname\empty}
+\def\letgvalueempty#1{\global\expandafter\let\csname#1\endcsname\empty}
+
+%D Sigh
+
+\def\settrue #1{\chardef#1\zerocount}
+\def\setfalse#1{\chardef#1\plusone}
+
+\let\newconditional = \setfalse
+\let\ifconditional  = \ifcase
+
+%D That's it. Please forget this junk and take a look at how
+%D it should be done.
+
+\StopLatexHack \protect \endinput
--- texlive-bin-2007.dfsg.2.orig/debian/texlive-metapost.root/usr/share/texmf-texlive/tex/context/base/supp-pdf.tex
+++ texlive-bin-2007.dfsg.2/debian/texlive-metapost.root/usr/share/texmf-texlive/tex/context/base/supp-pdf.tex
@@ -0,0 +1,2278 @@
+%D \module
+%D   [       file=supp-pdf,
+%D        version=2006.09.02, % 2004.12.16,
+%D          title=\CONTEXT\ Support Macros,
+%D       subtitle=\METAPOST\ to \PDF\ conversion,
+%D         author=Hans Hagen \& others (see text),
+%D           date=\currentdate,
+%D      copyright=\PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\ifx\writestatus\undefined
+  \immediate\write16{[Loading MPS to PDF converter (version 2006.09.02).]}
+\else
+  \writestatus{loading}{Context Support Macros / PDF}
+\fi
+
+%D This module is not optimized because it is used outside
+%D \CONTEXT\ and we cannot forsee what interference will take
+%D place. We no longer load supp-mis. I got too tired of
+%D keeping track of interferences with non \CONTEXT\ usage so
+%D I moved the necessary code in here and use a derived version
+%D in \CONTEXT. When I have the time I will clean up some of the
+%D code that is of no use for non||\CONTEXT\ users.
+
+\ifx\contextversion\undefined
+
+    \chardef\mptopdfstoredatcode\catcode`\@
+
+    \catcode\string`@=11
+
+    \def\unprotect
+      {\let\@@mpstopdf@@unprotect   \unprotect
+       \let\@@mpstopdf@@protect     \protect
+       \edef\protect
+         {\noexpand \let \noexpand \protect   \noexpand \@@mpstopdf@@protect
+          \noexpand \let \noexpand \unprotect \noexpand \@@mpstopdf@@unprotect
+          % context specific
+          \catcode\string`\noexpand @=\the\catcode\string`@
+          \catcode\string`\noexpand !=\the\catcode\string`!
+          \catcode\string`\noexpand ?=\the\catcode\string`?
+          % latex specific
+          \catcode\string`\noexpand /=\the\catcode\string`/
+          \catcode\string`\noexpand -=\the\catcode\string`-
+          \catcode\string`\noexpand :=\the\catcode\string`:
+          \catcode\string`\noexpand ;=\the\catcode\string`;
+          \catcode\string`\noexpand "=\the\catcode\string`"
+          \catcode\string`\noexpand <=\the\catcode\string`<
+          \catcode\string`\noexpand >=\the\catcode\string`>
+          \catcode\string`\noexpand `=\the\catcode\string``}
+      \catcode\string`@=11 \catcode\string`!=11 \catcode\string`?=11
+      \catcode\string`/=12 \catcode\string`-=12
+      \catcode\string`:=12 \catcode\string`;=12
+      \catcode\string`>=12 \catcode\string`<=12
+      \catcode\string`"=12 \catcode\string``=12 }
+
+    \def\defineMPtoPDFfallbacks
+      {% shortcuts
+       \chardef\@@escape      0
+       \chardef\@@begingroup  1
+       \chardef\@@endgroup    2
+       \chardef\@@endofline   5
+       \chardef\@@ignore      9
+       \chardef\@@space      10
+       \chardef\@@letter     11
+       \chardef\@@other      12
+       \chardef\@@active     13
+       \chardef\@@comment    14
+       % placeholders
+       \ifx\withoutpt         \undefined \let\withoutpt         \@@mptopdf@@withoutpt          \fi
+       \ifx\twodigitrounding  \undefined \let\twodigitrounding  \@@mptopdf@@twodigitrounding   \fi
+       \ifx\forgetall         \undefined \let\forgetall         \@@mptopdf@@forgetall          \fi
+       \ifx\uncatcodespecials \undefined \let\uncatcodespecials \@@mptopdf@@uncatcodespecials  \fi
+       \ifx\setnaturalcatcodes\undefined \let\setnaturalcatcodes\@@mptopdf@@setnaturalcatcodes \fi
+       \ifx\dospecials        \undefined \let\dospecials        \@@mptopdf@@dospecials         \fi}
+
+    \def\@@mptopdf@@forgetall
+      {\parskip0pt\leftskip0pt\parindent0pt\everypar{}}
+
+    \def\@@mptopdf@@twodigitrounding#1%
+      {#1}%
+
+    \def\@@mptopdf@@uncatcodespecials
+      {\def\do##1{\catcode`##1=\@@other}\dospecials
+       \catcode`\   =\@@space
+       \catcode`\^^L=\@@ignore
+       \catcode`\^^M=\@@endofline
+       \catcode`\^^?=\@@ignore}
+
+    \def\@@mptopdf@@setnaturalcatcodes
+      {\catcode`\!=\@@other \catcode`\?=\@@other \catcode`\@=\@@other
+       \catcode`\#=\@@other \catcode`\&=\@@other \catcode`\|=\@@other
+       \catcode`\$=\@@other \catcode`\^=\@@other \catcode`\_=\@@other
+       \catcode`\*=\@@other \catcode`\/=\@@other
+       \catcode`\-=\@@other \catcode`+=\@@other
+       \catcode`\==\@@other \catcode`\<=\@@other \catcode`\>=\@@other
+       \catcode`\"=\@@other \catcode`\'=\@@other \catcode`\`=\@@other
+       \catcode`\:=\@@other \catcode`\;=\@@other
+       \catcode`\,=\@@other \catcode`\.=\@@other \catcode`\~=\@@other
+       \catcode`\(=\@@other \catcode`\)=\@@other
+       \catcode`\{=\@@other \catcode`\}=\@@other
+       \catcode`\\=\@@other \catcode`\%=\@@other}
+
+    \def\@@mptopdf@@dospecials
+      {\do\ \do\\\do\{\do\}\do\$%
+       \do\#\do\^\do\_\do\&\do\%%
+       \do\~\do\^^A\do\^^K}
+
+    {
+        \catcode`\.=12
+        \catcode`\p=12
+        \catcode`\t=12
+        \gdef\@@MPTOPDF@@WITHOUTPT#1pt{#1}
+    }
+
+    \def\@@mptopdf@@withoutpt#1%
+      {\expandafter\@@MPTOPDF@@WITHOUTPT#1}
+
+%     \def\@@mptopdf@@newabove#1#2% \dimen \name
+%       {#1#2%
+%        \ifnum\expandafter\gobblesixarguments\meaning#2>20\else
+%          \expandafter\@@mptopdf@@newabove\expandafter#1\expandafter#2%
+%        \fi}
+
+    \def\@@mptopdf@@stripnewabove#1%
+      {\ifnum10<9#1 #1\else\expandafter\@@mptopdf@@stripnewabove\fi}%
+
+    \def\@@mptopdf@@newabove\csname#1\endcsname#2% \dimen \name
+      {\csname#1\endcsname#2%
+       \ifnum\expandafter\@@mptopdf@@stripnewabove\meaning#2>20\else
+         \@@mptopdf@@newabove\csname#1\endcsname#2%
+       \fi}
+
+    \@@mptopdf@@newabove \csname newcount\endcsname \scratchcounter
+    \@@mptopdf@@newabove \csname newdimen\endcsname \scratchdimen
+                         \csname   newbox\endcsname \scratchbox
+
+    \expandafter \newif \csname ifdone\endcsname
+
+    \catcode`\@=\mptopdfstoredatcode
+
+\else
+
+    \let\defineMPtoPDFfallbacks\relax
+
+\fi
+
+%D These macros are written as generic as possible. Some
+%D general support macro's are loaded from a small module
+%D especially made for non \CONTEXT\ use. In this module I
+%D use a matrix transformation macro written by Tanmoy
+%D Bhattacharya. Thanks to extensive testing by Sebastian
+%D Ratz I was able to complete this module within reasonable
+%D time. This module has support for \METAPOST\ extensions
+%D built in.
+%D
+%D Daniel H. Luecking came up with a better (more precise)
+%D transformation method. You can recognize his comment by
+%D his initials. (We keep the old code around because it's a
+%D nice illustration on how a module like this evolves.)
+
+%D Beware, we cannot use \type{\zeropoint} here since it may be
+%D defined in the range \type{\dimen0} - 20 which we happen to use
+%D as scratch registers; inside context we may consider
+%D using dedicated registers.
+
+%D This module handles some \PDF\ conversion and insertions
+%D topics. By default, the macros use the \PDFTEX\ primitive
+%D \type{\pdfliteral} when available. Since \PDFTEX\ is now the
+%D default engine for \TEX\ distributions, we need a more complex
+%D test.
+
+\unprotect
+
+\ifx\PDFcode\undefined
+  \ifx\pdfliteral\undefined
+    \def\PDFcode#1{\special{PDF: #1}}
+  \else\ifx\pdfoutput\undefined
+    \def\PDFcode#1{\special{PDF: #1}}
+  \else\ifcase\pdfoutput
+    \def\PDFcode#1{\special{PDF: #1}}
+  \else % pdftex as well as in pdf mode
+    \let\PDFcode\pdfliteral
+  \fi\fi\fi
+\else
+  % we probably use context
+\fi
+
+%D First we define a handy constant:
+
+\bgroup \defineMPtoPDFfallbacks \catcode`\%=\@@other \xdef\letterpercent{\string%} \egroup
+
+%D \macros
+%D   {pdfimage,pdfimages,pdfclippedimage}
+%D
+%D Starting with pdftex version 14, images are included more
+%D natural to the form embedding. This enables alternative
+%D images to be embedded.
+%D
+%D \starttyping
+%D \pdfimage  <optional dimensions> {file}
+%D \pdfimages <optional dimensions> {high res file} {low res file}
+%D \stoptyping
+%D
+%D The first one replaces the pre||version||14 original,
+%D while the latter provides alternative images.
+%D
+%D The next macro is dedicated to Maarten Gelderman, who
+%D needed to paste prepared \PDF\ pages into conference
+%D proceedings.
+%D
+%D \starttyping
+%D \pdfclippedimage <optional dimensions> {file} {l} {r} {t} {b}
+%D \stoptyping
+
+\ifx\pdftexversion\undefined \else \ifnum\pdftexversion>13
+
+  \def\pdfimage#1#%
+    {\dopdfimage{#1}}
+
+  \def\dopdfimage#1#2%
+    {\immediate\pdfximage#1{#2}%
+     \pdfrefximage\pdflastximage}
+
+  \def\pdfimages#1#%
+    {\dopdfimages{#1}}
+
+  \def\dopdfimages#1#2#3%
+    {\immediate\pdfximage#1{#2}%
+     \immediate\pdfobj{[ << /Image \the\pdflastximage\space0 R /DefaultForPrinting true >> ]}%
+     \immediate\pdfximage#1 attr {/Alternates \the\pdflastobj\space0 R}{#3}%
+     \pdfrefximage\pdflastximage}
+
+  \def\pdfclippedimage#1#% specs {file}{left}{right}{top}{bottom}
+    {\dopdfclippedimage{#1}}
+
+  \def\dopdfclippedimage#1#2#3#4#5#6%
+    {\bgroup
+     \pdfximage#1{#2}%
+     \setbox\scratchbox\hbox
+       {\pdfrefximage\pdflastximage}%
+     \hsize\wd\scratchbox
+     \advance\hsize -#3
+     \advance\hsize -#4
+     \vsize\ht\scratchbox
+     \advance\vsize -#5
+     \advance\vsize -#6
+     \setbox\scratchbox\vbox to \vsize
+       {\vskip-#5\hbox to \hsize{\hskip-#3\box\scratchbox\hss}}%
+     \pdfxform\scratchbox
+     \pdfrefxform\pdflastxform
+     \egroup}
+
+\fi \fi
+
+%D If you want to save a few hash entries, you may prefer the
+%D less readable alternatives, like:
+%D
+%D \starttyping
+%D \def\pdfimage#1#% This one is less readable but needs no additional
+%D   {\bgroup      % hash entry for the second stage macro.
+%D    \def\pdfimage##1%
+%D      {\immediate\pdfximage##1{#2}%
+%D       \pdfrefximage\pdflastximage\egroup}}
+%D \stoptyping
+
+%D For old times sake we provide a few aliases. These will be
+%D removed some day.
+
+\ifx\pdftexversion\undefined \else \ifnum\pdftexversion>13
+
+  \let\pdfform    =\pdfxform
+  \let\pdflastform=\pdflastxform
+  \let\pdfrefform =\pdfrefxform
+
+\fi \fi
+
+%D The main conversion macro wraps the \PDF\ codes in a box
+%D that is output as an object. The graphics are embedded
+%D in~\type{q} and~\type{Q} and are scaled and positioned using
+%D one transform call (\type{cm}). This saves some additional
+%D scaling.
+
+%D \macros
+%D   {convertMPtoPDF}
+%D
+%D The next set of macros implements \METAPOST\ to \PDF\
+%D conversion. Because we want to test as fast as possible, we
+%D first define the \POSTSCRIPT\ operators that \METAPOST\
+%D uses. We don't define irrelevant ones, because these are
+%D skipped anyway.
+
+%D The converter can be made a bit faster by replacing the
+%D two test macros (the ones with the many \type {\if's}) by
+%D a call to named branch macros (something \typ {\getvalue
+%D {xPSmoveto}}. For everyday documents with relatively
+%D small graphics the gain in speed can be neglected.
+
+\def \PScurveto          {curveto}
+\def \PSlineto           {lineto}
+\def \PSmoveto           {moveto}
+\def \PSshowpage         {showpage}
+\def \PSnewpath          {newpath}
+\def \PSfshow            {fshow}
+\def \PSclosepath        {closepath}
+\def \PSfill             {fill}
+\def \PSstroke           {stroke}
+\def \PSclip             {clip}
+\def \PSrlineto          {rlineto}
+\def \PSsetlinejoin      {setlinejoin}
+\def \PSsetlinecap       {setlinecap}
+\def \PSsetmiterlimit    {setmiterlimit}
+\def \PSsetgray          {setgray}
+\def \PSsetrgbcolor      {setrgbcolor}
+\def \PSsetcmykcolor     {setcmykcolor}
+\def \PSsetdash          {setdash}
+\def \PSgsave            {gsave}
+\def \PSgrestore         {grestore}
+\def \PStranslate        {translate}
+\def \PSscale            {scale}
+\def \PSconcat           {concat}
+\def \PSdtransform       {dtransform}
+\def \PSsetlinewidth     {setlinewidth}
+\def \PSpop              {pop}
+
+\def \PSnfont            {nfont}    % was needed for TUG98 proceedings
+\def \PSspecial          {special}  % extensions to MetaPost
+
+%D A previous version set \type {%} to ignore, which
+%D simplified the following definitions. At the start of
+%D conversion the percent character was made active again.
+%D Because the whole graphic is one paragraph (there are no
+%D empty lines) this does not give the desired effect. This
+%D went unnoticed untill Scott Pakin sent me a test file
+%D percent characters in a string. So, from now on we have
+%D to prefix the following strings with percentages.
+
+%D Some day I'll figure out a better solution (line by line reading
+%D using \ETEX).
+
+\edef \PSBoundingBox      {\letterpercent\letterpercent BoundingBox:}
+\edef \PSHiResBoundingBox {\letterpercent\letterpercent HiResBoundingBox:}
+\edef \PSExactBoundingBox {\letterpercent\letterpercent ExactBoundingBox:}
+\edef \PSMetaPostSpecial  {\letterpercent\letterpercent MetaPostSpecial:}
+\edef \PSMetaPostSpecials {\letterpercent\letterpercent MetaPostSpecials:}
+\edef \PSPage             {\letterpercent\letterpercent Page:}
+\edef \PSBeginProlog      {\letterpercent\letterpercent BeginProlog}
+\edef \PSEndProlog        {\letterpercent\letterpercent EndProlog}
+\edef \PSEof              {\letterpercent\letterpercent EOF}
+
+%D By the way, the \type {setcmykcolor} operator is not
+%D output by \METAPOST\ but can result from converting the
+%D \cap{RGB} color specifications, as implemented in
+%D \type{supp-mps}.
+
+%D In \POSTSCRIPT\ arguments precede the operators. Due to the
+%D fact that in some translations we need access to those
+%D arguments, and also because sometimes we have to skip them,
+%D we stack them up. The stack is one||dimensional for non path
+%D operators and two||dimensional for operators inside a path.
+%D This is because we have to save the whole path for
+%D (optional) postprocessing. Values are pushed onto the stack
+%D by:
+%D
+%D \starttyping
+%D \setMPargument {value}
+%D \stoptyping
+%D
+%D They can be retrieved by the short named macros:
+%D
+%D \starttyping
+%D \gMPa {number}
+%D \gMPs {number}
+%D \stoptyping
+%D
+%D When scanning a path specification, we also save the
+%D operator, using
+%D
+%D \starttyping
+%D \setMPkeyword {n}
+%D \stoptyping
+%D
+%D The path drawing operators are coded for speed: \type{clip},
+%D \type{stroke}, \type{fill} and \type{fillstroke} become
+%D 1, 2, 3 and~4.
+%D
+%D When processing the path this code can be retrieved
+%D using
+%D
+%D \starttyping
+%D \getMPkeyword % {n}
+%D \stoptyping
+%D
+%D When setting an argument, the exact position on the stack
+%D depends on the current value of the \COUNTERS\
+%D \type{\nofMPsegments} and \type{\nofMParguments}.
+
+\newcount\nofMPsegments
+\newcount\nofMParguments
+
+%D These variables hold the coordinates. The argument part of
+%D the stack is reset by:
+%D
+%D \starttyping
+%D \resetMPstack
+%D \stoptyping
+%D
+%D We use the prefix \type{@@MP} to keep the stack from
+%D conflicting with existing macros. To speed up things a bit
+%D more, we use the constant \type{\@@MP}.
+
+\def\@@MP{@@MP}
+
+\def\setMPargument% #1%
+  {\advance\nofMParguments 1
+   \expandafter\def
+     \csname\@@MP\the\nofMPsegments\the\nofMParguments\endcsname} % {#1}
+
+\def\letMPargument
+  {\advance\nofMParguments 1
+   \expandafter\let
+     \csname\@@MP\the\nofMPsegments\the\nofMParguments\endcsname}
+
+\def\setMPsequence#1 %
+  {\advance\nofMParguments 1
+   \expandafter\def
+     \csname\@@MP\the\nofMPsegments\the\nofMParguments\endcsname{#1}%
+   \handleMPsequence}
+
+\def\gMPa#1%
+  {\csname\@@MP0\number#1\endcsname}
+
+\def\gMPs#1%
+  {\csname\@@MP\the\nofMPsegments\number#1\endcsname}
+
+\def\dogMPa#1%
+  {\expandafter\expandafter\expandafter\do\csname\@@MP0\number#1\endcsname}
+
+\def\setMPkeyword#1 %
+  {\expandafter\def\csname\@@MP\the\nofMPsegments0\endcsname{#1}%
+   \advance\nofMPsegments 1
+   \nofMParguments0}
+
+\def\getMPkeyword% #1%
+  {\csname\@@MP\the\nofMPsegments0\endcsname} % {\csname\@@MP#10\endcsname}
+
+\def\docleanupMPargument#1% we need this because args can have [ or ] pre/appended
+  {\expandafter\edef\csname\@@MP\the\nofMPsegments\number#1\endcsname
+     {\csname\@@MP\the\nofMPsegments\number#1\endcsname}}
+
+%D When we reset the stack, we can assume that all further
+%D comment is to be ignored and handled in strings.
+%D By redefining the reset macro after the first call, we
+%D save some run time. Only use this macro after all
+%D comments are processed and use the simple alternative
+%D when dealing with comments.
+
+\def\doresetMPstack
+  {\nofMParguments0\relax}
+
+\def\resetMPstack
+  {\let\handleMPgraphic\handleMPendgraphic
+   \let\resetMPstack\doresetMPstack
+   \resetMPstack}
+
+%D The arguments are saved with the preceding command
+%D \type{\do}. By default this command expands to nothing, but
+%D when we deal with strings it's used to strip off the
+%D \type{(} and \type{)}.
+%D
+%D Strings are kind of tricky, because characters can be
+%D passed verbatim \type{(hello)}, by octal number
+%D \type{(\005)} or as command \type{(\()}. We therefore
+%D cannot simply ignore \type{(} and \type{)}, the way we do
+%D with \type{[} and \type{]}. Another complication is that
+%D strings may contain characters that normally have a
+%D special meaning in \TEX, like \type{$} and \type{{}}.
+%D
+%D A previous solution made \type{\} an active character and
+%D let it look ahead for a number or characters. We had to
+%D abandon this scheme because of the need for verbatim
+%D support. The next solution involved some \CATCODE\
+%D trickery but works well.
+
+\def\octalMPcharacter#1#2#3%
+  {\char'#1#2#3\relax}
+
+%D curly braces and squarly brackets are stored in the argument stack
+%D as part  of strings, for instance in:
+%D
+%D \starttyping
+%D /fshow {exch findfont exch scalefont setfont show}bind def
+%D [3 3 ] 0 setdash
+%D \stoptyping
+%D
+%D but we need to keep them in situation like
+%D
+%D \starttyping
+%D ([bla bla] bla bla) ec-lmr10 9.96265 fshow
+%D ({bla bla} bla bla) ec-lmr10 9.96265 fshow
+%D \stoptyping
+%D
+%D So, when we store the snippets, we keep the special tokens, and
+%D when needed we either ignore or obey them
+
+\bgroup
+\defineMPtoPDFfallbacks
+\catcode`\|=\@@comment
+\catcode`\%=\@@active
+\catcode`\[=\@@active
+\catcode`\]=\@@active
+\catcode`\{=\@@active
+\catcode`\}=\@@active
+\catcode`B=\@@begingroup
+\catcode`E=\@@endgroup
+\gdef\keepMPspecials|
+  B\let%\letterpercent|
+   \def[B\noexpand[E|
+   \def]B\noexpand]E|
+   \def{B\noexpand{E|
+   \def}B\noexpand}EE
+\gdef\ignoreMPspecials|
+  B\let%\letterpercent|
+   \def[BE|
+   \def]BE|
+   \def{BE|
+   \def}BEE
+\gdef\obeyMPspecials|
+  B\def%B\char 37\relax E|
+   \def[B\char 91\relax E|
+   \def]B\char 93\relax E|
+   \def{B\char123\relax E|
+   \def}B\char125\relax EE
+\gdef\setMPspecials|
+  B\setnaturalcatcodes
+   \catcode`\\=\@@escape
+   \catcode`\%=\@@active
+   \catcode`\[=\@@active
+   \catcode`\]=\@@active
+   \catcode`\{=\@@active
+   \catcode`\}=\@@active
+   \lccode`\-=0 | latex sets this to `\-
+   \lccode`\%=`\% | otherwise it's seen as a number
+   \def\(B\char40\relax     E|
+   \def\)B\char41\relax     E|
+   \def\\B\char92\relax     E|
+   \def\0B\octalMPcharacter0E|
+   \def\1B\octalMPcharacter1E|
+   \def\2B\octalMPcharacter2E|
+   \def\3B\octalMPcharacter3E|
+   \def\4B\octalMPcharacter4E|
+   \def\5B\octalMPcharacter5E|
+   \def\6B\octalMPcharacter6E|
+   \def\7B\octalMPcharacter7E|
+   \def\8B\octalMPcharacter8E|
+   \def\9B\octalMPcharacter9EE
+\egroup
+
+%D We use the comment symbol as a sort of trigger. Beware!
+%D The whole graphic is seen as on eparagraph, which means
+%D that we cannot change the catcodes in between.
+
+\bgroup
+\defineMPtoPDFfallbacks
+\catcode`\%=\@@active
+\gdef\startMPscanning{\let%=\startMPconversion}
+\egroup
+
+%D In earlier versions we used the sequence
+%D
+%D \starttyping
+%D \expandafter\handleMPsequence\input filename\relax
+%D \stoptyping
+%D
+%D Persistent problems in \LATEX\ however forced us to use a
+%D different scheme. Every \POSTSCRIPT\ file starts with a
+%D \type{%}, so we temporary make this an active character
+%D that starts the scanning and redefines itself. (The problem
+%D originates in the redefinition by \LATEX\ of the
+%D \type{\input} primitive.)
+
+\def\startMPconversion
+  {\keepMPspecials
+   \handleMPsequence}
+
+%D Here comes the main loop. Most arguments are numbers. This
+%D means that they can be recognized by their \type{\lccode}.
+%D This method saves a lot of processing time. We could
+%D speed up the conversion by handling the \type{path}
+%D seperately.
+
+\def\dohandleMPsequence#1%
+  {\ifdone
+     \ifcase\lccode`#1\relax
+       \expandafter\expandafter\expandafter\dohandleMPsequenceA
+     \else
+       \expandafter\expandafter\expandafter\dohandleMPsequenceB
+     \fi
+   \else
+     \expandafter\dohandleMPsequenceC
+   \fi#1}
+
+\let\dohandleMPsequenceA\setMPsequence
+
+\def\installMPSkeywordN#1#2%
+  {\expandafter\def\csname\@@MP:N:#1\endcsname{#2}}
+
+\def\installMPSshortcutN#1#2% todo: \let
+  {\expandafter\let\csname\@@MP:N:#1\expandafter\endcsname\csname\@@MP:N:#2\endcsname}
+
+\def\dohandleMPsequenceB#1 %
+  {\edef\somestring{#1}%
+   \ifcsname\@@MP:N:\somestring\endcsname
+     \csname\@@MP:N:\somestring\expandafter\endcsname
+   \else
+     \expandafter\handleMPgraphic
+   \fi
+   \handleMPsequence}
+
+\ifx\eTeXversion\undefined
+    \def\dohandleMPsequenceB#1 %
+      {\edef\somestring{#1}%
+       \expandafter\ifx\csname\@@MP:N:\somestring\endcsname\relax
+         \expandafter\handleMPgraphic
+       \else
+         \csname\@@MP:N:\somestring\expandafter\endcsname
+       \fi
+       \handleMPsequence}
+\fi
+
+\installMPSkeywordN \PSmoveto
+  {\edef\lastMPmoveX{\gMPa1}%
+   \edef\lastMPmoveY{\gMPa2}%
+   \resetMPstack}
+\installMPSkeywordN \PSnewpath
+  {\let\handleMPsequence\handleMPpath}
+\installMPSkeywordN \PSgsave
+  {\PDFcode{q}%
+   \resetMPstack}
+\installMPSkeywordN \PSgrestore
+  {\PDFcode{Q}%
+   \resetMPstack}
+\installMPSkeywordN \PSdtransform  % == setlinewidth
+  {\let\handleMPsequence\handleMPdtransform}
+   % after that we will encounter more tokens until setlinewidth+pop
+   % or pop+setlinewidth which we catch next; we explicitly need to
+   % reset the stack since [] n setdash may follow; a more clever
+   % approach would be to read on till the condition is met, but it's
+   % the only pop / setlinewidth we will encounter so ...
+\installMPSkeywordN \PSsetlinewidth
+  {% already handled in dtransform
+   \resetMPstack}
+\installMPSkeywordN \PSpop
+  {% already handled in dtransform
+   \resetMPstack}
+\installMPSkeywordN \PSconcat
+  {\cleanupMPconcat
+   \PDFcode{\gMPa1 \gMPa2 \gMPa3 \gMPa4 \gMPa5 \gMPa6 cm}%
+   \resetMPstack}
+\installMPSkeywordN \PSsetrgbcolor
+  {\handleMPrgbcolor
+   \resetMPstack}
+\installMPSkeywordN \PSsetcmykcolor
+  {\handleMPcmykcolor
+   \resetMPstack}
+\installMPSkeywordN \PSsetgray
+  {\handleMPgraycolor
+   \resetMPstack}
+\installMPSkeywordN \PStranslate
+  {\PDFcode{1 0 0 1 \gMPa1 \gMPa2 cm}%
+   \resetMPstack}
+\installMPSkeywordN \PSsetdash
+  {\handleMPsetdash
+   \resetMPstack}
+\installMPSkeywordN \PSsetlinejoin
+  {\PDFcode{\gMPa1 j}%
+   \resetMPstack}
+\installMPSkeywordN \PSsetmiterlimit
+  {\PDFcode{\gMPa1 M}%
+   \resetMPstack}
+\installMPSkeywordN \PSfshow
+  {%\PDFcode{n}% removed !
+   \handleMPfshow
+   \resetMPstack}
+\installMPSkeywordN \PSsetlinecap
+  {\PDFcode{\gMPa1 J}%
+   \resetMPstack}
+\installMPSkeywordN \PSrlineto
+  {\flushMPmoveto
+   \PDFcode{\!MP\lastMPmoveX\space\!MP\lastMPmoveY\space l S}%
+   \resetMPmoveto
+   \resetMPstack}
+\installMPSkeywordN \PSscale
+  {\PDFcode{\gMPa1 0 0 \gMPa2 0 0 cm}%
+   \resetMPstack}
+\installMPSkeywordN \PSspecial
+  {\handleMPspecialcommand
+   \resetMPstack}
+
+\installMPSshortcutN {n}  \PSnewpath
+\installMPSshortcutN {p}  \PSclosepath
+\installMPSshortcutN {l}  \PSlineto
+\installMPSshortcutN {r}  \PSrlineto
+\installMPSshortcutN {m}  \PSmoveto
+\installMPSshortcutN {c}  \PScurveto
+\installMPSshortcutN {C}  \PSsetcmykcolor
+\installMPSshortcutN {G}  \PSsetgray
+\installMPSshortcutN {R}  \PSsetrgbcolor
+\installMPSshortcutN {lj} \PSsetlinejoin
+\installMPSshortcutN {ml} \PSsetmiterlimit
+\installMPSshortcutN {lc} \PSsetlinecap
+\installMPSshortcutN {sd} \PSsetdash
+\installMPSshortcutN {S}  \PSstroke
+\installMPSshortcutN {F}  \PSfill
+\installMPSshortcutN {W}  \PSclip
+
+\installMPSshortcutN {q}  \PSgsave
+\installMPSshortcutN {Q}  \PSgrestore
+
+\installMPSshortcutN {s}  \PSscale
+\installMPSshortcutN {t}  \PSconcat
+\installMPSshortcutN {P}  \PSshowpage
+
+\installMPSkeywordN {hlw} {\PDFcode{\gMPa1 w}\resetMPstack}
+\installMPSkeywordN {vlw} {\PDFcode{\gMPa1 w}\resetMPstack}
+\installMPSkeywordN {rd}  {\PDFcode{[] 0   d}\resetMPstack}
+
+\def\dohandleMPsequenceC#1 %
+  {\edef\somestring{#1}%
+   \handleMPgraphic % {#1}%
+   \handleMPsequence}
+
+%D Since colors are not sensitive to transformations, they
+%D are sometimes used for signaling. Therefore, we handle them
+%D separately. The next macro can be redefined if needed.
+
+\def\handleMPrgbcolor
+  {\PDFcode{\!MPgMPa1 \!MPgMPa2 \!MPgMPa3 rg
+            \!MPgMPa1 \!MPgMPa2 \!MPgMPa3 RG}}
+
+\def\handleMPcmykcolor
+  {\PDFcode{\!MPgMPa1 \!MPgMPa2 \!MPgMPa3 \!MPgMPa4 k
+            \!MPgMPa1 \!MPgMPa2 \!MPgMPa3 \!MPgMPa4 K}}
+
+\def\handleMPgraycolor
+  {\PDFcode{\!MPgMPa1 g
+            \!MPgMPa1 G}}
+
+\def\handleMPspotcolor
+  {\PDFcode{0 g
+            0 G}}
+
+%D Beginning and ending the graphics is taken care of by the
+%D macro \type{\handleMPgraphic}, which is redefined when
+%D the first graphics operator is met.
+
+\def\handleMPendgraphic % #1%
+  {\ifx\somestring\PSshowpage
+     \let\handleMPsequence\finishMPgraphic
+   \else\ifx\somestring\PSEof
+     \let\handleMPsequence\finishMPgraphic
+   \else
+     \letMPargument\somestring % {#1}%
+   \fi\fi}
+
+\def\handleMPbegingraphic % #1%
+  {\ifx\somestring\PSBoundingBox
+     \def\handleMPsequence{\handleMPboundingbox1}%
+   \else\ifx\somestring\PSHiResBoundingBox
+     \def\handleMPsequence{\handleMPboundingbox2}%
+   \else\ifx\somestring\PSExactBoundingBox
+     \def\handleMPsequence{\handleMPboundingbox3}%
+   \else\ifx\somestring\PSshowpage
+     \let\handleMPsequence\finishMPgraphic
+   \else\ifx\somestring\PSEof
+     \let\handleMPsequence\finishMPgraphic
+   \else\ifx\somestring\PSPage
+     \let\handleMPsequence\handleMPpage
+   \else\ifx\somestring\PSMetaPostSpecials
+     \let\handleMPsequence\handleMPspecialscomment
+   \else\ifx\somestring\PSMetaPostSpecial
+     \let\handleMPsequence\handleMPspecialcomment
+   \else\ifx\somestring\PSBeginProlog
+     \let\handleMPsequence\handleMPprolog
+   \else
+     \letMPargument\somestring % {#1}%
+   \fi\fi\fi\fi\fi\fi\fi\fi\fi}
+
+\let\handleMPgraphic=\handleMPbegingraphic
+
+%D New: we can best filter the prolog because nowdays it can contain
+%D quite some code.
+
+% hm, catcode mess, so we need to tweak %'s catcode here
+% \long\expandafter\def\expandafter\handleMPprolog\expandafter#\expandafter1\PSEndProlog%
+% but today i'm not in the mood for ugly stuff
+
+\long\def\handleMPprolog#1EndProlog %
+  {\doresetMPstack
+   \let\handleMPsequence\dohandleMPsequence
+   \handleMPsequence}
+
+%D We check for three kind of bounding boxes: the normal one
+%D and two high precision ones:
+%D
+%D \starttyping
+%D BoundingBox: llx lly ucx ucy
+%D HiResBoundingBox: llx lly ucx ucy
+%D ExactBoundingBox: llx lly ucx ucy
+%D \stoptyping
+%D
+%D The original as well as the recalculated dimensions are
+%D saved for later use.
+
+\newif\ifskipemptyMPgraphic \skipemptyMPgraphicfalse
+
+\chardef\currentMPboundingbox=0
+
+\def\handleMPboundingbox#1#2 #3 #4 #5
+  {\ifnum#1>\currentMPboundingbox
+     \xdef\MPllx{#2}\xdef\MPlly{#3}%
+     \xdef\MPurx{#4}\xdef\MPury{#5}%
+     \dimen0=#2pt
+     \dimen0=-\MPxscale\dimen0
+     \dimen2=#3pt
+     \dimen2=-\MPyscale\dimen2
+     \xdef\MPxoffset{\withoutpt\the\dimen0}%
+     \xdef\MPyoffset{\withoutpt\the\dimen2}%
+     \dimen0=#2bp
+     \dimen0=-\dimen0
+     \dimen2=#3bp
+     \dimen2=-\dimen2
+     \advance\dimen0 #4bp
+     \dimen0=\MPxscale\dimen0
+     \xdef\MPwidth{\the\dimen0}%
+     \advance\dimen2 #5bp
+     \xdef\MPyshift{\the\dimen2}% unscaled
+     \dimen2=\MPyscale\dimen2
+     \xdef\MPheight{\the\dimen2}%
+     \chardef\currentMPboundingbox#1\relax
+   \fi
+   \doresetMPstack
+   \let\handleMPsequence\dohandleMPsequence
+   \let\next\handleMPsequence
+   \ifskipemptyMPgraphic
+     \ifdim\MPheight=0pt\relax\ifdim\MPwidth=0pt\relax
+       \def\next{\endinput\finishMPgraphic}%
+     \fi\fi
+   \fi
+   \next}
+
+%D Unless defined otherwise, we simply ignore specialcomments.
+
+\def\handleMPspecialcomment
+  {\doresetMPstack
+   \let\handleMPsequence\dohandleMPsequence
+   \handleMPsequence}
+
+\let\handleMPspecialscomment\handleMPspecialcomment
+
+%D We use the \type{page} comment as a signal that
+%D stackbuilding can be started.
+
+\def\handleMPpage #1 #2
+  {\doresetMPstack
+   \donetrue
+   \let\handleMPsequence\dohandleMPsequence
+   \handleMPsequence}
+
+%D The same applies to the special extensions.
+
+\def\handleMPspecialcommand
+  {\doresetMPstack
+   \let\handleMPsequence\dohandleMPsequence
+   \handleMPsequence}
+
+%D \METAPOST\ draws its dots by moving to a location and
+%D invoking \type{0 0 rlineto}. This operator is not
+%D available in \PDF. Our solution is straightforward: we draw
+%D a line from $(current\_x, current\_y)$ to itself. This
+%D means that the arguments of the preceding \type{moveto} have
+%D to be saved.
+
+\def\lastMPmoveX{0}
+\def\lastMPmoveY{0}
+
+%D These saved coordinates are also used when we handle the
+%D texts. Text handling proved to be a bit of a nuisance, but
+%D finally I saw the light. It proved that we also had to
+%D take care of \type{(split arguments)}.
+
+% \def\setMPfshowfont#1#2%
+%   {\font\temp=#1\space at #2\relax\temp}
+
+% \startMPcode
+%     draw btex Ga toch effe f\kern0ptietsen?{}` etex ;
+% \stopMPcode
+
+\newtoks \everyMPshowfont
+
+\def\setMPfshowfont#1#2%
+  {\font\temp=#1\space at #2\relax\temp
+   \the\everyMPshowfont}
+
+\let\MPfshowcommand\empty
+
+%D The next hackery handles characters one by one. We only support this
+%D for the latest greatest \METAPOST\ binaries, the ones that escape
+%D problematic chars.
+
+\def\doflushMPte