help-texinfo
[Top][All Lists]
Advanced

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

Re: [help-texinfo] texi2dvi: AUC-TeX and depots


From: Akim Demaille
Subject: Re: [help-texinfo] texi2dvi: AUC-TeX and depots
Date: Thu, 29 Sep 2005 10:56:15 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

>>> "Karl" == Karl Berry <address@hidden> writes:

 >     - I have no idea about `local'
 > Is it really needed?

Nope, but it's so much better with.

 >     I will ask to knowledge people (Dr. Autoconf List & Pr. Libtool List)
 >     what they think about it.

 > Sounds good.

They said local is not portable but return is.  Working around the
absence of local is easy, I did it below.  I also added a test harness
for texi2dvi, but since I can't cvs add, I append the files, they're
not part of the patch.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * doc/texinfo.txi: Document pdftexi2dvi.
        * doc/Makefile.am (common_texi2dvi_deps): New.
        Handle texi2pdf and pdftexi2dvi.
        * util/texi2dvi: Stop supporting shortened long options, as it's
        causing troubles.  Short options are here anyway.
        (local): Provide a default implementation if not supported by the
        shell.
        (findprog): Use return.
        (get_xref_files): Rename as...
        (xref_files_get): this.
        (xref_files_changed, xref_files_save): New.
        (run_tex_suite): New.
        (move_to_dest): Use `local'.
        ($textra_cmd): Compute it in...
        (insert_commands): here.

        * tests/defs.in, tests/texi2dvi.test, tests/local.test: New.
        * configure.ac, tests/Makefile.am: Adjust.

Index: configure.ac
===================================================================
RCS file: /cvsroot/texinfo/texinfo/configure.ac,v
retrieving revision 1.59
diff -u -u -r1.59 configure.ac
--- configure.ac 5 Aug 2005 09:25:44 -0000 1.59
+++ configure.ac 29 Sep 2005 08:52:49 -0000
@@ -83,7 +83,7 @@
 # We need to run some of our own binaries, most notably makedoc, but as
 # long as we have this process, we also use our own makeinfo and
 # install-info.
-# 
+#
 # This means that if we are cross compiling, we have to configure the
 # package twice: once with the native compiler (this is done in a
 # subdirectory $native_tools), and once with the cross compiler.
@@ -217,6 +217,6 @@
   makeinfo/Makefile
   makeinfo/tests/Makefile
   po/Makefile.in
-  util/Makefile
+  util/Makefile util/defs
 ])
 AC_OUTPUT
Index: doc/Makefile.am
===================================================================
RCS file: /cvsroot/texinfo/texinfo/doc/Makefile.am,v
retrieving revision 1.29
diff -u -u -r1.29 Makefile.am
--- doc/Makefile.am 17 Aug 2005 12:43:06 -0000 1.29
+++ doc/Makefile.am 29 Sep 2005 08:52:49 -0000
@@ -27,7 +27,7 @@
 
 TXI_XLATE = txi-cs.tex txi-de.tex txi-en.tex txi-es.tex txi-fr.tex \
            txi-it.tex txi-nl.tex txi-no.tex txi-pl.tex txi-pt.tex \
-           txi-sr.tex txi-tr.tex 
+           txi-sr.tex txi-tr.tex
 
 # Include our texinfo.tex, not Automake's.
 EXTRA_DIST = epsf.tex pdfcolor.tex texinfo.tex \
@@ -97,12 +97,23 @@
        mv $@ address@hidden
        sed '/^\.IP$$/N;/\nAlso/s/I//;/\nThe/s/I//' address@hidden >$@
        rm address@hidden
-       
+
 $(srcdir)/texindex.1: $(top_srcdir)/util/texindex.c $(common_mandeps)
        @name="sort Texinfo index files" && $(man_rule_bin)
 
