You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2001/02/08 03:37:30 UTC

cvs commit: apr/i18n/unix xlate.c

trawick     01/02/07 18:37:30

  Modified:    .        apr_common.m4 configure.in
               i18n/unix xlate.c
  Log:
  Handle the second parameter to iconv() differently, respecting that
  some systems declare it "const char **" while other systems (and current
  Single UNIX Spec.) declare it "char **".  We'll still have to add some
  hints for some platforms to avoid warnings.
  
  Revision  Changes    Path
  1.12      +33 -0     apr/apr_common.m4
  
  Index: apr_common.m4
  ===================================================================
  RCS file: /home/cvs/apr/apr_common.m4,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- apr_common.m4	2001/01/11 13:55:58	1.11
  +++ apr_common.m4	2001/02/08 02:37:29	1.12
  @@ -285,3 +285,36 @@
     $1="$$1 $2"; export $1
   ])
   
  +dnl
  +dnl APR_CHECK_ICONV_INBUF
  +dnl
  +dnl  Decide whether or not the inbuf parameter to iconv() is const.
  +dnl
  +dnl  We try to compile something without const.  If it fails to 
  +dnl  compile, we assume that the system's iconv() has const.  
  +dnl  Unfortunately, we won't realize when there was a compile
  +dnl  warning, so we allow a variable -- apr_iconv_inbuf_const -- to
  +dnl  be set in hints.m4 to specify whether or not iconv() has const
  +dnl  on this parameter.
  +dnl
  +AC_DEFUN(APR_CHECK_ICONV_INBUF,[
  +AC_MSG_CHECKING(for type of inbuf parameter to iconv)
  +if test "x$apr_iconv_inbuf_const" = "x"; then
  +    AC_TRY_COMPILE([
  +    #include <stddef.h>
  +    #include <iconv.h>
  +    ],[
  +    #if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR < 2
  +    #error We know this version of glibc has const char **, so fail this compile
  +    #endif
  +    iconv(0,(char **)0,(size_t *)0,(char **)0,(size_t *)0);
  +    ], apr_iconv_inbuf_const="0", apr_iconv_inbuf_const="1")
  +fi
  +if test "$apr_iconv_inbuf_const" = "1"; then
  +    AC_DEFINE(APR_ICONV_INBUF_CONST, 1, [Define if the inbuf parm to iconv() is const char **])
  +    msg="const char **"
  +else
  +    msg="char **"
  +fi
  +AC_MSG_RESULT([$msg])
  +])
  
  
  
  1.221     +3 -0      apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apr/configure.in,v
  retrieving revision 1.220
  retrieving revision 1.221
  diff -u -r1.220 -r1.221
  --- configure.in	2001/01/28 12:18:38	1.220
  +++ configure.in	2001/02/08 02:37:29	1.221
  @@ -245,6 +245,9 @@
   AC_CHECK_FUNC(_getch)
   AC_CHECK_FUNCS(gmtime_r localtime_r)
   AC_CHECK_FUNCS(iconv, [ iconv="1" ], [ iconv="0" ])
  +if test "$iconv" = "1"; then
  +  APR_CHECK_ICONV_INBUF
  +fi
   AC_CHECK_FUNCS(mmap, [ mmap="1" ], [ mmap="0" ])
   if test "$native_mmap_emul" = "1"; then
       mmap="1"
  
  
  
  1.19      +9 -3      apr/i18n/unix/xlate.c
  
  Index: xlate.c
  ===================================================================
  RCS file: /home/cvs/apr/i18n/unix/xlate.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- xlate.c	2001/01/28 11:33:52	1.18
  +++ xlate.c	2001/02/08 02:37:29	1.19
  @@ -80,6 +80,12 @@
   #include <iconv.h>
   #endif
   
  +#ifdef APR_ICONV_INBUF_CONST
  +#define ICONV_INBUF_TYPE const char **
  +#else
  +#define ICONV_INBUF_TYPE char **
  +#endif
  +
   #ifndef min
   #define min(x,y) ((x) <= (y) ? (x) : (y))
   #endif
  @@ -194,7 +200,7 @@
       }
   
       inbytes_left = outbytes_left = sizeof(inbuf);
  -    translated = iconv(convset->ich, &inbufptr, 
  +    translated = iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr, 
                          &inbytes_left, &outbufptr, &outbytes_left);
       if (translated != (size_t) -1 &&
           inbytes_left == 0 &&
  @@ -285,10 +291,10 @@
       size_t translated;
   
       if (convset->ich != (iconv_t)-1) {
  -        char *inbufptr = (char *)inbuf;
  +        const char *inbufptr = inbuf;
           char *outbufptr = outbuf;
           
  -        translated = iconv(convset->ich, &inbufptr, 
  +        translated = iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr, 
                              inbytes_left, &outbufptr, outbytes_left);
           /* If everything went fine but we ran out of buffer, don't
            * report it as an error.  Caller needs to look at the two