texinfo-commits
[Top][All Lists]
Advanced

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

[7144] texi2dvi reduce use of absolute paths


From: Gavin D. Smith
Subject: [7144] texi2dvi reduce use of absolute paths
Date: Tue, 03 May 2016 18:14:50 +0000

Revision: 7144
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7144
Author:   gavin
Date:     2016-05-03 18:14:49 +0000 (Tue, 03 May 2016)
Log Message:
-----------
texi2dvi reduce use of absolute paths

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/util/texi2dvi

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-05-01 11:31:22 UTC (rev 7143)
+++ trunk/ChangeLog     2016-05-03 18:14:49 UTC (rev 7144)
@@ -1,3 +1,30 @@
+2016-05-03  Gavin Smith  <address@hidden>
+
+       * util/texi2dvi (cd_dir): New function, to change directory
+       while updating variables containing paths.
+       (cd_orig): Reverse the changes to these variables made in cd_dir.
+
+       (run_tex_suite, make_openout_test): Use 'cd_dir' instead of 
+       'cd'.
+
+       (input_file_name_decode, main program loop): Don't change 
+       variables t2ddir, in_dir to be absolute.  This could cause 
+       problems passing filenames to TeX if the absolute path to the 
+       input file contained a space or another unusual character.  
+       (Problem found following report by Stephen Dawson.)
+
+       (run_tex) [--tidy]: Remove code that uses a symbolic link to the 
+       file being processed.  This meant that --command didn't work 
+       along with --tidy due to the path to the file with the inserted 
+       commands being overridden.  It is less necessary when absolute 
+       paths aren't used.  (Problem found following report by
+       Guo Yixuan).
+
+       (cleanup): Refer to 'clean' and 'tidy' variables instead of 
+       'build_mode'.  (No functional change.)
+       (compile): Change a comment.
+
+
 2016-05-01  Gavin Smith  <address@hidden>
 
        * util/texi2dvi (usage): Streamline help message.  Don't mention 

Modified: trunk/util/texi2dvi
===================================================================
--- trunk/util/texi2dvi 2016-05-01 11:31:22 UTC (rev 7143)
+++ trunk/util/texi2dvi 2016-05-03 18:14:49 UTC (rev 7144)
@@ -233,6 +233,37 @@
 
 #  Generic auxiliary functions.
 