-$(srcdir)/texi2dvi.1: $(top_srcdir)/util/texi2dvi $(common_mandeps)
-       $(HELP2MAN) --name="print Texinfo documents" 
$(top_srcdir)/util/texi2dvi >$@
+
+common_texi2dvi_deps =                                 \
+$(common_mandeps)                                      \
+$(top_srcdir)/util/texi2dvi $(top_srcdir)/util/texi2pdf
+
+$(srcdir)/texi2dvi.1: $(common_texi2dvi_deps)
+       $(HELP2MAN) --name="convert Texinfo documents to DVI" 
$(top_srcdir)/util/texi2dvi >$@
+
+$(srcdir)/texi2pdf.1: $(common_texi2dvi_deps)
+       $(HELP2MAN) --name="convert Texinfo documents to PDF" 
$(top_srcdir)/util/texi2pdf >$@
+
+$(srcdir)/pdftexi2dvi.1:  $(common_texi2dvi_deps)
+       $(HELP2MAN) --name="convert Texinfo documents to PDF" 
$(top_srcdir)/util/pdftexi2dvi >$@
 
 # Do not create info files for distribution.
 dist-info:
Index: doc/infokey.1
===================================================================
RCS file: /cvsroot/texinfo/texinfo/doc/infokey.1,v
retrieving revision 1.15
diff -u -u -r1.15 infokey.1
--- doc/infokey.1 15 May 2005 00:00:06 -0000 1.15
+++ doc/infokey.1 29 Sep 2005 08:52:49 -0000
@@ -1,5 +1,5 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.35.
-.TH INFOKEY "1" "May 2005" "infokey 4.8" "User Commands"
+.TH INFOKEY "1" "September 2005" "infokey 4.8" "User Commands"
 .SH NAME
 infokey \- compile customizations for Info
 .SH SYNOPSIS
@@ -23,10 +23,11 @@
 general questions and discussion to address@hidden
 Texinfo home page: http://www.gnu.org/software/texinfo/
 .SH COPYRIGHT
-Copyright \(co 2003 Free Software Foundation, Inc.
-There is NO warranty.  You may redistribute this software
+Copyright \(co 2005 Free Software Foundation, Inc.
+There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE.  You may redistribute copies of GNU texinfo
 under the terms of the GNU General Public License.
-For more information about these matters, see the files named COPYING.
+For more information about these matters, see the file named COPYING.
 .SH "SEE ALSO"
 The full documentation for
 .B infokey
Index: doc/texinfo.txi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/doc/texinfo.txi,v
retrieving revision 1.148
diff -u -u -r1.148 texinfo.txi
--- doc/texinfo.txi 19 Sep 2005 12:50:54 -0000 1.148
+++ doc/texinfo.txi 29 Sep 2005 08:52:50 -0000
@@ -60,6 +60,7 @@
 * install-info: (texinfo)Invoking install-info. Update info/dir entries.
 * texi2dvi: (texinfo)Format with texi2dvi.      Print Texinfo documents.
 * texi2pdf: (texinfo)PDF Output.                PDF output for Texinfo.
+* pdftexi2dvi: (texinfo)PDF Output.             PDF output for Texinfo.
 * texindex: (texinfo)Format with tex/texindex.  Sort Texinfo index files.
 * makeinfo: (texinfo)Invoking makeinfo.         Translate Texinfo source.
 @end direntry
@@ -7433,7 +7434,7 @@
 Info output, the argument is printed as-is.  In either format, if the
 second argument is present, it is printed in parentheses after the
 acronym.  In HTML, Docbook, and XML, the @code{<acronym>} tag is
-used.  
+used.
 
 For instance (since GNU is a recursive acronym, we use
 @code{@@acronym} recursively):
@@ -9149,7 +9150,7 @@
 In Texinfo, all floats are numbered the same way: with the chapter
 number (or appendix letter), a period, and the float number, which
 simply counts 1, 2, 3, @dots{}, and is reset at each chapter.  Each
-float type is counted independently.  
+float type is counted independently.
 
 Floats within an @code{@@unnumbered} are numbered, or outside of any
 chapter, are simply numbered consecutively from 1.
@@ -9315,7 +9316,7 @@
 For @TeX{} output, if an image is the first thing in a paragraph, for
 example if you want two images side-by-side, you must precede it with
 @code{@@noindent} (@pxref{noindent,,@code{@@noindent}}).  Otherwise it
-will be displayed on a line by itself.  If you want it centered, 
+will be displayed on a line by itself.  If you want it centered,
 use @code{@@center} (@pxref{titlefont center sp,,@code{@@titlefont
 @@center @@sp}}).
 
@@ -9956,7 +9957,7 @@
 
 The @code{@@defcodeindex} is like the @code{@@defindex} command,
 except that, in the printed output, it prints entries in an
address@hidden@@code} font by default instead of a roman font.  
address@hidden@@code} font by default instead of a roman font.
 
 You should define new indices before the end-of-header line of a
 Texinfo file, and (of course) before any @code{@@synindex} or
