diff options
| author | Paul Eggert | 2024-06-30 00:36:34 +0100 |
|---|---|---|
| committer | Paul Eggert | 2024-06-30 01:03:17 +0100 |
| commit | 69374fbe827b83c49eff084de8635220bd6d3ccf (patch) | |
| tree | f7aa15726b61598b6c5789d0d8c812d5fe2c39f7 /src | |
| parent | d2b847d2911218380d1640dea81d6e72d4a7dc7c (diff) | |
| download | emacs-69374fbe827b83c49eff084de8635220bd6d3ccf.tar.gz emacs-69374fbe827b83c49eff084de8635220bd6d3ccf.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 24 | ||||
| -rw-r--r-- | src/lisp.h | 6 | ||||
| -rw-r--r-- | src/sysdep.c | 4 |
3 files changed, 7 insertions, 27 deletions
diff --git a/src/emacs.c b/src/emacs.c index d8b6da5a65a..77929817447 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -399,14 +399,6 @@ section of the Emacs manual or the file BUGS.\n" | |||
| 399 | /* True if handling a fatal error already. */ | 399 | /* True if handling a fatal error already. */ |
| 400 | bool fatal_error_in_progress; | 400 | bool fatal_error_in_progress; |
| 401 | 401 | ||
| 402 | #if !HAVE_SETLOCALE | ||
| 403 | static char * | ||
| 404 | setlocale (int cat, char const *locale) | ||
| 405 | { | ||
| 406 | return 0; | ||
| 407 | } | ||
| 408 | #endif | ||
| 409 | |||
| 410 | /* True if the current system locale uses UTF-8 encoding. */ | 402 | /* True if the current system locale uses UTF-8 encoding. */ |
| 411 | static bool | 403 | static bool |
| 412 | using_utf8 (void) | 404 | using_utf8 (void) |
| @@ -3268,7 +3260,6 @@ You must run Emacs in batch mode in order to dump it. */) | |||
| 3268 | #endif | 3260 | #endif |
| 3269 | 3261 | ||
| 3270 | 3262 | ||
| 3271 | #if HAVE_SETLOCALE | ||
| 3272 | /* Recover from setlocale (LC_ALL, ""). */ | 3263 | /* Recover from setlocale (LC_ALL, ""). */ |
| 3273 | void | 3264 | void |
| 3274 | fixup_locale (void) | 3265 | fixup_locale (void) |
| @@ -3288,7 +3279,7 @@ synchronize_locale (int category, Lisp_Object *plocale, Lisp_Object desired_loca | |||
| 3288 | *plocale = desired_locale; | 3279 | *plocale = desired_locale; |
| 3289 | char const *locale_string | 3280 | char const *locale_string |
| 3290 | = STRINGP (desired_locale) ? SSDATA (desired_locale) : ""; | 3281 | = STRINGP (desired_locale) ? SSDATA (desired_locale) : ""; |
| 3291 | # ifdef WINDOWSNT | 3282 | #ifdef WINDOWSNT |
| 3292 | /* Changing categories like LC_TIME usually requires specifying | 3283 | /* Changing categories like LC_TIME usually requires specifying |
| 3293 | an encoding suitable for the new locale, but MS-Windows's | 3284 | an encoding suitable for the new locale, but MS-Windows's |
| 3294 | 'setlocale' will only switch the encoding when LC_ALL is | 3285 | '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 | |||
| 3297 | numbers is unaffected. */ | 3288 | numbers is unaffected. */ |
| 3298 | setlocale (LC_ALL, locale_string); | 3289 | setlocale (LC_ALL, locale_string); |
| 3299 | fixup_locale (); | 3290 | fixup_locale (); |
| 3300 | # else /* !WINDOWSNT */ | 3291 | #else |
| 3301 | setlocale (category, locale_string); | 3292 | setlocale (category, locale_string); |
| 3302 | # endif /* !WINDOWSNT */ | 3293 | #endif |
| 3303 | } | 3294 | } |
| 3304 | } | 3295 | } |
| 3305 | 3296 | ||
| @@ -3313,21 +3304,20 @@ synchronize_system_time_locale (void) | |||
| 3313 | Vsystem_time_locale); | 3304 | Vsystem_time_locale); |
| 3314 | } | 3305 | } |
| 3315 | 3306 | ||
| 3316 | # ifdef LC_MESSAGES | 3307 | #ifdef LC_MESSAGES |
| 3317 | static Lisp_Object Vprevious_system_messages_locale; | 3308 | static Lisp_Object Vprevious_system_messages_locale; |
| 3318 | # endif | 3309 | #endif |
| 3319 | 3310 | ||
| 3320 | /* Set system messages locale to match Vsystem_messages_locale, if | 3311 | /* Set system messages locale to match Vsystem_messages_locale, if |
| 3321 | possible. */ | 3312 | possible. */ |
| 3322 | void | 3313 | void |
| 3323 | synchronize_system_messages_locale (void) | 3314 | synchronize_system_messages_locale (void) |
| 3324 | { | 3315 | { |
| 3325 | # ifdef LC_MESSAGES | 3316 | #ifdef LC_MESSAGES |
| 3326 | synchronize_locale (LC_MESSAGES, &Vprevious_system_messages_locale, | 3317 | synchronize_locale (LC_MESSAGES, &Vprevious_system_messages_locale, |
| 3327 | Vsystem_messages_locale); | 3318 | Vsystem_messages_locale); |
| 3328 | # endif | 3319 | #endif |
| 3329 | } | 3320 | } |
| 3330 | #endif /* HAVE_SETLOCALE */ | ||
| 3331 | 3321 | ||
| 3332 | /* Return a diagnostic string for ERROR_NUMBER, in the wording | 3322 | /* Return a diagnostic string for ERROR_NUMBER, in the wording |
| 3333 | and encoding appropriate for the current locale. */ | 3323 | and encoding appropriate for the current locale. */ |
diff --git a/src/lisp.h b/src/lisp.h index 59d8e497f13..68b77a88aa7 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -5190,15 +5190,9 @@ extern AVOID terminate_due_to_signal (int, int); | |||
| 5190 | #ifdef WINDOWSNT | 5190 | #ifdef WINDOWSNT |
| 5191 | extern Lisp_Object Vlibrary_cache; | 5191 | extern Lisp_Object Vlibrary_cache; |
| 5192 | #endif | 5192 | #endif |
| 5193 | #if HAVE_SETLOCALE | ||
| 5194 | void fixup_locale (void); | 5193 | void fixup_locale (void); |
| 5195 | void synchronize_system_messages_locale (void); | 5194 | void synchronize_system_messages_locale (void); |
| 5196 | void synchronize_system_time_locale (void); | 5195 | void synchronize_system_time_locale (void); |
| 5197 | #else | ||
| 5198 | INLINE void fixup_locale (void) {} | ||
| 5199 | INLINE void synchronize_system_messages_locale (void) {} | ||
| 5200 | INLINE void synchronize_system_time_locale (void) {} | ||
| 5201 | #endif | ||
| 5202 | extern char *emacs_strerror (int) ATTRIBUTE_RETURNS_NONNULL; | 5196 | extern char *emacs_strerror (int) ATTRIBUTE_RETURNS_NONNULL; |
| 5203 | extern void shut_down_emacs (int, Lisp_Object); | 5197 | extern void shut_down_emacs (int, Lisp_Object); |
| 5204 | 5198 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 9e4f3b211bb..089fc74deb8 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -4593,15 +4593,11 @@ freelocale (locale_t loc) | |||
| 4593 | static char * | 4593 | static char * |
| 4594 | emacs_setlocale (int category, char const *locale) | 4594 | emacs_setlocale (int category, char const *locale) |
| 4595 | { | 4595 | { |
| 4596 | # ifdef HAVE_SETLOCALE | ||
| 4597 | errno = 0; | 4596 | errno = 0; |
| 4598 | char *loc = setlocale (category, locale); | 4597 | char *loc = setlocale (category, locale); |
| 4599 | if (loc || errno) | 4598 | if (loc || errno) |
| 4600 | return loc; | 4599 | return loc; |
| 4601 | errno = EINVAL; | 4600 | errno = EINVAL; |
| 4602 | # else | ||
| 4603 | errno = ENOTSUP; | ||
| 4604 | # endif | ||
| 4605 | return 0; | 4601 | return 0; |
| 4606 | } | 4602 | } |
| 4607 | 4603 | ||