mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
Assume setlocale exists
Like locale.h, it was standardized by C89, is universally available now, and some code already assumes it. * configure.ac: Do not check for setlocale. * src/emacs.c (setlocale) [!HAVE_SETLOCALE]: Remove. (fixup_locale, synchronize_locale, Vprevious_system_time_locale) (synchronize_system_time_locale): Define even if !HAVE_SETLOCALE. * src/sysdep.c (emacs_setlocale): Simplify by assuming HAVE_SETLOCALE.
This commit is contained in:
parent
d2b847d291
commit
69374fbe82
@ -5927,7 +5927,7 @@ LIBS="$LIB_PTHREAD $LIB_MATH $LIBS"
|
||||
AC_CHECK_FUNCS([accept4 fchdir gethostname \
|
||||
getrusage get_current_dir_name \
|
||||
lrand48 random rint tcdrain trunc \
|
||||
select getpagesize setlocale newlocale \
|
||||
select getpagesize newlocale \
|
||||
getrlimit setrlimit shutdown \
|
||||
pthread_sigmask strsignal setitimer \
|
||||
sendto recvfrom getsockname getifaddrs freeifaddrs \
|
||||
|
24
src/emacs.c
24
src/emacs.c
@ -399,14 +399,6 @@ section of the Emacs manual or the file BUGS.\n"
|
||||
/* True if handling a fatal error already. */
|
||||
bool fatal_error_in_progress;
|
||||
|
||||
#if !HAVE_SETLOCALE
|
||||
static char *
|
||||
setlocale (int cat, char const *locale)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* True if the current system locale uses UTF-8 encoding. */
|
||||
static bool
|
||||
using_utf8 (void)
|
||||
@ -3268,7 +3260,6 @@ You must run Emacs in batch mode in order to dump it. */)
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_SETLOCALE
|
||||
/* Recover from setlocale (LC_ALL, ""). */
|
||||
void
|
||||
fixup_locale (void)
|
||||
@ -3288,7 +3279,7 @@ synchronize_locale (int category, Lisp_Object *plocale, Lisp_Object desired_loca
|
||||
*plocale = desired_locale;
|
||||
char const *locale_string
|
||||
= STRINGP (desired_locale) ? SSDATA (desired_locale) : "";
|
||||
# ifdef WINDOWSNT
|
||||
#ifdef WINDOWSNT
|
||||
/* Changing categories like LC_TIME usually requires specifying
|
||||
an encoding suitable for the new locale, but MS-Windows's
|
||||
'setlocale' will only switch the encoding when LC_ALL is
|
||||
@ -3297,9 +3288,9 @@ synchronize_locale (int category, Lisp_Object *plocale, Lisp_Object desired_loca
|
||||
numbers is unaffected. */
|
||||
setlocale (LC_ALL, locale_string);
|
||||
fixup_locale ();
|
||||
# else /* !WINDOWSNT */
|
||||
#else
|
||||
setlocale (category, locale_string);
|
||||
# endif /* !WINDOWSNT */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -3313,21 +3304,20 @@ synchronize_system_time_locale (void)
|
||||
Vsystem_time_locale);
|
||||
}
|
||||
|
||||
# ifdef LC_MESSAGES
|
||||
#ifdef LC_MESSAGES
|
||||
static Lisp_Object Vprevious_system_messages_locale;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Set system messages locale to match Vsystem_messages_locale, if
|
||||
possible. */
|
||||
void
|
||||
synchronize_system_messages_locale (void)
|
||||
{
|
||||
# ifdef LC_MESSAGES
|
||||
#ifdef LC_MESSAGES
|
||||
synchronize_locale (LC_MESSAGES, &Vprevious_system_messages_locale,
|
||||
Vsystem_messages_locale);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_SETLOCALE */
|
||||
|
||||
/* Return a diagnostic string for ERROR_NUMBER, in the wording
|
||||
and encoding appropriate for the current locale. */
|
||||
|
@ -5190,15 +5190,9 @@ extern AVOID terminate_due_to_signal (int, int);
|
||||
#ifdef WINDOWSNT
|
||||
extern Lisp_Object Vlibrary_cache;
|
||||
#endif
|
||||
#if HAVE_SETLOCALE
|
||||
void fixup_locale (void);
|
||||
void synchronize_system_messages_locale (void);
|
||||
void synchronize_system_time_locale (void);
|
||||
#else
|
||||
INLINE void fixup_locale (void) {}
|
||||
INLINE void synchronize_system_messages_locale (void) {}
|
||||
INLINE void synchronize_system_time_locale (void) {}
|
||||
#endif
|
||||
extern char *emacs_strerror (int) ATTRIBUTE_RETURNS_NONNULL;
|
||||
extern void shut_down_emacs (int, Lisp_Object);
|
||||
|
||||
|
@ -4593,15 +4593,11 @@ freelocale (locale_t loc)
|
||||
static char *
|
||||
emacs_setlocale (int category, char const *locale)
|
||||
{
|
||||
# ifdef HAVE_SETLOCALE
|
||||
errno = 0;
|
||||
char *loc = setlocale (category, locale);
|
||||
if (loc || errno)
|
||||
return loc;
|
||||
errno = EINVAL;
|
||||
# else
|
||||
errno = ENOTSUP;
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user