Make LOCK_LC_NUMERIC_STANDARD recursive
authorKarl Williamson <khw@cpan.org>
Sat, 3 Jun 2017 15:08:50 +0000 (09:08 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 8 Jun 2017 19:07:19 +0000 (13:07 -0600)
Same for UNLOCK_LC_NUMERIC_STANDARD.

This partially fixes [perl #128207]

perl.h

diff --git a/perl.h b/perl.h
index de20aa2..9022114 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -6186,14 +6186,20 @@ expression, but with an empty argument list, like this:
         _restore_LC_NUMERIC_function = &Perl_set_numeric_standard;          \
     }
 
-/* Lock to the C locale until unlock is called */
+/* Lock/unlock to the C locale until unlock is called.  This needs to be
+ * recursively callable.  [perl #128207] */
 #define LOCK_LC_NUMERIC_STANDARD()                          \
         (__ASSERT_(PL_numeric_standard)                     \
-        PL_numeric_standard = 2)
-
+        PL_numeric_standard++)
 #define UNLOCK_LC_NUMERIC_STANDARD()                        \
-        (__ASSERT_(PL_numeric_standard == 2)                \
-        PL_numeric_standard = 1)
+            STMT_START {                                    \
+                if (PL_numeric_standard > 1) {              \
+                    PL_numeric_standard--;                  \
+                }                                           \
+                else {                                      \
+                    assert(0);                              \
+                }                                           \
+            } STMT_END
 
 #define RESTORE_LC_NUMERIC_UNDERLYING()                     \
        if (_was_local) set_numeric_local();