[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnulib-bug
Subject:    striconveha module: bug fixes
From:       Bruno Haible <bruno () clisp ! org>
Date:       2007-01-24 0:45:07
Message-ID: 200701240146.31902.bruno () clisp ! org
[Download RAW message or body]

This fixes two bugs in the new striconveha module.

2007-01-23  Bruno Haible  <bruno@clisp.org>

	* lib/striconveha.c (mem_iconveha): Fix endless recursion. Try all
	encodings without forgiving before trying any encoding with handler.
	(str_iconveha): Try all encodings without forgiving before trying any
	encoding with handler.

*** lib/striconveha.c	23 Jan 2007 01:09:41 -0000	1.2
--- lib/striconveha.c	24 Jan 2007 00:43:54 -0000
***************
*** 163,175 ****
        for (alias = autodetect_list; alias != NULL; alias = alias->next)
  	if (strcmp (from_codeset, alias->name) == 0)
  	  {
! 	    const char * const *encodings = alias->encodings_to_try;
  
  	    do
  	      {
  		retval = mem_iconveha (src, srclen,
! 				       from_codeset, to_codeset, handler,
! 				       offsets, resultp, lengthp);
  		if (!(retval < 0 && errno == EILSEQ))
  		  return retval;
  		encodings++;
--- 163,194 ----
        for (alias = autodetect_list; alias != NULL; alias = alias->next)
  	if (strcmp (from_codeset, alias->name) == 0)
  	  {
! 	    const char * const *encodings;
  
+ 	    if (handler != iconveh_error)
+ 	      {
+ 		/* First try all encodings without any forgiving.  */
+ 		encodings = alias->encodings_to_try;
+ 		do
+ 		  {
+ 		    retval = mem_iconveha (src, srclen,
+ 					   *encodings, to_codeset,
+ 					   iconveh_error, offsets,
+ 					   resultp, lengthp);
+ 		    if (!(retval < 0 && errno == EILSEQ))
+ 		      return retval;
+ 		    encodings++;
+ 		  }
+ 		while (*encodings != NULL);
+ 	      }
+ 
+ 	    encodings = alias->encodings_to_try;
  	    do
  	      {
  		retval = mem_iconveha (src, srclen,
! 				       *encodings, to_codeset,
! 				       handler, offsets,
! 				       resultp, lengthp);
  		if (!(retval < 0 && errno == EILSEQ))
  		  return retval;
  		encodings++;
***************
*** 204,214 ****
        for (alias = autodetect_list; alias != NULL; alias = alias->next)
  	if (strcmp (from_codeset, alias->name) == 0)
  	  {
! 	    const char * const *encodings = alias->encodings_to_try;
  
  	    do
  	      {
! 		result = str_iconveha (src, *encodings, to_codeset, handler);
  		if (!(result == NULL && errno == EILSEQ))
  		  return result;
  		encodings++;
--- 223,252 ----
        for (alias = autodetect_list; alias != NULL; alias = alias->next)
  	if (strcmp (from_codeset, alias->name) == 0)
  	  {
! 	    const char * const *encodings;
! 
! 	    if (handler != iconveh_error)
! 	      {
! 		/* First try all encodings without any forgiving.  */
! 		encodings = alias->encodings_to_try;
! 		do
! 		  {
! 		    result = str_iconveha (src,
! 					   *encodings, to_codeset,
! 					   iconveh_error);
! 		    if (!(result == NULL && errno == EILSEQ))
! 		      return result;
! 		    encodings++;
! 		  }
! 		while (*encodings != NULL);
! 	      }
  
+ 	    encodings = alias->encodings_to_try;
  	    do
  	      {
! 		result = str_iconveha (src,
! 				       *encodings, to_codeset,
! 				       handler);
  		if (!(result == NULL && errno == EILSEQ))
  		  return result;
  		encodings++;




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic