If g_convert fails, set bytes_written to 0 and close the iconv descriptor

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.
This commit is contained in:
Jeffrey Stedfast 2002-01-21 20:53:18 +00:00 committed by Jeffrey Stedfast
parent 0518fc417d
commit b23c1064bc
9 changed files with 63 additions and 2 deletions

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View 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> 2002-01-16 Sven Neumann <sven@gimp.org>
* acinclude.m4 * acinclude.m4

View File

@ -497,7 +497,12 @@ g_convert_with_fallback (const gchar *str,
utf8 = g_convert (str, len, "UTF-8", from_codeset, utf8 = g_convert (str, len, "UTF-8", from_codeset,
bytes_read, &inbytes_remaining, error); bytes_read, &inbytes_remaining, error);
if (!utf8) 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 /* Now the heart of the code. We loop through the UTF-8 string, and
* whenever we hit an offending character, we form fallback, convert * 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); g_iconv_close (cd);
if (bytes_written) if (bytes_written)
*bytes_written = outp - str; /* Doesn't include '\0' */ *bytes_written = outp - dest; /* Doesn't include '\0' */
g_free (utf8); g_free (utf8);