bug-texinfo
[Top][All Lists]
Advanced

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

Making texi2dvi more robust to broken texinfo.tex


From: Akim Demaille
Subject: Making texi2dvi more robust to broken texinfo.tex
Date: Fri, 14 Nov 2003 13:34:24 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

My CVS Automake copy had its test suite hang.  It took me a while to
discover the problem was that I had conflicts in my texinfo.tex (with
<<<<< and >>>>>).  It caused texi2dvi to hang in its section computing
the version of texinfo.tex (tex was expecting interaction with me, but
nothing was displayed as everything is devnull'ed).

So I propose the following patch that makes it an error to fail to
compile a simple Texinfo file.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * util/texi2dvi (fatal): New function.
        Use it.
        (txiversion): Be robust to broken texinfo.tex.

Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.27
diff -u -u -r1.27 texi2dvi
--- util/texi2dvi 27 Oct 2003 00:12:15 -0000 1.27
+++ util/texi2dvi 14 Nov 2003 12:29:17 -0000
@@ -113,6 +113,15 @@
 # In case someone crazy insists on using grep -E.
 : ${EGREP=egrep}
 
+
+# fatal(MESSAGE...)
+# -----------------
+# Report an error and exit with failure.
+fatal () {
+  echo "$0: $@" >&2
+  exit 1
+}
+
 # Save TEXINPUTS so we can construct a new TEXINPUTS path for each file.
 # Unfortunately bibtex and makeindex do not read TEXINPUTS.
 tex_envvars="BIBINPUTS BSTINPUTS INDEXSTYLE TEXINPUTS"
@@ -251,7 +260,7 @@
 # comment @macro/@end macro so that makeinfo does propagate them.
 # Unfortunately makeinfo --iftex --no-ifinfo doesn't work well enough
 # (yet), makeinfo can't parse the TeX commands, so work around with sed.
-# 
+#
 comment_iftex_sed=$utildir/comment.sed
 cat <<EOF >$comment_iftex_sed
 /address@hidden/,/address@hidden tex/{
@@ -491,12 +500,19 @@
         # We don't need to use [0-9] to match the digits since anyway
         # the comparison with $txiprereq, a number, will fail with non
         # digits.
-        txiversion_tex=txiversion.tex
-        echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
         # Run in the tmpdir to avoid leaving files.
-        eval `cd $tmpdir >/dev/null &&
-              $tex $txiversion_tex 2>/dev/null |
-              sed -n 's/^.*\[\(.*\)version 
\(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
+       (
+           cd $tmpdir
+          echo '\input texinfo.tex @bye' >txiversion.tex
+          # Be sure that if tex wants to fail, it is not interactive:
+          # close stdin.
+           $tex txiversion.tex </dev/null
+       ) >$tmpdir/txiversion.out 2>$tmpdir/txiversion.err
+       if test $? != 0; then
+         cat $tmpdir/txiversion.out
+         cat $tmpdir/txiversion.err >&2
+         fatal "$0: texinfo.tex appears to be broken, quitting."
+        fi
         $verbose "texinfo.tex preloaded as \`$txiformat', version is 
\`$txiversion' ..."
         if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
           makeinfo=
@@ -593,10 +609,8 @@
           >&6 2>&1; \
     then
       $verbose "Running $bibtex $filename_noext ..."
-      if $bibtex "$filename_noext" >&5; then :; else
-        echo "$0: $bibtex exited with bad status, quitting." >&2
-        exit 1
-      fi
+      $bibtex "$filename_noext" >&5 ||
+        fatal "$bibtex exited with bad status, quitting."
     fi
 
     # What we'll run texindex on -- exclude non-index files.
@@ -617,10 +631,8 @@
     # nonexistent.
     if test -n "$texindex" && test -n "$index_files"; then
       $verbose "Running $texindex $index_files ..."
-      if $texindex $index_files 2>&5 1>&2; then :; else
-         echo "$0: $texindex exited with bad status, quitting." >&2
-         exit 1
-      fi
+      $texindex $index_files 2>&5 1>&2 ||
+         fatal "$texindex exited with bad status, quitting."
     fi
 
     # Finally, run TeX.
@@ -685,10 +697,9 @@
      && grep 'thumbpdf\.sty'  "$filename_noext.log" >&6 2>&1; \
   then
     $verbose "Running $thumbpdf $filename_noext ..."
-    if $thumbpdf "$filename_noext" >&5; then :; else
-      echo "$0: $thumbpdf exited with bad status, quitting." >&2
-      exit 1
-    fi
+    $thumbpdf "$filename_noext" >&5 ||
+      fatal "$thumbpdf exited with bad status, quitting."
+
     $verbose "Running $cmd ..."
     if $cmd >&5; then :; else
       echo "$0: $tex exited with bad status, quitting." >&2




reply via email to

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