@@ -14242,7 +14243,10 @@
 With the @option{--pdf} option, @command{texi2dvi} produces PDF output
 instead of DVI (@pxref{PDF Output}), by running @command{pdftex}
 instead of @command{tex}.  Alternatively, the command
address@hidden is an abbreviation for running @samp{texi2dvi --pdf}.
address@hidden is an abbreviation for running @samp{texi2dvi
+--pdf}.  The command @command{pdftexi2dvi} is also supported as a
+convenience to address@hidden users, since the latter merely prepends
address@hidden to DVI producing tools to have PDF producing tools.
 
 @cindex @LaTeX{}, processing with @command{texi2dvi}
 @command{texi2dvi} can also be used to process @LaTeX{} files; simply
@@ -14919,12 +14923,12 @@
 
 @pindex pdftex
 The simplest way to generate PDF output from Texinfo source is to run
-the convenience script @command{texi2pdf}; this simply executes the
address@hidden script with the @option{--pdf} option
-(@pxref{Format with texi2dvi}).  If for some reason you want to
-process by hand, simply run the @command{pdftex} program instead of
-plain @command{tex}.  That is, run @samp{pdftex foo.texi} instead of
address@hidden foo.texi}.
+the convenience script @command{texi2pdf} (or @command{pdftexi2dvi});
+this simply executes the @command{texi2dvi} script with the
address@hidden option (@pxref{Format with texi2dvi}).  If for some
+reason you want to process by hand, simply run the @command{pdftex}
+program instead of plain @command{tex}.  That is, run @samp{pdftex
+foo.texi} instead of @samp{tex foo.texi}.
 
 @dfn{PDF} stands for `Portable Document Format'. It was invented by
 Adobe Systems some years ago for document interchange, based on their
@@ -15217,7 +15221,7 @@
 For the specified format, process @samp{@@address@hidden and
 @samp{@@@var{format}} commands even if not generating the given output
 format.  For instance, if @option{--iftex} is specified, then
address@hidden@@iftex} and @samp{@@tex} blocks will be read.  
address@hidden@@iftex} and @samp{@@tex} blocks will be read.
 
 @item address@hidden
 @itemx -E @var{file}
@@ -16250,7 +16254,7 @@
 When splitting, the HTML output files are written into a subdirectory,
 with the name chosen as follows:
 @enumerate
address@hidden 
address@hidden
 @command{makeinfo} first tries the subdirectory with the base name
 from @code{@@setfilename} (that is, any extension is removed).  For
 example, HTML output for @code{@@setfilename gcc.info} would be
@@ -16287,7 +16291,7 @@
 @uref{http://www.w3.org/Style/CSS/}.
 
 By default, @command{makeinfo} includes a few simple CSS commands to
-better implement the appearance of some of the environments.  Here 
+better implement the appearance of some of the environments.  Here
 are two of them, as an example:
 
 @example
@@ -16562,7 +16566,7 @@
 @end itemize
 
 On case-folding computer systems, nodes differing only by case will be
-mapped to the same file.  
+mapped to the same file.
 
 In particular, as mentioned above, Top always maps to the file
 @file{index.html}.  Thus, on a case-folding system, Top and a node
@@ -16772,9 +16776,9 @@
 texinfo split http://www.gnu.org/software/texinfo/manual/texinfo/html_node/
 texinfo mono http://www.gnu.org/software/texinfo/manual/texinfo/texinfo.html
 
-If the keyword is 'split', that is the target is split, the urlprefix gives 
+If the keyword is 'split', that is the target is split, the urlprefix gives
 the directory and host name.
-If the keyword is 'mono', that is the target is mono, the urlprefix gives 
+If the keyword is 'mono', that is the target is mono, the urlprefix gives
 directory, host and file name.
 
 '#' followed by a space begins comments. '#' followed by another character
Index: doc/version-stnd.texi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/doc/version-stnd.texi,v
retrieving revision 1.14
diff -u -u -r1.14 version-stnd.texi
--- doc/version-stnd.texi 15 May 2005 00:00:06 -0000 1.14
+++ doc/version-stnd.texi 29 Sep 2005 08:52:50 -0000
@@ -1,4 +1,4 @@
address@hidden UPDATED 14 May 2005
address@hidden UPDATED-MONTH May 2005
address@hidden UPDATED 22 September 2005
address@hidden UPDATED-MONTH September 2005
 @set EDITION 4.8
 @set VERSION 4.8
Index: doc/version.texi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/doc/version.texi,v
retrieving revision 1.32
diff -u -u -r1.32 version.texi
--- doc/version.texi 19 Sep 2005 12:50:55 -0000 1.32
+++ doc/version.texi 29 Sep 2005 08:52:50 -0000
@@ -1,4 +1,4 @@
address@hidden UPDATED 5 July 2005
address@hidden UPDATED-MONTH July 2005
address@hidden UPDATED 26 September 2005
address@hidden UPDATED-MONTH September 2005
 @set EDITION 4.8
 @set VERSION 4.8
Index: util/Makefile.am
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/Makefile.am,v
retrieving revision 1.16
diff -u -u -r1.16 Makefile.am
--- util/Makefile.am 23 Sep 2005 00:05:45 -0000 1.16
+++ util/Makefile.am 29 Sep 2005 08:52:50 -0000
@@ -46,3 +46,21 @@
   prepinfo.awk tex3patch texi-docstring-magic.el texi2dvi texi2pdf txitextest \
   $(dist_pkgdata_DATA) texinfo-cat.in
 CLEANFILES = $(pkgdata_DATA)
+
+
+## ------- ##
+## Tests.  ##
+## ------- ##
+
+XFAIL_TESTS =
+
+TESTS =        \
+local.test texi2dvi.test
+
+EXTRA_DIST += $(TESTS)
+
+# Each test case depends on defs.
+check_SCRIPTS = defs
+
+distclean-local:
+       -rm -rf testSubDir
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.62
diff -u -u -r1.62 texi2dvi
--- util/texi2dvi 23 Sep 2005 00:05:45 -0000 1.62
+++ util/texi2dvi 29 Sep 2005 08:52:50 -0000
@@ -147,7 +147,6 @@
 recode=false
 set_language=
 textra=         # Extra TeX commands to insert in the input file.
-textra_cmd=     # sed command to insert TEXTRA where appropriate
 txincludes=     # TEXINPUTS extensions, with trailing colon
 txiprereq=19990129 # minimum texinfo.tex version with macro expansion
 verb=false      # true for verbose mode
@@ -174,6 +173,22 @@
 ## Auxiliary functions.  ##
 ## --------------------- ##
 
+
+# In case `local' is not supported by the shell.
+(
+  foo=bar
+  test_local () {
+    local foo=foo
+  }
+  test_local
+  test $foo = bar
+) || local () {
+  case $1 in
+    *=*) eval "$1";;
+  esac
+}
+
+
 # func_dirname FILE
 # -----------------
 # Return the directory part of FILE.
