[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: $dvipdf
From: |
Akim Demaille |
Subject: |
FYI: $dvipdf |
Date: |
Wed, 21 Jun 2006 10:18:49 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
Index: ChangeLog
from Akim Demaille <address@hidden>
* util/texi2dvi (fatal): Rename as...
(error): this.
If the exit status is 0, don't exit.
(run): New.
Use it where appropriate.
(run_dvipdf): New.
Use it.
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.84
diff -u -u -r1.84 texi2dvi
--- util/texi2dvi 19 Jun 2006 09:35:01 -0000 1.84
+++ util/texi2dvi 21 Jun 2006 08:17:55 -0000
@@ -251,7 +251,7 @@
if test -d "$rel"; then
(cd "$rel" 2>/dev/null && echo `pwd`/`basename "$1"`);
else
- fatal 1 "not a directory: $rel"
+ error 1 "not a directory: $rel"
fi
;;
esac
@@ -295,6 +295,8 @@
done
}
+# verbose WORD1 WORD2
+# -------------------
# Report some verbose information.
verbose ()
{
@@ -303,15 +305,28 @@
fi
}
-# fatal EXIT_STATUS LINE1 LINE2...
+# run COMMAND-LINE
+# ----------------
+# Run the COMMAND-LINE verbosely, and catching errors as failures.
+run ()
+{
+ verbose "Running $@"
+ "$@" 2>&5 1>&2 ||
+ error 1 "$1 failed"
+}
+
+
+# error EXIT_STATUS LINE1 LINE2...
# --------------------------------
-# Report an error and exit with failure.
-fatal ()
+# Report an error and exit with failure if EXIT_STATUS is non null.
+error ()
{
- s=$1
+ local s=$1
shift
report "$@"
- exit $s
+ if test "$s" != 0; then
+ exit $s
+ fi
}
# ensure_dir DIR1 DIR2...
@@ -323,7 +338,7 @@
do
test -d "$dir" \
|| mkdir "$dir" \
- || fatal 1 "cannot create directory: $dir"
+ || error 1 "cannot create directory: $dir"
done
}
@@ -409,7 +424,7 @@
dvi | ps | dvipdf ) echo dvi;;
pdf ) echo $out_lang;;
html | info | text ) echo $out_lang;;
- *) fatal "$0: invalid out_lang: $1";;
+ *) error "$0: invalid out_lang: $1";;
esac
}
@@ -422,7 +437,7 @@
case $out_lang in
dvipdf ) echo pdf;;
dvi | html | info | pdf | ps | text ) echo $out_lang;;
- *) fatal "$0: invalid out_lang: $1";;
+ *) error "$0: invalid out_lang: $1";;
esac
}
@@ -505,7 +520,7 @@
*:*) dest=$(output_base_name "$1");;
esac
if test ! -f "$1"; then
- fatal 1 "no such file or directory: $1"
+ error 1 "no such file or directory: $1"
fi
if test -n "$dest"; then
verbose "Copying $1 to $dest"
@@ -708,7 +723,7 @@
esac;;
texinfo:pdf) tex=$PDFTEX;;
- *) fatal 1 "$0: $out_lang not supported for $in_lang";;
+ *) error 1 "$0: $out_lang not supported for $in_lang";;
esac
# Beware of aux files in subdirectories that require the
@@ -783,7 +798,7 @@
dvi | pdf ) move_to_dest "$in_noext.$out_lang";;
esac
else
- fatal 1 "$tex exited with bad status, quitting."
+ error 1 "$tex exited with bad status, quitting."
fi
}
@@ -820,9 +835,7 @@
then
for f in $(generated_files_get "$in_noext" bibaux_file_p)
do
- verbose "Running $bibtex $f ..."
- $bibtex "$f" >&5 ||
- fatal 1 "$bibtex exited with bad status, quitting."
+ run $bibtex "$f"
done
fi
}
@@ -841,9 +854,7 @@
esac
index_files=`generated_files_get $in_noext index_file_p`
if test -n "$texindex" && test -n "$index_files"; then
- verbose "Running $texindex $index_files ..."
- $texindex $index_files 2>&5 1>&2 ||
- fatal 1 "$texindex exited with bad status, quitting."
+ run $texindex $index_files
fi
}
@@ -868,6 +879,29 @@
}
+# run_dvipdf FILE.dvi
+# -------------------
+# Convert FILE.dvi to FILE.pdf.
+run_dvipdf ()
+{
+ # Find which dvi->pdf program is available.
+ if test -z "$dvipdf"; then
+ for i in "$DVIPDF" dvipdfmx dvipdfm dvipdf dvi2pdf dvitopdf;
+ do
+ if findprog $i; then
+ dvipdf=$i
+ fi
+ done
+ fi
+ # These tools have varying interfaces, some 'input output', others
+ # 'input -o output'. They all seem to accept 'input' only,
+ # outputting using the expected file name.
+ run $dvipdf "$1"
+ if test ! -f $(echo "$1" | sed -e 's/\.dvi$/.pdf/'); then
+ error 1 "$0: cannot find output file"
+ fi
+}
+
# run_tex_suite ()
# ----------------
# Run the TeX tools until a fix point is reached.
@@ -900,7 +934,7 @@
# dvipdf or ps).
case $out_lang in
dvipdf)
- dvipdf "$in_noext.$(out_lang_tex)" "$in_noext.$(out_lang_ext)"
+ run_dvipdf "$in_noext.$(out_lang_tex)"
move_to_dest "$in_noext.$(out_lang_ext)"
;;
ps)
@@ -982,7 +1016,7 @@
if test $? != 0; then
cat $version_test_dir/txiversion.out
cat $version_test_dir/txiversion.err >&2
- fatal 1 "texinfo.tex appears to be broken, quitting."
+ error 1 "texinfo.tex appears to be broken, quitting."
fi
eval `sed -n 's/^.*\[\(.*\)version
\(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'
$version_test_dir/txiversion.out`
verbose "texinfo.tex preloaded as \`$txiformat', version is
\`$txiversion' ..."
@@ -1123,7 +1157,7 @@
case $1 in
html) ;;
text|info) run_hevea="$run_hevea -$1";;
- *) fatal "run_hevea: invalid argument: $1";;
+ *) error "run_hevea: invalid argument: $1";;
esac
# Compiling to the tmp directory enables to preserve a previous
@@ -1136,7 +1170,7 @@
verbose "running $run_hevea"
if eval "$run_hevea" >&5; then :; else
- fatal 1 "$hevea exited with bad status, quitting."
+ error 1 "$hevea exited with bad status, quitting."
fi
}
@@ -1158,7 +1192,7 @@
latex:html|latex:text|latex:info)
run_hevea $out_lang;;
*)
- fatal "invalid input/output combination: $in_lang/$out_lang";;
+ error "invalid input/output combination: $in_lang/$out_lang";;
esac
cd_orig
@@ -1321,7 +1355,7 @@
done
break;;
-*)
- fatal 1 "Unknown or ambiguous option \`$1'." \
+ error 1 "Unknown or ambiguous option \`$1'." \
"Try \`--help' for more information."
;;
*) set dummy ${1+"$@"} "$1"; shift;;
@@ -1337,18 +1371,18 @@
local) clean=false; tidy=false;;
tidy) clean=false; tidy=true;;
clean) clean=true; tidy=true;;
- *) fatal 1 "invalid build mode: $build_mode";;
+ *) error 1 "invalid build mode: $build_mode";;
esac
# Interpret remaining command line args as filenames.
case $# in
0)
- fatal 2 "Missing file arguments." "Try \`--help' for more information."
+ error 2 "Missing file arguments." "Try \`--help' for more information."
;;
1) ;;
*)
if test -n "$oname"; then
- fatal 2 "Can't use option \`--output' with more than one argument."
+ error 2 "Can't use option \`--output' with more than one argument."
fi
;;
esac
@@ -1463,7 +1497,7 @@
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right xref files and so forth.
test -r "$command_line_filename" ||
- fatal 1 "cannot read $command_line_filename, skipping."
+ error 1 "cannot read $command_line_filename, skipping."
# Get the name of the current directory.
in_dir=`func_dirname "$command_line_filename"`
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: $dvipdf,
Akim Demaille <=