[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug #43122] texi2dvi does not compile enough times to get toc
From: |
Vincent Belaïche |
Subject: |
Re: [bug #43122] texi2dvi does not compile enough times to get toc |
Date: |
Sat, 29 Aug 2015 13:40:11 +0200 |
Some proposal below...
Le 22/08/2015 00:26, Karl Berry a écrit :
> At this point, I guess I have to conclude it is better to use -recorder
> if it is available.
>
> k
Hello,
Attached is a patch that solves the problem for me. It is a bit long,
because I did it as backward compatible as possible.
By setting environnement variable TEXI2DVI_USE_RECORDER you can suppress
the additional prior testing and make this novel texi2dvi almost as fast as it
used to be.
VBR,
Vincent Belaïche
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel
antivirus Avast.
http://www.avast.com
Index: texi2dvi
===================================================================
--- texi2dvi (revision 6531)
+++ texi2dvi (working copy)
@@ -51,7 +51,7 @@
# Instead, assign them an empty value.
action=compile
batch=false # interact normally
-catcode_special=maybe
+catcode_special=false # will be set to maybe after resolve_use_recorder fn
processing
debug=false
escape="\\"
expand=false # true for expansion via makeinfo
@@ -166,7 +166,23 @@
-t, --command=CMD insert CMD in copy of input file
or --texinfo=CMD multiple values accumulate
--translate-file=FILE use given charset translation file for TeX
+ -u, --use-recorder=USEREC override value of TEXI2DVI_USE_RECORDER
environment
+ variable
+The USEREC defines whether TeX output auxiliary files are detected with the
TeX
+\`-recorder' option, or with scanning for \`\\openout' in the log file. Valid
USEREC are:
+ yes use the -recorder option, no checks.
+ no scan for \\openout in the log file, no checks.
+ yesmaybe check whether -recorder option is supported, and if yes
+ use it, otherwise check for tracing \\openout in the log file
+ is supported, and if yes use it, else it is an error.
+ nomaybe same as \`yesmaybe', except that the \\openout trace in log
file
+ is checked first.
+
+If neither TEXI2DVI_USE_RECORDER environement variable is set, nor
+option --use-recorder is passed, defaults to \`nomaybe'.
+
+
Build modes:
--build=MODE specify the treatment of auxiliary files [$build_mode]
--tidy same as --build=tidy
@@ -694,7 +710,7 @@
# generated_files_get FILENAME-NOEXT [PREDICATE-FILTER] - Return the
# list of files generated by the TeX compilation of FILENAME-NOEXT,
# filtered by (piped through) PREDICATE-FILTER if specified.
-generated_files_get ()
+generated_files_get_from_log ()
{
gfg_filter=true
if test -n "$2"; then
@@ -751,12 +767,63 @@
uniq
}
+generated_files_get_from_fls ()
+{
+ gfg_filter=true
+ if test -n "$2"; then
+ gfg_filter=$2
+ fi
+ # Gather the files created by TeX.
+ (
+ if test -f "$1.fls"; then
+ grep '^OUTPUT ' "$1.fls" \
+ | cut -b 8-
+ fi
+ echo "$1.fls"
+ ) |
+ # Depending on these files, infer outputs from other tools.
+ while read file; do
+ echo $file
+ case $in_lang in
+ texinfo)
+ # texindex: texinfo.cp -> texinfo.cps
+ if index_file_p $file; then
+ echo ${file}s
+ fi
+ ;;
+ latex)
+ if aux_file_p $file; then
+ # bibtex: *.aux -> *.bbl and *.blg.
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.bbl/'
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.blg/'
+ # -recorder: .fls
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.fls/'
+ fi
+ ;;
+ esac
+ done |
+ # Filter existing files matching the criterion.
+ #
+ # With an input file name containing a space, this produces a
+ # "command not found" message (and filtering is ineffective).
+ # The situation with a newline is presumably even worse.
+ while read file; do
+ if $gfg_filter "$file"; then
+ echo $file
+ fi
+ done |
+ sort |
+ # Some files are opened several times, e.g., listings.sty's *.vrb.
+ uniq
+}
+
+
# xref_files_save - Save xref files in $work_bak with tar.
xref_files_save ()
{
# Save copies of auxiliary files for later comparison.
- xref_files_orig=`generated_files_get "$in_noext" xref_file_p`
+ xref_files_orig=`$generated_files_get "$in_noext" xref_file_p`
if test -n "$xref_files_orig"; then
verbose "Backing up xref files: $xref_files_orig"
# The following line improves `cp $xref_files_orig "$work_bak"'
@@ -790,7 +857,7 @@
# If old and new lists don't have the same file list,
# then something has definitely changed.
- xref_files_new=`generated_files_get "$in_noext" xref_file_p`
+ xref_files_new=`$generated_files_get "$in_noext" xref_file_p`
verbose "Original xref files = $xref_files_orig"
verbose "New xref files = $xref_files_new"
if test "x$xref_files_orig" != "x$xref_files_new"; then
@@ -814,11 +881,7 @@
return 1
}
-
-# Running the TeX suite.
-#
-# run_tex - Run TeX as "$tex $in_input", taking care of errors and logs.
-run_tex ()
+make_tex_cmd()
{
case $in_lang:$latex2html:`out_lang_tex` in
latex:*:dvi|latex:tex4ht:html)
@@ -876,6 +939,11 @@
esac
fi
+ # Tell TeX about -recorder option, if specified
+ # recorder_option_maybe is in { " -recorder", "" }
+ tex_cmd="$tex_cmd$recorder_option_maybe"
+
+
# Tell TeX about TCX file, if specified.
test -n "$translate_file" \
&& tex_cmd="$tex_cmd --translate-file=$translate_file"
@@ -914,6 +982,15 @@
# append the \input command.
tex_cmd="$tex_cmd '${escape}input'"
+}
+
+# Running the TeX suite.
+#
+# run_tex - Run TeX as "$tex $in_input", taking care of errors and logs.
+run_tex ()
+{
+ make_tex_cmd;
+
# TeX's \input does not (easily or reliably) support whitespace
# characters or other special characters in file names. Our intensive
# use of absolute file names makes this worse: the enclosing directory
@@ -986,7 +1063,7 @@
&& grep '^\\bibdata' "$in_noext.aux") ) \
>&6 2>&1; \
then
- bibtex_aux=`generated_files_get "$in_noext" bibaux_file_p`
+ bibtex_aux=`$generated_files_get "$in_noext" bibaux_file_p`
for f in $bibtex_aux; do
run $bibtex "$f"
done
@@ -1006,7 +1083,7 @@
# But we won't know that if the index files are out of date or nonexistent.
run_index ()
{
- index_files=`generated_files_get $in_noext index_file_p`
+ index_files=`$generated_files_get $in_noext index_file_p`
test -n "$index_files" \
|| return 0
@@ -1401,7 +1478,109 @@
run_tex_suite
}
+#
+make_openout_test()
+{
+ ensure_dir $workdir/check_recorder
+ pushd $workdir/check_recorder > /dev/null
+ cat > openout.tex <<EOF
+\newwrite\ourwrite
+\immediate\openout\ourwrite dum.dum
+\bye
+EOF
+ recorder_option_maybe="$1"
+ make_tex_cmd
+ tex_cmd="$tex_cmd openout.tex"
+ verbose "$0: running $tex_cmd ..."
+ rm -fr "openout.$2"
+ eval "$tex_cmd" > /dev/null 2&>1
+}
+# Check tex supports -recorder option
+check_recorder_support()
+{
+ verbose "Checking TeX recorder support..."
+ make_openout_test " -recorder" fls
+ if test -f openout.fls && grep '^OUTPUT dum.dum$' openout.fls > /dev/null;
then
+ popd > /dev/null
+ verbose "Checking TeX recorder support... yes"
+ return 0
+ else
+ popd > /dev/null
+ verbose "Checking TeX recorder support... no"
+ return 1
+ fi
+}
+
+# Check tex supports \openout traces in log
+check_openout_in_log_support()
+{
+ verbose "Checking TeX \openout in log support..."
+ make_openout_test "" log
+ if test -f openout.log && grep '^\\openout0= *`?dum.dum'"'? *$"
openout.log; then
+ popd > /dev/null
+ verbose "Checking TeX \openout in log support... yes"
+ return 0
+ else
+ popd > /dev/null
+ verbose "Checking TeX \openout in log support... no"
+ return 1
+ fi
+}
+
+# set that output auxiliary files are detected with the -recorder option
+set_xref_detection_from_fls()
+{
+ recorder_option_maybe=" -recorder"
+ generated_files_get=generated_files_get_from_fls
+}
+
+# set that output auxiliary files are detected with greping for \openout in
the log file
+set_xref_detection_from_log()
+{
+ recorder_option_maybe=''
+ generated_files_get=generated_files_get_from_log
+}
+
+# Decide whether output auxiliary files are detected with -recorder option, or
+# with greping for \openout in the log file.
+resolve_use_recorder()
+{
+ # Select output file detection method
+ test -n "$TEXI2DVI_USE_RECORDER" || TEXI2DVI_USE_RECORDER=nomaybe
+
+ case $TEXI2DVI_USE_RECORDER in
+
+ yes) set_xref_detection_from_fls;;
+
+ no) set_xref_detection_from_log;;
+
+ yesmaybe)
+ if check_recorder_support; then
+ set_xref_detection_from_fls;
+ elif check_openout_in_log_support; then
+ set_xref_detection_from_log;
+ else
+ error 1 "TeX does not support -recorder, neither does it output
openout in log"
+ fi
+ ;;
+
+ nomaybe)
+ if check_openout_in_log_support; then
+ set_xref_detection_from_log;
+ elif check_recorder_support; then
+ set_xref_detection_from_fls;
+ else
+ error 1 "TeX does not support -recorder, neither does it output
openout in log"
+ fi
+ ;;
+
+ *) error 1 "Invalid value of TEXI2DVI_USE_RECORDER environment variable
: $TEXI2DVI_USE_RECORDER.";;
+ esac
+ # we need to reinitialize this as now comes the user's input file
processing.
+ catcode_special=maybe
+}
+
# remove FILE...
remove ()
{
@@ -1419,7 +1598,7 @@
shift
$tidy || {
mc_log="$work_build/$in_noext.log"
- set X ${1+"$@"} "$mc_log" `generated_files_get "$work_build/$in_noext"`
+ set X ${1+"$@"} "$mc_log" `$generated_files_get "$work_build/$in_noext"`
shift
}
remove ${1+"$@"}
@@ -1634,6 +1813,7 @@
"`echo "$1" | $SED 's/\\\\/\\\\\\\\/g'`;;
--translate-file ) shift; translate_file="$1";;
--tidy) build_mode=tidy;;
+ -u | --use-recorder) shift; TEXI2DVI_USE_RECORDER="$1";;
-v | --vers*) version;;
-V | --verb*) verb=true;;
--) # What remains are not options.
@@ -1797,6 +1977,10 @@
# Make those directories.
ensure_dir "$work_build" "$work_bak"
+ # Decide whether output auxiliary files are detected with -recorder option,
or
+ # with greping for \openout in the log file.
+ resolve_use_recorder
+
case $action in
compile)
# Compile the document.
texi2dvi
Description: Binary data
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, (continued)
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, Vincent Belaïche, 2015/08/21
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, Vincent Belaïche, 2015/08/21
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, Vincent Belaïche, 2015/08/22
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, Vincent Belaïche, 2015/08/22
- Re: [bug #43122] texi2dvi does not compile enough times to get toc,
Vincent Belaïche <=
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, Vincent Belaïche, 2015/08/30
- Re: [bug #43122] texi2dvi does not compile enough times to get toc, Vincent Belaïche, 2015/08/30