@@ -183,13 +198,12 @@
   || { echo "$1" | sed 's!/[^/]*$!!;s!^$!.!'; }
 }
 
-# return true if program $1 is somewhere in PATH, else false.
-#
+# findprog PROG
+# -------------
+# Return true if PROG is somewhere in PATH, else false.
 findprog ()
 {
-  foundprog=false
-
-  saveIFS=$IFS
+  local saveIFS=$IFS
   IFS=$path_sep  # break path components at the path separator
   for dir in $PATH; do
     IFS=$saveIFS
@@ -204,11 +218,10 @@
     #
     if  { test -f "$dir/$1"    && test -x "$dir/$1"; } ||
        { test -f "$dir/$1.exe" && test -x "$dir/$1.exe"; }; then
-      foundprog=true
-      break
+      return 0
     fi
   done
-  $foundprog
+  return 1
 }
 
 # report LINE1 LINE2...
@@ -266,36 +279,6 @@
 done
 
 
-# get_xref_files FILENAME-NOEXT
-# -----------------------------
-# Compute the list of xref files (indexes, tables and lists).
-get_xref_files ()
-{
-  if $tidy; then
-    # In a tidy build, all the files around as actual outputs.
-    ls * 2>/dev/null
-  else
-    # Find all files having root filename with a two-letter extension,
-    # saves the ones that are really Texinfo-related files.
-    # - .?o?
-    #   .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
-    # - bu[0-9]*.aux
-    #   Sub bibliography when using the LaTeX bibunits package.
-    ls "$1".?o? "$1".aux bu[0-9]*.aux "$1".?? "$1".idx 2>/dev/null
-  fi |
-  while read file; do
-    # 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 or at, as long as the first line isn't
-    # \input texinfo.
-    case `sed '1q' $file` in
-      "\\input texinfo"*) ;;
-      [\\''@]*) echo "./$file";;
-    esac
-  done
-}
-
-
 # get_index_files FILE1 FILE2...
 # ------------------------------
 # Select the files that are indexes to run texindex/makeindex onto.
