[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
@documentencoding and TeX
From: |
Akim Demaille |
Subject: |
@documentencoding and TeX |
Date: |
Wed, 25 Aug 2004 10:24:12 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
It is my understanding that all the outputs properly understand
@documentencoding except TeX. Since TeX is behind texi2dvi, and since
recode is fairly common, at least on the machine where LC_ALL != C, I
suggest the following patch. It does considerably simplify my file,
until proper TeX support is implemented.
Index: ChangeLog
from Akim Demaille <address@hidden>
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.
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.31
diff -u -u -r1.31 texi2dvi
--- util/texi2dvi 14 Aug 2004 00:54:34 -0000 1.31
+++ util/texi2dvi 25 Aug 2004 08:21:35 -0000
@@ -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 <<EOM
You don't have a working TeX binary (${TEX:-tex}) installed anywhere in
your PATH, and texi2dvi cannot proceed without one. If you want to use
@@ -249,7 +249,7 @@
# didn't explicitly specify. We don't check for elatex and pdfelatex
# because (as of 2003), the LaTeX team has asked that new distributions
# use etex by default anyway.
-#
+#
# End up with the TEX and PDFTEX variables set to what we are going to use.
if test -z "$TEX"; then
if findprog etex; then TEX=etex; else TEX=tex; fi
@@ -310,34 +310,31 @@
s/address@hidden texi2dvi//
EOF
-# A shell script that computes the list of xref files.
+# Compute the list of xref files.
# Takes the filename (without extension) of which we look for xref
# files as argument. The index files must be reported last.
-get_xref_files=$utildir/get_xref.sh
-cat <<\EOF >$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, 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'"; 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, 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'"; then
+ xref_files="$xref_files ./$this_file"
+ fi
+ done
+ echo "$xref_files"
+}
# File descriptor usage:
# 0 standard input
@@ -404,12 +401,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
@@ -488,6 +489,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}
@@ -502,6 +504,7 @@
*)
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
+ language=texinfo
bibtex=
texindex=${TEXINDEX:-texindex}
textra_cmd='/address@hidden/a'
@@ -595,6 +598,22 @@
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
+ encoding=`sed -ne ' \
+ /@documentencoding/{ \
+ s/address@hidden \([^ ]*\).*/\1/p; \
+ q \
+ }' \
+ <$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"
@@ -602,7 +621,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
@@ -687,7 +706,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'`"
- @documentencoding and TeX,
Akim Demaille <=
Re: @documentencoding and TeX, Karl Berry, 2004/08/25
Re: @documentencoding and TeX, Stepan Kasal, 2004/08/25