bug-texinfo
[Top][All Lists]
Advanced

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

texi2dvi: --dvipdf and --ps


From: Akim Demaille
Subject: texi2dvi: --dvipdf and --ps
Date: Mon, 19 Jun 2006 11:35:54 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

pstricks is alive and kicking.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Support dvips and dvipdf for sake of pstricks, and to
        spare the use tweaking TEXINPUTS.
        * util/defs.in (optionset_get, assert_and_remove_files): New.
        * util/texi2dvi (out_lang_tex, out_lang_ext): New.
        Use them.
        ($language): Rename as...
        ($in_lang): this for consistency.
        Support --dvipdf and --ps.
        Not documented yet.
        * util/dvipdf.test: New.
        * util/Makefile.am (TESTS): Adjust.
        * util/texi2dvi.tests (one_run): New.

Index: util/Makefile.am
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/Makefile.am,v
retrieving revision 1.22
diff -u -u -r1.22 Makefile.am
--- util/Makefile.am 18 Jun 2006 23:39:43 -0000 1.22
+++ util/Makefile.am 19 Jun 2006 09:34:55 -0000
@@ -59,6 +59,7 @@
 
 TESTS =        \
 bibtex.test \
+dvipdf.test \
 latex2html.test \
 local.test \
 texi2dvi.test
Index: util/defs.in
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/defs.in,v
retrieving revision 1.4
diff -u -u -r1.4 defs.in
--- util/defs.in 30 May 2006 15:02:33 -0000 1.4
+++ util/defs.in 19 Jun 2006 09:34:55 -0000
@@ -226,6 +226,30 @@
 }
 
 
+# optionset_get N OPTIONSET<1> -- OPTIONSET<2> -- ...
+# ---------------------------------------------------
+# Return OPTIONSET<N>
+optionset_get ()
+{
+  n=$1
+  shift
+  # Find the optionset.
+  while test $n != 1; do
+    case $1 in
+      --) n=$(expr $n - 1);;
+    esac
+    shift
+  done
+  # Return the optionset.
+  while true; do
+    case $#:$1 in
+      0:) break;;
+    *:--) shift; break;;
+       *) echo "$1"; shift;;
+    esac
+  done
+}
+
 # list_files ()
 # -------------
 # Return the sorted list of files in this directory, except the "invisible" 
ones.
@@ -254,6 +278,17 @@
   diff -u ls.expected ls.value
 }
 
+
+# assert_and_remove_files (EXPECTED-FILES)
+# ----------------------------------------
+# Only those files are valid in the current directory.  Remove them
+# afterwards.
+assert_and_remove_files ()
+{
+  assert_files "$@"
+  rm -rf "$@"
+}
+
 # Turn on shell traces when VERBOSE is set.
 if test -n "$VERBOSE"; then
   set -x
Index: util/dvipdf.test
===================================================================
RCS file: util/dvipdf.test
diff -N util/dvipdf.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ util/dvipdf.test 19 Jun 2006 09:34:55 -0000
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2006  Free Software Foundation, Inc.
+#
+# This file is part of GNU Texinfo.
+#
+# GNU Texinfo is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Texinfo is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Texinfo; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+. ./defs || exit 1
+
+set -e
+
+# one_run ARGS -- FILES
+# ---------------------
+# Run texi2dvi with ARGS, expect the FILES to be left.  Remove them.
+one_run ()
+{
+  # Use pstricks.
+  cat >input.tex <<EOF
+\documentclass[a4paper]{article}
+\usepackage{pst-node}
+\pagestyle{empty}
+\begin{document}
+\begin{psmatrix}
+  A & B & C & D & E & F
+\end{psmatrix}
+\psset{arrows=->}
+\nccircle{1,1}{0.5}
+\nccircle[angleA=30]{1,2}{0.4}
+\nccircle[arrows=-,nodesep=0.05]{1,3}{0.2}
+\ncloop[angleB=180]{1,4}{1,4}
+\ncloop[angleB=180,linearc=0.35,nodesep=0.1]{1,5}{1,5}
+\ncloop[angleB=180,linearc=0.15,loopsize=0.4]{1,6}{1,6}
+
+\vspace{1cm}
+\begin{psmatrix}
+  A & B & C & D
+\end{psmatrix}
+\psset{arrows=->,nodesep=0.05}
+\ncangles[armA=0.8,armB=0,angleA=70,angleB=110,linearc=0.22]{1,1}{1,1}
+\ncdiag[arm=0.9,angleA=70,angleB=110,linearc=0.3]{1,2}{1,2}
+\ncdiag[arm=0.8,angleA=50,angleB=130,linearc=0.25]{1,3}{1,3}
+\ncdiag[arm=0.8,angleA=50,angleB=130,linearc=0.28]{1,4}{1,4}
+\end{document}
+EOF
+
+  TEXI2DVI_pass $(optionset_get 1 "$@") input.tex
+  # There should only be the expected and input files.
+  assert_and_remove_files $(optionset_get 2 "$@") input.tex
+}
+
+one_run --dvipdf --batch --clean \
+   -- \
+   input.pdf
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.83
diff -u -u -r1.83 texi2dvi
--- util/texi2dvi 3 Jun 2006 20:31:29 -0000 1.83
+++ util/texi2dvi 19 Jun 2006 09:34:55 -0000
@@ -395,6 +395,38 @@
   eval $ld_l=\"address@hidden"
 }
 
