This patch replaces the calls to g_strcasecmp with either
authorMiguel de Icaza <miguel@gnome.org>
Wed, 23 Sep 2009 21:11:12 +0000 (21:11 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 23 Sep 2009 21:11:12 +0000 (21:11 -0000)
memcmp, g_ascii_strcasecmp or mono_utf8_strcasecmp since the
symbols are becoming deprecated in newer Glibs.

svn path=/trunk/mono/; revision=142515

mono/metadata/ChangeLog
mono/metadata/assembly.c
mono/metadata/class.c
mono/metadata/icall.c
mono/metadata/mono-config.c
mono/metadata/reflection.c
mono/metadata/verify.c
mono/utils/Makefile.am
mono/utils/mono-string.h [new file with mode: 0644]

index 249093b5b95a01a4d2fff151b2a9677e4d5c7aac..fcfedd8656bf1da14d4923d5834c7545a542868f 100644 (file)
@@ -1,3 +1,14 @@
+2009-09-23  Miguel de Icaza  <miguel@novell.com>
+
+       * verify.c: when comparing culture strings, use g_ascii_strcmp
+
+       * assembly.c (mono_public_tokens_are_equal): Change g_strcasecmp
+       when comparing public key tokens to use memcmp on 16 bytes.   I do
+       not believe this ever worked as advertised in the past.
+
+       The standard Public Key is 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00
+       which would have always failed earlier.
+       
 2009-06-25  Miguel de Icaza  <miguel@novell.com>
 
        * gc.c: Raise a NullArgumentException if the object passed is
index f431649c9fc1d8c5fdf7d1a21ad6b48d773808d7..538767850fc4a34a731450e3944b8c5f4b0735ab 100644 (file)
@@ -159,7 +159,7 @@ encode_public_tok (const guchar *token, gint32 len)
 gboolean
 mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2)
 {
-       return g_strcasecmp ((char*)pubt1, (char*)pubt2) == 0;
+       return memcmp (pubt1, pubt2, 16) == 0;
 }
 
 static void
index 06bac2ec1f1593f681ceb42db45efa4b61596749..4521e49c4aadaf0fbdc2b37e60662a806fff898e 100644 (file)
@@ -39,6 +39,7 @@
 #include <mono/metadata/verify-internals.h>
 #include <mono/metadata/mono-debug.h>
 #include <mono/utils/mono-counters.h>
+#include <mono/utils/mono-string.h>
 
 MonoStats mono_stats;
 
@@ -5834,7 +5835,7 @@ find_nocase (gpointer key, gpointer value, gpointer user_data)
        char *name = (char*)key;
        FindUserData *data = (FindUserData*)user_data;
 
-       if (!data->value && (g_strcasecmp (name, (char*)data->key) == 0))
+       if (!data->value && (mono_utf8_strcasecmp (name, (char*)data->key) == 0))
                data->value = value;
 }
 
@@ -5903,7 +5904,7 @@ mono_class_from_name_case (MonoImage *image, const char* name_space, const char
                        continue;
                n = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]);
                nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]);
-               if (g_strcasecmp (n, name) == 0 && g_strcasecmp (nspace, name_space) == 0)
+               if (mono_utf8_strcasecmp (n, name) == 0 && mono_utf8_strcasecmp (nspace, name_space) == 0)
                        return mono_class_get (image, MONO_TOKEN_TYPE_DEF | i);
        }
        return NULL;
index bb170153ec2bf1576082501f72b78dd3f3b99529..7c778759b5cd55c45b223c4ca3cdfa515696dd75 100644 (file)
@@ -72,6 +72,7 @@
 #include <mono/utils/monobitset.h>
 #include <mono/utils/mono-time.h>
 #include <mono/utils/mono-proclib.h>
+#include <mono/utils/mono-string.h>
 
 #if defined (PLATFORM_WIN32)
 #include <windows.h>
@@ -3263,7 +3264,7 @@ ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bfl
        if (type->type->byref)
                return NULL;
 
