From 79f7c85067d4ac4a325960a522671ec9f2d53a20 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Mon, 22 Feb 1999 21:01:24 +0000 Subject: [PATCH] Add locale support (slapd.conf keyword "locale") to slapd if HAVE_LOCALE_H --- configure | 1 + configure.in | 1 + doc/man/man5/slapd.conf.5 | 12 ++++++++++++ include/portable.h.in | 3 +++ include/portable.h.nt | 3 +++ servers/slapd/config.c | 32 ++++++++++++++++++++++++++++++++ servers/slapd/tools/centipede.c | 4 +--- 7 files changed, 53 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 4361158c11..203f266fcc 100755 --- a/configure +++ b/configure @@ -7988,6 +7988,7 @@ for ac_hdr in \ getopt.h \ libutil.h \ limits.h \ + locale.h \ malloc.h \ memory.h \ regex.h \ diff --git a/configure.in b/configure.in index 95f79d2982..44904c3f40 100644 --- a/configure.in +++ b/configure.in @@ -1404,6 +1404,7 @@ AC_CHECK_HEADERS( \ getopt.h \ libutil.h \ limits.h \ + locale.h \ malloc.h \ memory.h \ regex.h \ diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index 8cfdb7674b..a3acdefa15 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -124,6 +124,17 @@ The ( absolute ) name of a file that will hold the server's command line options if started without the debugging command line option. .TP +.B +locale { | on | off } +Obey 's character classification and case conversion; i.e. the +.BR locale (5) +LC_CTYPE category. See +.BR locale (5) +for details about locales. "on" takes the locale from the environment, +typically $LANG or $LC_CTYPE, and will only work properly if slapd will +run with the same environment variables as when the database was +generated. "off" (the default setting) resets to the initial "C" locale. +.TP .B loglevel Specify the level at which debugging statements and operation statistics should be syslogged (currently logged to the @@ -354,6 +365,7 @@ ETCDIR/slapd.conf .SH SEE ALSO .BR ldap (3), .BR slapd.replog (5), +.BR locale (5), .BR passwd (5), .BR slapd (8), .BR slurpd (8), diff --git a/include/portable.h.in b/include/portable.h.in index a297f2c9d1..0d116b6bbb 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -411,6 +411,9 @@ /* Define if you have the header file. */ #undef HAVE_LIMITS_H +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + /* Define if you have the header file. */ #undef HAVE_LWP_LWP_H diff --git a/include/portable.h.nt b/include/portable.h.nt index e01023a684..47b02791aa 100644 --- a/include/portable.h.nt +++ b/include/portable.h.nt @@ -456,6 +456,9 @@ typedef char * caddr_t; /* Define if you have the header file. */ #define HAVE_LIMITS_H 1 +/* Define if you have the header file. */ +#define HAVE_LOCALE_H 1 + /* Define if you have the header file. */ /* #undef HAVE_LWP_LWP_H */ diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 03d69e750e..28005b2153 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -3,6 +3,9 @@ #include "portable.h" #include +#ifdef HAVE_LOCALE_H +#include +#endif #include #include @@ -309,6 +312,35 @@ read_config( char *fname ) strcpy( default_referral, "Referral:\n" ); strcat( default_referral, cargv[1] ); + /* specify locale */ + } else if ( strcasecmp( cargv[0], "locale" ) == 0 ) { +#ifdef HAVE_LOCALE_H + char *locale; + if ( cargc < 2 ) { + Debug( LDAP_DEBUG_ANY, + "%s: line %d: missing locale in \"locale \" line\n", + fname, lineno, 0 ); + return( 1 ); + } + + locale = (strcasecmp( cargv[1], "on" ) == 0 ? "" + : strcasecmp( cargv[1], "off" ) == 0 ? "C" + : ch_strdup( cargv[1] ) ); + + if ( setlocale( LC_CTYPE, locale ) == 0 ) { + Debug( LDAP_DEBUG_ANY, + (*locale + ? "%s: line %d: bad locale \"%s\"\n" + : "%s: line %d: bad locale\n"), + fname, lineno, locale ); + return( 1 ); + } +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: \"locale\" unsupported\n", + fname, lineno, 0 ); + return( 1 ); +#endif /* specify an objectclass */ } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) { parse_oc( be, fname, lineno, cargc, cargv ); diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index 388602ece5..022d950878 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -502,9 +502,7 @@ generate_new_centroids( /* normalize the value */ for ( s = val[j]; *s; s++ ) { - if ( isascii( *s ) ) { - *s = TOLOWER( *s ); - } + *s = TOLOWER( (unsigned char) *s ); last = *s; } if ( isascii( last ) && isdigit( last ) ) { -- 2.39.5