summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-08-27 03:21:36 (GMT)
committer卜部昌平 <shyouhei@ruby-lang.org>2019-08-27 06:52:26 (GMT)
commit78628618da98236fc1bf702079185b36ed394e2a (patch)
tree35dbfb9a3a01707619b332f77e71462902c89bad /st.c
parent6dd60cf114701f1ff3526381c0e742c588af2f91 (diff)
struct st_hash_type now free from ANYARGS
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit adds function prototypes for struct st_hash_type. Honestly I don't understand why they were commented out at the first place.
Diffstat (limited to 'st.c')
-rw-r--r--st.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/st.c b/st.c
index c32a7ed..880ab87 100644
--- a/st.c
+++ b/st.c
@@ -145,16 +145,17 @@ static const struct st_hash_type st_hashtype_num = {
st_numhash,
};
-/* extern int strcmp(const char *, const char *); */
+static int st_strcmp(st_data_t, st_data_t);
static st_index_t strhash(st_data_t);
static const struct st_hash_type type_strhash = {
- strcmp,
+ st_strcmp,
strhash,
};
+static int st_locale_insensitive_strcasecmp_i(st_data_t lhs, st_data_t rhs);
static st_index_t strcasehash(st_data_t);
static const struct st_hash_type type_strcasehash = {
- st_locale_insensitive_strcasecmp,
+ st_locale_insensitive_strcasecmp_i,
strcasehash,
};
@@ -2091,6 +2092,22 @@ st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n)
return 0;
}
+static int
+st_strcmp(st_data_t lhs, st_data_t rhs)
+{
+ const char *s1 = (char *)lhs;
+ const char *s2 = (char *)rhs;
+ return strcmp(s1, s2);
+}
+
+static int
+st_locale_insensitive_strcasecmp_i(st_data_t lhs, st_data_t rhs)
+{
+ const char *s1 = (char *)lhs;
+ const char *s2 = (char *)rhs;
+ return st_locale_insensitive_strcasecmp(s1, s2);
+}
+
NO_SANITIZE("unsigned-integer-overflow", PUREFUNC(static st_index_t strcasehash(st_data_t)));
static st_index_t
strcasehash(st_data_t arg)