| 1 |
--- a/libidu/walker.c |
| 2 |
+++ b/libidu/walker.c |
| 3 |
@@ -618,14 +618,15 @@ |
| 4 |
dir_link = 0; |
| 5 |
#endif |
| 6 |
links = links_0 = vectorize_string (cwd, SLASH_STRING); |
| 7 |
- while (*links) |
| 8 |
- { |
| 9 |
- struct stat st; |
| 10 |
- char const* link_name = *links++; |
| 11 |
- dir_link = get_link_from_string (link_name, dir_link); |
| 12 |
- if (!dir_link->fl_flags) |
| 13 |
- dir_link->fl_flags = classify_link (dir_link, &st); |
| 14 |
- } |
| 15 |
+ if (*links && **links) /* Not in / */ |
| 16 |
+ while (*links) |
| 17 |
+ { |
| 18 |
+ struct stat st; |
| 19 |
+ char const* link_name = *links++; |
| 20 |
+ dir_link = get_link_from_string (link_name, dir_link); |
| 21 |
+ if (!dir_link->fl_flags) |
| 22 |
+ dir_link->fl_flags = classify_link (dir_link, &st); |
| 23 |
+ } |
| 24 |
chdir_to_link (dir_link); |
| 25 |
free (links_0); |
| 26 |
free (cwd); |
| 27 |
@@ -1111,16 +1112,16 @@ |
| 28 |
/* Expand to the definition of a function that hashes a dev+inode pair, |
| 29 |
with application of XFORM. */ |
| 30 |
#define DEV_INO_HASH_DEFUN(FN_NAME, XFORM) \ |
| 31 |
-static size_t _GL_ATTRIBUTE_PURE \ |
| 32 |
+static unsigned long _GL_ATTRIBUTE_PURE \ |
| 33 |
FN_NAME (void const *x) \ |
| 34 |
{ \ |
| 35 |
struct dev_ino const *p = x; \ |
| 36 |
ino_t ino = p->di_ino; \ |
| 37 |
\ |
| 38 |
- /* When INO is wider than size_t, XOR the words of INO into H. \ |
| 39 |
+ /* When INO is wider than unsigned long, XOR the words of INO into H. \ |
| 40 |
This avoids loss of info, without applying % to the wider type, \ |
| 41 |
which could be quite slow on some systems. */ \ |
| 42 |
- size_t h = XFORM (ino); \ |
| 43 |
+ unsigned long h = XFORM (ino); \ |
| 44 |
unsigned int n_words = sizeof ino / sizeof h + (sizeof ino % sizeof h != 0); \ |
| 45 |
for (unsigned int i = 1; i < n_words; i++) \ |
| 46 |
h ^= XFORM (ino >> CHAR_BIT * sizeof h * i); \ |
| 47 |
@@ -1133,17 +1134,26 @@ |
| 48 |
\ |
| 49 |
return h; \ |
| 50 |
} |
| 51 |
-static inline size_t xform_NOP (size_t k) { return k; } |
| 52 |
-static inline size_t xform_NOT (size_t k) { return ~k; } |
| 53 |
+static inline unsigned long xform_NOP (unsigned long k) { return k; } |
| 54 |
+static inline unsigned long xform_NOT (unsigned long k) { return ~k; } |
| 55 |
DEV_INO_HASH_DEFUN(dev_ino_hash_1, xform_NOP) |
| 56 |
DEV_INO_HASH_DEFUN(dev_ino_hash_2, xform_NOT) |
| 57 |
|
| 58 |
+/* Note, this is a compare, not a boolian test for equality. |
| 59 |
+It returns negative, positive, or 0, with 0 indicating equality. */ |
| 60 |
static int |
| 61 |
dev_ino_hash_compare (void const *xv, void const *yv) |
| 62 |
{ |
| 63 |
struct dev_ino const *x = xv; |
| 64 |
struct dev_ino const *y = yv; |
| 65 |
- return x->di_ino == y->di_ino && x->di_dev == y->di_dev; |
| 66 |
+ int result; |
| 67 |
+ INTEGER_COMPARE ( x->di_ino, |
| 68 |
+ y->di_ino, result); |
| 69 |
+ if (result) |
| 70 |
+ return result; |
| 71 |
+ INTEGER_COMPARE (x->di_dev, |
| 72 |
+ y->di_dev, result); |
| 73 |
+ return result; |
| 74 |
} |
| 75 |
|
| 76 |
#endif |