]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
c#: Recognize Unicode surrogate character pair
authorDaiki Ueno <ueno@gnu.org>
Mon, 1 Dec 2014 04:39:30 +0000 (13:39 +0900)
committerDaiki Ueno <ueno@gnu.org>
Mon, 1 Dec 2014 04:44:49 +0000 (13:44 +0900)
* 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:
<https://savannah.gnu.org/bugs/?32505>.

gettext-tools/src/ChangeLog
gettext-tools/src/x-csharp.c

index e45bbc5f8bf4bfd00f722cb4a950c12c201ff546..4fb7bdbf0b0f102ffbe7c19e41ec22f6344f7d66 100644 (file)
@@ -1,3 +1,12 @@
+2014-12-01  Daiki Ueno  <ueno@gnu.org>
+
+       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:
+       <https://savannah.gnu.org/bugs/?32505>.
+
 2014-11-28  Daiki Ueno  <ueno@gnu.org>
 
        * msgfilter.c (prepare_read): Simplify the last commit 06e206f5,
index ffadb0d7bcf7c5587f90eeaf87d0bb0b02b514af..5091c3b8903d5a48e598719929f8cb99c9d8735d 100644 (file)
@@ -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;
           }