more iconv open cache fixing: close discarded entry!
This commit is contained in:
parent
47b9f72ee4
commit
04cbb5cd8b
@ -63,6 +63,10 @@ bool transcode(const string &in, string &out, const string &icode,
|
|||||||
|
|
||||||
#ifdef ICONV_CACHE_OPEN
|
#ifdef ICONV_CACHE_OPEN
|
||||||
if (cachedicode.compare(icode) || cachedocode.compare(ocode)) {
|
if (cachedicode.compare(icode) || cachedocode.compare(ocode)) {
|
||||||
|
if (ic != (iconv_t)-1) {
|
||||||
|
iconv_close(ic);
|
||||||
|
ic = (iconv_t)-1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if((ic = iconv_open(ocode.c_str(), icode.c_str())) == (iconv_t)-1) {
|
if((ic = iconv_open(ocode.c_str(), icode.c_str())) == (iconv_t)-1) {
|
||||||
out = string("iconv_open failed for ") + icode
|
out = string("iconv_open failed for ") + icode
|
||||||
@ -73,6 +77,7 @@ bool transcode(const string &in, string &out, const string &icode,
|
|||||||
#endif
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ICONV_CACHE_OPEN
|
#ifdef ICONV_CACHE_OPEN
|
||||||
cachedicode.assign(icode);
|
cachedicode.assign(icode);
|
||||||
cachedocode.assign(ocode);
|
cachedocode.assign(ocode);
|
||||||
@ -113,8 +118,7 @@ bool transcode(const string &in, string &out, const string &icode,
|
|||||||
icopen = false;
|
icopen = false;
|
||||||
if(iconv_close(ic) == -1) {
|
if(iconv_close(ic) == -1) {
|
||||||
out.erase();
|
out.erase();
|
||||||
out = string("iconv_close failed for ") + icode
|
out = string("iconv_close failed for ") + icode + " -> " + ocode;
|
||||||
+ " -> " + ocode;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -122,12 +126,14 @@ bool transcode(const string &in, string &out, const string &icode,
|
|||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (icopen)
|
if (icopen) {
|
||||||
#ifndef ICONV_CACHE_OPEN
|
#ifndef ICONV_CACHE_OPEN
|
||||||
iconv_close(ic);
|
iconv_close(ic);
|
||||||
#else
|
#else
|
||||||
|
// Just reset conversion
|
||||||
iconv(ic, 0, 0, 0, 0);
|
iconv(ic, 0, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (mecnt)
|
if (mecnt)
|
||||||
LOGDEB(("transcode: [%s]->[%s] %d errors\n",
|
LOGDEB(("transcode: [%s]->[%s] %d errors\n",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user