help-texinfo
[Top][All Lists]
Advanced

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

[help-texinfo] texi2dvi: Handling of list of directories


From: Akim Demaille
Subject: [help-texinfo] texi2dvi: Handling of list of directories
Date: Fri, 18 Nov 2005 14:00:52 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

I installed the following.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Factor the handling of list of directories.
        * util/texi2dvi (list_append, list_prefix, list_infix)
        (list_dir_to_abs, absolute): New.
        Use them.
        ($miincludes, $txincludes): Remove, replaced by...
        ($includes): this one.
        (func_dirname): Don't use fd6 that might not be set up yet.
        (run_to_html): Use $includes.

Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.66
diff -u -u -r1.66 texi2dvi
--- util/texi2dvi 11 Nov 2005 00:02:31 -0000 1.66
+++ util/texi2dvi 18 Nov 2005 12:58:45 -0000
@@ -140,14 +140,13 @@
 debug=false
 escape="\\"
 expand=         # t for expansion via makeinfo
-miincludes=     # makeinfo include path
+includes=
 out_lang=dvi
 oname=          # --output
 quiet=false     # by default let the tools' message be displayed
 recode=false
 set_language=
 textra=         # Extra TeX commands to insert in the input file.
-txincludes=     # TEXINPUTS extensions, with trailing colon
 txiprereq=19990129 # minimum texinfo.tex version with macro expansion
 verb=false      # true for verbose mode
 
@@ -194,10 +193,29 @@
 # Return the directory part of FILE.
 func_dirname ()
 {
-  dirname "$1" 2>&6 \
+  dirname "$1" 2>/dev/null \
   || { echo "$1" | sed 's!/[^/]*$!!;s!^$!.!'; }
 }
 
+
+# absolute NAME -> ABS-NAME
+# -------------------------
+# Return an absolute path to NAME.
+absolute ()
+{
+  case $1 in
+   [\\/]* | ?:[\\/]*)
+      # Absolute paths don't need to be expanded.
+      echo "$1"
+      ;;
+   *)
+      (cd "$orig_pwd/`func_dirname $1`" 2>/dev/null &&
+       echo `pwd`/`basename "$1"`)
+      ;;
+  esac
+}
+
+
 # findprog PROG
 # -------------
 # Return true if PROG is somewhere in PATH, else false.
@@ -266,6 +284,74 @@
 }
 
 
+## ---------------- ##
+## Handling lists.  ##
+## ---------------- ##
+
+
+# list_append LIST-NAME ELEM
+# --------------------------
+# Set LIST-NAME to its former contents, with ELEM appended.
+list_append ()
+{
+  local la_l="$1"
+  shift
+  eval set X \$$la_l "$@"
+  shift
+  eval $la_l=\""$@"\"
+}
+
+# list_prefix LIST-NAME SEP -> STRING
+# -----------------------------------
+# Return a string that is composed of the LIST-NAME with each item
+# preceded by SEP.
+list_prefix ()
+{
+  local lp_p=$2
+  eval set X \$$1
+  shift
+  local lp_res
+  for i
+  do
+    lp_res="$lp_res \"$lp_p\" \"$i\""
+  done
+  echo "$lp_res"
+}
+
+# list_infix LIST-NAME SEP -> STRING
+# ----------------------------------
+# Same as list_prefix, but a separator.
+list_infix ()
+{
+  eval set X \$$1
+  shift
+  local la_IFS=$IFS
+  IFS=$path_sep
+  echo "$*"
+  IFS=$la_IFS
+}
+
+# list_dir_to_abs LIST-NAME
+# -------------------------
+# Convert the list to using only absolute dir names.
+# Currently unused, but should replace absolute_filenames some day.
+list_dir_to_abs ()
+{
+  local ld_l=$1
+  eval set X \$$ld_l
+  shift
+  local ld_res
+  for dir
+  do
+    dir=`absolute "$dir"`
+    test -d "$dir" || continue
+    ld_res="$ld_res \"$dir\""
+  done
+  set X $ld_res; shift
+  eval $ld_l=\"address@hidden"
+  eval echo $ld_l=\$$ld_l
+}
+
 ## ------------------------- ##
 ## TeX auxiliary functions.  ##
 ## ------------------------- ##
