From: Todd C. Miller Date: Mon, 12 Nov 2012 13:51:58 +0000 (-0500) Subject: #unifdef HAVE_SETLOCALE, it is C89 so no need to check for it. X-Git-Tag: SUDO_1_8_7~1^2~336 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acf8af9aac5e7cf3ed50a7030d98178a84b99619;p=sudo #unifdef HAVE_SETLOCALE, it is C89 so no need to check for it. --- diff --git a/common/sudo_conf.c b/common/sudo_conf.c index 608a78b3c..f8ec9d307 100644 --- a/common/sudo_conf.c +++ b/common/sudo_conf.c @@ -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; } diff --git a/config.h.in b/config.h.in index 8aedaade0..bead6ae8c 100644 --- a/config.h.in +++ b/config.h.in @@ -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 diff --git a/configure b/configure index 4af44088c..d3b8c62e8 100755 --- a/configure +++ b/configure @@ -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` diff --git a/configure.in b/configure.in index 7e40144d1..3d0f0af6f 100644 --- a/configure.in +++ b/configure.in @@ -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, [], [ diff --git a/include/gettext.h b/include/gettext.h index db1f35910..95e48aaf0 100644 --- a/include/gettext.h +++ b/include/gettext.h @@ -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 -#endif +#include #ifdef HAVE_LIBINTL_H diff --git a/plugins/sudoers/locale.c b/plugins/sudoers/locale.c index d2727720e..d0b72dcb9 100644 --- a/plugins/sudoers/locale.c +++ b/plugins/sudoers/locale.c @@ -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 */ diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 4f011f8bd..f03e73adb 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -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 */ diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 0f49c7e1a..81c2c2c7b 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -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"); diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 109eaa3d0..81498b011 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -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"); diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 6df0d3fa9..ba8c5938e 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -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"); diff --git a/src/error.c b/src/error.c index 6502df98d..d41fb5106 100644 --- a/src/error.c +++ b/src/error.c @@ -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 } diff --git a/src/exec.c b/src/exec.c index 808ed30bf..7dd36ff7c 100644 --- a/src/exec.c +++ b/src/exec.c @@ -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 diff --git a/src/sesh.c b/src/sesh.c index c6e41da90..1de8ba03b 100644 --- a/src/sesh.c +++ b/src/sesh.c @@ -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); diff --git a/src/sudo.c b/src/sudo.c index ec82a141f..01161a4f9 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -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);