From: Miguel de Icaza Date: Wed, 23 Sep 2009 21:11:12 +0000 (-0000) Subject: This patch replaces the calls to g_strcasecmp with either X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=24845a088636f97398dcff1f1b50dc8ac51756c0;p=mono.git This patch replaces the calls to g_strcasecmp with either memcmp, g_ascii_strcasecmp or mono_utf8_strcasecmp since the symbols are becoming deprecated in newer Glibs. svn path=/trunk/mono/; revision=142515 --- diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 249093b5b95..fcfedd8656b 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,3 +1,14 @@ +2009-09-23 Miguel de Icaza + + * 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 * gc.c: Raise a NullArgumentException if the object passed is diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index f431649c9fc..538767850fc 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -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 diff --git a/mono/metadata/class.c b/mono/metadata/class.c index 06bac2ec1f1..4521e49c4aa 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -39,6 +39,7 @@ #include #include #include +#include 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; diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index bb170153ec2..7c778759b5c 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -72,6 +72,7 @@ #include #include #include +#include #if defined (PLATFORM_WIN32) #include @@ -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); diff --git a/mono/metadata/mono-config.c b/mono/metadata/mono-config.c index 7f2a3ebe193..141b594766d 100644 --- a/mono/metadata/mono-config.c +++ b/mono/metadata/mono-config.c @@ -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); } } diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index e472ed31d38..9722a02cfad 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -38,6 +38,7 @@ #include #include #include +#include #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) diff --git a/mono/metadata/verify.c b/mono/metadata/verify.c index af1c1445577..15c427d18ef 100644 --- a/mono/metadata/verify.c +++ b/mono/metadata/verify.c @@ -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; } diff --git a/mono/utils/Makefile.am b/mono/utils/Makefile.am index 4af317d78e6..519b95f7161 100644 --- a/mono/utils/Makefile.am +++ b/mono/utils/Makefile.am @@ -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 index 00000000000..6e2daade7a5 --- /dev/null +++ b/mono/utils/mono-string.h @@ -0,0 +1,12 @@ +#ifndef __UTILS_MONO_STRING_H__ +#define __UTILS_MONO_STRING_H__ +#include +/* + * 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__ */