+# List of variables containing paths to directories or files that
+# we need to update.
+path_vars='work_build workdir t2ddir work_bak in_input'
+
+# Change directory, updating some relative paths.
+cd_dir ()
+{
+  cd "$1"
+  # Replace each path component with ".." and remove any trailing slash.
+  cdd_prefix=`echo "$1" | sed -e 's/[^/\\]\+/../g' -e 's/[/\\]$//'`
+
+  # Add this prefix for some variables.
+  for cdd_dir in $path_vars; do
+    eval "case \"$$cdd_dir\" in
+          [\\/]* | ?:[\\/]*) ;;  # absolute path - do nothing
+          ?*)
+             eval \"\$cdd_dir=\$cdd_prefix/\\\$\$cdd_dir\" ;;
+          esac"
+    # Without first level of quotes, where CDD_DIR is $cdd_dir:
+    #      case "$CDD_DIR" in
+    #      [\\/]* | ?:[\\/]*) ;;
+    #      *)
+    #         eval "$cdd_dir=$cdd_prefix/\$$cdd_dir" ;;
+    #      esac
+    #
+    # Inner 'eval' becomes
+    #     CDD_DIR=CDD_PREFIX/$CDD_DIR
+    # where CDD_DIR is $cdd_dir and CDD_PREFIX is $cdd_prefix
+  done
+}
+
 # cd_orig - Return to the original directory.
 cd_orig ()
 {
@@ -243,6 +274,11 @@
   # - the next file is processed in correct conditions
   # - the temporary file can be removed
   cd "$orig_pwd" || exit 1
+  
+  # strip off ../../ from some variables
+  for cdo_dir in $path_vars ; do
+    eval $cdo_dir=\${$cdo_dir#\$cdd_prefix/}
+  done
 }
 
 
@@ -890,34 +926,7 @@
 {
   make_tex_cmd
     
-  # TeX's \input does not (easily or reliably) support whitespace
-  # characters or other special characters in file names.  Our intensive
-  # use of absolute file names makes this worse: the enclosing directory
-  # names may include white spaces.  Improve the situation using a
-  # symbolic link to the filename in the current directory, in tidy mode
-  # only.  Do not alter in_input.
-  #
-  # The filename is almost always tokenized using plain TeX conventions
-  # (the exception would be if the user made a texinfo.fmt file).  Not
-  # all the plain TeX special characters cause trouble, but there's no
-  # harm in making the link.
-  #
-  case $tidy:`func_dirname "$in_input"` in
-    true:*["$space$tab$newline\"#\$%\\^_{}~"]*)
-      _run_tex_file_name=`basename "$in_input"`
-      if test ! -f "$_run_tex_file_name"; then
-        # It might not be a file, clear it.
-        run rm -f "$_run_tex_file_name"
-        run ln -s "$in_input"
-      fi
-      tex_cmd="$tex_cmd '$_run_tex_file_name'"
-      ;;
-
-    *)
-      tex_cmd="$tex_cmd '$in_input'"
-      ;;
-  esac
-
+  tex_cmd="$tex_cmd '$in_input'"
   verbose "$0: Running $tex_cmd ..."
   if eval "$tex_cmd" >&5; then
     case $out_lang in
@@ -1103,7 +1112,7 @@
   # Move to the working directory.
   if $tidy; then
     verbose "cd $work_build"
-    cd "$work_build" || exit 1
+    cd_dir "$work_build" || exit 1
   fi
 
   # Count the number of cycles.
@@ -1448,7 +1457,7 @@
   # --command, --texinfo
   insert_commands
 
-  # Run until a fix point is reached.
+  # Run until a fixed point is reached.
   run_tex_suite
 }
 
@@ -1458,7 +1467,7 @@
 make_openout_test ()
 {
     ensure_dir "$workdir"/check_recorder
-    cd "$workdir"/check_recorder
+    cd_dir "$workdir"/check_recorder
     cat > openout.tex <<EOF
 \newwrite\ourwrite
 \immediate\openout\ourwrite dum.dum
@@ -1642,10 +1651,9 @@
 # the script.  Changes the current directory.
 cleanup ()
 {
-  case $build_mode in
-    local) cd_orig; remove "$t2ddir";;
-    clean) mostly_clean;;
-    tidy)  ;;
+  case $clean:$tidy in
+    true:false) mostly_clean ;;               # build mode is "clean"
+    false:false) cd_orig; remove "$t2ddir";;  # build mode is "local"
   esac
 }
 
@@ -1656,7 +1664,7 @@
 # - COMMAND_LINE_FILENAME
 #   The filename given on the commmand line, but cleaned of TeX commands.
 # - IN_DIR
-#   The directory containing the input file, possibly absolute if needed.
+#   The directory containing the input file.
 # - IN_DIR_ABS
 #   The absolute directory of the input file.
 # - IN_BASE
@@ -1699,10 +1707,6 @@
   # Get the name of the current directory.
   in_dir=`func_dirname "$command_line_filename"`
   in_dir_abs=`absolute "$in_dir"`
-  # In a clean build, we `cd', so get an absolute file name.
-  if $tidy; then
-    in_dir=$in_dir_abs
-  fi
 
   # Strip directory part but leave extension.
   in_base=`basename "$command_line_filename"`
@@ -1938,8 +1942,6 @@
 
   ensure_dir "$build_dir" "$t2ddir"
 
-  # We will change directory, better work with an absolute path...
-  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.




reply via email to

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