+
+## ------------------------------ ##
+## Language auxiliary functions.  ##
+## ------------------------------ ##
+
+# out_lang_tex
+# ------------
+# Return the tex output language (DVI or PDF) for $OUT_LANG.
+out_lang_tex ()
+{
+  case $out_lang in
+    dvi | ps | dvipdf ) echo dvi;;
+    pdf ) echo $out_lang;;
+    html | info | text ) echo $out_lang;;
+    *)    fatal "$0: invalid out_lang: $1";;
+  esac
+}
+
+
+# out_lang_ext
+# ------------
+# Return the extension for $OUT_LANG.
+out_lang_ext ()
+{
+  case $out_lang in
+    dvipdf ) echo pdf;;
+    dvi | html | info | pdf | ps | text ) echo $out_lang;;
+    *)    fatal "$0: invalid out_lang: $1";;
+  esac
+}
+
+
 ## ------------------------- ##
 ## TeX auxiliary functions.  ##
 ## ------------------------- ##
@@ -568,7 +600,7 @@
   # Depending on these files, infer outputs from other tools.
   while read file; do
     echo $file
-    case $language in
+    case $in_lang in
       (texinfo)
         # texindex: texinfo.cp -> texinfo.cps
        if index_file_p $file; then
@@ -657,12 +689,14 @@
 ## Running the TeX suite.  ##
 ## ----------------------- ##
 
+
+
 # run_tex ()
 # ----------
 # Run TeX as "$tex $in_input", taking care of errors and logs.
 run_tex ()
 {
-  case $language:$out_lang in
+  case $in_lang:$(out_lang_tex) in
     latex:dvi)   tex=${LATEX:-latex};;
     latex:pdf)   tex=${PDFLATEX:-pdflatex};;
     texinfo:dvi)
@@ -674,12 +708,12 @@
         esac;;
     texinfo:pdf) tex=$PDFTEX;;
 
-    *) fatal 1 "$out_lang not supported for $language";;
+    *) fatal 1 "$0: $out_lang not supported for $in_lang";;
   esac
 
   # Beware of aux files in subdirectories that require the
   # subdirectory to exist.
-  case $language:$tidy in
+  case $in_lang:$tidy in
     latex:true)
        sed -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
        sort -u |
@@ -745,7 +779,9 @@
 
   echo "$0: Running $cmd ..."
   if eval "$cmd" >&5; then
-    move_to_dest "$in_noext.$out_lang"
+    case $out_lang in
+      dvi | pdf ) move_to_dest "$in_noext.$out_lang";;
+    esac
   else
     fatal 1 "$tex exited with bad status, quitting."
   fi
@@ -769,7 +805,7 @@
 # easier, though we take the risk to match false messages.
 run_bibtex ()
 {
-  case $language in
+  case $in_lang in
     latex)   bibtex=${BIBTEX:-bibtex};;
     texinfo) return;;
   esac
