Update headers and omit CVS Ids.
[yaz-moved-to-github.git] / util / yaziconv.c
index 3cf8afe..9f7f797 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * Copyright (C) 1995-2005, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data
  * See the file LICENSE for details.
- *
- * $Id: yaziconv.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -44,6 +42,11 @@ void convert (FILE *inf, yaz_iconv_t cd, int verbose)
                 {
                     if (outbuf != outbuf0)
                         fwrite (outbuf0, 1, outbuf - outbuf0, stdout);
+                    outbuf = outbuf0;
+                    outbytesleft = CHUNK_OUT;
+                    r = yaz_iconv (cd, 0, 0, &outbuf, &outbytesleft);
+                    if (outbuf != outbuf0)
+                        fwrite (outbuf0, 1, outbuf - outbuf0, stdout);
                     break;
                 }
                 inbytesleft = r;
@@ -51,8 +54,8 @@ void convert (FILE *inf, yaz_iconv_t cd, int verbose)
         }
         if (verbose > 1)
         {
-            fprintf (stderr, "yaz_iconv: inbytesleft=%d outbytesleft=%d\n",
-                     inbytesleft, outbytesleft);
+            fprintf (stderr, "yaz_iconv: inbytesleft=%ld outbytesleft=%ld\n",
+                     (long) inbytesleft, (long) outbytesleft);
 
         }
         r = yaz_iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
@@ -81,7 +84,7 @@ void convert (FILE *inf, yaz_iconv_t cd, int verbose)
                 }
                 if (r == 0)
                 {
-                    fprintf (stderr, "invalid sequence\n");
+                    fprintf (stderr, "invalid sequence due to missing input\n");
                     return ;
                 }
                 inbytesleft += r;
@@ -148,7 +151,7 @@ int main (int argc, char **argv)
             break;
         default:
             fprintf (stderr, "yaziconv: Usage\n"
-                     "siconv -f encoding -t encoding [-v] [file]\n");
+                     "yaziconv -f encoding -t encoding [-v] [file]\n");
             exit(1);
         }
     }