eina_value: fix convert to string on empty/null cases.

SVN revision: 67838
This commit is contained in:
Gustavo Sverzut Barbieri 2012-02-10 21:18:59 +00:00
parent 63cc1bceea
commit 0d1b66d44e
1 changed files with 13 additions and 12 deletions

View File

@ -2506,12 +2506,13 @@ _eina_value_type_array_convert_to(const Eina_Value_Type *type __UNUSED__, const
(convert == EINA_VALUE_TYPE_STRINGSHARE)) (convert == EINA_VALUE_TYPE_STRINGSHARE))
{ {
Eina_Strbuf *str = eina_strbuf_new(); Eina_Strbuf *str = eina_strbuf_new();
const char *ptr;
if (!tmem->array) eina_strbuf_append(str, "[]"); if (!tmem->array) eina_strbuf_append(str, "[]");
else else
{ {
const Eina_Value_Type *subtype = tmem->subtype; const Eina_Value_Type *subtype = tmem->subtype;
unsigned char sz; unsigned char sz;
const char *ptr, *ptr_end; const char *ptr_end;
Eina_Value tmp; Eina_Value tmp;
Eina_Bool first = EINA_TRUE; Eina_Bool first = EINA_TRUE;
@ -2552,11 +2553,11 @@ _eina_value_type_array_convert_to(const Eina_Value_Type *type __UNUSED__, const
} }
eina_strbuf_append_char(str, ']'); eina_strbuf_append_char(str, ']');
}
ptr = eina_strbuf_string_get(str); ptr = eina_strbuf_string_get(str);
ret = eina_value_type_pset(convert, convert_mem, &ptr); ret = eina_value_type_pset(convert, convert_mem, &ptr);
eina_strbuf_free(str); eina_strbuf_free(str);
} }
}
else if ((tmem->array) && (tmem->array->len == 1)) else if ((tmem->array) && (tmem->array->len == 1))
{ {
const Eina_Value_Type *subtype = tmem->subtype; const Eina_Value_Type *subtype = tmem->subtype;
@ -2822,13 +2823,13 @@ _eina_value_type_list_convert_to(const Eina_Value_Type *type __UNUSED__, const E
(convert == EINA_VALUE_TYPE_STRINGSHARE)) (convert == EINA_VALUE_TYPE_STRINGSHARE))
{ {
Eina_Strbuf *str = eina_strbuf_new(); Eina_Strbuf *str = eina_strbuf_new();
const char *s;
if (!tmem->list) eina_strbuf_append(str, "[]"); if (!tmem->list) eina_strbuf_append(str, "[]");
else else
{ {
const Eina_Value_Type *subtype = tmem->subtype; const Eina_Value_Type *subtype = tmem->subtype;
const Eina_List *node; const Eina_List *node;
Eina_Value tmp; Eina_Value tmp;
const char *s;
Eina_Bool first = EINA_TRUE; Eina_Bool first = EINA_TRUE;
eina_value_setup(&tmp, EINA_VALUE_TYPE_STRING); eina_value_setup(&tmp, EINA_VALUE_TYPE_STRING);
@ -2868,11 +2869,11 @@ _eina_value_type_list_convert_to(const Eina_Value_Type *type __UNUSED__, const E
} }
eina_strbuf_append_char(str, ']'); eina_strbuf_append_char(str, ']');
}
s = eina_strbuf_string_get(str); s = eina_strbuf_string_get(str);
ret = eina_value_type_pset(convert, convert_mem, &s); ret = eina_value_type_pset(convert, convert_mem, &s);
eina_strbuf_free(str); eina_strbuf_free(str);
} }
}
else if ((tmem->list) && (tmem->list->next == NULL)) else if ((tmem->list) && (tmem->list->next == NULL))
{ {
const Eina_Value_Type *subtype = tmem->subtype; const Eina_Value_Type *subtype = tmem->subtype;
@ -3241,11 +3242,11 @@ _eina_value_type_hash_convert_to(const Eina_Value_Type *type __UNUSED__, const E
(convert == EINA_VALUE_TYPE_STRINGSHARE)) (convert == EINA_VALUE_TYPE_STRINGSHARE))
{ {
Eina_Strbuf *str = eina_strbuf_new(); Eina_Strbuf *str = eina_strbuf_new();
const char *s;
if (!tmem->hash) eina_strbuf_append(str, "{}"); if (!tmem->hash) eina_strbuf_append(str, "{}");
else else
{ {
struct _eina_value_type_hash_convert_to_string_each_ctx ctx; struct _eina_value_type_hash_convert_to_string_each_ctx ctx;
const char *s;
ctx.subtype = tmem->subtype; ctx.subtype = tmem->subtype;
ctx.str = str; ctx.str = str;
@ -3259,11 +3260,11 @@ _eina_value_type_hash_convert_to(const Eina_Value_Type *type __UNUSED__, const E
&ctx); &ctx);
eina_strbuf_append_char(str, '}'); eina_strbuf_append_char(str, '}');
}
s = eina_strbuf_string_get(str); s = eina_strbuf_string_get(str);
ret = eina_value_type_pset(convert, convert_mem, &s); ret = eina_value_type_pset(convert, convert_mem, &s);
eina_strbuf_free(str); eina_strbuf_free(str);
} }
}
else if ((tmem->hash) && (eina_hash_population(tmem->hash) == 1)) else if ((tmem->hash) && (eina_hash_population(tmem->hash) == 1))
{ {
const Eina_Value_Type *subtype = tmem->subtype; const Eina_Value_Type *subtype = tmem->subtype;