Author: zoltan
Date: 2005-03-04 09:08:11 -0500 (Fri, 04 Mar 2005)
New Revision: 41439

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/string-icalls.c
Log:
2005-03-04  Zoltan Varga  <[EMAIL PROTECTED]>

        * string-icalls.c: Return String.Empty where needed. Fixes #73310.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2005-03-04 13:55:37 UTC (rev 41438)
+++ trunk/mono/mono/metadata/ChangeLog  2005-03-04 14:08:11 UTC (rev 41439)
@@ -1,5 +1,7 @@
 2005-03-04  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * string-icalls.c: Return String.Empty where needed. Fixes #73310.
+
        * object-internals.h (MonoStackFrame): Sync with managed object layout.
 
        * appdomain.c: Bump corlib version.

Modified: trunk/mono/mono/metadata/string-icalls.c
===================================================================
--- trunk/mono/mono/metadata/string-icalls.c    2005-03-04 13:55:37 UTC (rev 
41438)
+++ trunk/mono/mono/metadata/string-icalls.c    2005-03-04 14:08:11 UTC (rev 
41439)
@@ -27,6 +27,32 @@
 static gboolean
 string_icall_is_in_array (MonoArray *chars, gint32 arraylength, gunichar2 chr);
 
+static MonoString*
+empty_string (MonoDomain *domain)
+{
+       MonoVTable *vtable = mono_class_vtable (domain, 
mono_defaults.string_class);
+       MonoObject *o;
+       static MonoClassField *empty_field = NULL;
+
+       if (!empty_field) {
+               MonoClassField *field;
+               gpointer iter;
+
+               iter = NULL;
+               while ((field = mono_class_get_fields 
(mono_defaults.string_class, &iter))) {
+                       if (!strcmp (field->name, "Empty"))
+                               break;
+               }
+
+               g_assert (field);
+               empty_field = field;
+       }
+
+       mono_field_static_get_value (vtable, empty_field, &o);
+       g_assert (o);
+       return (MonoString*)o;
+}
+
 MonoString *
 ves_icall_System_String_ctor_charp (gpointer dummy, gunichar2 *value)
 {
@@ -86,10 +112,8 @@
        if ((sindex < 0) || (length < 0))
                mono_raise_exception (mono_get_exception_argument_out_of_range 
("Out of range"));
        
-       if (length == 0) {      /* fixme: return String.Empty here */
-               g_warning ("string doesn't yet support empy strings in char* 
constructor");
-               g_assert_not_reached ();
-       }
+       if (length == 0)
+               return empty_string (domain);
        
        begin = (gunichar2 *) (value + sindex);
 
@@ -105,10 +129,8 @@
 
        domain = mono_domain_get ();
 
-       if (NULL == value) {    /* fixme: return String.Empty here */
-               g_warning ("string doesn't yet support empy strings in char* 
constructor");
-               g_assert_not_reached ();
-       }
+       if (NULL == value)
+               return empty_string (domain);
 
        return mono_string_new (domain, (const char *) value);
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to