@@ -799,7 +835,7 @@
 # that if the index files are out of date or nonexistent.
 run_index ()
 {
-  case $language in
+  case $in_lang in
     latex)   texindex=${MAKEINDEX:-makeindex};;
     texinfo) texindex=${TEXINDEX:-texindex};;
   esac
@@ -816,7 +852,7 @@
 # ---------------
 run_thumbpdf ()
 {
-  if test $out_lang = pdf \
+  if test $(out_lang_tex) = pdf \
      && test -r "$in_noext.log" \
      && grep 'thumbpdf\.sty'  "$in_noext.log" >&6 2>&1; \
   then
@@ -859,6 +895,19 @@
   # If we were using thumbpdf and producing PDF, then run thumbpdf
   # and TeX one last time.
   run_thumbpdf
+
+  # Install the result if we didn't already (i.e., if the output is
+  # dvipdf or ps).
+  case $out_lang in
+    dvipdf)
+      dvipdf "$in_noext.$(out_lang_tex)" "$in_noext.$(out_lang_ext)"
+      move_to_dest "$in_noext.$(out_lang_ext)"
+      ;;
+    ps)
+      dvips -o "$in_noext.$(out_lang_ext)" "$in_noext.$(out_lang_tex)"
+      move_to_dest "$in_noext.$(out_lang_ext)"
+      ;;
+  esac
 }
 
 ## -------------------------------- ##
@@ -908,7 +957,7 @@
 # main info output, the user asked to run TeX, not makeinfo.
 run_makeinfo ()
 {
-  case $language in
+  case $in_lang in
   texinfo)
     # Unless required by the user, makeinfo expansion is wanted only
     # if texinfo.tex is too old.
@@ -982,10 +1031,10 @@
 insert_commands ()
 {
   local textra_cmd
-  case $language in
+  case $in_lang in
     latex)   textra_cmd=1i;;
     texinfo) textra_cmd='/address@hidden/a';;
-    *)       echo "$0: internal error, unknown language: $language" >&2;
+    *)       echo "$0: internal error, unknown language: $in_lang" >&2;
   esac
 
   if test -n "$textra"; then
@@ -1009,7 +1058,7 @@
   local from
   local to
 
-  if test $language = texinfo; then
+  if test $in_lang = texinfo; then
     pgm='s/^ address@hidden  *\([^ ][^ ]*\) *$/\1/
        t found
        d
@@ -1103,13 +1152,13 @@
     cd "$work_build" || exit 1
   fi
 
-  case $language:$out_lang in
+  case $in_lang:$(out_lang_tex) in
     *:dvi|*:pdf)
        run_tex_suite;;
     latex:html|latex:text|latex:info)
        run_hevea $out_lang;;
     *)
-       fatal "invalid input/output combination: $language/$out_lang";;
+       fatal "invalid input/output combination: $in_lang/$out_lang";;
   esac
 
   cd_orig
@@ -1233,6 +1282,7 @@
     -c | --clean) build_mode=clean;;
     -D | --debug) debug=true;;
          --dvi)   out_lang=dvi;;
+         --dvipdf)   out_lang=dvipdf;;
     -e | -E | --expand) expand=t;;
     -h | --help) echo "$usage"; exit 0;;
          --html) out_lang=html;;
@@ -1251,6 +1301,7 @@
       # Make it absolute, just in case we also have --clean, or whatever.
       oname=`absolute "$1"`;;
     -p | --pdf) out_lang=pdf;;
+         --ps)  out_lang=ps;;
     -q | -s | --quiet | --silent) quiet=true; batch=true;;
     -r | --recode) recode=true;;
     --recode-from) shift; recode=true; recode_from="$1";;
@@ -1436,7 +1487,7 @@
   if test x"$oname" != x; then
     out_name=$oname
   else
-    out_name=$in_noext.$out_lang
+    out_name=$in_noext.$(out_lang_ext)
   fi
   out_dir=`func_dirname "$out_name"`
   out_dir_abs=`absolute "$out_dir"`
@@ -1455,7 +1506,7 @@
   input_file_name_decode
 
   # `texinfo' or `latex'?
-  language=`compute_language $command_line_filename`
+  in_lang=`compute_language $command_line_filename`
 
   # An auxiliary directory used for all the auxiliary tasks involved
   # in compiling this document.
