texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[6637] texi2dvi: don't call generated_files_get so often, remove tricks


From: Gavin D. Smith
Subject: [6637] texi2dvi: don't call generated_files_get so often, remove tricks to handle fl index, don't compare sorted index files in loop
Date: Tue, 22 Sep 2015 17:29:59 +0000

Revision: 6637
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6637
Author:   gavin
Date:     2015-09-22 17:29:58 +0000 (Tue, 22 Sep 2015)
Log Message:
-----------
texi2dvi: don't call generated_files_get so often, remove tricks to handle fl 
index, don't compare sorted index files in loop

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/util/texi2dvi

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-09-20 16:28:07 UTC (rev 6636)
+++ trunk/ChangeLog     2015-09-22 17:29:58 UTC (rev 6637)
@@ -1,3 +1,54 @@
+2015-09-22  Gavin Smith  <address@hidden>
+
+       * util/texi2dvi (decide_aux_files_method): Default to not using 
+       recorder.
+       (run_core_conversion): Eliminate all renaming to handle indexes 
+       called "fl".  When \openout lines are missing from the log file, 
+       this will be dealt with by changes to texinfo.tex.
+       (generated_files_get_from_fls): Use fls extension (not flz).
+
+       (generated_files_get): Don't add extra files to the list or 
+       filter it at all.  Don't take any arguments.
+       (filter_files): New function, using the filtering logic that was 
+       in generated_files_get.
+       (aux_file_p, bibtex_file_p, index_file_p): Make suitable for 
+       using with filter_files by echoing file name if the predicate is 
+       true of the file.
+
+       (all_files, add_all_filter): Logic for finding generated files 
+       moved from generated_files_get, used in mostly_clean function.
+       (top-level part of script): Call generated_files_get to set 
+       a value for xref_files_new before calling mostly_clean.
+       (mostly_clean): Call all_files to get list of files to remove, 
+       instead of generated_files_get.
+
+       (generated_files_get_from_fls, generated_files_get_from_log): 
+       Don't output names of log or recorder file.
+       (xref_files_changed): Compare all files output, not just those 
+       that pass xref_files_p (not including the *.log or *.fls files 
+       themselves).  However, don't compare derivative files such as
+       sorted index files.
+       (xref_files_p): Add comment to say this function isn't used.
+       (run_tex_suite): Call xref_files_save once at the beginning, and 
+       then immediately after each use of xref_files_changed in the 
+       main loop.  This reduces the chances of an infinite loop 
+       happening if one of the output files is overwritten by mistake 
+       in the meantime.
+       (xref_files_save): Don't call generated_files_get; use value of 
+       xref_files_new for the files to save.
+       (run_index, run_bibtex): Call filter_files instead of 
+       generated_files_get.
+
+       (compile): Put working directory back at the start of TEXINPUTS, 
+       as this is clearer, and it was reported that on some versions of 
+       MikTeX, the working directory always took priority regardless.
+       Remove backup directory from search path, as this was a trick 
+       for processing fl indices that didn't work reliably.
+       Redirect output of test for \openout lines in log file to /dev/null.
+
+       (usage): Move some options that aren't "build modes" out of the 
+       build mode section.
+
 2015-09-20  Gavin Smith  <address@hidden>
 
        * doc/texinfo.texi (Optional Arguments): Remove use of @var from 

Modified: trunk/util/texi2dvi
===================================================================
--- trunk/util/texi2dvi 2015-09-20 16:28:07 UTC (rev 6636)
+++ trunk/util/texi2dvi 2015-09-22 17:29:58 UTC (rev 6637)
@@ -145,6 +145,9 @@
   -s, --silent        same as --quiet
   -v, --version       display version information and exit successfully
   -V, --verbose       report on what is done
+  --max-iterations=N   don't process files more than N times [$max_iters]
+  --mostly-clean      remove the auxiliary files and directories,
+                         but not the output
 
 Output format:
       --dvi     output a DVI file [default]
@@ -174,9 +177,6 @@
       --build-dir=DIR  specify where the tidy compilation is performed;
                          implies --tidy;
                          defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
-  --mostly-clean       remove the auxiliary files and directories
-                         but not the output
-  --max-iterations=N   don't process files more than N times [$max_iters]
 
 The MODE specifies where the TeX compilation takes place, and, as a
 consequence, how auxiliary files are treated.  The build mode can also
@@ -614,20 +614,20 @@
 
 #  Managing xref files.
 #
-# aux_file_p FILE - Return success if FILE is an aux file.
+# aux_file_p FILE - Echo FILE if FILE is an aux file.
 aux_file_p ()
 {
-  test -f "$1" || return 1
+  test -f "$1" || return 0
   case $1 in
-    *.aux) return 0;;
-    *)     return 1;;
+    *.aux) echo "$1";;
+    *)     return 0;;
   esac
 }
 
