projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
i18n: Ensure that every recoding starts from the initial shift state.
[pspp]
/
src
/
libpspp
/
i18n.c
diff --git
a/src/libpspp/i18n.c
b/src/libpspp/i18n.c
index 3735e95d8438821e6b338641581836f83dc7da7c..06c67d947928122ec8e75f665a4e6f9b62d9df45 100644
(file)
--- a/
src/libpspp/i18n.c
+++ b/
src/libpspp/i18n.c
@@
-142,6
+142,10
@@
recode_string_pool (const char *to, const char *from,
if ( (iconv_t) -1 == conv )
return xstrdup (text);
if ( (iconv_t) -1 == conv )
return xstrdup (text);
+ /* Put the converter into the initial shift state, in case there was any
+ state information left over from its last usage. */
+ iconv (conv, NULL, 0, NULL, 0);
+
for ( outbufferlength = 1 ; outbufferlength != 0; outbufferlength <<= 1 )
if ( outbufferlength > length)
break;
for ( outbufferlength = 1 ; outbufferlength != 0; outbufferlength <<= 1 )
if ( outbufferlength > length)
break;
@@
-176,6
+180,7
@@
recode_string_pool (const char *to, const char *from,
}
/* Fall through */
case E2BIG:
}
/* Fall through */
case E2BIG:
+ iconv (conv, NULL, 0, NULL, 0);
pool_free (pool, outbuf);
outbufferlength <<= 1;
outbuf = pool_malloc (pool, outbufferlength);
pool_free (pool, outbuf);
outbufferlength <<= 1;
outbuf = pool_malloc (pool, outbufferlength);