[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: texi2dvi: simplify move_to_dest
From: |
Akim Demaille |
Subject: |
FYI: texi2dvi: simplify move_to_dest |
Date: |
Wed, 15 Apr 2009 16:56:20 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) |
Index: ChangeLog
from Akim Demaille <address@hidden>
texi2dvi: simplify move_to_dest.
* bin/texi2dvi (move_to_dest): Exit immediately if there is
nothing to do.
This allows to simplify the body of the loop, as we no longer have
to check whether something has to be done.
Don't build-and-then-split $dest, just build the split components.
$dest is no longer needed.
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.146
diff -u -u -r1.146 texi2dvi
--- util/texi2dvi 15 Apr 2009 14:50:14 -0000 1.146
+++ util/texi2dvi 15 Apr 2009 14:54:38 -0000
@@ -648,7 +648,11 @@
# an auxiliary file with the same base name.
move_to_dest ()
{
- local dest
+ # If we built in place, there is nothing to install, leave.
+ case $tidy:$oname in
+ false:) return;;
+ esac
+
local destfile
local destdir
local destbase
@@ -657,42 +661,32 @@
for file
do
+ test -f "$file" ||
+ error 1 "no such file or directory: $file"
case $tidy:$oname in
- true:) dest=$orig_pwd;;
- false:) dest=;;
- *:*) dest=`output_base_name "$file"`;;
+ true:) destdir=$orig_pwd
+ destfile=$destdir/$file;;
+ *:*) destfile=`output_base_name "$file"`
+ destdir=`dirname "$destfile"`;;
esac
- if test ! -f "$file"; then
- error 1 "no such file or directory: $file"
- fi
- if test -n "$dest"; then
- # We need to know whether $dest is a directory.
- if test -d "$dest"; then
- destdir=$dest
- destfile=$dest/$file
- else
- destdir=`dirname "$dest"`
- destfile=$dest
- fi
- # We want to compare the source location and the output location,
- # and if they are different, do the move. But if they are the
- # same, we must preserve the source. Since we can't assume
- # stat(1) or test -ef is available, resort to comparing the
- # directory names, canonicalized with pwd. We can't use cmp -s
- # since the output file might not actually change from run to run;
- # e.g., TeX DVI output is timestamped to only the nearest minute.
- destdir=`cd "$destdir" && pwd`
- destbase=`basename "$destfile"`
- #
- sourcedir=`dirname "$file"`
- sourcedir=`cd "$sourcedir" && pwd`
- sourcebase=`basename "$file"`
- #
- if test "$sourcedir/$sourcebase" != "$destdir/$destbase"; then
- verbose "Moving $file to $destfile"
- rm -f "$destfile"
- mv "$file" "$destfile"
- fi
+ # We want to compare the source location and the output location,
+ # and if they are different, do the move. But if they are the
+ # same, we must preserve the source. Since we can't assume
+ # stat(1) or test -ef is available, resort to comparing the
+ # directory names, canonicalized with pwd. We can't use cmp -s
+ # since the output file might not actually change from run to run;
+ # e.g., TeX DVI output is timestamped to only the nearest minute.
+ destdir=`cd "$destdir" && pwd`
+ destbase=`basename "$destfile"`
+
+ sourcedir=`dirname "$file"`
+ sourcedir=`cd "$sourcedir" && pwd`
+ sourcebase=`basename "$file"`
+
+ if test "$sourcedir/$sourcebase" != "$destdir/$destbase"; then
+ verbose "Moving $file to $destfile"
+ rm -f "$destfile"
+ mv "$file" "$destfile"
fi
done
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: texi2dvi: simplify move_to_dest,
Akim Demaille <=