From 6aad665c4854f6dd4039bdb592f95037e9c30cb7 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Mon, 1 Dec 2014 13:39:30 +0900 Subject: c#: Recognize Unicode surrogate character pair * x-csharp.c (accumulate_escaped): Change the first argument type from 'struct string_buffer *' to 'struct mixed_string_buffer *', for Unicode surrogate character pair handling; all callers changed. Reported by Petr Kadlec at: . --- gettext-tools/src/ChangeLog | 9 +++++++++ gettext-tools/src/x-csharp.c | 22 ++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'gettext-tools') diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index e45bbc5..4fb7bdb 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,12 @@ +2014-12-01 Daiki Ueno + + c#: Recognize Unicode surrogate character pair + * x-csharp.c (accumulate_escaped): Change the first argument type + from 'struct string_buffer *' to 'struct mixed_string_buffer *', + for Unicode surrogate character pair handling; all callers + changed. Reported by Petr Kadlec at: + . + 2014-11-28 Daiki Ueno * msgfilter.c (prepare_read): Simplify the last commit 06e206f5, diff --git a/gettext-tools/src/x-csharp.c b/gettext-tools/src/x-csharp.c index ffadb0d..5091c3b 100644 --- a/gettext-tools/src/x-csharp.c +++ b/gettext-tools/src/x-csharp.c @@ -1491,7 +1491,7 @@ do_getc_escaped () /* Read a regular string literal or character literal. See ECMA-334 sections 9.4.4.4., 9.4.4.5. */ static void -accumulate_escaped (struct string_buffer *literal, int delimiter) +accumulate_escaped (struct mixed_string_buffer *literal, int delimiter) { int c; @@ -1516,7 +1516,8 @@ accumulate_escaped (struct string_buffer *literal, int delimiter) } if (c == '\\') c = do_getc_escaped (); - string_buffer_append_unicode (literal, c); + if (literal) + mixed_string_buffer_append_unicode (literal, c); } } @@ -1637,13 +1638,14 @@ phase6_get (token_ty *tp) case '"': /* Regular string literal. */ { - struct string_buffer literal; + struct mixed_string_buffer *literal; lexical_context = lc_string; - init_string_buffer (&literal); - accumulate_escaped (&literal, '"'); - tp->string = xstrdup (string_buffer_result (&literal)); - free_string_buffer (&literal); + literal = mixed_string_buffer_alloc (lexical_context, + logical_file_name, + logical_line_number); + accumulate_escaped (literal, '"'); + tp->string = mixed_string_buffer_done (literal); tp->comment = add_reference (savable_comment); lexical_context = lc_outside; tp->type = token_type_string_literal; @@ -1653,11 +1655,7 @@ phase6_get (token_ty *tp) case '\'': /* Character literal. */ { - struct string_buffer literal; - - init_string_buffer (&literal); - accumulate_escaped (&literal, '\''); - free_string_buffer (&literal); + accumulate_escaped (NULL, '\''); tp->type = token_type_other; return; } -- cgit v1.1