@@ -319,29 +302,29 @@
 # Hopefully no one will have an actual directory named EMPTY.
 absolute_filenames ()
 {
-  replace_empty="-e 's/^$path_sep/EMPTY$path_sep/g' \
-                 -e 's/$path_sep\$/${path_sep}EMPTY/g' \
-                 -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
-  _res=`echo "$1" | eval sed $replace_empty`
+  local replace_empty="-e 's/^$path_sep/EMPTY$path_sep/g' \
+                       -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+                       -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+  local res=`echo "$1" | eval sed $replace_empty`
   save_IFS=$IFS
   IFS=$path_sep
-  set x $_res; shift
-  _res=.
+  set x $res; shift
+  res=.
   for dir
   do
     case $dir in
       EMPTY)
-        _res=$_res$path_sep
+        res=$res$path_sep
         ;;
       [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expanded.
-        test -d $dir && _res=$_res$path_sep$dir
+        test -d $dir && res=$res$path_sep$dir
         ;;
       *)
-        test -d $dir && abs=`cd "$dir" && pwd` && _res=$_res$path_sep$abs
+        test -d $dir && abs=`cd "$dir" && pwd` && res=$res$path_sep$abs
         ;;
     esac
   done
-  echo "$_res"
+  echo "$res"
 }
 
 # move_to_dest FILE
@@ -351,26 +334,111 @@
 # file with the same base name.
 move_to_dest ()
 {
-  _file_noext=`echo "$1" | sed 's/\.[^.]*$//'`
-  _file_ext=`echo "$1" | sed 's/^.*\.//'`
-  _out_noext=`echo "$oname" | sed 's/\.[^.]*$//'`
-  _out_ext=`echo "$oname" | sed 's/^.*\.//'`
+  local file_noext=`echo "$1" | sed 's/\.[^.]*$//'`
+  local file_ext=`echo "$1" | sed 's/^.*\.//'`
+  local out_noext=`echo "$oname" | sed 's/\.[^.]*$//'`
+  local out_ext=`echo "$oname" | sed 's/^.*\.//'`
+  local dest
 
   case $tidy:$oname in
-    true:)  _dest=$orig_pwd;;
-    false:) _dest=;;
-    *:*)    _dest=$_out_noext.$_file_ext;;
+    true:)  dest=$orig_pwd;;
+    false:) dest=;;
+    *:*)    dest=$out_noext.$file_ext;;
   esac
   if test ! -f "$1"; then
     fatal 1 "no such file or directory: $1"
   fi
