Index: ChangeLog =================================================================== --- ChangeLog (revision 7143) +++ ChangeLog (working copy) @@ -1,3 +1,29 @@ +2016-05-03 Gavin Smith + + * 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, cleanup): Don't + change variables t2ddir, in_dir to be absolute. This could + cause problems if the absolute path to the input file contained + a space. (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 * util/texi2dvi (usage): Streamline help message. Don't mention Index: util/texi2dvi =================================================================== --- util/texi2dvi (revision 7143) +++ util/texi2dvi (working copy) @@ -233,6 +233,37 @@ EOF # 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 @@ cd_orig () # - 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 @@ run_tex () { 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 @@ run_tex_suite () # 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 @@ compile () # --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 @@ compile () make_openout_test () { ensure_dir "$workdir"/check_recorder - cd "$workdir"/check_recorder + cd_dir "$workdir"/check_recorder cat > openout.tex <