[tlbuild] hashcode return type

Karl Berry karl at freefriends.org
Mon Jun 8 01:58:22 CEST 2009


Hi Eddie, 

When I grep in lcdf-typetools 2.78 for hashcode, they all have a return
type of "unsigned" with two exceptions: lcdf/permstr.hh (return type
size_t) and liblcdf/string.cc (return type uint32_t).  There's also a
second uint32_t instance in string.cc that is commented out.

A person building on Cygwin (Angelo Graziosi
<angelo.graziosi at alice.it>), reports a conflict with the uint32_t.  His
fix was to change string.hh to use uint32_t.

I tried changing the uint32_t in string.cc to unsigned, and that worked
for me too (on i386-linux).   I don't know what's up with the one in
permstr.hh.

In any case, could we reconcile this, one way or another?

If uint32_t is used, I think the necessary header might need to be
included in more places.  [Personally I try to avoid such types like the
plague :).]

I'll append Angelo's patch (had to tinker with the formatting, don't
know if it actually applies, sorry), in case it helps.  My "patch" is
one line, string.cc:534 --
-uint32_t
+unsigned

Wdyt?

Thanks,
Karl

===============================
--- texlive-source/texk/lcdf-typetools/include/lcdf/string.hh.orig 2009-03-20 10:50:07.000000000 +0100
+++ texlive-source/texk/lcdf-typetools/include/lcdf/string.hh
2009-05-11 17:53:22.859375000 +0200
@@ -243,10 +243,10 @@
       * @invariant If end1 - begin1 == end2 - begin2 and memcmp(begin1, begin2,
       * end1 - begin1) == 0, then hashcode(begin1, end1) == hashcode(begin2,
       * end2). */
-    static unsigned hashcode(const char *begin, const char *end);
+    static uint32_t hashcode(const char *begin, const char *end);

      /** @overload */
-    static inline unsigned hashcode(const unsigned char *begin,
+    static inline uint32_t hashcode(const unsigned char *begin,
                                     const unsigned char *end) {
         return hashcode(reinterpret_cast<const char *>(begin),
                         reinterpret_cast<const char *>(end));
@@ -258,7 +258,7 @@
       * "SuperFastHash."
       *
       * @invariant  If s1 == s2, then s1.hashcode() == s2.hashcode(). */
-    inline unsigned hashcode() const {
+    inline uint32_t hashcode() const {
         return length() ? hashcode(begin(), end()) : 0;
      }
===============================


More information about the tlbuild mailing list