diff --git a/ChangeLog b/ChangeLog
index 85dcb1808e..1a50d14e6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/NEWS b/NEWS
index df5af760a6..1da60c23f4 100644
--- a/NEWS
+++ b/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.
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index c9a5b82c40..7ef33df247 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -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, "
");
+ else if (ch == _TAB)
+ eina_strbuf_append(sbuf, "");
+ 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, "");
+ 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, "
");
- else if (ch == _TAB)
- eina_strbuf_append(sbuf, "");
- 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, "");
- 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;
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index 9f42021dc1..54865bb56e 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -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();
}