-# bibaux_file_p FILE - Return success if FILE contains citation requests.
+# bibaux_file_p FILE - Echo FILE if FILE contains citation requests.
 bibaux_file_p ()
 {
-  test -s "$1" || return 1
+  test -s "$1" || return 0
   if (grep '^\\bibstyle[{]' "$1"   \
       && grep '^\\bibdata[{]' "$1" \
       ## The following line is suspicious: fails when there
@@ -636,15 +636,15 @@
       ## && grep '^\\citation[{]' "$f"
       ) >&6 2>&1;
   then
-    return 0
+    echo "$1"
   fi
-  return 1
+  return 0
 }
 
-# index_file_p FILE - Return success if FILE is an index file.
+# index_file_p FILE - Echo FILE if FILE is an index file.
 index_file_p ()
 {
-  test -f "$1" || return 1
+  test -f "$1" || return 0
   case $in_lang:$latex2html:`out_lang_tex`:`$SED '1q' "$1"` in
     # When working with TeX4HT, *.idx are created by LaTeX.  They must
     # be processed to produce *.4ix, *.4dx files.  The *.4dx file is
@@ -652,17 +652,17 @@
     # handled by run_index, so we are only interested in the *.idx
     # files, which have each "\indexentry" preceded by a
     # "\beforeentry".
-    latex:tex4ht:html:"\\beforeentry {"*) return 0;;
+    latex:tex4ht:html:"\\beforeentry {"*) echo $1;;
 
     # When index.sty is used, there is a space before the brace.
-    latex:*:*:"\\indexentry{"*|latex:*:*:"\\indexentry {"*) return 0;;
+    latex:*:*:"\\indexentry{"*|latex:*:*:"\\indexentry {"*) echo $1;;
 
-    texinfo:*:*:"\\entry{"*) return 0;;
-
-    *) return 1;;
+    texinfo:*:*:"\\entry{"*) echo $1;;
   esac
+  return 0
 }
 
+########### not used currently
 # xref_file_p FILE - Return success if FILE is an xref file (indexes,
 # tables and lists).
 xref_file_p ()
@@ -693,75 +693,31 @@
       | $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" \
+  if test -f "$1.fls"; then
+    grep '^OUTPUT ' "$1.fls" \
       | 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 - Output the list of files generated by the TeX 
+#                       compilation.
 generated_files_get ()
 {
-  gfg_filter=true
-  if test -n "$2"; then
-    gfg_filter=$2
-  fi
-
-  # Gather the files created by TeX.
-  # Depending on these files, infer outputs from other tools.
-  $generated_files_get_method "$1" |
-  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
+  $generated_files_get_method "$in_noext"
 }
 
 
-# xref_files_save - Save xref files in $work_bak, and set xref_files_orig.
+# xref_files_save - set xref_files_orig from xref_files_orig, and save xref 
+#                   files in $work_bak.
 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=$xref_files_new
   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"'
@@ -776,7 +732,7 @@
 }
 
 
