[m-rev.] diff: fix string_hash bug
Simon Taylor
stayl at cs.mu.OZ.AU
Sat Nov 23 01:59:39 AEDT 2002
Estimated hours taken: 0.5
Branches: main, release
runtime/mercury_string.h:
runtime/mercury_string.c:
Fix bug which caused the results of MR_hash_string() and
string__hash to differ when `sizeof(int) != sizeof(MR_Integer)'.
runtime/mercury_misc.c:
MR_hash_string() was defined here for non-GCC compilers
for historical reasons. Move it to mercury_string.c.
Index: mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.25
diff -u -u -r1.25 mercury_misc.c
--- mercury_misc.c 30 Sep 2002 06:08:22 -0000 1.25
+++ mercury_misc.c 22 Nov 2002 14:53:03 -0000
@@ -104,17 +104,3 @@
exit(EXIT_FAILURE);
}
-/*
-** Note that MR_hash_string is actually defined as a macro in mercury_imp.h,
-** if we're using GNU C. We define it here whether or not we're using
-** gcc, so that users can easily switch between gcc and cc without
-** rebuilding the libraries.
-*/
-
-#undef MR_hash_string
-
-int
-MR_hash_string(MR_ConstString s)
-{
- MR_HASH_STRING_FUNC_BODY
-}
Index: mercury_string.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_string.c,v
retrieving revision 1.14
diff -u -u -r1.14 mercury_string.c
--- mercury_string.c 18 Feb 2002 07:01:20 -0000 1.14
+++ mercury_string.c 22 Nov 2002 14:53:03 -0000
@@ -91,3 +91,18 @@
return result;
}
+
+/*
+** Note that MR_hash_string is actually defined as a macro in
+** mercury_string.h, if we're using GNU C.
+** We define it here whether or not we're using gcc, so that users
+** can easily switch between gcc and cc without rebuilding the libraries.
+*/
+
+#undef MR_hash_string
+
+MR_Integer
+MR_hash_string(MR_ConstString s)
+{
+ MR_HASH_STRING_FUNC_BODY
+}
Index: mercury_string.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_string.h,v
retrieving revision 1.27.2.1
diff -u -u -r1.27.2.1 mercury_string.h
--- mercury_string.h 21 Nov 2002 09:19:23 -0000 1.27.2.1
+++ mercury_string.h 22 Nov 2002 14:53:03 -0000
@@ -153,11 +153,11 @@
** MR_hash_string(s):
** Given a Mercury string `s', return a hash value for that string.
*/
-int MR_hash_string(MR_ConstString);
+MR_Integer MR_hash_string(MR_ConstString);
#ifdef __GNUC__
#define MR_hash_string(s) \
- ({ int hash_string_result; \
+ ({ MR_Integer hash_string_result; \
MR_CHECK_EXPR_TYPE(s, MR_ConstString); \
MR_do_hash_string(hash_string_result, s); \
hash_string_result; \
@@ -171,7 +171,7 @@
*/
#define MR_HASH_STRING_FUNC_BODY \
- int hash_string_result; \
+ MR_Integer hash_string_result; \
MR_do_hash_string(hash_string_result, s); \
return hash_string_result;
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list