[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6595] -recorder use by texi2dvi
From: |
Gavin D. Smith |
Subject: |
[6595] -recorder use by texi2dvi |
Date: |
Fri, 04 Sep 2015 18:34:35 +0000 |
Revision: 6595
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6595
Author: gavin
Date: 2015-09-04 18:34:34 +0000 (Fri, 04 Sep 2015)
Log Message:
-----------
-recorder use by texi2dvi
Modified Paths:
--------------
trunk/ChangeLog
trunk/util/texi2dvi
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-09-04 10:35:49 UTC (rev 6594)
+++ trunk/ChangeLog 2015-09-04 18:34:34 UTC (rev 6595)
@@ -1,9 +1,42 @@
-2015-08-04 Gavin Smith <address@hidden>
+2015-09-02 Vincent Bela\xEFche <address@hidden>, and
+ Gavin Smith <address@hidden>
+ * util/texi2dvi
+ (generated_files_get_from_log): new function.
+ (generated_files_get_from_fls): new function.
+ (generated_files_get): Generate files based on log
+ file or fls file whichever applicable according to variable
+ generated_files_get_method.
+
+ (make_tex_cmd): New function taking on preamble part of
+ run_tex. Insert -recorder option when applicable, based on
+ recorder_option_maybe variable.
+ (run_tex): Delegate to make_tex_cmd making of the tex command.
+ (make_openout_test): new function.
+ (check_recorder_support): new function.
+ (check_openout_in_log_support): new function.
+ (set_aux_files_from_fls): new function.
+ (set_aux_files_from_log): new function.
+ (decide_aux_files_method): new function.
+ (Main part/preamble to action): call decide_aux_files_method.
+ (End of file): Add "Local Variables" comments to set indent
+ style for Emacs.
+
+ (run_tex_suite): Call run_core_conversion before run_index, to
+ avoid overwriting a sorted index file.
+ (run_core_conversion): If a recorder file was output, rename it
+ to avoid it being overwritten.
+ (compile): Put backup directory at front of search path for TeX.
+ (absolute_filenames): Don't prepend "." to the list.
+
+ (xref_files_save): Comment changed.
+
+2015-09-04 Gavin Smith <address@hidden>
+
* doc/texinfo.tex (\dosubindwrite): If index sort key ends up as
empty, use a space.
-2015-08-03 Gavin Smith <address@hidden>
+2015-09-03 Gavin Smith <address@hidden>
* doc/texinfo.texi (Indexing Commands): Update documentation of
@sortas.
@@ -11,7 +44,7 @@
* doc/refcard/txirefcard.tex: Add @sortas.
* NEWS: Mention @sortas.
-2015-08-03 Gavin Smith <address@hidden>
+2015-09-03 Gavin Smith <address@hidden>
* doc/texinfo.tex: Let - always be active, and set it to
\normaldash.
@@ -29,7 +62,7 @@
Remove it for \mathopsup.
Correct entry <<' (umlaut accent)>> to <<' (acute accent)>>.
-2015-08-01 Gavin Smith <address@hidden>
+2015-09-01 Gavin Smith <address@hidden>
* info/info-utils.c (printed_representation): Cast a char * to
unsigned * so undisplayable bytes aren't always displayed as \377.
Modified: trunk/util/texi2dvi
===================================================================
--- trunk/util/texi2dvi 2015-09-04 10:35:49 UTC (rev 6594)
+++ trunk/util/texi2dvi 2015-09-04 18:34:34 UTC (rev 6595)
@@ -508,7 +508,7 @@
#
# absolute_filenames TEX-PATH -> TEX-PATH - Convert relative paths to
# absolute, so we can run in another directory (e.g., in tidy build
-# mode, or during the macro-support detection). Prepend ".$path_sep".
+# mode, or during the macro-support detection).
absolute_filenames ()
{
# Empty path components are meaningful to tex. We rewrite them as
@@ -521,25 +521,27 @@
save_IFS=$IFS
IFS=$path_sep
set x $af_result; shift
- af_result=.
+ af_result=
+ af_path_sep=
for dir
do
case $dir in
EMPTY)
- af_result=$af_result$path_sep
+ af_result=$af_result$af_path_sep
;;
*)
if test -d "$dir"; then
- af_result=$af_result$path_sep`absolute "$dir"`
+ af_result=$af_result$af_path_sep`absolute "$dir"`
else
# Even if $dir is not a directory, preserve it in the path.
# It might contain metacharacters that TeX will expand in
# turn, e.g., /some/path/{a,b,c}. This will not get the
# implicit absolutification of the path, but we can't help that.
- af_result=$af_result$path_sep$dir
+ af_result=$af_result$af_path_sep$dir
fi
;;
esac
+ af_path_sep=$path_sep
done
echo "$af_result"
}
@@ -691,9 +693,37 @@
}
-# generated_files_get FILENAME-NOEXT [PREDICATE-FILTER] - Return the
+# Used in generated_files_get
+generated_files_get_from_log ()
+{
+ if test -f "$1.log"; then
+ # Usually the output is like: \openout1 = `foobar.tex'.
+ # (including the final period)
+ # but luatex outputs: \openout1 = foobar.tex
+ # (no quotes, no period).
+ # So we have to make the punctuation optional.
+ grep '^\\openout[0-9]' "$1.log" \
+ | $SED -e "s/\\\\openout[^=]*= *[\`']*//" \
+ -e "s/'\.$//"
+ fi
+ echo "$1.log"
+}
+
+# Used in generated_files_get
+generated_files_get_from_fls ()
+{
+ if test -f "$1.flz"; then
+ grep '^OUTPUT ' "$1.flz" \
+ | cut -b 8-
+ fi
+ echo "$1.flz"
+}
+
+#
+# generated_files_get FILENAME-NOEXT [PREDICATE-FILTER] - Output the
# list of files generated by the TeX compilation of FILENAME-NOEXT,
# filtered by (piped through) PREDICATE-FILTER if specified.
+
generated_files_get ()
{
gfg_filter=true
@@ -702,20 +732,8 @@
fi
# Gather the files created by TeX.
- (
- if test -f "$1.log"; then
- # Usually the output is like: \openout1 = `foobar.tex'.
- # (including the final period)
- # but luatex outputs: \openout1 = foobar.tex
- # (no quotes, no period).
- # So we have to make the punctuation optional.
- grep '^\\openout[0-9]' "$1.log" \
- | $SED -e "s/\\\\openout[^=]*= *[\`']*//" \
- -e "s/'\.$//"
- fi
- echo "$1.log"
- ) |
# Depending on these files, infer outputs from other tools.
+ $generated_files_get_method "$1" |
while read file; do
echo $file
case $in_lang in
@@ -752,7 +770,7 @@
}
-# xref_files_save - Save xref files in $work_bak with tar.
+# xref_files_save - Save xref files in $work_bak, and set xref_files_orig.
xref_files_save ()
{
# Save copies of auxiliary files for later comparison.
@@ -814,11 +832,10 @@
return 1
}
-
# Running the TeX suite.
#
-# run_tex - Run TeX as "$tex $in_input", taking care of errors and logs.
-run_tex ()
+# Set tex_cmd variable, for running TeX.
+make_tex_cmd ()
{
case $in_lang:$latex2html:`out_lang_tex` in
latex:*:dvi|latex:tex4ht:html)
@@ -876,6 +893,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"
@@ -898,7 +920,6 @@
# we'd like to handle arbitrary input file names, especially
# foo~bar/a~b.tex, since Debian likes ~ characters.
if $catcode_special; then
- # $normaltilde is just to reduce line length in this source file.
# The idea is to define \normaltilde as a catcode other ~ character,
# then make the active ~ be equivalent to that, instead of the plain
# TeX tie. Then when the active ~ appears in the filename, it will
@@ -913,7 +934,13 @@
# append the \input command.
tex_cmd="$tex_cmd '${escape}input'"
+}
+# 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
@@ -1130,12 +1157,16 @@
xref_files_save
- # We run bibtex first, because it's more likely for the indexes
+ run_core_conversion
+
+ # We ran the conversion before making the sorted index files
+ # because otherwise a sorted *.fls file (for an index `fl') could
+ # be overwritten by a *.fls file produced with --recorder.
+ # We run bibtex first, because it's more likely for the indexes
# to change after bibtex is run than the reverse, though either
# would be rare.
run_bibtex
run_index
- run_core_conversion
xref_files_changed || break
done
@@ -1359,6 +1390,7 @@
*)
error 1 "invalid input/output combination: $in_lang/$out_lang";;
esac
+ test -f "$in_noext.fls" && mv "$in_noext.fls" "$in_noext.flz"
}
@@ -1366,17 +1398,20 @@
# installation of the output at its expected location.
compile ()
{
- # Source file might include additional sources.
- # We want `.:$orig_pwd' before anything else. (We'll add `.:' later
- # after all other directories have been turned into absolute paths.)
- # `.' goes first to ensure that any old .aux, .cps,
- # etc. files in ${directory} don't get used in preference to fresher
- # files in `.'. Include orig_pwd in case we are in clean build mode, where
- # we have cd'd to a temp directory.
- common="$orig_pwd$path_sep$in_dir$path_sep"
+ # Set include path for tools:
+ # . Include work_bak so we can use a sorted FILE.fls index file there
+ # while still writing to FILE.fls if using --recorder.
+ # . Include current directory in case there are files there already, so
+ # we don't have more TeX runs than necessary. orig_pwd is used in case
+ # we are in clean build mode, where we have cd'd to a temp directory.
+ # . Include directory containing file, in case there are other
+ # files @include'd.
+ # . Keep a final path_sep to get the default (system) TeX
+ # directories included.
+ # . If we have any includes, put those at the end.
+
+ common="$work_bak$path_sep$orig_pwd$path_sep$in_dir$path_sep"
#
- # If we have any includes, put those at the end.
- # Keep a final path_sep to get the default (system) TeX directories included.
txincludes=`list_infix includes $path_sep`
test -n "$txincludes" && common="$common$txincludes$path_sep"
#
@@ -1384,7 +1419,7 @@
eval val="\$common\$${var}_orig"
# Convert relative paths to absolute paths, so we can run in another
# directory (e.g., in clean build mode, or during the macro-support
- # detection). ".:" is added here.
+ # detection).
val=`absolute_filenames "$val"`
eval $var="\"$val\""
export $var
@@ -1401,7 +1436,125 @@
run_tex_suite
}
+#
+make_openout_test ()
+{
+ ensure_dir $workdir/check_recorder
+ cd $workdir/check_recorder
+ 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
+ cd_orig
+ verbose "Checking TeX recorder support... yes"
+ return 0
+ else
+ cd_orig
+ 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
+ cd_orig
+ verbose "Checking TeX \openout in log support... yes"
+ return 0
+ else
+ cd_orig
+ verbose "Checking TeX \openout in log support... no"
+ return 1
+ fi
+}
+
+# Set that output auxiliary files are detected with the -recorder option,
+# which creates a file JOBNAME.fls which is a machine-readable listing of
+# files read and written during the job.
+set_aux_files_from_fls ()
+{
+ recorder_option_maybe=" -recorder"
+ generated_files_get_method=generated_files_get_from_fls
+}
+
+# Set that output auxiliary files are detected with searching for \openout
+# in the log file.
+set_aux_files_from_log ()
+{
+ recorder_option_maybe=''
+ generated_files_get_method=generated_files_get_from_log
+}
+
+# Decide whether output auxiliary files are detected with the -recorder
+# option, or by searching for \openout in the log file.
+decide_aux_files_method ()
+{
+ # Select output file detection method
+ # Valid values of TEXI2DVI_USE_RECORDER 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.
+ #
+ # The default behaviour is `nomaybe'.
+
+ test -n "$TEXI2DVI_USE_RECORDER" || TEXI2DVI_USE_RECORDER=yesmaybe
+
+ case $TEXI2DVI_USE_RECORDER in
+ yes) set_aux_files_from_fls;;
+
+ no) set_aux_files_from_log;;
+
+ yesmaybe)
+ if check_recorder_support; then
+ set_aux_files_from_fls
+ elif check_openout_in_log_support; then
+ set_aux_files_from_log
+ else
+ error 1 "TeX neither supports -recorder nor outputs \\openout lines in
its log file"
+ fi
+ ;;
+
+ nomaybe)
+ if check_openout_in_log_support; then
+ set_aux_files_from_log
+ elif check_recorder_support; then
+ set_aux_files_from_fls
+ else
+ error 1 "TeX neither supports -recorder nor outputs \\openout lines in
its log file"
+ fi
+ ;;
+
+ *) error 1 "Invalid value of TEXI2DVI_USE_RECORDER environment variable :
$TEXI2DVI_USE_RECORDER.";;
+
+ esac
+}
+
# remove FILE...
remove ()
{
@@ -1797,6 +1950,9 @@
# Make those directories.
ensure_dir "$work_build" "$work_bak"
+ # Decide how to find auxiliary files created by TeX.
+ decide_aux_files_method
+
case $action in
compile)
# Compile the document.
@@ -1812,3 +1968,7 @@
verbose "done."
exit 0 # exit successfully, not however we ended the loop.
+# Local Variables:
+# sh-basic-offset: 2
+# sh-indentation: 2
+# End:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6595] -recorder use by texi2dvi,
Gavin D. Smith <=