]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/unicode/iconv.c
libiconv warning fix
[netatalk.git] / libatalk / unicode / iconv.c
index 924f2d436c0a2e1ed0e825e25bb9d96c2a5ad62b..48f903bc7e3482225ca3cfeaf06c2b4e8de2e4aa 100644 (file)
 #include <unistd.h>
 #include <string.h>
 #include <ctype.h>
+#include <errno.h>
 #include <sys/param.h>
 #include <sys/stat.h>
-#include <atalk/logger.h>
-#include <errno.h>
-
-#include <netatalk/endian.h>
-#include <atalk/unicode.h>
-
 #ifdef HAVE_USABLE_ICONV
 #include <iconv.h>
 #endif
+
+#include <netatalk/endian.h>
+#include <atalk/unicode.h>
+#include <atalk/logger.h>
 #include "byteorder.h"
 
 
@@ -92,7 +91,7 @@ struct charset_functions charset_ucs2 =
         0,
         iconv_copy,
         iconv_copy,
-        CHARSET_WIDECHAR
+        CHARSET_WIDECHAR | CHARSET_PRECOMPOSED
 };
 
 struct charset_functions charset_ascii =
@@ -206,7 +205,7 @@ static size_t sys_iconv(void *cd,
 {
 #ifdef HAVE_USABLE_ICONV
        size_t ret = iconv((iconv_t)cd, 
-                          inbuf, inbytesleft, 
+                          (ICONV_CONST char**)inbuf, inbytesleft, 
                           outbuf, outbytesleft);
        if (ret == (size_t)-1) iconv(cd, NULL, NULL, NULL, NULL);
        return ret;
@@ -297,14 +296,12 @@ atalk_iconv_t atalk_iconv_open(const char *tocode, const char *fromcode)
 
        /* check if we can use iconv for this conversion */
 #ifdef HAVE_USABLE_ICONV
-       LOG (log_debug, logtype_default, "Trying %s/%s", UCS2ICONV, fromcode);
        if (!ret->pull) {
                ret->cd_pull = iconv_open(UCS2ICONV, fromcode);
                if (ret->cd_pull != (iconv_t)-1)
                        ret->pull = sys_iconv;
        }
 
-       LOG (log_debug, logtype_default, "Trying %s/%s", tocode, UCS2ICONV);
        if (!ret->push) {
                ret->cd_push = iconv_open(tocode, UCS2ICONV);
                if (ret->cd_push != (iconv_t)-1)
@@ -380,10 +377,11 @@ static size_t ascii_pull(void *cd, char **inbuf, size_t *inbytesleft,
                         char **outbuf, size_t *outbytesleft)
 {
        ucs2_t curchar;
+
        while (*inbytesleft >= 1 && *outbytesleft >= 2) {
                if ((unsigned char)(*inbuf)[0] < 0x80) {
                        curchar = (ucs2_t) (*inbuf)[0];
-                       SSVAL((*outbuf),0,curchar);     
+                       SSVAL((*outbuf),0,curchar);
                }
                else {
                        errno = EILSEQ;