- added LOCALE patch from vorlon@debian.org (Steve Langasek) (bug #122)
authorAndrew Tridgell <tridge@samba.org>
Mon, 30 Jun 2003 02:11:13 +0000 (02:11 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 30 Jun 2003 02:11:13 +0000 (02:11 +0000)
- changed --enable-developer debug to use -gstabs as it makes the
  samba binaries about 10x smaller and is still quite functional for
  samba debugging
(This used to be commit 53bfcd478a193d4def8da872e92d7ed8f46aa4b9)

source3/configure.in
source3/include/includes.h
source3/lib/charcnv.c
source3/param/loadparm.c

index 186c3ea090218f6353dabdb3b6d00f9664cf989b..69d901cdc27975cbf51988f4bd6acc3bfbde9923 100644 (file)
@@ -173,13 +173,13 @@ AC_ARG_ENABLE(debug,
 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
     [if eval "test x$enable_developer = xyes"; then
         developer=yes
-       CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
     fi])
 
 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
     [if eval "test x$enable_krb5developer = xyes"; then
         developer=yes
-       CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
     fi])
 
 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
@@ -529,6 +529,7 @@ AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h t
 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h dlfcn.h)
 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
+AC_CHECK_HEADERS(langinfo.h locale.h)
 
 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
 # subdirectory of headers.
@@ -843,6 +844,7 @@ AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
 AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
+AC_CHECK_FUNCS(setlocale nl_langinfo)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
 
index 3dbe6d10934b58cb00a0ac07bd378c0cb20d5154..edaeda3abedaf55bb659aeb10f0b3639d6a8851f 100644 (file)
 #include <attr/xattr.h>
 #endif
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#if HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+
 /* Special macros that are no-ops except when run under Valgrind on
  * x86.  They've moved a little bit from valgrind 1.0.4 to 1.9.4 */
 #if HAVE_VALGRIND_MEMCHECK_H
index 708ef343e1a91a704569d7639b09fc6d5abdf9f8..55cf73d2b11058552a7a73167ec44a76e72a165a 100644 (file)
@@ -55,6 +55,30 @@ static const char *charset_name(charset_t ch)
        else if (ch == CH_DISPLAY) ret = lp_display_charset();
        else if (ch == CH_UTF8) ret = "UTF8";
 
+#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
+       if (ret && strcasecmp(ret, "LOCALE") == 0) {
+               const char *ln = NULL;
+
+#ifdef HAVE_SETLOCALE
+               setlocale(LC_ALL, "");
+#endif
+               ln = nl_langinfo(CODESET);
+               if (ln) {
+                       /* Check whether the charset name is supported
+                          by iconv */
+                       smb_iconv_t handle = smb_iconv_open(ln,"UCS-2LE");
+                       if (handle == (smb_iconv_t) -1) {
+                               DEBUG(5,("Locale charset '%s' unsupported, using ASCII instead\n", ln));
+                               ln = NULL;
+                       } else {
+                               DEBUG(5,("Substituting charset '%s' for LOCALE\n", ln));
+                               smb_iconv_close(handle);
+                       }
+               }
+               ret = ln;
+       }
+#endif
+
        if (!ret || !*ret) ret = "ASCII";
        return ret;
 }
index cee61f54cd78a60ab4c6dd8dec4eff0798ff7975..95f6896e6b43fbe1076433c21c61f76781c839c4 100644 (file)
@@ -1281,8 +1281,13 @@ static void init_globals(void)
        /* using UTF8 by default allows us to support all chars */
        string_set(&Globals.unix_charset, "UTF8");
 
-       /* using UTF8 by default allows us to support all chars */
+#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");
+#endif
 
        /* Use codepage 850 as a default for the dos character set */
        string_set(&Globals.dos_charset, "CP850");