]> granicus.if.org Git - postgis/commitdiff
Make use of iconvctl conditional on it existing
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 27 May 2010 14:02:07 +0000 (14:02 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 27 May 2010 14:02:07 +0000 (14:02 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5648 b70326c6-7e19-0410-871a-916f4a2858ee

configure.ac
loader/shp2pgsql-core.c

index cefb3ccbc01251d0f4a0a37d16244fa28c55f870..496172318a544336a4ffc287453cbe7acd488865 100644 (file)
@@ -252,6 +252,8 @@ else
        AC_MSG_ERROR([Could not find iconv.h header. Please install libiconv and libiconv-devel.])
 fi
 
+AC_CHECK_FUNCS([iconvctl libiconvctl],[],[])
+
 LDFLAGS="$LDFLAGS_SAVE"
 CFLAGS="$CFLAGS_SAVE"
 
index 18c8cb14a2b70617442e1955c41a6a6e2901fdf0..f4a0383f8db512dbee0f3220c63631df57a3b0b3 100644 (file)
@@ -63,7 +63,6 @@ int utf8(const char *fromcode, char *inputbuf, char **outputbuf)
        char *outputptr;
        size_t outbytesleft;
        size_t inbytesleft;
-    int on = 1;
 
        inbytesleft = strlen(inputbuf);
 
@@ -83,7 +82,8 @@ int utf8(const char *fromcode, char *inputbuf, char **outputbuf)
     /* Does this string convert cleanly? */
        if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == -1 )
        {
-
+#ifdef HAVE_ICONVCTL
+        int on = 1;
            /* No. Try to convert it while transliterating. */
         iconvctl(cd, ICONV_SET_TRANSLITERATE, &on);
        if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == -1 )
@@ -100,6 +100,10 @@ int utf8(const char *fromcode, char *inputbuf, char **outputbuf)
         }
         iconv_close(cd);
         return UTF8_BAD_RESULT;
+#else
+        free(*outputbuf);
+        return UTF8_NO_RESULT;        
+#endif
     }
     /* Return a good result, converted string is in buffer. */
        iconv_close(cd);