-  if test -n "$_dest"; then
-    verbose "Copying $1 to $_dest"
-    cp -p "$1" "$_dest"
+  if test -n "$dest"; then
+    verbose "Copying $1 to $dest"
+    cp -p "$1" "$dest"
+  fi
+}
+
+
+## --------------------- ##
+## Managing xref files.  ##
+## --------------------- ##
+
+
+# xref_files_get FILENAME-NOEXT
+# -----------------------------
+# Compute the list of xref files (indexes, tables and lists).
+xref_files_get ()
+{
+  if $tidy; then
+    # In a tidy build, all the files around as actual outputs.
+    ls * 2>/dev/null
+  else
+    # Find all files having root filename with a two-letter extension,
+    # saves the ones that are really Texinfo-related files.
+    # - .?o?
+    #   .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
+    # - bu[0-9]*.aux
+    #   Sub bibliography when using the LaTeX bibunits package.
+    ls "$1".?o? "$1".aux bu[0-9]*.aux "$1".?? "$1".idx 2>/dev/null
+  fi |
+  while read file; do
+    # 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 or at, as long as the first line isn't
+    # \input texinfo.
+    case `sed '1q' $file` in
+      "\\input texinfo"*) ;;
+      [\\''@]*) echo "./$file";;
+    esac
+  done
+}
+
+# xref_files_save
+# ---------------
+# Save the xref files.
+xref_files_save ()
+{
+  # Save copies of auxiliary files for later comparison.
+  xref_files_orig=`xref_files_get  "$filename_noext"`
+  if test -n "$xref_files_orig"; then
+    verbose "Backing up xref files: $xref_files_orig"
+    cp $xref_files_orig "$work_bak"
   fi
 }
 
 
+# xref_files_changed
+# ------------------
+# Whether the xref files were changed since the previous run.
+xref_files_changed ()
+{
+  # LaTeX (and the package changebar) report in the LOG file if it
+  # should be rerun.  This is needed for files included from
+  # subdirs, since texi2dvi does not try to compare xref files in
+  # subdirs.  Performing xref files test is still good since LaTeX
+  # does not report changes in xref files.
+  grep "Rerun to get" "$filename_noext.log" >&6 2>&1 &&
+    return 0
+
+  # If old and new lists don't at least have the same file list,
+  # then one file or another has definitely changed.
+  xref_files_new=`xref_files_get  "$filename_noext"`
+  verbose "Original xref files = $xref_files_orig"
+  verbose "New xref files      = $xref_files_new"
+  test "x$xref_files_orig" != "x$xref_files_new" &&
+    return 0
+
+  # Compare each file until we find a difference.
+  for this_file in $xref_files_new; do
+    verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
+    # cmp -s returns nonzero exit status if files differ.
+    if cmp -s "$this_file" "$work_bak/$this_file"; then :; else
+      verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
+      $debug && diff -u "$work_bak/$this_file" "$this_file"
+      return 0
+    fi
+  done
+
+  # No change.
+  return 1
+}
+
 ## ----------------------- ##
 ## Running the TeX suite.  ##
 ## ----------------------- ##
@@ -381,8 +449,8 @@
 run_tex ()
 {
   case $language:$oformat in
-    latex:pdf)   tex=${PDFLATEX:-pdflatex};;
     latex:dvi)   tex=${LATEX:-latex};;
+    latex:pdf)   tex=${PDFLATEX:-pdflatex};;
     texinfo:pdf) tex=$PDFTEX;;
     texinfo:dvi)
         # MetaPost also uses the TEX environment variable.  If the user
@@ -507,7 +575,7 @@
     latex)   texindex=${MAKEINDEX:-makeindex};;
     texinfo) texindex=${TEXINDEX:-texindex};;
   esac
-  index_files=`get_index_files $orig_xref_files`
+  index_files=`get_index_files $xref_files_orig`
   if test -n "$texindex" && test -n "$index_files"; then
     verbose "Running $texindex $index_files ..."
     $texindex $index_files 2>&5 1>&2 ||
