This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX.xs: White space only
[perl5.git] / ext / POSIX / POSIX.xs
index 922f4d1..76fc9a3 100644 (file)
@@ -1598,8 +1598,8 @@ static const struct lconv_offset lconv_strings[] = {
 
 /* The Linux man pages say these are the field names for the structure
  * components that are LC_NUMERIC; the rest being LC_MONETARY */
-#   define isLC_NUMERIC_STRING(name) (strEQ(name, "decimal_point")     \
-                                      || strEQ(name, "thousands_sep")  \
+#   define isLC_NUMERIC_STRING(name) (   strEQ(name, "decimal_point")   \
+                                      || strEQ(name, "thousands_sep")   \
                                                                         \
                                       /* There should be no harm done   \
                                        * checking for this, even if     \
@@ -2198,7 +2198,7 @@ localeconv()
             }
        }
 
-        RESTORE_LC_NUMERIC_STANDARD();
+        RESTORE_LC_NUMERIC();
 #endif  /* HAS_LOCALECONV */
     OUTPUT:
        RETVAL
@@ -3295,6 +3295,7 @@ strtod(str)
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
         STORE_LC_NUMERIC_FORCE_TO_UNDERLYING();
        num = strtod(str, &unparsed);
+        RESTORE_LC_NUMERIC();
        PUSHs(sv_2mortal(newSVnv(num)));
        if (GIMME_V == G_ARRAY) {
            EXTEND(SP, 1);
@@ -3303,7 +3304,6 @@ strtod(str)
            else
                PUSHs(&PL_sv_undef);
        }
-        RESTORE_LC_NUMERIC_STANDARD();
 
 #ifdef HAS_STRTOLD
 
@@ -3317,6 +3317,7 @@ strtold(str)
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
         STORE_LC_NUMERIC_FORCE_TO_UNDERLYING();
        num = strtold(str, &unparsed);
+        RESTORE_LC_NUMERIC();
        PUSHs(sv_2mortal(newSVnv(num)));
        if (GIMME_V == G_ARRAY) {
            EXTEND(SP, 1);
@@ -3325,7 +3326,6 @@ strtold(str)
            else
                PUSHs(&PL_sv_undef);
        }
-        RESTORE_LC_NUMERIC_STANDARD();
 
 #endif
 
@@ -3560,18 +3560,23 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
             /* allowing user-supplied (rather than literal) formats
              * is normally frowned upon as a potential security risk;
              * but this is part of the API so we have to allow it */
-            GCC_DIAG_IGNORE(-Wformat-nonliteral);
+            GCC_DIAG_IGNORE_STMT(-Wformat-nonliteral);
            buf = my_strftime(SvPV_nolen(fmt), sec, min, hour, mday, mon, year, wday, yday, isdst);
-            GCC_DIAG_RESTORE;
+            GCC_DIAG_RESTORE_STMT;
             sv = sv_newmortal();
            if (buf) {
-                const U8 * first_variant;
                 STRLEN len = strlen(buf);
                sv_usepvn_flags(sv, buf, len, SV_HAS_TRAILING_NUL);
                if (       SvUTF8(fmt)
                     || (   is_utf8_non_invariant_string((U8*) buf, len)
 #ifdef USE_LOCALE_TIME
                         && _is_cur_LC_category_utf8(LC_TIME)
+#else   /* If can't check directly, at least can see if script is consistent,
+           under UTF-8, which gives us an extra measure of confidence. */
+
+                        && isSCRIPT_RUN((const U8 *) buf, buf + len,
+                                        TRUE, /* Means assume UTF-8 */
+                                        NULL)
 #endif
                 )) {
                    SvUTF8_on(sv);