Evas textblock: fixed *_markup_get issue with escaped chars.
Markup_get was misbehaving and returning wrong results with some escaped chars. markup_to_utf8 was working correctly. Merged the code together and now both are consistent and correct. Thanks to WooHyun for reporting.
This commit is contained in:
parent
0af10ae93f
commit
bda3ceb632
|
@ -1,3 +1,8 @@
|
|||
2013-09-03 Tom Hacohen
|
||||
|
||||
* Evas textblock: fixed an issue with markup_get and markup_to_utf8
|
||||
behaving differently (markup_get was misbehaving).
|
||||
|
||||
2013-09-02 Shinwoo Kim
|
||||
|
||||
* Ecore_Input_Evas: Check the state of last mouse event more properly.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -333,6 +333,7 @@ Fixes:
|
|||
- Fix a long-standing off-by-1 in the C "simd" multiplier.
|
||||
- Skip the map rendering if all points are transparent.
|
||||
- Evas bidi: Fixed a bug causing BiDi not to work in some cases.
|
||||
- Evas textblock: fixed an issue with markup_get and markup_to_utf8 behaving differently (markup_get was misbehaving).
|
||||
* Ecore:
|
||||
- Don't leak fd on exec.
|
||||
- Fix fd handler increase issue when ecore_pipe_add/del is called repeatedly.
|
||||
|
|
|
@ -6127,6 +6127,43 @@ _markup_get_format_append(Eina_Strbuf *txt, Evas_Object_Textblock_Node_Format *f
|
|||
eina_strbuf_append_char(txt, '>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* An helper function to _markup_get_text_append and others, used for getting
|
||||
* back only the "dangerous" escapes.
|
||||
*/
|
||||
static void
|
||||
_markup_get_text_utf8_append(Eina_Strbuf *sbuf, const char *text)
|
||||
{
|
||||
int ch, pos = 0, pos2 = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
pos = pos2;
|
||||
pos2 = evas_string_char_next_get(text, pos2, &ch);
|
||||
if ((ch <= 0) || (pos2 <= 0)) break;
|
||||
|
||||
if (ch == _NEWLINE)
|
||||
eina_strbuf_append(sbuf, "<br/>");
|
||||
else if (ch == _TAB)
|
||||
eina_strbuf_append(sbuf, "<tab/>");
|
||||
else if (ch == '<')
|
||||
eina_strbuf_append(sbuf, "<");
|
||||
else if (ch == '>')
|
||||
eina_strbuf_append(sbuf, ">");
|
||||
else if (ch == '&')
|
||||
eina_strbuf_append(sbuf, "&");
|
||||
else if (ch == _PARAGRAPH_SEPARATOR)
|
||||
eina_strbuf_append(sbuf, "<ps/>");
|
||||
else if (ch == _REPLACEMENT_CHAR)
|
||||
eina_strbuf_append(sbuf, "");
|
||||
else if (ch != '\r')
|
||||
{
|
||||
eina_strbuf_append_length(sbuf, text + pos, pos2 - pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* An helper function to markup get. Appends the text in text.
|
||||
|
@ -6137,25 +6174,10 @@ _markup_get_format_append(Eina_Strbuf *txt, Evas_Object_Textblock_Node_Format *f
|
|||
static void
|
||||
_markup_get_text_append(Eina_Strbuf *txt, const Eina_Unicode *text)
|
||||
{
|
||||
char *p = eina_unicode_unicode_to_utf8(text, NULL);
|
||||
char *base = p;
|
||||
while (*p)
|
||||
{
|
||||
const char *escape;
|
||||
int adv;
|
||||
char *base = eina_unicode_unicode_to_utf8(text, NULL);
|
||||
|
||||
_markup_get_text_utf8_append(txt, base);
|
||||
|
||||
escape = _escaped_char_match(p, &adv);
|
||||
if (escape)
|
||||
{
|
||||
p += adv;
|
||||
eina_strbuf_append(txt, escape);
|
||||
}
|
||||
else
|
||||
{
|
||||
eina_strbuf_append_char(txt, *p);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
free(base);
|
||||
}
|
||||
EAPI const char *
|
||||
|
@ -6377,7 +6399,6 @@ evas_textblock_text_utf8_to_markup(const Evas_Object *eo_obj, const char *text)
|
|||
{
|
||||
Eina_Strbuf *sbuf;
|
||||
char *str = NULL;
|
||||
int ch, pos = 0, pos2 = 0;
|
||||
|
||||
(void) eo_obj;
|
||||
|
||||
|
@ -6385,31 +6406,8 @@ evas_textblock_text_utf8_to_markup(const Evas_Object *eo_obj, const char *text)
|
|||
|
||||
sbuf = eina_strbuf_new();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
pos = pos2;
|
||||
pos2 = evas_string_char_next_get(text, pos2, &ch);
|
||||
if ((ch <= 0) || (pos2 <= 0)) break;
|
||||
_markup_get_text_utf8_append(sbuf, text);
|
||||
|
||||
if (ch == _NEWLINE)
|
||||
eina_strbuf_append(sbuf, "<br/>");
|
||||
else if (ch == _TAB)
|
||||
eina_strbuf_append(sbuf, "<tab/>");
|
||||
else if (ch == '<')
|
||||
eina_strbuf_append(sbuf, "<");
|
||||
else if (ch == '>')
|
||||
eina_strbuf_append(sbuf, ">");
|
||||
else if (ch == '&')
|
||||
eina_strbuf_append(sbuf, "&");
|
||||
else if (ch == _PARAGRAPH_SEPARATOR)
|
||||
eina_strbuf_append(sbuf, "<ps/>");
|
||||
else if (ch == _REPLACEMENT_CHAR)
|
||||
eina_strbuf_append(sbuf, "");
|
||||
else if (ch != '\r')
|
||||
{
|
||||
eina_strbuf_append_length(sbuf, text + pos, pos2 - pos);
|
||||
}
|
||||
}
|
||||
str = eina_strbuf_string_steal(sbuf);
|
||||
eina_strbuf_free(sbuf);
|
||||
return str;
|
||||
|
|
|
@ -2593,11 +2593,11 @@ START_TEST(evas_textblock_escaping)
|
|||
|
||||
const char *buf = "This · is";
|
||||
evas_object_textblock_text_markup_set(tb, buf);
|
||||
fail_if(strcmp(evas_object_textblock_text_markup_get(tb), buf));
|
||||
fail_if(strcmp(evas_object_textblock_text_markup_get(tb), "This \xc2\xb7 is"));
|
||||
|
||||
buf = "This is";
|
||||
evas_object_textblock_text_markup_set(tb, buf);
|
||||
fail_if(strcmp(evas_object_textblock_text_markup_get(tb), buf));
|
||||
fail_if(strcmp(evas_object_textblock_text_markup_get(tb), "This \xc2\xa0 is"));
|
||||
|
||||
END_TB_TEST();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue