summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2006-02-06 16:21:59 +0000
committerPaul Smith <psmith@gnu.org>2006-02-06 16:21:59 +0000
commita4e3523fe408158c15026a884d1515c34de27de6 (patch)
tree04e2cbfa11c6c6f30c625a6427f736d0719fbb76 /dir.c
parent7a8549f5dd339eec9cb57c8cfe11cf71b77759d2 (diff)
downloadgunmake-a4e3523fe408158c15026a884d1515c34de27de6.tar.gz
Fix Savannah bugs # 15341, 15534, and 15533.
Rewrite large chunks of the "Commands" section of the manual to better describe then backslash-newline handling, the SHELL variable, etc.
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/dir.c b/dir.c
index f6a03bd..d2f6b98 100644
--- a/dir.c
+++ b/dir.c
@@ -289,6 +289,17 @@ directory_contents_hash_2 (const void *key_0)
return hash;
}
+/* Sometimes it's OK to use subtraction to get this value:
+ result = X - Y;
+ But, if we're not sure of the type of X and Y they may be too large for an
+ int (on a 64-bit system for example). So, use ?: instead.
+ See Savannah bug #15534.
+
+ NOTE! This macro has side-effects!
+*/
+
+#define MAKECMP(_x,_y) ((_x)<(_y)?-1:((_x)==(_y)?0:1))
+
static int
directory_contents_hash_cmp (const void *xv, const void *yv)
{
@@ -300,28 +311,28 @@ directory_contents_hash_cmp (const void *xv, const void *yv)
ISTRING_COMPARE (x->path_key, y->path_key, result);
if (result)
return result;
- result = x->ctime - y->ctime;
+ result = MAKECMP(x->ctime, y->ctime);
if (result)
return result;
#else
# ifdef VMS
- result = x->ino[0] - y->ino[0];
+ result = MAKECMP(x->ino[0], y->ino[0]);
if (result)
return result;
- result = x->ino[1] - y->ino[1];
+ result = MAKECMP(x->ino[1], y->ino[1]);
if (result)
return result;
- result = x->ino[2] - y->ino[2];
+ result = MAKECMP(x->ino[2], y->ino[2]);
if (result)
return result;
# else
- result = x->ino - y->ino;
+ result = MAKECMP(x->ino, y->ino);
if (result)
return result;
# endif
#endif /* WINDOWS32 */
- return x->dev - y->dev;
+ return MAKECMP(x->dev, y->dev);
}
/* Table of directory contents hashed by device and inode number. */