Index: ChangeLog
from Akim Demaille
Let DVI and PDF files honor the document encoding in TeX.
* util/texi2dvi ($language): Be sure to set its value.
(get_xref_files): Turn this external shell script into a function.
(filename_rcd, $tmpdir_rcd): New.
If the file is in Texinfo, and has @documentencoding, and recode
is available, then run it.
2004-08-26 Stepan Kasal
* util/texi2dvi: fix the sed script searching for @documentencoding;
Double-quote some instances of "$filename_???"
--- util/texi2dvi.prev 2004-08-26 08:16:30.575997201 +0200
+++ util/texi2dvi 2004-08-26 09:03:28.389436589 +0200
@@ -114,7 +114,7 @@
: ${EGREP=egrep}
# return true if program $1 is somewhere in PATH, else false.
-#
+#
findprog () {
foundprog=false
for dir in `echo $PATH | tr "$path_sep" " "`; do
@@ -229,7 +229,7 @@
# We can't do much without tex.
-#
+#
if findprog ${TEX:-tex}; then :; else cat <$get_xref_files
-#! /bin/sh
-
-# Get list of xref files (indexes, tables and lists).
-# Find all files having root filename with a two-letter extension,
-# saves the ones that are really Texinfo-related files. .?o? catches
-# many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
-for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
- # If file is empty, skip it.
- test -s "$this_file" || continue
- # If the file is not suitable to be an index or xref file, don't
- # process it. It's suitable if the first character is a
- # backslash or right quote or at, as long as the first line isn't
- # \input texinfo.
- first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
- if (test "x$first_character" = "x\\" \
- && sed 1q $this_file | grep -v '^\\input *texinfo' >/dev/null) \
- || test "x$first_character" = "x'" \
- || test "x$first_character" = "x@"; then
- xref_files="$xref_files ./$this_file"
- fi
-done
-echo "$xref_files"
-EOF
-chmod 500 $get_xref_files
+get_xref_files ()
+{
+ # Get list of xref files (indexes, tables and lists).
+ # Find all files having root filename with a two-letter extension,
+ # saves the ones that are really Texinfo-related files. .?o? catches
+ # many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
+ for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
+ # If file is empty, skip it.
+ test -s "$this_file" || continue
+ # If the file is not suitable to be an index or xref file, don't
+ # process it. It's suitable if the first character is a
+ # backslash or right quote or at, as long as the first line isn't
+ # \input texinfo.
+ first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
+ if (test "x$first_character" = "x\\" \
+ && sed 1q $this_file | grep -v '^\\input *texinfo' >/dev/null) \
+ || test "x$first_character" = "x'" \
+ || test "x$first_character" = "x@"; then
+ xref_files="$xref_files ./$this_file"
+ fi
+ done
+ echo "$xref_files"
+}
# File descriptor usage:
# 0 standard input
@@ -405,12 +402,16 @@
tmpdir_xtr=$tmpdir/xtr
filename_xtr=$tmpdir_xtr/$filename_noext.$ext
+ # _rcd. The Texinfo file recoded in 7bit.
+ tmpdir_rcd=$tmpdir/rcd
+ filename_rcd=$tmpdir_rcd/$filename_noext.$ext
+
# _bak. Copies of the previous xref files (another round is run if
# they differ from the new one).
tmpdir_bak=$tmpdir/bak
# Make all those directories and give up if we can't succeed.
- mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
+ mkdir $tmpdir_src $tmpdir_xtr $tmpdir_rcd $tmpdir_bak || exit 1
# Source file might include additional sources.
# We want `.:$orig_pwd' before anything else. (We'll add `.:' later
@@ -489,6 +490,7 @@
[lL]a[tT]e[xX] | *.ltx | *.tex)
# Assume a LaTeX file. LaTeX needs bibtex and uses latex for
# compilation. No makeinfo.
+ language=latex
bibtex=${BIBTEX:-bibtex}
makeinfo= # no point in running makeinfo on latex source.
texindex=${MAKEINDEX:-makeindex}
@@ -503,6 +505,7 @@
*)
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
+ language=texinfo
bibtex=
texindex=${TEXINDEX:-texindex}
textra_cmd='/address@hidden/a'
@@ -592,10 +595,26 @@
if test -n "$textra"; then
$verbose "Inserting extra commands: $textra"
sed "$textra_cmd\\
-$textra" "$filename_input" >$filename_xtr
+$textra" "$filename_input" >"$filename_xtr"
filename_input=$filename_xtr
fi
+ # If this is a Texinfo file with a specified input encoding, and
+ # recode is available, then recode to plain 7 bit Texinfo.
+ if test $language = texinfo; then
+ pgm='s/\(^\|.* \)@documentencoding *\([^ ][^ ]*\)\( .*\|$\)/\2/
+ t found
+ d
+ :found
+ q'
+ encoding=`sed -e "$pgm" "$filename_input"`
+ if test -n "$encoding" && findprog recode; then
+ $verbose "Recoding from $encoding to Texinfo."
+ recode "$encoding"..texinfo <"$filename_input" >"$filename_rcd"
+ filename_input=$filename_rcd
+ fi
+ fi
+
# If clean mode was specified, then move to the temporary directory.
if test "$clean" = t; then
$verbose "cd $tmpdir_src"
@@ -603,7 +622,7 @@
fi
while :; do # will break out of loop below
- orig_xref_files=`$get_xref_files "$filename_noext"`
+ orig_xref_files=`get_xref_files "$filename_noext"`
# Save copies of originals for later comparison.
if test -n "$orig_xref_files"; then
@@ -664,9 +683,9 @@
fi
# Finally, run TeX.
- cmd="$tex $tex_args $filename_input"
- $verbose "Running $cmd ..."
- if $cmd >&5; then :; else
+ cmd="$tex $tex_args"
+ $verbose "Running $cmd $filename_input ..."
+ if $cmd "$filename_input" >&5; then :; else
echo "$0: $tex exited with bad status, quitting." >&2
echo "$0: see $filename_noext.log for errors." >&2
test "$clean" = t \
@@ -688,7 +707,7 @@
fi
# Check if xref files changed.
- new_xref_files=`$get_xref_files "$filename_noext"`
+ new_xref_files=`get_xref_files "$filename_noext"`
$verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
$verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
@@ -728,8 +747,8 @@
$thumbpdf "$filename_noext" >&5 ||
fatal "$thumbpdf exited with bad status, quitting."
- $verbose "Running $cmd ..."
- if $cmd >&5; then :; else
+ $verbose "Running $cmd $filename_input..."
+ if $cmd "$filename_input" >&5; then :; else
echo "$0: $tex exited with bad status, quitting." >&2
echo "$0: see $filename_noext.log for errors." >&2
test "$clean" = t \