From 7ddf760beabd61b180c10b6a5a45d472d432da93 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Fri, 15 Aug 2003 20:09:12 +0000 Subject: Fix charset detection code in configure. Now we are: 1. Try to find correct name for default character sets for the platform 2. Use DEFAULT_{DOS|DISPLAY|UNIX}_CHARSET defines set during configure phase as defaults This should fix CP850 problem on Solaris (at least) because it actually has IBM850 which is the same but under different name (This used to be commit 836b9fffa0eadc818019ba36ed764e97d4f9a801) --- source3/aclocal.m4 | 11 +++----- source3/configure.in | 69 ++++++++++++++++++++++++++++++++++++------------ source3/param/loadparm.c | 6 ++--- 3 files changed, 59 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 88f055f9ba..a6aa1bb1de 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -610,10 +610,9 @@ AC_DEFUN(jm_ICONV, fi ]) -AC_DEFUN(rjs_CHARSET -[ +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_MSG_CHECKING([can we convert from $1 to UCS2-LE?]) AC_TRY_RUN([ #include <$jm_cv_include> main(){ @@ -623,10 +622,8 @@ main(){ } return 0; } - ],ICONV_CHARSET=$1,ICONV_CHARSET="",]) - if test x"$ICONV_CHARSET" != x; then - AC_MSG_RESULT($ICONV_CHARSET) - fi + ],ICONV_CHARSET=$1,ICONV_CHARSET=no,ICONV_CHARSET=cross) + AC_MSG_RESULT($ICONV_CHARSET) ]) dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR) diff --git a/source3/configure.in b/source3/configure.in index 6f38adfd92..0fa6d8f748 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1570,29 +1570,64 @@ dnl there might be a working iconv further down the list of LOOK_DIRS LIBS="$LIBS -L$ICONV_LOCATION/lib" fi AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[ - AC_TRY_RUN([ -#include <$jm_cv_include> -main(){ - iconv_t cd = iconv_open("ASCII", "UCS-2LE"); - if (cd == 0 || cd == (iconv_t)-1) { - cd = iconv_open("CP850", "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; -} - ], - samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)]) + default_dos_charset=no + default_display_charset=no + default_unix_charset=no + echo + + # check for default dos charset name + for j in CP850 IBM850 ; do + rjs_CHARSET($j) + if test x"$ICONV_CHARSET" = x"$j"; then + default_dos_charset="\"$j\"" + break + fi + done + # check for default display charset name + for j in ASCII 646 ; do + rjs_CHARSET($j) + if test x"$ICONV_CHARSET" = x"$j"; then + default_display_charset="\"$j\"" + break + fi + done + # check for default unix charset name + for j in UTF-8 UTF8 ; do + rjs_CHARSET($j) + if test x"$ICONV_CHARSET" = x"$j"; then + default_unix_charset="\"$j\"" + break + fi + done + + if test "$default_dos_charset" != "no" -a \ + "$default_dos_charset" != "cross" -a \ + "$default_display_charset" != "no" -a \ + "$default_display_charset" != "cross" -a \ + "$default_unix_charset" != "no" -a \ + "$default_unix_charset" != "cross" + then + samba_cv_HAVE_NATIVE_ICONV=yes + else if test "$default_dos_charset" = "cross" -o \ + "$default_display_charset" = "cross" -o \ + "$default_unix_charset" = "cross" + then + samba_cv_HAVE_NATIVE_ICONV=cross + else + samba_cv_HAVE_NATIVE_ICONV=no + fi + fi +]) + LIBS="$ic_save_LIBS" if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then CPPFLAGS=$save_CPPFLAGS CFLAGS_ADD_DIR(CPPFLAGS, "$i/include") export CPPFLAGS AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv]) + AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name]) + AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name]) + AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name]) break fi dnl We didn't find a working iconv, so keep going diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 70efa8042b..7982b87ffc 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1310,18 +1310,18 @@ static void init_globals(void) string_set(&Globals.szGuestaccount, GUEST_ACCOUNT); /* using UTF8 by default allows us to support all chars */ - string_set(&Globals.unix_charset, "UTF8"); + string_set(&Globals.unix_charset, DEFAULT_UNIX_CHARSET); #if defined(HAVE_NL_LANGINFO) && defined(CODESET) /* If the system supports nl_langinfo(), try to grab the value from the user's locale */ string_set(&Globals.display_charset, "LOCALE"); #else - string_set(&Globals.display_charset, "ASCII"); + string_set(&Globals.display_charset, DEFAULT_DISPLAY_CHARSET); #endif /* Use codepage 850 as a default for the dos character set */ - string_set(&Globals.dos_charset, "CP850"); + string_set(&Globals.dos_charset, DEFAULT_DOS_CHARSET); /* * Allow the default PASSWD_CHAT to be overridden in local.h. -- cgit