-# xref_files_changed - Return success if  the xref files have changed
+# xref_files_changed - Return success if the xref files have changed
 # since the previous run.
 xref_files_changed ()
 {
@@ -795,7 +751,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`
   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
@@ -1000,7 +956,7 @@
               && grep '^\\bibdata' "$in_noext.aux") ) \
         >&6 2>&1; \
   then
-    bibtex_aux=`generated_files_get "$in_noext" bibaux_file_p`
+    bibtex_aux=`filter_files bibaux_file_p`
     for f in $bibtex_aux; do
       run $bibtex "$f"
     done
@@ -1014,13 +970,28 @@
 }
 
 
+# filter_file PREDICATE - Print the names of files in xref_files_new
+#                         that match PREDICATE.
+filter_files ()
+{
+  test -n "$xref_files_new" && echo "$xref_files_new" |
+  # Filter existing files matching the criterion.
+  #
+  while read file; do
+    $1 "$file"
+  done |
+  sort |
+  # Some files are opened several times, e.g., listings.sty's *.vrb.
+  uniq
+}
+
 # run_index - Run texindex (or makeindex or texindy) on current index
 # files.  If they already exist, and after running TeX a first time the
 # index files don't change, then there's no reason to run TeX again.
 # 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=`filter_files index_file_p`
   test -n "$index_files" \
   || return 0
 
@@ -1131,6 +1102,11 @@
   # Count the number of cycles.
   suite_cycle=0
 
+  # Start by checking the log files for what files were created last
+  # time.  This will mean that if they don't change, we finish in 1 cycle.
+  xref_files_new=`generated_files_get`
+  xref_files_save
+
   while :; do
     # check for (probably) LaTeX loop (e.g. varioref)
     if test $suite_cycle -eq "$max_iters"; then
@@ -1142,10 +1118,9 @@
     suite_cycle=`expr $suite_cycle + 1`
     verbose "Cycle $suite_cycle for $command_line_filename"
 
-    xref_files_save
-
     run_core_conversion
     xref_files_changed || break
+    xref_files_save
 
     # We run bibtex first, because it's more likely for the indexes
     # to change after bibtex is run than the reverse, though either
@@ -1365,9 +1340,6 @@
 # run_core_conversion - Run TeX (or HeVeA).
 run_core_conversion ()
 {
-  # Backup a sorted index file
-  test -f "$in_noext.fls" && cp "$in_noext.fls" "$in_noext.f0s"
-
   case $in_lang:$latex2html:`out_lang_tex` in
     *:dvi|*:pdf|latex:tex4ht:html)
         run_tex;;
@@ -1376,17 +1348,6 @@
     *)
         error 1 "invalid input/output combination: $in_lang/$out_lang";;
   esac
-  # Use a different extension for a recorder file
-  test -f "$in_noext.fls" && mv "$in_noext.fls" "$in_noext.flz"
-
-  # Restore a sorted index file
-  test -f "$in_noext.f0s" && mv "$in_noext.f0s" "$in_noext.fls"
-
-  # Stop this last command leading to an exit because of "set -e".  Even though
-  # failures in non-final components of command lists don't cause set -e
-  # to fail (failure for "test -f"), it would lead the exit status of the call
-  # to run_core_conversion to be non-zero, which *would* lead to an exit.
-  true
 }
 
 
@@ -1395,8 +1356,6 @@
 compile ()
 {
   # 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.
@@ -1406,7 +1365,7 @@
   #     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"
+  common="$orig_pwd$path_sep$in_dir$path_sep"
   #
   txincludes=`list_infix includes $path_sep`
   test -n "$txincludes" && common="$common$txincludes$path_sep"
@@ -1481,7 +1440,7 @@
   verbose "Checking TeX \openout in log support..."
   make_openout_test "" log
   if test -f openout.log \
-     && grep '^\\openout0 *= *`\?dum\.dum'\''\?' openout.log
+     && grep '^\\openout0 *= *`\?dum\.dum'\''\?' openout.log >/dev/null
   then
     cd_orig
     verbose "Checking TeX \openout in log support... yes"
@@ -1527,7 +1486,7 @@
   #
   #  The default behaviour is `nomaybe'.
 
-  test -n "$TEXI2DVI_USE_RECORDER" || TEXI2DVI_USE_RECORDER=yesmaybe
+  test -n "$TEXI2DVI_USE_RECORDER" || TEXI2DVI_USE_RECORDER=nomaybe
 
   case $TEXI2DVI_USE_RECORDER in
     yes) set_aux_files_from_fls;;
@@ -1567,7 +1526,39 @@
 }
 
 
-# mostly_clean - Remove auxiliary files and directories.  Changes back
+# all_files - Echo the names of all files generated, including those by
+#             auxiliary tools like texindex.
+all_files ()
+{
+  echo $in_noext.log
+  echo $in_noext.fls
+  filter_files add_all_filter
+}
+
+# Echo FILE and any generated file based thereon.
+add_all_filter ()
+{
+  echo $1
+  case $in_lang in
+    texinfo)
+      # texindex: texinfo.cp -> texinfo.cps
+      if test -n "`index_file_p $1`" ; then
+        echo $1s
+      fi
+      ;;
+    latex)
+      if test -n "`aux_file_p $1`"; then
+        # bibtex: *.aux -> *.bbl and *.blg.
+        echo $1 | $SED 's/^\(.*\)\.aux$/\1.bbl/'
+        echo $1 | $SED 's/^\(.*\)\.aux$/\1.blg/'
+        # -recorder: .fls
+        echo $1 | $SED 's/^\(.*\)\.aux$/\1.fls/'
+      fi
+      ;;
+  esac
+}
+
+# mostly_clean - Remove auxiliary files and directories.  Changes back to
 # the original directory.
 mostly_clean ()
 {
@@ -1575,8 +1566,7 @@
   set X "$t2ddir"
   shift
   $tidy || {
-    mc_log="$work_build/$in_noext.log"
-    set X ${1+"$@"} "$mc_log" `generated_files_get "$work_build/$in_noext"`
+    set X ${1+"$@"} `all_files`
     shift
   }
   remove ${1+"$@"}
@@ -1965,6 +1955,7 @@
       ;;
 
     mostly-clean)
+      xref_files_new=`generated_files_get`
       mostly_clean
       ;;
   esac




reply via email to

[Prev in Thread] Current Thread [Next in Thread]