@@ -536,6 +604,32 @@
 }
 
 
+# run_tex_suite
+# -------------
+# Run the TeX tools until a fix point is reached.
+run_tex_suite ()
+{
+  # Count the number of cycles.
+  cycle=0
+
+  while :; do
+    cycle=`expr $cycle + 1`
+    verbose "Cycle $cycle for $command_line_filename"
+
+    xref_files_save
+
+    run_bibtex
+    run_index
+    run_tex
+
+    xref_files_changed || break
+  done
+
+  # If we were using thumbpdf and producing PDF, then run thumbpdf
+  # and TeX one last time.
+  run_thumbpdf
+}
+
 ## -------------------------------- ##
 ## TeX processing auxiliary tools.  ##
 ## -------------------------------- ##
@@ -650,6 +744,12 @@
 # Used most commonly for @finalout, @smallbook, etc.
 insert_commands ()
 {
+  local textra_cmd
+  case language in
+    latex)   textra_cmd=1i;;
+    texinfo) textra_cmd='/address@hidden/a';;
+  esac
+
   if test -n "$textra"; then
     # _xtr.  The file with the user's extra commands.
     work_xtr=$workdir/xtr
@@ -691,6 +791,30 @@
   fi
 }
 
+# compute_language FILENAME
+# -------------------------
+# Return the short string describing the language in which FILENAME
+# is written: `texinfo' or `latex'.
+compute_language ()
+{
+  # If the user explicitly specified the language, use that.
+  # Otherwise, if the first line is \input texinfo, assume it's texinfo.
+  # Otherwise, guess from the file extension.
+  if test -n "$set_language"; then
+    echo $set_language
+  elif sed 1q "$1" | grep 'input texinfo' >&6; then
+    echo texinfo
+  else
+    # Get the type of the file (latex or texinfo) from the given language
+    # we just guessed, or from the file extension if not set yet.
+    case $1 in
+      *.ltx | *.tex | *.drv | *.dtx) echo latex;;
+      *)                             echo texinfo;;
+    esac
+  fi
+}
+
+
 ## ---------------------- ##
 ## Command line parsing.  ##
 ## ---------------------- ##
@@ -723,29 +847,29 @@
   case "$1" in
     -@ ) escape=@;;
     # Silently and without documentation accept -b and --b[atch] as synonyms.
-    -b | --b*) batch=true;;
-    -c | --c*) build_mode=clean;;
+    -b | --batch) batch=true;;
+    -c | --clean) build_mode=clean;;
          --build-dir)  shift; build_dir=$1; build_mode=tidy;;
-    -D | --d*) debug=true;;
-    -e | -E | --e*) expand=t;;
-    -h | --h*) echo "$usage"; exit 0;;
+    -D | --debug) debug=true;;
+    -e | -E | --expand) expand=t;;
+    -h | --help) echo "$usage"; exit 0;;
     -I | --I*)
       shift
       miincludes="$miincludes -I $1"
       txincludes="$txincludes$1$path_sep"
       ;;
