]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Make mixed_string_buffer_done always return UTF-8 string
authorDaiki Ueno <ueno@gnu.org>
Wed, 7 May 2014 03:32:27 +0000 (12:32 +0900)
committerDaiki Ueno <ueno@gnu.org>
Wed, 7 May 2014 03:33:27 +0000 (12:33 +0900)
gettext-tools/src/xgettext.c
gettext-tools/src/xgettext.h

index 339afcf11c3eadbcaf7de41411f4e6e3ed416042..7481d3aa4febc916b4271e908034102ae72c5e1a 100644 (file)
@@ -3247,40 +3247,22 @@ mixed_string_buffer_append_unicode (struct mixed_string_buffer *bp, int c)
 char *
 mixed_string_buffer_done (struct mixed_string_buffer *bp)
 {
-  if (bp->utf8_buffer || bp->utf16_surr != 0)
-    {
-      char *utf8_buffer;
-
-      /* Flush all into bp->utf8_buffer.  */
-      mixed_string_buffer_flush_utf16_surr (bp);
-      mixed_string_buffer_flush_curr_buffer (bp, bp->line_number);
-      /* NUL-terminate it.  */
-      mixed_string_buffer_grow_utf8_buffer (bp, 1);
-      bp->utf8_buffer[bp->utf8_buflen] = '\0';
-
-      /* Free curr_buffer and bp itself.  */
-      utf8_buffer = bp->utf8_buffer;
-      free (bp->curr_buffer);
-      free (bp);
-
-      /* Return it.  */
-      return utf8_buffer;
-    }
-  else
-    {
-      char *curr_buffer;
+  char *utf8_buffer;
 
-      /* NUL-terminate it.  */
-      mixed_string_buffer_append_to_curr_buffer (bp, '\0');
+  /* Flush all into bp->utf8_buffer.  */
+  mixed_string_buffer_flush_utf16_surr (bp);
+  mixed_string_buffer_flush_curr_buffer (bp, bp->line_number);
+  /* NUL-terminate it.  */
+  mixed_string_buffer_grow_utf8_buffer (bp, 1);
+  bp->utf8_buffer[bp->utf8_buflen] = '\0';
 
-      /* Free utf8_buffer and bp itself.  */
-      curr_buffer = bp->curr_buffer;
-      free (bp->utf8_buffer);
-      free (bp);
+  /* Free curr_buffer and bp itself.  */
+  utf8_buffer = bp->utf8_buffer;
+  free (bp->curr_buffer);
+  free (bp);
 
-      /* Return it.  */
-      return curr_buffer;
-    }
+  /* Return it.  */
+  return utf8_buffer;
 }
 
 
index 706309a1a549b1501ff9384b2353dcb1cc694ff1..059a419d341d84cec3ed8926c0df338e1573d6f4 100644 (file)
@@ -370,9 +370,7 @@ extern void mixed_string_buffer_append_char (struct mixed_string_buffer *bp,
 extern void mixed_string_buffer_append_unicode (struct mixed_string_buffer *bp,
                                                 int c);
 
-/* Frees mixed_string_buffer and returns the accumulated string.  If
-   any Unicode character has been added to BP, the result is in UTF-8.
-   Otherwise, it doesn't do any conversion.  */
+/* Frees mixed_string_buffer and returns the accumulated string in UTF-8.  */
 extern char * mixed_string_buffer_done (struct mixed_string_buffer *bp);