This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Use common fcn for error message
authorKarl Williamson <khw@cpan.org>
Wed, 22 Jan 2020 16:25:26 +0000 (09:25 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 23 Jan 2020 22:46:56 +0000 (15:46 -0700)
There is now a function that generates this error message.  This is so
that it is always the same from wherever generated.

embed.fnc
embed.h
proto.h
utf8.c

index e91f00e..4bb864f 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1167,7 +1167,7 @@ EpRX      |const char *|form_alien_digit_msg|const U8 which       \
 #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_TOKE_C)
 EiRT   |bool   |regcurly       |NN const char *s
 #endif
-#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_TOKE_C) || defined(PERL_IN_DQUOTE_C)
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_TOKE_C) || defined(PERL_IN_DQUOTE_C) || defined(PERL_IN_UTF8_C)
 EpRX   |const char *|form_cp_too_large_msg|const U8 which      \
                                |NULLOK const char * string     \
                                |const Size_t len               \
diff --git a/embed.h b/embed.h
index 4326414..c948c45 100644 (file)
--- a/embed.h
+++ b/embed.h
 #  endif
 #  if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_TOKE_C) || defined(PERL_IN_DQUOTE_C)
 #define form_alien_digit_msg(a,b,c,d,e,f)      Perl_form_alien_digit_msg(aTHX_ a,b,c,d,e,f)
-#define form_cp_too_large_msg(a,b,c,d) Perl_form_cp_too_large_msg(aTHX_ a,b,c,d)
 #define grok_bslash_c(a,b,c,d) Perl_grok_bslash_c(aTHX_ a,b,c,d)
 #define grok_bslash_o(a,b,c,d,e,f,g,h) Perl_grok_bslash_o(aTHX_ a,b,c,d,e,f,g,h)
 #define grok_bslash_x(a,b,c,d,e,f,g,h) Perl_grok_bslash_x(aTHX_ a,b,c,d,e,f,g,h)
 #  endif
+#  if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_TOKE_C) || defined(PERL_IN_DQUOTE_C) || defined(PERL_IN_UTF8_C)
+#define form_cp_too_large_msg(a,b,c,d) Perl_form_cp_too_large_msg(aTHX_ a,b,c,d)
+#  endif
 #  if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C) || defined(PERL_IN_OP_C) || defined(PERL_IN_DOOP_C)
 #define _add_range_to_invlist(a,b,c)   Perl__add_range_to_invlist(aTHX_ a,b,c)
 #define _invlist_intersection_maybe_complement_2nd(a,b,c,d)    Perl__invlist_intersection_maybe_complement_2nd(aTHX_ a,b,c,d)
diff --git a/proto.h b/proto.h
index 8e915ba..9110ed8 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -5919,10 +5919,6 @@ PERL_CALLCONV const char *       Perl_form_alien_digit_msg(pTHX_ const U8 which, const
 #define PERL_ARGS_ASSERT_FORM_ALIEN_DIGIT_MSG  \
        assert(first_bad); assert(send)
 
-PERL_CALLCONV const char *     Perl_form_cp_too_large_msg(pTHX_ const U8 which, const char * string, const Size_t len, const UV cp)
-                       __attribute__warn_unused_result__;
-#define PERL_ARGS_ASSERT_FORM_CP_TOO_LARGE_MSG
-
 PERL_CALLCONV bool     Perl_grok_bslash_c(pTHX_ const char source, U8 * result, const char** message, U32 * packed_warn)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_GROK_BSLASH_C \
@@ -5939,6 +5935,12 @@ PERL_CALLCONV bool       Perl_grok_bslash_x(pTHX_ char** s, const char* const send, UV
        assert(s); assert(send); assert(uv); assert(message)
 
 #endif
+#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_TOKE_C) || defined(PERL_IN_DQUOTE_C) || defined(PERL_IN_UTF8_C)
+PERL_CALLCONV const char *     Perl_form_cp_too_large_msg(pTHX_ const U8 which, const char * string, const Size_t len, const UV cp)
+                       __attribute__warn_unused_result__;
+#define PERL_ARGS_ASSERT_FORM_CP_TOO_LARGE_MSG
+
+#endif
 #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C) || defined(PERL_IN_OP_C) || defined(PERL_IN_DOOP_C)
 PERL_CALLCONV SV*      Perl__add_range_to_invlist(pTHX_ SV* invlist, UV start, UV end)
                        __attribute__warn_unused_result__;
diff --git a/utf8.c b/utf8.c
index a67c987..471ad04 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -37,11 +37,6 @@ static const char malformed_text[] = "Malformed UTF-8 character";
 static const char unees[] =
                         "Malformed UTF-8 character (unexpected end of string)";
 
-/* Be sure to synchronize this message with the similar one in regcomp.c */
-static const char cp_above_legal_max[] =
-                        "Use of code point 0x%" UVXf " is not allowed; the"
-                        " permissible max is 0x%" UVXf;
-
 /*
 =head1 Unicode Support
 These are various utility functions for manipulating UTF8-encoded
@@ -324,7 +319,7 @@ Perl_uvoffuni_to_utf8_flags_msgs(pTHX_ U8 *d, UV uv, const UV flags, HV** msgs)
         if (UNLIKELY(      uv > MAX_LEGAL_CP
                      && ! (flags & UNICODE_ALLOW_ABOVE_IV_MAX)))
         {
-            Perl_croak(aTHX_ cp_above_legal_max, uv, MAX_LEGAL_CP);
+            Perl_croak(aTHX_ "%s", form_cp_too_large_msg(16, NULL, 0, uv));
         }
         if (       (flags & UNICODE_WARN_SUPER)
             || (   (flags & UNICODE_WARN_PERL_EXTENDED)
@@ -3324,8 +3319,7 @@ S__to_utf8_case(pTHX_ const UV uv1, const U8 *p,
 
                 if (UNLIKELY(UNICODE_IS_SUPER(uv1))) {
                     if (UNLIKELY(uv1 > MAX_LEGAL_CP)) {
-                        Perl_croak(aTHX_ cp_above_legal_max, uv1,
-                                         MAX_LEGAL_CP);
+                        Perl_croak(aTHX_ "%s", form_cp_too_large_msg(16, NULL, 0, uv1));
                     }
                     if (ckWARN_d(WARN_NON_UNICODE)) {
                         const char* desc = (PL_op) ? OP_DESC(PL_op) : normal;