@@ -292,7 +378,8 @@
   done
 }
 
-
+# absolute_filenames TEX-PATH -> TEX-PATH
+# ---------------------------------------
 # Convert relative paths to absolute paths, so we can run in another
 # directory (e.g., in tidy build mode, or during the macro-support
 # detection).
@@ -316,11 +403,8 @@
       EMPTY)
         res=$res$path_sep
         ;;
-      [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expanded.
-        test -d $dir && res=$res$path_sep$dir
-        ;;
       *)
-        test -d $dir && abs=`cd "$dir" && pwd` && res=$res$path_sep$abs
+        test -d $dir && res=$res$path_sep`absolute "$dir"`
         ;;
     esac
   done
@@ -750,7 +834,7 @@
       work_src=$workdir/src
       ensure_dir "$work_src"
       in_src=$work_src/$in_base
-
+      local $miincludes=`list_prefix includes -I`
       verbose "Macro-expanding $command_line_filename to $in_src ..."
       sed "$comment_iftex" "$command_line_filename" \
         | $makeinfo --footnote-style=end -I "$in_dir" $miincludes \
@@ -856,9 +940,11 @@
   # successful compilation.  Unfortunately it makes it hard to move
   # the image back to the destination directory.  So compile to the
   # actual destination.
-  local to_html="$hevea -fix -noiso -O -o '$out_name' '$in_input'"
+  local to_html="$hevea -fix -noiso -O -o '$out_name'"
+  to_html="$to_html `list_prefix includes -I`"
+  to_html="$to_html '$in_input'"
 
-  verbose "running $cmd"
+  verbose "running $to_html"
   if eval "$to_html" >&5; then :; else
     fatal 1 "$hevea exited with bad status, quitting."
   fi
@@ -932,17 +1018,15 @@
          --html) out_lang=html;;
     -I | --I*)
       shift
-      miincludes="$miincludes -I $1"
-      txincludes="$txincludes$1$path_sep"
+      # Use absolute dir names in the includes.
+      val=`absolute "$1"`
+      list_append includes "$val"
       ;;
     -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;;
+      oname=`absolute "$1"`;;
     -p | --pdf) out_lang=pdf;;
     -q | -s | --quiet | --silent) quiet=true; batch=true;;
     -r | --recode) recode=true;;
@@ -1105,7 +1189,7 @@
 
   # Get the name of the current directory.
   in_dir=`func_dirname "$command_line_filename"`
-  in_dir_abs=`cd "$in_dir" >&6 && pwd`
+  in_dir_abs=`absolute "$in_dir"`
   # In a clean build, we `cd', so get an absolute file name.
   $tidy && in_dir=$in_dir_abs
 
@@ -1126,7 +1210,7 @@
     out_name=$in_noext.$out_lang
   fi
   out_dir=`func_dirname "$out_name"`
-  out_dir_abs=`cd $out_dir && pwd`
+  out_dir_abs=`absolute "$out_dir"`
   out_base=`basename "$out_name"`
   out_noext=`echo "$out_base" | sed 's/\.[^.]*$//'`
 }
@@ -1156,7 +1240,7 @@
   ensure_dir "$build_dir" "$t2ddir"
 
   # We will change directory, better work with an absolute path...
-  t2ddir=`cd "$t2ddir" && pwd`
+  t2ddir=`absolute "$t2ddir"`
   # 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.
@@ -1184,7 +1268,8 @@
   # etc. files in ${directory} don't get used in preference to fresher
   # files in `.'.  Include orig_pwd in case we are in clean build mode, where
   # we've cd'd to a temp directory.
-  common="$orig_pwd$path_sep$in_dir$path_sep$txincludes"
+  txincludes=`list_infix includes $path_sep`
+  common="$orig_pwd$path_sep$in_dir$path_sep$txincludes$path_sep"
   for var in $tex_envvars; do
     eval val="\$common\$${var}_orig"
     # Convert relative paths to absolute paths, so we can run in another





reply via email to

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