gst-libs/gst/tag/tags.c: Try encodings from all environment variables, not just those...
authorTim-Philipp Müller <tim@centricular.net>
Thu, 12 Apr 2007 16:36:36 +0000 (16:36 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 12 Apr 2007 16:36:36 +0000 (16:36 +0000)
Original commit message from CVS:
* gst-libs/gst/tag/tags.c: (gst_tag_freeform_string_to_utf8):
Try encodings from all environment variables, not just those in the
first environment variable that is set.

ChangeLog
gst-libs/gst/tag/tags.c

index 4aff7a4..5da8fa4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-12  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst-libs/gst/tag/tags.c: (gst_tag_freeform_string_to_utf8):
+         Try encodings from all environment variables, not just those in the
+         first environment variable that is set.
+
 2007-04-12  Wim Taymans  <wim@fluendo.com>
 
        * gst/videorate/gstvideorate.c: (gst_video_rate_setcaps),
index e1966cf..706ab96 100644 (file)
@@ -246,7 +246,7 @@ gchar *
 gst_tag_freeform_string_to_utf8 (const gchar * data, gint size,
     const gchar ** env_vars)
 {
-  const gchar *env = NULL;
+  const gchar *cur_loc = NULL;
   gsize bytes_read;
   gchar *utf8 = NULL;
 
@@ -260,33 +260,35 @@ gst_tag_freeform_string_to_utf8 (const gchar * data, gint size,
   if (g_utf8_validate (data, size, NULL))
     return g_strndup (data, size);
 
-  while ((env == NULL || *env == '\0') && env_vars && *env_vars != NULL) {
-    env = g_getenv (*env_vars);
-    ++env_vars;
-  }
-
-  /* Try charsets specified via the environment */
-  if (env != NULL && *env != '\0') {
-    gchar **c, **csets;
-
-    csets = g_strsplit (env, G_SEARCHPATH_SEPARATOR_S, -1);
+  while (env_vars && *env_vars != NULL) {
+    const gchar *env = NULL;
 
-    for (c = csets; c && *c; ++c) {
-      if ((utf8 = g_convert (data, size, "UTF-8", *c, &bytes_read, NULL, NULL))) {
-        if (bytes_read == size) {
-          g_strfreev (csets);
-          goto beach;
+    /* Try charsets specified via the environment */
+    env = g_getenv (*env_vars);
+    if (env != NULL && *env != '\0') {
+      gchar **c, **csets;
+
+      csets = g_strsplit (env, G_SEARCHPATH_SEPARATOR_S, -1);
+
+      for (c = csets; c && *c; ++c) {
+        if ((utf8 =
+                g_convert (data, size, "UTF-8", *c, &bytes_read, NULL, NULL))) {
+          if (bytes_read == size) {
+            g_strfreev (csets);
+            goto beach;
+          }
+          g_free (utf8);
+          utf8 = NULL;
         }
-        g_free (utf8);
-        utf8 = NULL;
       }
-    }
 
-    g_strfreev (csets);
+      g_strfreev (csets);
+    }
+    ++env_vars;
   }
 
   /* Try current locale (if not UTF-8) */
-  if (!g_get_charset (&env)) {
+  if (!g_get_charset (&cur_loc)) {
     if ((utf8 = g_locale_to_utf8 (data, size, &bytes_read, NULL, NULL))) {
       if (bytes_read == size) {
         goto beach;