#unifdef HAVE_SETLOCALE, it is C89 so no need to check for it.

This commit is contained in:
Todd C. Miller
2012-11-12 08:51:58 -05:00
parent 6485906583
commit acf8af9aac
14 changed files with 5 additions and 50 deletions

View File

@@ -294,14 +294,11 @@ sudo_conf_read(void)
struct sudo_conf_table *cur;
struct stat sb;
FILE *fp;
char *cp;
#ifdef HAVE_SETLOCALE
char *prev_locale = estrdup(setlocale(LC_ALL, NULL));
char *cp, *prev_locale = estrdup(setlocale(LC_ALL, NULL));
/* Parse sudo.conf in the "C" locale. */
if (prev_locale[0] != 'C' || prev_locale[1] != '\0')
setlocale(LC_ALL, "C");
#endif
switch (sudo_secure_file(_PATH_SUDO_CONF, ROOT_UID, -1, &sb)) {
case SUDO_PATH_SECURE:
@@ -353,11 +350,9 @@ sudo_conf_read(void)
}
fclose(fp);
done:
#ifdef HAVE_SETLOCALE
/* Restore locale if needed. */
if (prev_locale[0] != 'C' || prev_locale[1] != '\0')
setlocale(LC_ALL, prev_locale);
efree(prev_locale);
#endif
return;
}

View File

@@ -470,9 +470,6 @@
/* Define to 1 if you have the `setkeycreatecon' function. */
#undef HAVE_SETKEYCREATECON
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the `setresuid' function. */
#undef HAVE_SETRESUID

2
configure vendored
View File

@@ -16630,7 +16630,7 @@ fi
LIBS=$ac_save_LIBS
for ac_func in glob strrchr sysconf tzset strftime setenv \
regcomp setlocale nl_langinfo mbr_check_membership \
regcomp nl_langinfo mbr_check_membership \
setrlimit64
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`

View File

@@ -2216,7 +2216,7 @@ dnl Function checks
dnl
AC_FUNC_GETGROUPS
AC_CHECK_FUNCS(glob strrchr sysconf tzset strftime setenv \
regcomp setlocale nl_langinfo mbr_check_membership \
regcomp nl_langinfo mbr_check_membership \
setrlimit64)
AC_REPLACE_FUNCS(getgrouplist)
AC_CHECK_FUNCS(getline, [], [

View File

@@ -21,9 +21,7 @@
* Solaris locale.h includes libintl.h which causes problems when we
* redefine the gettext functions. We include it first to avoid this.
*/
#if defined(HAVE_SETLOCALE)
# include <locale.h>
#endif
#include <locale.h>
#ifdef HAVE_LIBINTL_H

View File

@@ -49,7 +49,6 @@ sudoers_getlocale(void)
* If prevlocale is non-NULL it will be filled in with the
* old SUDOERS_LOCALE_* value.
*/
#ifdef HAVE_SETLOCALE
bool
sudoers_setlocale(int newlocale, int *prevlocale)
{
@@ -82,19 +81,3 @@ sudoers_setlocale(int newlocale, int *prevlocale)
}
return res ? true : false;
}
#else
bool
sudoers_setlocale(int newlocale, int *prevlocale)
{
switch (newlocale) {
case SUDOERS_LOCALE_USER:
case SUDOERS_LOCALE_SUDOERS:
if (prevlocale)
*prevlocale = current_locale;
current_locale = newlocale;
return true;
default:
return false;
}
}
#endif /* HAVE_SETLOCALE */

View File

@@ -552,9 +552,7 @@ init_vars(char * const envp[])
(void) tzset(); /* set the timezone if applicable */
#endif /* HAVE_TZSET */
#ifdef HAVE_SETLOCALE
user_locale = estrdup(setlocale(LC_ALL, NULL));
#endif
for (ep = envp; *ep; ep++) {
/* XXX - don't fill in if empty string */

View File

@@ -242,7 +242,7 @@ main(int argc, char *argv[])
{
int ch, idx, plen, exitcode = 0, rows = 0, cols = 0;
bool interactive = false, listonly = false, need_nlcr = false;
const char *id, *user = NULL, *pattern = NULL, *tty = NULL, *decimal = ".";
const char *decimal, *id, *user = NULL, *pattern = NULL, *tty = NULL;
char path[PATH_MAX], buf[LINE_MAX], *cp, *ep;
double seconds, to_wait, speed = 1.0, max_wait = 0;
sigaction_t sa;
@@ -263,10 +263,8 @@ main(int argc, char *argv[])
setprogname(argc > 0 ? argv[0] : "sudoreplay");
#endif
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
decimal = localeconv()->decimal_point;
#endif
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have sudoreplay domain */
textdomain("sudoers");

View File

@@ -148,9 +148,7 @@ main(int argc, char *argv[])
setprogname(argc > 0 ? argv[0] : "testsudoers");
#endif
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have own domain */
textdomain("sudoers");

View File

@@ -161,9 +161,7 @@ main(int argc, char *argv[])
setprogname(argc > 0 ? argv[0] : "visudo");
#endif
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */
textdomain("sudoers");

View File

@@ -105,13 +105,11 @@ static void
_warning(int use_errno, const char *fmt, va_list ap)
{
int serrno = errno;
#ifdef HAVE_SETLOCALE
char *prev_locale = estrdup(setlocale(LC_ALL, NULL));
/* Set locale to user's if different. */
if (*prev_locale != '\0')
setlocale(LC_ALL, "");
#endif
fputs(getprogname(), stderr);
if (fmt != NULL) {
@@ -124,10 +122,8 @@ _warning(int use_errno, const char *fmt, va_list ap)
}
putc('\n', stderr);
#ifdef HAVE_SETLOCALE
/* Restore locale if needed. */
if (*prev_locale != '\0')
setlocale(LC_ALL, prev_locale);
efree(prev_locale);
#endif
}

View File

@@ -346,13 +346,11 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
if (ISSET(details->flags, CD_SET_TIMEOUT))
alarm(details->timeout);
#ifdef HAVE_SETLOCALE
/*
* I/O logging must be in the C locale for floating point numbers
* to be logged consistently.
*/
setlocale(LC_ALL, "C");
#endif
/*
* In the event loop we pass input from user tty to master

View File

@@ -60,9 +60,7 @@ main(int argc, char *argv[], char *envp[])
int noexec = 0;
debug_decl(main, SUDO_DEBUG_MAIN)
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
textdomain(PACKAGE_NAME);

View File

@@ -153,9 +153,7 @@ main(int argc, char *argv[], char *envp[])
os_init(argc, argv, envp);
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
textdomain(PACKAGE_NAME);