added test for iconv parm 2 constness

This commit is contained in:
dockes 2007-06-19 07:52:33 +00:00
parent 18b3573358
commit c4b099e8d3
5 changed files with 249 additions and 545 deletions

View File

@ -20,3 +20,7 @@
/* Compile the inotify interface */
#undef RCL_USE_INOTIFY
/* iconv parameter 2 is const char** */
#undef RCL_ICONV_INBUF_CONST

749
src/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -113,7 +113,7 @@ fi
##### Look for iconv. We first look for libiconv in /usr/local/lib:/usr/lib
## then in libc (Linux, solaris)
AC_LANG(C)
AC_LANG(C++)
LIBICONV=""
S_LDFLAGS=$LDFLAGS
dir=/usr/local/lib
@ -143,6 +143,18 @@ fi
#echo LIBICONV $LIBICONV
#echo INCICONV $INCICONV
CPPFLAGS="$CPPFLAGS $INCICONV"
AC_MSG_CHECKING(for type of inbuf parameter to iconv)
AC_TRY_COMPILE([
#include <stddef.h>
#include <iconv.h>
],[
iconv(0,(const char **)0,(size_t *)0,(char **)0,(size_t *)0);
], rcl_iconv_inbuf_const="1", rcl_iconv_inbuf_const="0")
if test X$rcl_iconv_inbuf_const = X1 ; then
AC_DEFINE(RCL_ICONV_INBUF_CONST, 1, [iconv parameter 2 is const char**])
fi
#### Look for Xapian
AC_PATH_PROG(XAPIAN_CONFIG, xapian-config, no)
if test "$XAPIAN_CONFIG" = "no" ; then

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: csguess.cpp,v 1.5 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: csguess.cpp,v 1.6 2007-06-19 07:52:33 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -51,6 +51,12 @@ using std::string;
#include <iconv.h>
#include "csguess.h"
#include "autoconfig.h"
#ifdef RCL_ICONV_INBUF_CONST
#define ICV_P2_TYPE const char**
#else
#define ICV_P2_TYPE char**
#endif
// The values from estraier were 32768, 256, 0.001
const int ICONVCHECKSIZ = 32768;
@ -73,13 +79,7 @@ static int transcodeErrCnt(const char *ptr, int size,
while(isiz > 0){
osiz = 2*ICONVCHECKSIZ;
wp = obuf;
if(iconv(ic,
#if defined(_LIBICONV_VERSION)
(const char **)&rp,
#else
(char **)&rp,
#endif
&isiz, &wp, &osiz) == (size_t)-1){
if(iconv(ic, (ICV_P2_TYPE)&rp, &isiz, &wp, &osiz) == (size_t)-1){
if(errno == EILSEQ || errno == EINVAL){
rp++;
isiz--;

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: transcode.cpp,v 1.10 2007-05-30 12:31:19 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: transcode.cpp,v 1.11 2007-06-19 07:52:33 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -32,11 +32,12 @@ using std::string;
#include "transcode.h"
#include "debuglog.h"
#include "autoconfig.h"
#if !defined(_LIBICONV_VERSION)
#define CHARPP (char **)
#ifdef RCL_ICONV_INBUF_CONST
#define ICV_P2_TYPE const char**
#else
#define CHARPP
#define ICV_P2_TYPE char**
#endif
bool transcode(const string &in, string &out, const string &icode,
@ -66,7 +67,7 @@ bool transcode(const string &in, string &out, const string &icode,
osiz = OBSIZ;
int isiz0=isiz;
if(iconv(ic, CHARPP&ip, &isiz, &op, &osiz) == (size_t)-1 &&
if(iconv(ic, (ICV_P2_TYPE)&ip, &isiz, &op, &osiz) == (size_t)-1 &&
errno != E2BIG) {
#if 0
out.erase();