If g_convert fails, set bytes_written to 0 and close the iconv descriptor
authorJeffrey Stedfast <fejj@ximian.com>
Mon, 21 Jan 2002 20:53:18 +0000 (20:53 +0000)
committerJeffrey Stedfast <fejj@src.gnome.org>
Mon, 21 Jan 2002 20:53:18 +0000 (20:53 +0000)
2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>

* glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
set bytes_written to 0 and close the iconv descriptor that was
opened a few lines above. On a successful return, calculate
bytes_written to be outp - dest instead of outp - str.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gconvert.c

index 9404970..88effe9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 9404970..88effe9 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-21  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * glib/gconvert.c (g_convert_with_fallback): If g_convert fails,
+       set bytes_written to 0 and close the iconv descriptor that was
+       opened a few lines above. On a successful return, calculate
+       bytes_written to be outp - dest instead of outp - str.
+
 2002-01-16  Sven Neumann  <sven@gimp.org>
 
        * acinclude.m4
index 5ae83ef..e8adccd 100644 (file)
@@ -497,7 +497,12 @@ g_convert_with_fallback (const gchar *str,
   utf8 = g_convert (str, len, "UTF-8", from_codeset, 
                    bytes_read, &inbytes_remaining, error);
   if (!utf8)
-    return NULL;
+    {
+      g_iconv_close (cd);
+      if (bytes_written)
+        *bytes_written = 0;
+      return NULL;
+    }
 
   /* Now the heart of the code. We loop through the UTF-8 string, and
    * whenever we hit an offending character, we form fallback, convert
@@ -597,7 +602,7 @@ g_convert_with_fallback (const gchar *str,
   g_iconv_close (cd);
 
   if (bytes_written)
-    *bytes_written = outp - str;       /* Doesn't include '\0' */
+    *bytes_written = outp - dest;      /* Doesn't include '\0' */
 
   g_free (utf8);