Index: xlate.c
===================================================================
RCS file: /home/cvspublic/apr-util/xlate/xlate.c,v
retrieving revision 1.13
diff -u -r1.13 xlate.c
--- xlate.c 1 Jan 2003 00:02:22 -0000   1.13
+++ xlate.c 8 Jan 2003 09:49:37 -0000
@@ -81,7 +81,7 @@
 #include <apr_iconv.h>
 #endif
 
-#if defined(APU_ICONV_INBUF_CONST) || APU_HAS_APR_ICONV
+#if defined(APU_ICONV_INBUF_CONST) || APU_HAVE_APR_ICONV
 #define ICONV_INBUF_TYPE const char **
 #else
 #define ICONV_INBUF_TYPE char **
@@ -119,9 +119,9 @@
 {
     apr_xlate_t *old = convset;
 
-#if APU_HAS_APR_ICONV
-    if (old->ich != (apr_iconv_t)-1) {
-        return apr_iconv_close(old->ich);
+#if APU_HAVE_APR_ICONV
+    if (old->ich != (iconv_t)-1) {
+        return apr_iconv_close(old->ich, old->pool);
     }
 
 #elif APU_HAVE_ICONV
@@ -138,7 +138,8 @@
     return APR_SUCCESS;
 }
 
-#if APU_HAVE_ICONV
+#if APU_HAVE_APR_ICONV || APU_HAVE_ICONV
+
 static void check_sbcs(apr_xlate_t *convset)
 {
     char inbuf[256], outbuf[256];
@@ -153,9 +154,14 @@
     }
 
     inbytes_left = outbytes_left = sizeof(inbuf);
+#if APU_HAVE_ICONV
     translated = iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr,
                        &inbytes_left, &outbufptr, &outbytes_left);
-
+#else
+    apr_iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr,
+                       &inbytes_left, &outbufptr, &outbytes_left,
+                       &translated);
+#endif
     if (translated != (apr_size_t)-1
         && inbytes_left == 0
         && outbytes_left == 0) {
@@ -165,13 +171,17 @@
 
         convset->sbcs_table = apr_palloc(convset->pool, sizeof(outbuf));
         memcpy(convset->sbcs_table, outbuf, sizeof(outbuf));
+#if APU_HAVE_ICONV
         iconv_close(convset->ich);
+#else
+        apr_iconv_close(convset->ich, convset->pool);
+#endif
         convset->ich = (iconv_t)-1;
 
         /* TODO: add the table to the cache */
     }
 }
-#endif /* APU_HAVE_ICONV */
+#endif /* APU_HAVE_APR_ICONV || APU_HAVE_ICONV */
 
 static void make_identity_table(apr_xlate_t *convset)
 {
@@ -222,16 +232,16 @@
         make_identity_table(new);
     }
 
-#if APU_HAS_APR_ICONV
+#if APU_HAVE_APR_ICONV
     if (!found) {
-        rv = apr_iconv_open(topage, frompage, pool, &new->ich);
-        if (rv != APR_SUCCESS) {
-            return rv;
+        status = apr_iconv_open(topage, frompage, pool, &new->ich);
+        if (status != APR_SUCCESS) {
+            return status;
         }
         found = 1;
         check_sbcs(new);
     } else
-        new->ich = (apr_iconv_t)-1;
+        new->ich = (iconv_t)-1;
 
 #elif APU_HAVE_ICONV
     if (!found) {
@@ -312,7 +322,7 @@
 
              /* Sometimes, iconv is not good about setting errno. */
             case 0:
-                if (inbytes_left)
+                if (*inbytes_left)
                     status = APR_INCOMPLETE;
                 break;
 
@@ -387,7 +397,6 @@
         *inbytes_left -= converted;
         *outbytes_left -= converted;
     }
-
     return status;
 }
