bug-gnu-libiconv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnu-libiconv] Re: libiconv interface compliance


From: Bruno Haible
Subject: [bug-gnu-libiconv] Re: libiconv interface compliance
Date: Sat, 31 Mar 2007 18:12:30 +0200
User-agent: KMail/1.5.4

Hello,

Andreas Krennmair wrote:
> I noticed that GNU libiconv's iconv() function, when compiled on systems
> that have no own iconv() function, looks like this:
> 
> extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, 
> char* * outbuf, size_t *outbytesleft); 
> 
> while according to SuSv3, iconv() is supposed to look like this:
> 
> size_t iconv(iconv_t cd, char **restrict inbuf, size_t *restrict inbytesleft, 
> char **restrict outbuf, size_t *restrict outbytesleft);
> ...
> Is there a special reason why this is done this way?

The POSIX interface is broken, since the input buffer is not written to by
the function. This POSIX interface forces casts in the programs that use
iconv(). I hoped that they would fix it someday. But that hasn't happened.
The brokenness has spread.

In the current situation, it probably causes less problems if libiconv
uses the same function prototype (since for porting to glibc systems, the
programmer will have to insert the stupid and pointless cast anyway).
Therefore I'm applying this patch.

2007-03-31  Bruno Haible  <address@hidden>

        Follow broken iconv() prototype in POSIX.
        * configure.ac (ICONV_CONST): Set to empty if the system has no iconv.
        Reported by Andreas Krennmair <address@hidden>.

*** configure.ac        5 Mar 2007 01:01:56 -0000       1.16
--- configure.ac        31 Mar 2007 16:06:15 -0000
***************
*** 87,96 ****
  
  dnl           checks for header files, functions and declarations
  
! if test "$am_cv_func_iconv" = yes -a -z "$am_cv_proto_iconv_arg1"; then
!   ICONV_CONST=""
! else
    ICONV_CONST="const"
  fi
  AC_SUBST(ICONV_CONST)
  
--- 87,96 ----
  
  dnl           checks for header files, functions and declarations
  
! if test "$am_cv_func_iconv" = yes -a -n "$am_cv_proto_iconv_arg1"; then
    ICONV_CONST="const"
+ else
+   ICONV_CONST=""
  fi
  AC_SUBST(ICONV_CONST)
  


> Also, the libiconv ChangeLog contains the following entry, dated
> 2003-04-05:
> (ICONV_CONST): Define to const if the system has no iconv.

The ICONV_CONST in src/iconv.c does not matter to programs that use libiconv.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]