@@ -1478,7 +1529,7 @@
   # Sometimes there are incompatibilities between auxiliary files for
   # DVI and PDF.  The contents can also change whether we work on PDF
   # and/or DVI.  So keep separate spaces for each.
-  workdir=$t2ddir/$out_lang
+  workdir=$t2ddir/$(out_lang_tex)
   ensure_dir "$workdir"
 
   # _build.  In a tidy build, where the auxiliary files are output.
Index: util/texi2dvi.test
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi.test,v
retrieving revision 1.10
diff -u -u -r1.10 texi2dvi.test
--- util/texi2dvi.test 30 May 2006 14:44:04 -0000 1.10
+++ util/texi2dvi.test 19 Jun 2006 09:34:55 -0000
@@ -22,45 +22,58 @@
 
 set -e
 
-create_input_texi </dev/null
+# one_run ARGS -- FILES
+# ---------------------
+# Run texi2dvi with ARGS, expect the FILES to be left.  Remove them.
+one_run ()
+{
+  # Testing the local build mode.
+  create_input_texi </dev/null
+  TEXI2DVI_pass $(optionset_get 1 "$@") input.texi
+  # There should only be the expected FILES and the input file.
+  assert_and_remove_files $(optionset_get 2 "$@") input.texi
+}
+
+one_run --batch \
+   -- \
+   input.aux input.cp input.dvi input.fn input.ky input.log \
+   input.pg input.tp input.vr
+
+
+one_run --batch -o output.dvi \
+   -- \
+   input.aux input.cp input.dvi input.fn input.ky input.log \
+   input.pg input.tp input.vr output.dvi
 
-# Testing the local build mode.
-TEXI2DVI_pass --batch input.texi
-# There should only be the DVI and the TEXI file.
-assert_files input.aux input.cp input.dvi input.fn input.ky input.log input.pg 
input.texi input.tp input.vr
-rm input.aux input.cp input.dvi input.fn input.ky input.log input.pg input.tp 
input.vr
-
-TEXI2DVI_pass --batch input.texi -o output.dvi
-# There should only be the DVI and the TEXI file.
-assert_files input.aux input.cp input.dvi input.fn input.ky input.log input.pg 
input.texi input.tp input.vr output.dvi
-rm input.aux input.cp input.dvi input.fn input.ky input.log input.pg input.tp 
input.vr output.dvi
 
 # Testing the clean build mode.
 for mode in --clean --build=clean
 do
-  TEXI2DVI_pass $mode --batch input.texi
   # There should only be the DVI and the TEXI file.
-  assert_files input.dvi input.texi
-  rm input.dvi
+  one_run $mode --batch -- input.dvi
 
-  TEXI2DVI_pass $mode --batch input.texi -o output.dvi
   # There should only be the DVI and the TEXI file.
-  assert_files input.texi output.dvi
-  rm output.dvi
+  one_run $mode --batch -o output.dvi -- output.dvi
 done
 
 
 # Testing the tidy build mode.
-TEXI2DVI_pass --build=tidy --batch input.texi -o output.dvi
-# There should only be the DVI and the TEXI file.
-assert_files input.texi output.dvi output.t2d
-TEXI2DVI_pass --build=tidy --batch input.texi -o output.dvi --mostly-clean
-assert_files input.texi output.dvi
-rm output.dvi
+one_run --build=tidy --batch -o output.dvi \
+   -- \
+   output.dvi output.t2d
+
+
+# mostly-clean should remove auxiliary files, but not the expected
+# output.
+touch output.dvi
+one_run --build=tidy --batch -o output.dvi --mostly-clean \
+   -- \
+   output.dvi
 
-cp input.texi input2.texi
 
-TEXI2DVI_pass --clean --batch input.texi input2.texi
 # There should only be the DVI and the TEXI file.
-assert_files input2.dvi input2.texi input.dvi input.texi
-rm input.dvi input2.dvi
+create_input_texi </dev/null
+cp input.texi input2.texi
+one_run --clean --batch input.texi input2.texi \
+   -- \
+   input2.dvi input2.texi input.dvi





reply via email to

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