@@ -1064,6 +1064,10 @@ violations are fatal.
1064
1064
1065
1065
#include " perl_langinfo.h" /* Needed for _NL_LOCALE_NAME */
1066
1066
1067
+ /* =========================================================================
1068
+ * The defines from here to the following ===== line are unfortunately
1069
+ * duplicated in makedef.pl, and changes here MUST also be made there */
1070
+
1067
1071
/* If not forbidden, we enable locale handling if either 1) the POSIX 2008
1068
1072
* functions are available, or 2) just the setlocale() function. This logic is
1069
1073
* repeated in t/loc_tools.pl and makedef.pl; The three should be kept in
@@ -1215,35 +1219,32 @@ violations are fatal.
1215
1219
# define LC_ALL_INDEX_ PERL_DUMMY_TOD_ + 1
1216
1220
# endif
1217
1221
1218
- /* XXX The next few defines are unfortunately duplicated in makedef.pl, and
1219
- * changes here MUST also be made there */
1220
1222
1221
1223
# if defined(USE_ITHREADS) && ! defined(NO_LOCALE_THREADS)
1222
1224
# define USE_LOCALE_THREADS
1223
1225
# endif
1224
- # if ! defined(HAS_SETLOCALE) && defined(HAS_POSIX_2008_LOCALE)
1225
- # define USE_POSIX_2008_LOCALE
1226
- # ifdef USE_LOCALE_THREADS
1227
- # define USE_THREAD_SAFE_LOCALE
1228
- # endif
1229
- /* If compiled with
1230
- * -DUSE_THREAD_SAFE_LOCALE, will do so even
1231
- * on unthreaded builds */
1232
- # elif (defined(USE_LOCALE_THREADS) || defined(USE_THREAD_SAFE_LOCALE)) \
1233
- && ( defined (HAS_POSIX_2008_LOCALE) \
1234
- || (defined (WIN32) && defined (_MSC_VER))) \
1235
- && ! defined (NO_THREAD_SAFE_LOCALE)
1236
- # ifndef USE_THREAD_SAFE_LOCALE
1226
+
1227
+ /* Use POSIX 2008 locales if available, and no alternative exists
1228
+ * ('setlocale()' is the alternative); or is threaded and not forbidden to
1229
+ * use them */
1230
+ # if defined(HAS_POSIX_2008_LOCALE) && ( ! defined(HAS_SETLOCALE) \
1231
+ || ( defined (USE_LOCALE_THREADS) \
1232
+ && ! defined (NO_POSIX_2008_LOCALE)))
1233
+ # define USE_POSIX_2008_LOCALE
1234
+ # endif
1235
+
1236
+ /* On threaded builds, use thread-safe locales if they are available and not
1237
+ * forbidden. Availability is when we are using POSIX 2008 locales, or
1238
+ * Windows for quite a few releases now. */
1239
+ # if defined(USE_LOCALE_THREADS) && ! defined(NO_THREAD_SAFE_LOCALE)
1240
+ # if defined(USE_POSIX_2008_LOCALE) || (defined(WIN32) && defined(_MSC_VER))
1237
1241
# define USE_THREAD_SAFE_LOCALE
1238
1242
# endif
1239
- # ifdef HAS_POSIX_2008_LOCALE
1240
- # define USE_POSIX_2008_LOCALE
1241
- # endif
1242
1243
# endif
1243
1244
1244
1245
# include " perl_langinfo.h" /* Needed for _NL_LOCALE_NAME */
1245
1246
1246
- /* Allow use of glib 's undocumented querylocale() equivalent if asked for, and
1247
+ /* Allow use of glibc 's undocumented querylocale() equivalent if asked for, and
1247
1248
* appropriate */
1248
1249
# ifdef USE_POSIX_2008_LOCALE
1249
1250
# if defined(HAS_QUERYLOCALE) \
@@ -1262,21 +1263,28 @@ violations are fatal.
1262
1263
# endif
1263
1264
# endif
1264
1265
1266
+ /* POSIX 2008 has no means of finding out the current locale without a
1267
+ * querylocale; so must keep track of it ourselves */
1265
1268
# if (defined(USE_POSIX_2008_LOCALE) && ! defined(USE_QUERYLOCALE))
1266
1269
# define USE_PL_CURLOCALES
1267
1270
# endif
1268
1271
1269
- /* Microsoft documentation reads in the change log for VS 2015:
1270
- * "The localeconv function declared in locale.h now works correctly when
1271
- * per-thread locale is enabled. In previous versions of the library, this
1272
- * function would return the lconv data for the global locale, not the
1273
- * thread's locale."
1274
- */
1275
- # if defined(WIN32) && defined(USE_THREAD_SAFE_LOCALE) && _MSC_VER < 1900
1276
- # define TS_W32_BROKEN_LOCALECONV
1272
+ # if defined(WIN32) && defined(USE_THREAD_SAFE_LOCALE)
1273
+
1274
+ /* Microsoft documentation reads in the change log for VS 2015: "The
1275
+ * localeconv function declared in locale.h now works correctly when
1276
+ * per-thread locale is enabled. In previous versions of the library, this
1277
+ * function would return the lconv data for the global locale, not the
1278
+ * thread's locale." */
1279
+ # if _MSC_VER < 1900
1280
+ # define TS_W32_BROKEN_LOCALECONV
1281
+ # endif
1277
1282
# endif
1278
1283
#endif
1279
1284
1285
+ /* end of makedef.pl logic duplication
1286
+ * ========================================================================= */
1287
+
1280
1288
#ifdef PERL_CORE
1281
1289
1282
1290
/* Both typedefs are used in locale.c only, but defined here so that embed.fnc
0 commit comments