summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-07-08 02:07:38 +0200
committerBruno Haible <bruno@clisp.org>2020-07-08 02:41:32 +0200
commit8e867216109f764c195790a53f67bf1bc925b27f (patch)
tree6377bdc81e63dc381dc19a243199465c29d17da3
parent9d5dc512b84adc1a257f0c7d3dd98b0fbb13dc59 (diff)
downloadgnulib-8e867216109f764c195790a53f67bf1bc925b27f.tar.gz
gnulib-8e867216109f764c195790a53f67bf1bc925b27f.tar.bz2
canonicalize: Trim module dependencies.
* lib/hash-triple.h: Group declarations. * lib/hash-triple-simple.c: New file, extracted from lib/hash-triple.c. * lib/hash-triple.c: Don't include <stdlib.h>, <string.h>, hash-pjw.h. (STREQ): Remove macro. (triple_hash, triple_compare_ino_str, triple_free): Remove functions. * modules/hash-triple-simple: New file, based on modules/hash-triple. * modules/hash-triple (Files): Remove lib/hash-triple.h. (Depends-on): Add hash-triple-simple. Remove hash-pjw. * modules/canonicalize (Depends-on): Remove hash-triple. Add hash-triple-simple. * modules/file-set (Depends-on): Likewise.
-rw-r--r--ChangeLog15
-rw-r--r--lib/hash-triple-simple.c59
-rw-r--r--lib/hash-triple.c35
-rw-r--r--lib/hash-triple.h10
-rw-r--r--modules/canonicalize2
-rw-r--r--modules/file-set2
-rw-r--r--modules/hash-triple3
-rw-r--r--modules/hash-triple-simple24
8 files changed, 109 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index ec447a9831..5d0ba82438 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2020-07-07 Bruno Haible <bruno@clisp.org>
+ canonicalize: Trim module dependencies.
+ * lib/hash-triple.h: Group declarations.
+ * lib/hash-triple-simple.c: New file, extracted from lib/hash-triple.c.
+ * lib/hash-triple.c: Don't include <stdlib.h>, <string.h>, hash-pjw.h.
+ (STREQ): Remove macro.
+ (triple_hash, triple_compare_ino_str, triple_free): Remove functions.
+ * modules/hash-triple-simple: New file, based on modules/hash-triple.
+ * modules/hash-triple (Files): Remove lib/hash-triple.h.
+ (Depends-on): Add hash-triple-simple. Remove hash-pjw.
+ * modules/canonicalize (Depends-on): Remove hash-triple. Add
+ hash-triple-simple.
+ * modules/file-set (Depends-on): Likewise.
+
+2020-07-07 Bruno Haible <bruno@clisp.org>
+
Clarify dependencies to double-slash-root.
* modules/canonicalize (Files): Remove m4/double-slash-root.m4.
(Depends-on): Add double-slash-root.
diff --git a/lib/hash-triple-simple.c b/lib/hash-triple-simple.c
new file mode 100644
index 0000000000..98728f2a99
--- /dev/null
+++ b/lib/hash-triple-simple.c
@@ -0,0 +1,59 @@
+/* Hash functions for file-related triples: name, device, inode.
+ Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+#include <config.h>
+
+/* Specification. */
+#include "hash-triple.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "hash-pjw.h"
+#include "same-inode.h"
+
+#define STREQ(a, b) (strcmp (a, b) == 0)
+
+/* Hash an F_triple, and *do* consider the file name. */
+size_t
+triple_hash (void const *x, size_t table_size)
+{
+ struct F_triple const *p = x;
+ size_t tmp = hash_pjw (p->name, table_size);
+
+ /* Ignoring the device number here should be fine. */
+ return (tmp ^ p->st_ino) % table_size;
+}
+
+/* Compare two F_triple structs. */
+bool
+triple_compare_ino_str (void const *x, void const *y)
+{
+ struct F_triple const *a = x;
+ struct F_triple const *b = y;
+ return (SAME_INODE (*a, *b) && STREQ (a->name, b->name)) ? true : false;
+}
+
+/* Free an F_triple. */
+void
+triple_free (void *x)
+{
+ struct F_triple *a = x;
+ free (a->name);
+ free (a);
+}
diff --git a/lib/hash-triple.c b/lib/hash-triple.c
index 560e442fbd..ad1a559e9d 100644
--- a/lib/hash-triple.c
+++ b/lib/hash-triple.c
@@ -18,28 +18,12 @@
#include <config.h>
+/* Specification. */
#include "hash-triple.h"
-#include <stdlib.h>
-#include <string.h>
-
-#include "hash-pjw.h"
#include "same.h"
#include "same-inode.h"
-#define STREQ(a, b) (strcmp (a, b) == 0)
-
-/* Hash an F_triple, and *do* consider the file name. */
-size_t
-triple_hash (void const *x, size_t table_size)
-{
- struct F_triple const *p = x;
- size_t tmp = hash_pjw (p->name, table_size);
-
- /* Ignoring the device number here should be fine. */
- return (tmp ^ p->st_ino) % table_size;
-}
-
/* Hash an F_triple, without considering the file name. */
size_t
triple_hash_no_name (void const *x, size_t table_size)
@@ -58,20 +42,3 @@ triple_compare (void const *x, void const *y)
struct F_triple const *b = y;
return (SAME_INODE (*a, *b) && same_name (a->name, b->name)) ? true : false;
}
-
-bool
-triple_compare_ino_str (void const *x, void const *y)
-{
- struct F_triple const *a = x;
- struct F_triple const *b = y;
- return (SAME_INODE (*a, *b) && STREQ (a->name, b->name)) ? true : false;
-}
-
-/* Free an F_triple. */
-void
-triple_free (void *x)
-{
- struct F_triple *a = x;
- free (a->name);
- free (a);
-}
diff --git a/lib/hash-triple.h b/lib/hash-triple.h
index c65450e62b..16f53302d9 100644
--- a/lib/hash-triple.h
+++ b/lib/hash-triple.h
@@ -31,12 +31,16 @@ struct F_triple
dev_t st_dev;
};
+/* Defined in module 'hash-triple-simple'. */
+
extern size_t triple_hash (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE;
-extern size_t triple_hash_no_name (void const *x, size_t table_size)
- _GL_ATTRIBUTE_PURE;
-extern bool triple_compare (void const *x, void const *y);
extern bool triple_compare_ino_str (void const *x, void const *y)
_GL_ATTRIBUTE_PURE;
extern void triple_free (void *x);
+/* Defined in module 'hash-triple'. */
+extern size_t triple_hash_no_name (void const *x, size_t table_size)
+ _GL_ATTRIBUTE_PURE;
+extern bool triple_compare (void const *x, void const *y);
+
#endif
diff --git a/modules/canonicalize b/modules/canonicalize
index a59b9fb6b1..16dfb6999f 100644
--- a/modules/canonicalize
+++ b/modules/canonicalize
@@ -13,7 +13,7 @@ errno
extensions
file-set
filename
-hash-triple
+hash-triple-simple
lstat
memmove
nocrash
diff --git a/modules/file-set b/modules/file-set
index 7895cdac19..532828c574 100644
--- a/modules/file-set
+++ b/modules/file-set
@@ -7,7 +7,7 @@ lib/file-set.h
Depends-on:
hash
-hash-triple
+hash-triple-simple
stdbool
xalloc
xalloc-die
diff --git a/modules/hash-triple b/modules/hash-triple
index b746d47519..b726192a8d 100644
--- a/modules/hash-triple
+++ b/modules/hash-triple
@@ -3,10 +3,9 @@ Hash functions for file-related triples: name, device, inode.
Files:
lib/hash-triple.c
-lib/hash-triple.h
Depends-on:
-hash-pjw
+hash-triple-simple
same
same-inode
diff --git a/modules/hash-triple-simple b/modules/hash-triple-simple
new file mode 100644
index 0000000000..1ef3209d78
--- /dev/null
+++ b/modules/hash-triple-simple
@@ -0,0 +1,24 @@
+Description:
+Hash functions for file-related triples: name, device, inode.
+
+Files:
+lib/hash-triple-simple.c
+lib/hash-triple.h
+
+Depends-on:
+hash-pjw
+same-inode
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += hash-triple-simple.c
+
+Include:
+"hash-triple.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering

Return to:

Send suggestions and report system problems to the System administrator.