-       compare_func = (bflags & BFLAGS_IgnoreCase) ? g_strcasecmp : strcmp;
+       compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp;
 
 handle_parent:
        if (klass->exception_type != MONO_EXCEPTION_NONE)
@@ -3439,7 +3440,7 @@ ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, gui
        len = 0;
        if (name != NULL) {
                mname = mono_string_to_utf8 (name);
-               compare_func = (ignore_case) ? g_strcasecmp : strcmp;
+               compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp;
        }
 
        /* An optimization for calls made from Delegate:CreateDelegate () */
@@ -3682,7 +3683,7 @@ ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name,
        klass = startklass = mono_class_from_mono_type (type->type);
        if (name != NULL) {
                propname = mono_string_to_utf8 (name);
-               compare_func = (ignore_case) ? g_strcasecmp : strcmp;
+               compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp;
        }
 
        mono_class_setup_vtable (klass);
index 7f2a3ebe1935eaf5fb3e4b58c5d6b3979e72bef6..141b594766d1b24ea62f12fc02f2266497709fee 100644 (file)
@@ -326,7 +326,7 @@ legacyUEP_start (gpointer user_data,
                        (attribute_names [0] != NULL) &&
                        (strcmp (attribute_names [0], "enabled") == 0)) {
                if ((strcmp (attribute_values [0], "1") == 0) ||
-                               (g_strcasecmp (attribute_values [0], "true") == 0)) {
+                               (g_ascii_strcasecmp (attribute_values [0], "true") == 0)) {
                        mono_runtime_unhandled_exception_policy_set (MONO_UNHANDLED_POLICY_LEGACY);
                }
        }
index e472ed31d38c922267bcc6d1d4f094a04080fd2d..9722a02cfad400d46dd67ad2009ff759341defcc 100644 (file)
@@ -38,6 +38,7 @@
 #include <mono/metadata/mempool-internals.h>
 #include <mono/metadata/security-core-clr.h>
 #include <mono/metadata/debug-helpers.h>
+#include <mono/utils/mono-string.h>
 
 #if HAVE_SGEN_GC
 static void* reflection_info_desc = NULL;
@@ -7235,7 +7236,7 @@ mono_reflection_get_type_internal (MonoImage *rootimage, MonoImage* image, MonoT
 
                while ((klass = mono_class_get_nested_types (parent, &iter))) {
                        if (ignorecase) {
-                               if (g_strcasecmp (klass->name, mod->data) == 0)
+                               if (mono_utf8_strcasecmp (klass->name, mod->data) == 0)
                                        break;
                        } else {
                                if (strcmp (klass->name, mod->data) == 0)
index af1c1445577417e60260ebdca7e70bc957d2abc2..15c427d18efdc45d520fee35092ed7d55d83a3bc 100644 (file)
@@ -1072,7 +1072,7 @@ is_valid_culture (const char *cname)
 
        found = *cname == 0;
        for (i = 0; i < G_N_ELEMENTS (valid_cultures); ++i) {
-               if (g_strcasecmp (valid_cultures [i], cname)) {
+               if (g_ascii_strcasecmp (valid_cultures [i], cname)) {
                        found = 1;
                        break;
                }
index 4af317d78e60b1eb064293f0e058abf68dbbe502..519b95f71615c8528884fc4e03122b24f73dd44f 100644 (file)
@@ -40,6 +40,7 @@ libmonoutils_la_SOURCES = \
        mono-mmap.h             \
        mono-proclib.c          \
        mono-proclib.h          \
+       mono-string.h           \
        mono-time.c             \
        mono-time.h             \
        strtod.h                \
diff --git a/mono/utils/mono-string.h b/mono/utils/mono-string.h
new file mode 100644 (file)
index 0000000..6e2daad
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __UTILS_MONO_STRING_H__
+#define __UTILS_MONO_STRING_H__
+#include <glib.h>
+/*
+ * This definition is used to we remember later to implement this properly
+ *
+ * Currently we merely call into the ascii comparison, but we should be
+ * instead doing case folding and comparing the result.
+ */
+#define mono_utf8_strcasecmp g_ascii_strcasecmp
+
+#endif /* __UTILS_MONO_STRING_H__ */