]> Savannah Git Hosting - gnulib.git/commitdiff
canonicalize: Trim module dependencies.
authorBruno Haible <bruno@clisp.org>
Wed, 8 Jul 2020 00:07:38 +0000 (02:07 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 8 Jul 2020 00:41:32 +0000 (02:41 +0200)
* 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.

ChangeLog
lib/hash-triple-simple.c [new file with mode: 0644]
lib/hash-triple.c
lib/hash-triple.h
modules/canonicalize
modules/file-set
modules/hash-triple
modules/hash-triple-simple [new file with mode: 0644]

index ec447a9831f7f9f268320a3cd1b33a1be2521bad..5d0ba8243856f0c788106207b245b3366a50a404 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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.
diff --git a/lib/hash-triple-simple.c b/lib/hash-triple-simple.c
new file mode 100644 (file)
index 0000000..98728f2
--- /dev/null
@@ -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);
+}
index 560e442fbd7897f69756af8f3f82d6c98ae2253e..ad1a559e9dad67f50232f51bcfdcb9c6d2a16f8b 100644 (file)
 
 #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);
-}
index c65450e62b1256d021fa9e23468532f5f1917486..16f53302d991e61a61a11bee319c90128414a4ce 100644 (file)
@@ -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
index a59b9fb6b127a3b509df3d5bdb0c532aa94d5aa2..16dfb6999fbe387934f9144a6dd8ed49adad8ed9 100644 (file)
@@ -13,7 +13,7 @@ errno
 extensions
 file-set
 filename
-hash-triple
+hash-triple-simple
 lstat
 memmove
 nocrash
index 7895cdac197d2913011b5612731a3d7f9635b9ac..532828c57466d0b20027cb8affda1262fb8c7bbc 100644 (file)
@@ -7,7 +7,7 @@ lib/file-set.h
 
 Depends-on:
 hash
-hash-triple
+hash-triple-simple
 stdbool
 xalloc
 xalloc-die
index b746d47519ad68bec749a9fea33e3a7f41f2fd56..b726192a8d493774cefdcb8b0cc0400b9ad37ad1 100644 (file)
@@ -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 (file)
index 0000000..1ef3209
--- /dev/null
@@ -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