This is an intermediate commit ... we check for three different charsets
authorRichard Sharpe <sharpe@samba.org>
Wed, 13 Aug 2003 21:29:59 +0000 (21:29 +0000)
committerRichard Sharpe <sharpe@samba.org>
Wed, 13 Aug 2003 21:29:59 +0000 (21:29 +0000)
in an iconv_open to be more robust.

However, what we really want to do is find the name for something like CP850,
which can be IBM850 on Solaris, and we might want to also check for
ISO-8859-1.

So, this commit adds a macro to aclocal.m4 that can check for a specific
charset.
(This used to be commit 81dc28ca82b94d1bc42f96273f6cefac6ca1848c)

source3/aclocal.m4
source3/configure.in

index acf36c6cbb1a1fa4b0465d700e0f85387ae671f2..b069c516edd7aed054234a784f1458ed6944eff0 100644 (file)
@@ -609,6 +609,25 @@ AC_DEFUN(jm_ICONV,
   fi
 ])
 
+AC_DEFUN(rjs_CHARSET
+[
+  dnl Find out if we can convert from $1 to UCS2-LE
+  AC_MSG_CHECKING(we can convert from $1 to UCS2-LE)
+  AC_TRY_RUN([
+#include <$jm_cv_include>
+main(){
+    iconv_t cd = iconv_open("$1", "UCS-2LE");
+    if (cd == 0 || cd == (iconv_t)-1) {
+       return -1;
+    }
+    return 0;
+}
+  ],ICONV_CHARSET=$1,ICONV_CHARSET="",])
+  if test x"$ICONV_CHARSET" != x; then
+     AC_MSG_RESULT($ICONV_CHARSET)
+  fi
+])
+
 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
 dnl This function doesn't add -I/usr/include into CFLAGS
 AC_DEFUN(CFLAGS_ADD_DIR,[
index 9dcc53364ba1d8f9c7631ac3a2e09d3730b1d872..16efcdec1784a1029879c0e48bfa761ba175969d 100644 (file)
@@ -1550,9 +1550,7 @@ for i in $LOOK_DIRS ; do
 dnl Try to find iconv(3)
     jm_ICONV($i)
 
-    CPPFLAGS=$save_CPPFLAGS
     if test "$ICONV_FOUND" = yes; then
-        LDFLAGS=$save_LDFLAGS
         LIB_ADD_DIR(LDFLAGS, "$i/lib")
         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
         LIBS="$save_LIBS $LIBS"
@@ -1570,7 +1568,15 @@ dnl there might be a working iconv further down the list of LOOK_DIRS
 #include <$jm_cv_include>
 main(){
     iconv_t cd = iconv_open("ASCII", "UCS-2LE");
-    if (cd == 0 || cd == (iconv_t)-1) return -1;
+    if (cd == 0 || cd == (iconv_t)-1) {
+       cd = iconv_open("ISO-8859-1", "UCS-2LE");
+       if (cd == 0 || cd == (iconv_t)-1) {
+          cd = iconv_open("IBM850", "UCS-2LE"); /* Solaris has this */
+          if (cd == 0 || cd == (iconv_t)-1) {
+             return -1;
+          }
+       }
+    }
     return 0;
 }
         ],
@@ -1582,6 +1588,8 @@ main(){
         fi
 dnl We didn't find a working iconv, so keep going
     fi
+dnl We only need to clean these up here for the next pass through the loop
+    CPPFLAGS=$save_CPPFLAGS
     LDFLAGS=$save_LDFLAGS
     LIBS=$save_LIBS
     export LDFLAGS LIBS CPPFLAGS