Fixed problem with unset variable (compose_char) in yaz_iconv system
[yaz-moved-to-github.git] / src / siconv.c
index cc90210..7e9d0fd 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: siconv.c,v 1.26 2006-08-27 19:04:03 adam Exp $
+ * $Id: siconv.c,v 1.29 2006-08-31 18:19:53 adam Exp $
  */
 /**
  * \file siconv.c
@@ -183,6 +183,7 @@ static unsigned long yaz_read_ISO8859_1 (yaz_iconv_t cd, unsigned char *inp,
     return x;
 }
 
+
 static size_t yaz_init_UTF8 (yaz_iconv_t cd, unsigned char *inp,
                              size_t inbytesleft, size_t *no_read)
 {
@@ -743,7 +744,7 @@ static unsigned long lookup_marc8(yaz_iconv_t cd,
         x = yaz_marc8r_9_conv(inp, inbytesleft, &no_read_sub, comb);
         if (x)
         {
-            *page_chr = "\033(1";
+            *page_chr = "\033$1";
             return x;
         }
         cd->my_errno = YAZ_ICONV_EILSEQ;
@@ -949,13 +950,6 @@ yaz_iconv_t yaz_iconv_open (const char *tocode, const char *fromcode)
     cd->read_handle = 0;
     cd->init_handle = 0;
     cd->my_errno = YAZ_ICONV_UNKNOWN;
-    cd->marc8_esc_mode = 'B';
-    cd->comb_offset = cd->comb_size = 0;
-    cd->compose_char = 0;
-
-    cd->write_marc8_comb_no = 0;
-    cd->write_marc8_last = 0;
-    cd->write_marc8_page_chr = "\033(B";
 
     /* a useful hack: if fromcode has leading @,
        the library not use YAZ's own conversions .. */
@@ -1065,7 +1059,7 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft,
     {
         if (cd->init_handle)
         {
-            size_t no_read;
+            size_t no_read = 0;
             size_t r = (cd->init_handle)(cd, (unsigned char *) *inbuf,
                                          *inbytesleft, &no_read);
             if (r)
@@ -1078,6 +1072,15 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft,
             *inbytesleft -= no_read;
             *inbuf += no_read;
         }
+        cd->marc8_esc_mode = 'B';
+        
+        cd->comb_offset = cd->comb_size = 0;
+        cd->compose_char = 0;
+        
+        cd->write_marc8_comb_no = 0;
+        cd->write_marc8_last = 0;
+        cd->write_marc8_page_chr = "\033(B";
+        
         cd->init_flag = 0;
         cd->unget_x = 0;
         cd->no_read_x = 0;