utf8.c: Rename macro and move to utf8.h, and use it in regcomp.c
authorKarl Williamson <khw@cpan.org>
Mon, 20 Aug 2018 04:35:29 +0000 (22:35 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 20 Aug 2018 18:44:25 +0000 (12:44 -0600)
This hides an internal detail

regcomp.c
utf8.c
utf8.h

index d8e29d9..31fc6b4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -12410,8 +12410,8 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
             /* Loop through the hex digits of the current code point */
             do {
                 /* Adding this digit will shift the result 4 bits.  If that
-                 * result would be above IV_MAX, it's overflow */
-                if (cp > IV_MAX >> 4) {
+                 * result would be above the legal max, it's overflow */
+                if (cp > MAX_LEGAL_CP >> 4) {
 
                     /* Find the end of the code point */
                     do {
@@ -12422,7 +12422,8 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
                      * in utf8.c */
                     vFAIL4("Use of code point 0x%.*s is not allowed; the"
                         " permissible max is 0x%" UVxf,
-                        (int) (RExC_parse - start_digit), start_digit, IV_MAX);
+                        (int) (RExC_parse - start_digit), start_digit,
+                        MAX_LEGAL_CP);
                 }
 
                 /* Accumulate this (valid) digit into the running total */
diff --git a/utf8.c b/utf8.c
index cba1523..b1ac5a8 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -42,8 +42,6 @@ static const char cp_above_legal_max[] =
                         "Use of code point 0x%" UVXf " is not allowed; the"
                         " permissible max is 0x%" UVXf;
 
-#define MAX_EXTERNALLY_LEGAL_CP ((UV) (IV_MAX))
-
 /*
 =head1 Unicode Support
 These are various utility functions for manipulating UTF8-encoded
@@ -309,8 +307,8 @@ Perl_uvoffuni_to_utf8_flags_msgs(pTHX_ U8 *d, UV uv, const UV flags, HV** msgs)
      * performance hit on these high EBCDIC code points. */
 
     if (UNLIKELY(UNICODE_IS_SUPER(uv))) {
-        if (UNLIKELY(uv > MAX_EXTERNALLY_LEGAL_CP)) {
-            Perl_croak(aTHX_ cp_above_legal_max, uv, MAX_EXTERNALLY_LEGAL_CP);
+        if (UNLIKELY(uv > MAX_LEGAL_CP)) {
+            Perl_croak(aTHX_ cp_above_legal_max, uv, MAX_LEGAL_CP);
         }
         if (       (flags & UNICODE_WARN_SUPER)
             || (   (flags & UNICODE_WARN_PERL_EXTENDED)
@@ -3428,9 +3426,9 @@ S__to_utf8_case(pTHX_ const UV uv1, const U8 *p,
                 }
 
                 if (UNLIKELY(UNICODE_IS_SUPER(uv1))) {
-                    if (UNLIKELY(uv1 > MAX_EXTERNALLY_LEGAL_CP)) {
+                    if (UNLIKELY(uv1 > MAX_LEGAL_CP)) {
                         Perl_croak(aTHX_ cp_above_legal_max, uv1,
-                                         MAX_EXTERNALLY_LEGAL_CP);
+                                         MAX_LEGAL_CP);
                     }
                     if (ckWARN_d(WARN_NON_UNICODE)) {
                         const char* desc = (PL_op) ? OP_DESC(PL_op) : normal;
diff --git a/utf8.h b/utf8.h
index af24637..f5ff61d 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -758,6 +758,8 @@ point's representation.
 
 #define UTF8_IS_REPLACEMENT(s, send) is_REPLACEMENT_utf8_safe(s,send)
 
+#define MAX_LEGAL_CP  IV_MAX
+
 /*
 =for apidoc Am|bool|UTF8_IS_SUPER|const U8 *s|const U8 *e