Flush the iconv sequence for each sequence in a .chr file. This fixes
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 25 May 2007 14:05:52 +0000 (14:05 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 25 May 2007 14:05:52 +0000 (14:05 +0000)
nothing because the ICONV handles in use always flushed themselves. They
may not always do that, so we must do it.

util/charmap.c

index 85c9239..2ca7af1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: charmap.c,v 1.45 2007-05-25 13:46:01 adam Exp $
+/* $Id: charmap.c,v 1.46 2007-05-25 14:05:52 adam Exp $
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -420,6 +420,10 @@ static int scan_to_utf8(yaz_iconv_t t, ucs4_t *from, size_t inlen,
     else
     {
         ret = yaz_iconv(t, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+        if (ret != (size_t) (-1))
+            ret = yaz_iconv(t, 0, 0, &outbuf, &outbytesleft);
+        
+            
         if (ret == (size_t) (-1))
         {
            yaz_log(YLOG_LOG, "from: %2X %2X %2X %2X",
@@ -454,6 +458,9 @@ static int scan_string(char *s_native,
         size_t ret;            
        ret = yaz_iconv(t_unicode, &inbuf, &inbytesleft,
                         &outbuf, &outbytesleft);
+        if (ret != (size_t)(-1))
+            ret = yaz_iconv(t_unicode, 0, 0, &outbuf, &outbytesleft);
+            
         if (ret == (size_t)(-1))
             return -1;
         i = (outbuf - (char*) arg)/sizeof(ucs4_t);