mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 00:12:19 +01:00 
			
		
		
		
	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:
		
				
					committed by
					
						 Jeffrey Stedfast
						Jeffrey Stedfast
					
				
			
			
				
	
			
			
			
						parent
						
							0518fc417d
						
					
				
				
					commit
					b23c1064bc
				
			| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user