texi2dvi not passing locale to texindex
Vincent Belaïche <[email protected]> Fri, 17 Apr 2026 20:02:37 +0000
| Newsgroups | gmane.comp.tex.texinfo.bugs |
|---|---|
| Message-ID | <AMBP194MB26919F6A27CE74E3F3A866AD84202@AMBP194MB2691.EURP194.PROD.OUTLOOK.COM> |
This is a continuation of report: https://tug.org/pipermail/latexrefman/2026q1/000983.html To summarize the point: it would be great if texi2pdf / texi2dvi would autonomously pass the correct locale to AWK texindex script based on @documentlanguage + @documentencoding statements. Please note that I came accross one more time on this issue, and I was suggested to report it to you, see here: https://lists.gnu.org/archive/html/emacs-devel/2026-04/msg00573.html I attached a patch that fixes the problem for me. Please note that IMHO changing sh to bash would not harm anybody and would make that sort of fix quite easier. Please note that looking at only over the 64 first lines is arbitrary. The objective is not to degrade too much the compile time. Please note that stopping after the first match is to avoid silently the case were there are several @documentlanguage (or @documentencoding) statements. I am not sure was Texinfo behaviour is, but I assume that it should consider only the first one and emit a warning/error on the subsequent ones. Vincent.
patch 2.diff
(application/octet-stream, 1.9 KB)
diff --git a/util/texi2dvi b/util/texi2dvi
index ac4a7db6ef..036f149b26 100755
--- a/util/texi2dvi
+++ b/util/texi2dvi
@@ -55,6 +55,8 @@ textra= # Extra TeX commands to insert in the input file.
txiprereq=19990129 # minimum texinfo.tex version with macro expansion
verb=false # true for verbose mode
translate_file= # name of charset translation file
+texindexlocale_set=false # Set LC_ALL according to @documentlanguage and @documentencoding.
+
# We have to initialize IFS to space tab newline since we save and
# restore IFS and apparently POSIX allows stupid/broken behavior with
@@ -354,8 +356,28 @@ report ()
run ()
{
verbose "Running $@"
- "$@" 2>&5 1>&2 \
- || error 1 "$1 failed"
+ case "$1" in
+ *=*)
+ (
+ again=true;
+ while $again; do
+ export "$1"
+ shift
+ case "$1" in
+ *=*) ;;
+ *)
+ again=false;
+ "$@" 2>&5 1>&2 \
+ || error 1 "$1 failed"
+ ;;
+ esac
+ done
+ )
+ ;;
+ *)
+ "$@" 2>&5 1>&2 \
+ || error 1 "$1 failed"
+ esac
}
@@ -969,7 +991,21 @@ run_index ()
;;
texinfo)
- run $TEXINDEX $index_files
+ if $texindexlocale_set; then :; else
+ _document_encoding=`$SED -ne 's/^[[:blank:]]*@documentencoding[[:blank:]]\+\([-A-Z0-9a-z]\+\).*$/\1/p' -e '/^[[:blank:]]*@documentencoding[[:blank:]]/q' -e '64q' $command_line_filename`
+ _document_language=`$SED -ne 's/^[[:blank:]]*@documentlanguage[[:blank:]]\+\([_A-Z0-9a-z]\+\).*$/\1/p' -e '/^[[:blank:]]*@documentlanguage[[:blank:]]/q' -e '64q' $command_line_filename`
+ if [ -z "$_document_encoding" ]; then
+ TEXINDEXLOCALE=''
+ else
+ if [ -z "$_document_language" ]; then
+ TEXINDEXLOCALE="LC_ALL=C.$_document_encoding "
+ else
+ TEXINDEXLOCALE="LC_ALL=$_document_language.$_document_encoding "
+ fi
+ fi
+ texindexlocale_set=true;
+ fi
+ run $TEXINDEXLOCALE$TEXINDEX $index_files
;;
esac
}