bug-texinfo
[Top][All Lists]
Advanced

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

texi2dvi: Support bibunits


From: Akim Demaille
Subject: texi2dvi: Support bibunits
Date: Tue, 22 Feb 2005 13:39:00 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

Here is a set of suggested changes to texi2dvi.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * util/texi2dvi (uncomment_iftex_sed): Skip nonexistent
        directories.
        (fd6): Document and use more extensively.
        (get_xref_files): Accept bu[0-9]#.aux files from the bibunits
        package.
        Also adjust the bibtex invocation.

Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.44
diff -u -u -r1.44 texi2dvi
--- util/texi2dvi 19 Feb 2005 14:39:18 -0000 1.44
+++ util/texi2dvi 22 Feb 2005 12:37:44 -0000
@@ -141,7 +141,7 @@
     # for that.
     elif test -x "$dir/$1.exe"; then
       foundprog=true
-      break      
+      break
     fi
   done
   IFS=$saveIFS
@@ -348,16 +348,23 @@
 s/address@hidden texi2dvi//
 EOF
 
-# Compute the list of xref files.
+
+# get_xref_files FILENAME-NOEXT
+# -----------------------------
+# Get list of xref files (indexes, tables and lists).
 # Takes the filename (without extension) of which we look for xref
 # files as argument.  The index files must be reported last.
 get_xref_files ()
 {
-  # Get list of xref files (indexes, tables and lists).
   # Find all files having root filename with a two-letter extension,
-  # saves the ones that are really Texinfo-related files.  .?o? catches
-  # many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
-  for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
+  # saves the ones that are really Texinfo-related files.
+  # Use `ls' because some patterns are likely not to match.
+  # - .?o?
+  #   .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
+  # - bu[0-9]*.aux
+  #   Sub bibliography when using the LaTeX bibunits package.
+  for this_file in `(ls "$1".?o? "$1".aux bu[0-9]*.aux "$1".?? "$1".idx) 2>&6`
+  do
     # If file is empty, skip it.
     test -s "$this_file" || continue
     # If the file is not suitable to be an index or xref file, don't
@@ -366,7 +373,7 @@
     # \input texinfo.
     first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
     if (test "x$first_character" = "x\\" \
-        && sed 1q $this_file | grep -v '^\\input *texinfo' >/dev/null) \
+        && sed 1q $this_file | grep -v '^\\input *texinfo' >&6) \
        || test "x$first_character" = "x'" \
        || test "x$first_character" = "x@"; then
       xref_files="$xref_files ./$this_file"
@@ -398,10 +405,10 @@
         _res=$_res$path_sep
         ;;
       [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expanded.
-        _res=$_res$path_sep$dir
+        test -d $dir && _res=$_res$path_sep$dir
         ;;
       *)
-        abs=`cd "$dir" && pwd` && _res=$_res$path_sep$abs
+        test -d $dir && abs=`cd "$dir" && pwd` && _res=$_res$path_sep$abs
         ;;
     esac
   done
@@ -452,14 +459,23 @@
 # 5 tools output (turned off by --quiet)
 # 6 tracing/debugging (set -x output, etc.)
 
-# Tools' output.  If quiet, discard, else redirect to the message flow.
+
+# Main tools' output (TeX, etc.) that TeX users are used to see.
+#
+# If quiet, discard, else redirect to the message flow.
 if test "$quiet" = t; then
   exec 5>/dev/null
 else
   exec 5>&1
 fi
 
-# Enable tracing
+
+# Enable tracing, and auxiliary tools output.
+#
+# Should be used where you'd typically use /dev/null to throw output
+# away.  But sometimes it is convenient to see that output (e.g., from
+# a grep) to aid debugging.  Especially debugging at distance, via the
+# user.
 if test "$debug" = t; then
   exec 6>&1
   set -x
@@ -491,7 +507,7 @@
   # because in clean mode we are in tmp, in which case a relative
   # path has no meaning.
   filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
-  filename_dir=`cd "$filename_dir" >/dev/null && pwd`
+  filename_dir=`cd "$filename_dir" >&6 && pwd`
 
   # Strip directory part but leave extension.
   filename_ext=`basename "$command_line_filename"`
@@ -529,21 +545,14 @@
   # we've cd'd to a temp directory.
   common="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
   for var in $tex_envvars; do
-    eval ${var}="\$common\$${var}_orig"
-    export $var
+    eval val="\$common\$${var}_orig"
+    # Convert relative paths to absolute paths, so we can run in another
+    # directory (e.g., in --clean mode, or during the macro-support detection.)
+    val=`absolute_filenames "$val"`
+    eval export $var=$val
+    eval verbose "$var=\'\$${var}\'"
   done
 