-    -l | --l*) shift; set_language=$1;;
-    -o | --o*)
+    -l | --lang | --language) shift; set_language=$1;;
+    -o | --out  | --output)
       shift
       # Make it absolute, just in case we also have --clean, or whatever.
       case "$1" in
         /* | ?:/*) oname=$1;;
                 *) oname="$orig_pwd/$1";;
       esac;;
-    -p | --p*) oformat=pdf;;
-    -q | -s | --q* | --s*) quiet=true; batch=true;;
-    -r | --r*) recode=true;;
-    -t | --tex* | --com* ) shift; textra="$textra\\
+    -p | --pdf) oformat=pdf;;
+    -q | -s | --quiet | --silent) quiet=true; batch=true;;
+    -r | --recode) recode=true;;
+    -t | --texinfo | --command ) shift; textra="$textra\\
 "`echo "$1" | sed 's/\\\\/\\\\\\\\/g'`;;
     --tidy) build_mode=tidy;;
     -v | --vers*) echo "$version"; exit 0;;
@@ -889,7 +1013,6 @@
   # though the user may be able to reenter a valid filename at the tex
   # prompt (assuming they're attending the terminal), this script won't
   # be able to find the right xref files and so forth.
-  pwd
   if test ! -r "$command_line_filename"; then
     report "cannot read $command_line_filename, skipping."
     continue
@@ -967,33 +1090,8 @@
     eval verbose "$var=\'\$${var}\'"
   done
 
-  # If the user explicitly specified the language, use that.
-  # Otherwise, if the first line is \input texinfo, assume it's texinfo.
-  # Otherwise, guess from the file extension.
-  if test -n "$set_language"; then
-    language=$set_language
-  elif sed 1q "$command_line_filename" | grep 'input texinfo' >&6; then
-    language=texinfo
-  else
-    language=
-  fi
-
-  # Get the type of the file (latex or texinfo) from the given language
-  # we just guessed, or from the file extension if not set yet.
-  case ${language:-$filename_ext} in
-    [lL]a[tT]e[xX] | *.ltx | *.tex | *.drv | *.dtx)
-      # Assume a LaTeX file.  LaTeX needs bibtex and uses latex for
-      # compilation.  No makeinfo.
-      language=latex
-      textra_cmd=1i
-      ;;
-
-    *)
-      # Assume a Texinfo file.
-      language=texinfo
-      textra_cmd='/address@hidden/a'
-      ;;
-  esac
+  # `texinfo' or `latex'?
+  language=`compute_language $command_line_filename`
 
   # --expand
   run_makeinfo
@@ -1004,64 +1102,14 @@
   # --recode
   run_recode
 
-  # Count the number of cycles.
-  cycle=0
-
   # Move to the working directory.
   if $tidy; then
     verbose "cd $work_build"
     cd "$work_build" || exit 1
   fi
 
-  while :; do # will break out of loop below
-    cycle=`expr $cycle + 1`
-    verbose "Cycle $cycle for $command_line_filename"
-
-    # Save copies of auxiliary files for later comparison.
-    orig_xref_files=`get_xref_files  "$filename_noext"`
-    if test -n "$orig_xref_files"; then
-      verbose "Backing up xref files: $orig_xref_files"
-      cp $orig_xref_files "$work_bak"
-    fi
-
-    run_bibtex
-    run_index
-    run_tex
-
-    # LaTeX (and the package changebar) report in the LOG file if it
-    # should be rerun.  This is needed for files included from
-    # subdirs, since texi2dvi does not try to compare xref files in
-    # subdirs.  Performing xref files test is still good since LaTeX
-    # does not report changes in xref files.
-    grep "Rerun to get" "$filename_noext.log" >&6 2>&1 &&
-      continue
-
-    # If old and new lists don't at least have the same file list,
-    # then one file or another has definitely changed.
-    new_xref_files=`get_xref_files  "$filename_noext"`
-    verbose "Original xref files = $orig_xref_files"
-    verbose "New xref files      = $new_xref_files"
-    test "x$orig_xref_files" != "x$new_xref_files" &&
-      continue
-
-    # Compare each file until we find a difference.
-    for this_file in $new_xref_files; do
-      verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
-      # cmp -s returns nonzero exit status if files differ.
-      if cmp -s "$this_file" "$work_bak/$this_file"; then :; else
-        verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
-        $debug && diff -u "$work_bak/$this_file" "$this_file"
-        continue 2
-      fi
-    done
-
-    # We're done.
-    break
-  done # while :;
-
-  # If we were using thumbpdf and producing PDF, then run thumbpdf
-  # and TeX one last time.
-  run_thumbpdf
+  # Run until a fix point is reached.
+  run_tex_suite
 
   # Both to make sure we can remove $t2ddir (we might have cd'd into
   # it), and in case $orig_pwd is on a different drive (for DOS).

Attachment: texi2dvi.test
Description: Binary data

Attachment: local.test
Description: Binary data


reply via email to

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