@@ -930,7 +930,6 @@ main (int argc, char **argv)
930
930
for pointers. */
931
931
void * stack_bottom_variable ;
932
932
933
- bool do_initial_setlocale ;
934
933
bool no_loadup = false;
935
934
char * junk = 0 ;
936
935
char * dname_arg = 0 ;
@@ -1235,19 +1234,17 @@ main (int argc, char **argv)
1235
1234
set_binary_mode (STDOUT_FILENO , O_BINARY );
1236
1235
#endif /* MSDOS */
1237
1236
1238
- /* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case.
1239
- The build procedure uses this while dumping, to ensure that the
1240
- dumped Emacs does not have its system locale tables initialized,
1241
- as that might cause screwups when the dumped Emacs starts up. */
1242
- {
1243
- char * lc_all = getenv ("LC_ALL" );
1244
- do_initial_setlocale = ! lc_all || strcmp (lc_all , "C" );
1245
- }
1246
-
1247
- /* Set locale now, so that initial error messages are localized properly.
1248
- fixup_locale must wait until later, since it builds strings. */
1249
- if (do_initial_setlocale )
1250
- setlocale (LC_ALL , "" );
1237
+ /* Set locale, so that initial error messages are localized properly.
1238
+ However, skip this if LC_ALL is "C", as it's not needed in that case.
1239
+ Skipping helps if dumping with unexec, to ensure that the dumped
1240
+ Emacs does not have its system locale tables initialized, as that
1241
+ might cause screwups when the dumped Emacs starts up. */
1242
+ char * lc_all = getenv ("LC_ALL" );
1243
+ if (! (lc_all && strcmp (lc_all , "C" ) == 0 ))
1244
+ {
1245
+ setlocale (LC_ALL , "" );
1246
+ fixup_locale ();
1247
+ }
1251
1248
text_quoting_flag = using_utf8 ();
1252
1249
1253
1250
inhibit_window_system = 0 ;
@@ -1576,14 +1573,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1576
1573
init_alloc ();
1577
1574
init_bignum ();
1578
1575
init_threads ();
1579
-
1580
- if (do_initial_setlocale )
1581
- {
1582
- fixup_locale ();
1583
- Vsystem_messages_locale = Vprevious_system_messages_locale ;
1584
- Vsystem_time_locale = Vprevious_system_time_locale ;
1585
- }
1586
-
1587
1576
init_eval ();
1588
1577
init_atimer ();
1589
1578
running_asynch_code = 0 ;
@@ -2617,25 +2606,25 @@ synchronize_locale (int category, Lisp_Object *plocale, Lisp_Object desired_loca
2617
2606
if (! EQ (* plocale , desired_locale ))
2618
2607
{
2619
2608
* plocale = desired_locale ;
2620
- #ifdef WINDOWSNT
2609
+ char const * locale_string
2610
+ = STRINGP (desired_locale ) ? SSDATA (desired_locale ) : "" ;
2611
+ # ifdef WINDOWSNT
2621
2612
/* Changing categories like LC_TIME usually requires specifying
2622
2613
an encoding suitable for the new locale, but MS-Windows's
2623
2614
'setlocale' will only switch the encoding when LC_ALL is
2624
2615
specified. So we ignore CATEGORY, use LC_ALL instead, and
2625
2616
then restore LC_NUMERIC to "C", so reading and printing
2626
2617
numbers is unaffected. */
2627
- setlocale (LC_ALL , (STRINGP (desired_locale )
2628
- ? SSDATA (desired_locale )
2629
- : "" ));
2618
+ setlocale (LC_ALL , locale_string );
2630
2619
fixup_locale ();
2631
- #else /* !WINDOWSNT */
2632
- setlocale (category , (STRINGP (desired_locale )
2633
- ? SSDATA (desired_locale )
2634
- : "" ));
2635
- #endif /* !WINDOWSNT */
2620
+ # else /* !WINDOWSNT */
2621
+ setlocale (category , locale_string );
2622
+ # endif /* !WINDOWSNT */
2636
2623
}
2637
2624
}
2638
2625
2626
+ static Lisp_Object Vprevious_system_time_locale ;
2627
+
2639
2628
/* Set system time locale to match Vsystem_time_locale, if possible. */
2640
2629
void
2641
2630
synchronize_system_time_locale (void )
@@ -2644,15 +2633,19 @@ synchronize_system_time_locale (void)
2644
2633
Vsystem_time_locale );
2645
2634
}
2646
2635
2636
+ # ifdef LC_MESSAGES
2637
+ static Lisp_Object Vprevious_system_messages_locale ;
2638
+ # endif
2639
+
2647
2640
/* Set system messages locale to match Vsystem_messages_locale, if
2648
2641
possible. */
2649
2642
void
2650
2643
synchronize_system_messages_locale (void )
2651
2644
{
2652
- #ifdef LC_MESSAGES
2645
+ # ifdef LC_MESSAGES
2653
2646
synchronize_locale (LC_MESSAGES , & Vprevious_system_messages_locale ,
2654
2647
Vsystem_messages_locale );
2655
- #endif
2648
+ # endif
2656
2649
}
2657
2650
#endif /* HAVE_SETLOCALE */
2658
2651
@@ -2974,19 +2967,16 @@ build directory. */);
2974
2967
DEFVAR_LISP ("system-messages-locale" , Vsystem_messages_locale ,
2975
2968
doc : /* System locale for messages. */ );
2976
2969
Vsystem_messages_locale = Qnil ;
2977
-
2978
- DEFVAR_LISP ("previous-system-messages-locale" ,
2979
- Vprevious_system_messages_locale ,
2980
- doc : /* Most recently used system locale for messages. */ );
2970
+ #ifdef LC_MESSAGES
2981
2971
Vprevious_system_messages_locale = Qnil ;
2972
+ staticpro (& Vprevious_system_messages_locale );
2973
+ #endif
2982
2974
2983
2975
DEFVAR_LISP ("system-time-locale" , Vsystem_time_locale ,
2984
2976
doc : /* System locale for time. */ );
2985
2977
Vsystem_time_locale = Qnil ;
2986
-
2987
- DEFVAR_LISP ("previous-system-time-locale" , Vprevious_system_time_locale ,
2988
- doc : /* Most recently used system locale for time. */ );
2989
2978
Vprevious_system_time_locale = Qnil ;
2979
+ staticpro (& Vprevious_system_time_locale );
2990
2980
2991
2981
DEFVAR_LISP ("before-init-time" , Vbefore_init_time ,
2992
2982
doc : /* Value of `current-time' before Emacs begins initialization. */ );
0 commit comments