-  # Convert relative paths to absolute paths, so we can run in another
-  # directory (e.g., in --clean mode, or during the macro-support detection.)
-  TEXINPUTS=`absolute_filenames "$TEXINPUTS"`
-  verbose "TEXINPUTS: $TEXINPUTS"
-  BIBINPUTS=`absolute_filenames "$BIBINPUTS"`
-  verbose "BIBINPUTS: $BIBINPUTS"
-  BSTINPUTS=`absolute_filenames "$BSTINPUTS"`
-  verbose "BSTINPUTS: $BSTINPUTS"
-  INDEXSTYLE=`absolute_filenames "$INDEXSTYLE"`
-  verbose "INDEXSTYLE: $INDEXSTYLE"
-
   # 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.
@@ -583,7 +592,7 @@
       if test $oformat = dvi; then
         # MetaPost also uses the TEX environment variable.  If the user
         # has set TEX=latex for that reason, don't bomb out.
-        if echo $TEX | grep 'latex$' >/dev/null; then
+        if echo $TEX | grep 'latex$' >&6; then
           tex=tex  # don't bother trying to find etex
         else
           tex=$TEX
@@ -616,7 +625,7 @@
         fi
        eval `sed -n 's/^.*\[\(.*\)version 
\(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' 
$tmpdir/txiversion.out`
         verbose "texinfo.tex preloaded as \`$txiformat', version is 
\`$txiversion' ..."
-        if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
+        if test "$txiprereq" -le "$txiversion" >&6 2>&1; then
           makeinfo=
         else
           makeinfo=${MAKEINFO:-makeinfo}
@@ -630,7 +639,7 @@
 
   # Go to $tmpdir to try --help, since old versions that don't accept
   # --help will generate a texput.log.
-  tex_help=`cd $tmpdir >/dev/null && $tex --help </dev/null 2>&1`
+  tex_help=`cd $tmpdir >&6 && $tex --help </dev/null 2>&1`
 
   # Expand macro commands in the original source file using Makeinfo.
   # Always use `end' footnote style, since the `separate' style
@@ -697,7 +706,6 @@
 
     # Run bibtex on current file.
     # - If its input (AUX) exists.
-    # - If AUX contains both `\bibdata' and `\bibstyle'.
     # - If some citations are missing (LOG contains `Citation').
     #   or the LOG complains of a missing .bbl
     #
@@ -705,24 +713,34 @@
     # to change after bibtex is run, but I see no reason for the
     # converse.
     #
-    # Don't try to be too smart.  Running bibtex only if the bbl file
-    # exists and is older than the LaTeX file is wrong, since the
-    # document might include files that have changed.  Because there
-    # can be several AUX (if there are \include's), but a single LOG,
-    # looking for missing citations in LOG is easier, though we take
-    # the risk to match false messages.
+    # Don't try to be too smart:
+    #
+    # 1. Running bibtex only if the bbl file exists and is older than
+    # the LaTeX file is wrong, since the document might include files
+    # that have changed.
+    #
+    # 3. Because there can be several AUX (if there are \include's),
+    # but a single LOG, looking for missing citations in LOG is
+    # easier, though we take the risk to match false messages.
     if test -n "$bibtex" \
        && test -r "$filename_noext.aux" \
        && test -r "$filename_noext.log" \
-       && (grep '^\\bibdata[{]'  "$filename_noext.aux" \
-           && grep '^\\bibstyle[{]' "$filename_noext.aux" \
-           && (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
-               || grep 'No file .*\.bbl\.' "$filename_noext.log")) \
+       && (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
+            || grep 'No file .*\.bbl\.' "$filename_noext.log") \
           >&6 2>&1; \
     then
-      verbose "Running $bibtex $filename_noext ..."
-      $bibtex "$filename_noext" >&5 ||
-        fatal 1 "$bibtex exited with bad status, quitting."
+      # If using the bibunits package, we might have to run bibtex
+      # on subfiles.
+      for f in `(ls "$filename_noext".aux bu[0-9]*.aux) 2>&6`
+      do
+       if (grep '^\\bibstyle[{]' $f   \
+           && grep '^\\bibdata[{]' $f \
+           && grep '^\\citation[{]' $f) >&6 2>&1; then
+          verbose "Running $bibtex $f ..."
+          $bibtex "$f" >&5 ||
+            fatal 1 "$bibtex exited with bad status, quitting."
+       fi
+      done
     fi
 
     # What we'll run texindex on -- exclude non-index files.

reply via email to

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