@@ -668,79 +668,26 @@ Perl_upg_version(pTHX_ SV *ver, bool qv)
668
668
locale_name_on_entry = NULL ;
669
669
}
670
670
671
- # else
672
- const locale_t locale_obj_on_entry = uselocale ((locale_t ) 0 );
673
- const char * locale_name_on_entry = NULL ;
674
- DECLARATION_FOR_LC_NUMERIC_MANIPULATION ;
675
-
676
- if (locale_obj_on_entry == LC_GLOBAL_LOCALE ) {
677
-
678
- /* in the global locale, we can call system setlocale and if it
679
- * isn't C, set it to C. */
680
- LC_NUMERIC_LOCK (0 );
681
-
682
- locale_name_on_entry = setlocale (LC_NUMERIC , NULL );
683
- if ( strNE (locale_name_on_entry , "C" )
684
- && strNE (locale_name_on_entry , "POSIX" ))
685
- {
686
- /* the setlocale() call might free or overwrite the name */
687
- locale_name_on_entry = savepv (locale_name_on_entry );
688
- setlocale (LC_NUMERIC , "C" );
689
- }
690
- else { /* This value indicates to the restore code that we
691
- didn't change the locale */
692
- locale_name_on_entry = NULL ;
693
- }
694
- }
695
- else if (locale_obj_on_entry == PL_underlying_numeric_obj ) {
696
- /* Here, the locale appears to have been changed to use the
697
- * program's underlying locale. Just use our mechanisms to
698
- * switch back to C. It might be possible for this pointer to
699
- * actually refer to something else if it got released and
700
- * reused somehow. But it doesn't matter, our mechanisms will
701
- * work even so */
702
- STORE_LC_NUMERIC_SET_STANDARD ();
703
- }
704
- else if (locale_obj_on_entry != PL_C_locale_obj ) {
705
- /* The C object should be unchanged during a program's
706
- * execution, so it should be safe to assume it means what it
707
- * says, so if we are in it, no locale change is required.
708
- * Otherwise, simply use the thread-safe operation. */
709
- uselocale (PL_C_locale_obj );
710
- }
711
-
712
- # endif
713
671
/* Prevent recursed calls from trying to change back */
714
672
LOCK_LC_NUMERIC_STANDARD ();
715
- #endif
716
- GET_NUMERIC_VERSION (ver , sv , tbuf , buf , len );
717
673
718
- #ifdef USE_LOCALE_NUMERIC
674
+ GET_NUMERIC_VERSION ( ver , sv , tbuf , buf , len );
719
675
720
676
UNLOCK_LC_NUMERIC_STANDARD ();
721
677
722
- # ifndef USE_POSIX_2008_LOCALE
723
-
724
678
if (locale_name_on_entry ) {
725
679
setlocale (LC_NUMERIC , locale_name_on_entry );
726
680
Safefree (locale_name_on_entry );
727
681
}
728
682
729
683
LC_NUMERIC_UNLOCK ; /* End critical section */
730
- # else
731
-
732
- if (locale_name_on_entry ) {
733
- setlocale (LC_NUMERIC , locale_name_on_entry );
734
- Safefree (locale_name_on_entry );
735
- LC_NUMERIC_UNLOCK ;
736
- }
737
- else if (locale_obj_on_entry == PL_underlying_numeric_obj ) {
738
- RESTORE_LC_NUMERIC ();
739
- }
740
- else if (locale_obj_on_entry != PL_C_locale_obj ) {
741
- uselocale (locale_obj_on_entry );
742
- }
743
684
685
+ # else
686
+ /* With POSIX 2008, all we have to do is toggle to the C locale
687
+ * just long enough to get the value (which should have a dot). */
688
+ const locale_t locale_obj_on_entry = uselocale (PL_C_locale_obj );
689
+ GET_NUMERIC_VERSION (ver , sv , tbuf , buf , len );
690
+ uselocale (locale_obj_on_entry );
744
691
# endif
745
692
746
693
}
0 commit comments