Pekka Lampila
2007-Oct-22 15:07 UTC
[Swfdec] 5 commits - libswfdec/swfdec_html_parser.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c test/trace
libswfdec/swfdec_html_parser.c | 8 +++--- libswfdec/swfdec_text_field_movie.c | 31 ++++++++++++++++++++------- libswfdec/swfdec_text_field_movie_as.c | 18 ++++++++------- test/trace/text-field-html-input-6.swf |binary test/trace/text-field-html-input-6.swf.trace | 28 ++++++++++++++++++++++++ test/trace/text-field-html-input-7.swf |binary test/trace/text-field-html-input-7.swf.trace | 26 ++++++++++++++++++++++ test/trace/text-field-html-input-8.swf |binary test/trace/text-field-html-input-8.swf.trace | 26 ++++++++++++++++++++++ test/trace/text-field-html-input.as | 3 +- 10 files changed, 119 insertions(+), 21 deletions(-) New commits: commit 35c8434fcb33a0df05e7a488798654325d434a94 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Mon Oct 22 17:59:28 2007 +0300 Fix a memory leak in TextField code diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c index 5d51698..bf3edce 100644 --- a/libswfdec/swfdec_text_field_movie.c +++ b/libswfdec/swfdec_text_field_movie.c @@ -343,6 +343,7 @@ swfdec_text_field_movie_free_paragraphs (SwfdecParagraph *paragraphs) { for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next) { pango_tab_array_free (((SwfdecBlock *)(iter->data))->tab_stops); + g_free (iter->data); } g_list_free (paragraphs[i].blocks); commit ec5a4b0e2ba4e62952a3f484a57567b35e64b3b3 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Mon Oct 22 17:50:38 2007 +0300 Free the GString used inside TextField diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c index ef8f2ce..5d51698 100644 --- a/libswfdec/swfdec_text_field_movie.c +++ b/libswfdec/swfdec_text_field_movie.c @@ -861,9 +861,15 @@ swfdec_text_field_movie_dispose (GObject *object) text->formats->data = NULL; } g_slist_free (text->formats); + text->formats = NULL; + + g_string_free (text->input, TRUE); + text->input = NULL; cairo_destroy (text->cr); + text->cr = NULL; cairo_surface_destroy (text->surface); + text->surface = NULL; G_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->dispose (object); } commit 6558d9d7481094f0c5b601cef0421b8cbd67a862 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Mon Oct 22 17:48:11 2007 +0300 Fix replaceText with multibyte chars Also make it actually replace and not just insert again diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c index df76d49..ef8f2ce 100644 --- a/libswfdec/swfdec_text_field_movie.c +++ b/libswfdec/swfdec_text_field_movie.c @@ -1544,7 +1544,14 @@ swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie *text, g_return_if_fail (start_index <= end_index); g_return_if_fail (str != NULL); - text->input = g_string_insert (text->input, start_index, str); + text->input = g_string_erase (text->input, + g_utf8_offset_to_pointer (text->input->str, start_index) - + text->input->str, + g_utf8_offset_to_pointer (text->input->str, end_index) - + g_utf8_offset_to_pointer (text->input->str, start_index)); + text->input = g_string_insert (text->input, + g_utf8_offset_to_pointer (text->input->str, start_index) - + text->input->str, str); first = TRUE; prev = NULL; commit f0e9d6a78c45216b4861c984005818a964d267f6 Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Mon Oct 22 17:34:52 2007 +0300 Add a test case with multibyte character to text-field-html-input diff --git a/test/trace/text-field-html-input-6.swf b/test/trace/text-field-html-input-6.swf index 6e68068..9640b1f 100644 Binary files a/test/trace/text-field-html-input-6.swf and b/test/trace/text-field-html-input-6.swf differ diff --git a/test/trace/text-field-html-input-6.swf.trace b/test/trace/text-field-html-input-6.swf.trace index e976072..43479bd 100644 --- a/test/trace/text-field-html-input-6.swf.trace +++ b/test/trace/text-field-html-input-6.swf.trace @@ -118,3 +118,31 @@ ab c 1/b: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url 2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url 3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: false condenseWhite: false +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: true condenseWhite: false +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: false condenseWhite: true +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: true condenseWhite: true +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning= leading=0 leftMargin=0 letterSpacing= rightMargin=0 size=12 tabStops= target= underline=false urldiff --git a/test/trace/text-field-html-input-7.swf b/test/trace/text-field-html-input-7.swf index bf7b7b4..f7e2285 100644 Binary files a/test/trace/text-field-html-input-7.swf and b/test/trace/text-field-html-input-7.swf differ diff --git a/test/trace/text-field-html-input-7.swf.trace b/test/trace/text-field-html-input-7.swf.trace index 5150aee..08c64de 100644 --- a/test/trace/text-field-html-input-7.swf.trace +++ b/test/trace/text-field-html-input-7.swf.trace @@ -116,3 +116,29 @@ ab c 1/b: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url 2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url 3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: false condenseWhite: false +a??c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+2/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: true condenseWhite: false +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: false condenseWhite: true +a??c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+2/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: true condenseWhite: true +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=undefined leading=0 leftMargin=0 letterSpacing=undefined rightMargin=0 size=12 tabStops= target= underline=false urldiff --git a/test/trace/text-field-html-input-8.swf b/test/trace/text-field-html-input-8.swf index c580f99..b84be18 100644 Binary files a/test/trace/text-field-html-input-8.swf and b/test/trace/text-field-html-input-8.swf differ diff --git a/test/trace/text-field-html-input-8.swf.trace b/test/trace/text-field-html-input-8.swf.trace index 6079e11..d5f60d6 100644 --- a/test/trace/text-field-html-input-8.swf.trace +++ b/test/trace/text-field-html-input-8.swf.trace @@ -116,3 +116,29 @@ ab c 1/b: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url 2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url 3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: false condenseWhite: false +a??c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+2/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: true condenseWhite: false +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: false condenseWhite: true +a??c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+2/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+5: multiline: true condenseWhite: true +a?? c +<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">a??</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">c</FONT></P> +0/a: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+1/??: align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+2/ : align=right blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false url+3/c: align=left blockIndent=0 bold=false bullet=false color=0 display=block font=Times New Roman indent=0 italic=false kerning=false leading=0 leftMargin=0 letterSpacing=0 rightMargin=0 size=12 tabStops= target= underline=false urldiff --git a/test/trace/text-field-html-input.as b/test/trace/text-field-html-input.as index da34d4a..a6f0558 100644 --- a/test/trace/text-field-html-input.as +++ b/test/trace/text-field-html-input.as @@ -37,7 +37,8 @@ var texts = [ "a\rb", "a\r\nb", "a\r\rb", - "a<p align='right'>b</p>c" + "a<p align='right'>b</p>c", + "a<p align='right'>??</p>c" ]; t.html = true; commit 7c5b356d5bb6389a4a6f4e9b71b6812e8e9abe9c Author: Pekka Lampila <pekka.lampila at iki.fi> Date: Mon Oct 22 17:34:25 2007 +0300 Make TextField work correctly when multibyte characters are used diff --git a/libswfdec/swfdec_html_parser.c b/libswfdec/swfdec_html_parser.c index a6a0aa0..00c085c 100644 --- a/libswfdec/swfdec_html_parser.c +++ b/libswfdec/swfdec_html_parser.c @@ -63,8 +63,8 @@ swfdec_text_field_movie_html_parse_close_tag (ParserData *data, ParserTag *tag) ParserTag *n = g_new0 (ParserTag, 1); n->name = f->name; n->name_length = f->name_length; - n->index = data->text->len; - n->end_index = data->text->len + 1; + n->index = g_utf8_strlen (data->text->str, -1); + n->end_index = n->index + 1; n->format = swfdec_text_format_copy (f->format); data->tags_closed = g_slist_prepend (data->tags_closed, n); break; @@ -73,7 +73,7 @@ swfdec_text_field_movie_html_parse_close_tag (ParserData *data, ParserTag *tag) data->text = g_string_append_c (data->text, '\n'); } - tag->end_index = data->text->len; + tag->end_index = g_utf8_strlen (data->text->str, -1); data->tags_open = g_slist_remove (data->tags_open, tag); data->tags_closed = g_slist_prepend (data->tags_closed, tag); @@ -313,7 +313,7 @@ swfdec_text_field_movie_html_parse_tag (ParserData *data, const char *p) tag->name = name; tag->name_length = name_length; tag->format = SWFDEC_TEXT_FORMAT (swfdec_text_format_new (data->cx)); - tag->index = data->text->len; + tag->index = g_utf8_strlen (data->text->str, -1); data->tags_open = g_slist_prepend (data->tags_open, tag); diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c index 0bc39e1..df76d49 100644 --- a/libswfdec/swfdec_text_field_movie.c +++ b/libswfdec/swfdec_text_field_movie.c @@ -1013,7 +1013,7 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text, g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text)); g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format)); g_return_if_fail (start_index < end_index); - g_return_if_fail (end_index <= text->input->len); + g_return_if_fail (end_index <= g_utf8_strlen (text->input->str, -1)); g_assert (text->formats != NULL); g_assert (text->formats->data != NULL); @@ -1031,7 +1031,7 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text, findex_end_index ((SwfdecFormatIndex *)iter->next->data)->index; } else { - findex_end_index = text->input->len; + findex_end_index = g_utf8_strlen (text->input->str, -1); } if (findex_end_index <= start_index) @@ -1093,7 +1093,7 @@ swfdec_text_field_movie_get_text_format (SwfdecTextFieldMovie *text, g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text)); g_assert (start_index < end_index); - g_assert (end_index <= text->input->len); + g_assert (end_index <= g_utf8_strlen (text->input->str, -1)); g_assert (text->formats != NULL); g_assert (text->formats->data != NULL); @@ -1540,7 +1540,7 @@ swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie *text, gboolean first; g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text)); - g_return_if_fail (end_index <= text->input->len); + g_return_if_fail (end_index <= g_utf8_strlen (text->input->str, -1)); g_return_if_fail (start_index <= end_index); g_return_if_fail (str != NULL); @@ -1553,8 +1553,9 @@ swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie *text, findex = iter->data; if (findex->index >= start_index) { - if (end_index == text->input->len || (iter->next != NULL && - ((SwfdecFormatIndex *)iter->next->data)->index <= end_index)) + if (end_index == g_utf8_strlen (text->input->str, -1) || + (iter->next != NULL && + ((SwfdecFormatIndex *)iter->next->data)->index <= end_index)) { g_free (iter->data); text->formats = g_slist_remove (text->formats, iter->data); @@ -1571,7 +1572,7 @@ swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie *text, } prev = iter; } - if (end_index == text->input->len) { + if (end_index == g_utf8_strlen (text->input->str, -1)) { if (SWFDEC_AS_OBJECT (text)->context->version < 8) { SWFDEC_FIXME ("replaceText to the end of the TextField might use wrong text format on version 7"); } diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c index 48057e8..bef2ca6 100644 --- a/libswfdec/swfdec_text_field_movie_as.c +++ b/libswfdec/swfdec_text_field_movie_as.c @@ -942,15 +942,16 @@ swfdec_text_field_movie_setTextFormat (SwfdecAsContext *cx, i = 0; if (argc >= 2) { start_index = swfdec_as_value_to_integer (cx, &argv[i++]); - start_index = CLAMP (start_index, 0, (int)text->input->len); + start_index = CLAMP (start_index, 0, g_utf8_strlen (text->input->str, -1)); } else { start_index = 0; } if (argc >= 3) { end_index = swfdec_as_value_to_integer (cx, &argv[i++]); - end_index = CLAMP (end_index, start_index, (int)text->input->len); + end_index + CLAMP (end_index, start_index, g_utf8_strlen (text->input->str, -1)); } else { - end_index = text->input->len; + end_index = g_utf8_strlen (text->input->str, -1); } if (start_index == end_index) return; @@ -979,15 +980,16 @@ swfdec_text_field_movie_getTextFormat (SwfdecAsContext *cx, if (argc == 0) { start_index = 0; - end_index = text->input->len; + end_index = g_utf8_strlen (text->input->str, -1); } else { start_index = swfdec_as_value_to_integer (cx, &argv[0]); - start_index = MIN (start_index, text->input->len); + start_index = MIN (start_index, g_utf8_strlen (text->input->str, -1)); if (argc == 1) { end_index = start_index + 1; } else { end_index = swfdec_as_value_to_integer (cx, &argv[1]); - end_index = CLAMP (end_index, start_index, text->input->len); + end_index + CLAMP (end_index, start_index, g_utf8_strlen (text->input->str, -1)); } } @@ -1011,11 +1013,11 @@ swfdec_text_field_movie_replaceText (SwfdecAsContext *cx, SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "iis", &start_index, &end_index, &str); - start_index = MIN (start_index, (int)text->input->len); + start_index = MIN (start_index, g_utf8_strlen (text->input->str, -1)); if (start_index < 0) return; - end_index = MIN (end_index, (int)text->input->len); + end_index = MIN (end_index, g_utf8_strlen (text->input->str, -1)); if (end_index < start_index) return;
Apparently Analagous Threads
- 12 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie.h test/trace
- 20 commits - libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h
- 18 commits - libswfdec/swfdec_player_internal.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_format.c libswfdec/swfdec_text_format.h libswfdec/swfdec_xml.c libswfdec/swfdec_xml_node.c libswfdec/swfdec_xml_node.h test/trace
- 6 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c
- 2 commits - libswfdec/swfdec_sound.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie_html.c