X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fi18n.c;h=360c9abd3145ca6cc64a66996bfe309d164fa624;hb=762876f19fa870401ae882515de1b58703b73ac4;hp=bcac52cf58b35b062aa6a45503887d84cc68c780;hpb=655bf3a3917cdf16f99fcbb680d2bf3159126a93;p=pspp diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index bcac52cf58..360c9abd31 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -54,6 +54,9 @@ recode_string(enum conv_id how, const char *text, int length) /* FIXME: Need to ensure that this char is valid in the target encoding */ const char fallbackchar = '?'; + if ( text == NULL ) + return NULL; + if ( length == -1 ) length = strlen(text); @@ -71,8 +74,6 @@ recode_string(enum conv_id how, const char *text, int length) inbytes = length; do { - - result = iconv(convertor[how], &ip, &inbytes, &op, &outbytes); @@ -108,11 +109,17 @@ recode_string(enum conv_id how, const char *text, int length) } } - } while ( -1 == result ); + if (outbytes == 0 ) + { + char *const oldaddr = outbuf; + outbuf = xrealloc(outbuf, outbufferlength + 1); + + op += (outbuf - oldaddr) ; + } + *op = '\0'; - return outbuf; }