This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_length: only call sv_len_utf8_nomg() if needed
[perl5.git] / proto.h
diff --git a/proto.h b/proto.h
index 367352c..d6df7f4 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -256,12 +256,15 @@ PERL_CALLCONV void        Perl_boot_core_mro(pTHX);
 PERL_CALLCONV int      Perl_bytes_cmp_utf8(pTHX_ const U8 *b, STRLEN blen, const U8 *u, STRLEN ulen);
 #define PERL_ARGS_ASSERT_BYTES_CMP_UTF8        \
        assert(b); assert(u)
-PERL_CALLCONV U8*      Perl_bytes_from_utf8(pTHX_ const U8 *s, STRLEN *len, bool *is_utf8);
+PERL_CALLCONV U8*      Perl_bytes_from_utf8(pTHX_ const U8 *s, STRLEN *lenp, bool *is_utf8p);
 #define PERL_ARGS_ASSERT_BYTES_FROM_UTF8       \
-       assert(s); assert(len)
-PERL_CALLCONV U8*      Perl_bytes_to_utf8(pTHX_ const U8 *s, STRLEN *len);
+       assert(s); assert(lenp); assert(is_utf8p)
+PERL_CALLCONV U8*      Perl_bytes_from_utf8_loc(const U8 *s, STRLEN *lenp, bool *is_utf8p, const U8 ** first_unconverted);
+#define PERL_ARGS_ASSERT_BYTES_FROM_UTF8_LOC   \
+       assert(s); assert(lenp); assert(is_utf8p)
+PERL_CALLCONV U8*      Perl_bytes_to_utf8(pTHX_ const U8 *s, STRLEN *lenp);
 #define PERL_ARGS_ASSERT_BYTES_TO_UTF8 \
-       assert(s); assert(len)
+       assert(s); assert(lenp)
 PERL_CALLCONV I32      Perl_call_argv(pTHX_ const char* sub_name, I32 flags, char** argv);
 #define PERL_ARGS_ASSERT_CALL_ARGV     \
        assert(sub_name); assert(argv)
@@ -789,7 +792,7 @@ PERL_CALLCONV OP*   Perl_do_readline(pTHX)
                        __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_do_seek(pTHX_ GV* gv, Off_t pos, int whence);
-PERL_CALLCONV void     Perl_do_sprintf(pTHX_ SV* sv, I32 len, SV** sarg);
+PERL_CALLCONV void     Perl_do_sprintf(pTHX_ SV* sv, SSize_t len, SV** sarg);
 #define PERL_ARGS_ASSERT_DO_SPRINTF    \
        assert(sv); assert(sarg)
 PERL_CALLCONV void     Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim);
@@ -1617,10 +1620,13 @@ PERL_CALLCONV bool      Perl_is_utf8_idfirst(pTHX_ const U8 *p)
 #define PERL_ARGS_ASSERT_IS_UTF8_IDFIRST       \
        assert(p)
 
+/* PERL_CALLCONV bool  is_utf8_invariant_string(const U8* const s, STRLEN const len)
+                       __attribute__warn_unused_result__; */
+
 #ifndef PERL_NO_INLINE_FUNCTIONS
-PERL_STATIC_INLINE bool        S_is_utf8_invariant_string(const U8* const s, STRLEN const len)
+PERL_STATIC_INLINE bool        S_is_utf8_invariant_string_loc(const U8* const s, STRLEN const len, const U8 ** ep)
                        __attribute__warn_unused_result__;
-#define PERL_ARGS_ASSERT_IS_UTF8_INVARIANT_STRING      \
+#define PERL_ARGS_ASSERT_IS_UTF8_INVARIANT_STRING_LOC  \
        assert(s)
 #endif
 
@@ -2357,10 +2363,6 @@ PERL_CALLCONV CV *       Perl_newXS_flags(pTHX_ const char *name, XSUBADDR_t subaddr,
 PERL_CALLCONV CV *     Perl_newXS_len_flags(pTHX_ const char *name, STRLEN len, XSUBADDR_t subaddr, const char *const filename, const char *const proto, SV **const_svp, U32 flags);
 #define PERL_ARGS_ASSERT_NEWXS_LEN_FLAGS       \
        assert(subaddr)
-PERL_CALLCONV void     Perl_new_collate(pTHX_ const char* newcoll);
-PERL_CALLCONV void     Perl_new_ctype(pTHX_ const char* newctype);
-#define PERL_ARGS_ASSERT_NEW_CTYPE     \
-       assert(newctype)
 PERL_CALLCONV void     Perl_new_numeric(pTHX_ const char* newcoll);
 PERL_CALLCONV PERL_SI* Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
                        __attribute__warn_unused_result__;
@@ -2909,12 +2911,12 @@ PERL_CALLCONV void      Perl_set_context(void *t);
 #define PERL_ARGS_ASSERT_SET_CONTEXT   \
        assert(t)
 PERL_CALLCONV void     Perl_set_numeric_local(pTHX);
-PERL_CALLCONV void     Perl_set_numeric_radix(pTHX);
 PERL_CALLCONV void     Perl_set_numeric_standard(pTHX);
 PERL_CALLCONV void     Perl_setdefout(pTHX_ GV* gv);
 #define PERL_ARGS_ASSERT_SETDEFOUT     \
        assert(gv)
-PERL_CALLCONV HEK*     Perl_share_hek(pTHX_ const char* str, I32 len, U32 hash);
+PERL_CALLCONV char*    Perl_setlocale(int category, const char* locale);
+PERL_CALLCONV HEK*     Perl_share_hek(pTHX_ const char* str, SSize_t len, U32 hash);
 #define PERL_ARGS_ASSERT_SHARE_HEK     \
        assert(str)
 PERL_CALLCONV void     Perl_sortsv(pTHX_ SV** array, size_t num_elts, SVCOMPARE_t cmp);
@@ -3454,10 +3456,10 @@ PERL_CALLCONV void      Perl_sv_vcatpvf(pTHX_ SV *const sv, const char *const pat, va
 PERL_CALLCONV void     Perl_sv_vcatpvf_mg(pTHX_ SV *const sv, const char *const pat, va_list *const args);
 #define PERL_ARGS_ASSERT_SV_VCATPVF_MG \
        assert(sv); assert(pat)
-PERL_CALLCONV void     Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted);
+PERL_CALLCONV void     Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const Size_t sv_count, bool *const maybe_tainted);
 #define PERL_ARGS_ASSERT_SV_VCATPVFN   \
        assert(sv); assert(pat)
-PERL_CALLCONV void     Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted, const U32 flags);
+PERL_CALLCONV void     Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const Size_t sv_count, bool *const maybe_tainted, const U32 flags);
 #define PERL_ARGS_ASSERT_SV_VCATPVFN_FLAGS     \
        assert(sv); assert(pat)
 PERL_CALLCONV void     Perl_sv_vsetpvf(pTHX_ SV *const sv, const char *const pat, va_list *const args);
@@ -3466,7 +3468,7 @@ PERL_CALLCONV void        Perl_sv_vsetpvf(pTHX_ SV *const sv, const char *const pat, va
 PERL_CALLCONV void     Perl_sv_vsetpvf_mg(pTHX_ SV *const sv, const char *const pat, va_list *const args);
 #define PERL_ARGS_ASSERT_SV_VSETPVF_MG \
        assert(sv); assert(pat)
-PERL_CALLCONV void     Perl_sv_vsetpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted);
+PERL_CALLCONV void     Perl_sv_vsetpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const Size_t sv_count, bool *const maybe_tainted);
 #define PERL_ARGS_ASSERT_SV_VSETPVFN   \
        assert(sv); assert(pat)
 PERL_CALLCONV UV       Perl_swash_fetch(pTHX_ SV *swash, const U8 *ptr, bool do_utf8);
@@ -3515,11 +3517,6 @@ PERL_CALLCONV U32        Perl_to_uni_upper_lc(pTHX_ U32 c)
                        __attribute__deprecated__
                        __attribute__warn_unused_result__;
 
-PERL_CALLCONV UV       Perl_to_utf8_case(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special)
-                       __attribute__deprecated__;
-#define PERL_ARGS_ASSERT_TO_UTF8_CASE  \
-       assert(p); assert(ustrp); assert(swashp); assert(normal)
-
 #ifndef NO_MATHOMS
 PERL_CALLCONV UV       Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
                        __attribute__deprecated__;
@@ -3608,9 +3605,9 @@ PERL_CALLCONV STRLEN      Perl_utf8_length(pTHX_ const U8* s, const U8 *e)
 #define PERL_ARGS_ASSERT_UTF8_LENGTH   \
        assert(s); assert(e)
 
-PERL_CALLCONV U8*      Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *len);
+PERL_CALLCONV U8*      Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *lenp);
 #define PERL_ARGS_ASSERT_UTF8_TO_BYTES \
-       assert(s); assert(len)
+       assert(s); assert(lenp)
 PERL_CALLCONV UV       Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
                        __attribute__deprecated__;
 #define PERL_ARGS_ASSERT_UTF8_TO_UVCHR \
@@ -3802,9 +3799,6 @@ PERL_CALLCONV void*       Perl_my_cxt_init(pTHX_ int *index, size_t size);
        assert(index)
 #  endif
 #endif
-#if !(defined(WIN32))
-/* PERL_CALLCONV char* my_setlocale(pTHX_ int category, const char* locale); */
-#endif
 #if !(defined(_MSC_VER))
 PERL_CALLCONV_NO_RET int       Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
                        __attribute__noreturn__;
@@ -4077,6 +4071,15 @@ PERL_CALLCONV int        Perl_my_sprintf(char *buffer, const char *pat, ...);
 STATIC NV      S_mulexp10(NV value, I32 exponent);
 #  endif
 #endif
+#if !defined(UV_IS_QUAD)
+#  if defined(PERL_IN_UTF8_C)
+STATIC int     S_is_utf8_cp_above_31_bits(const U8 * const s, const U8 * const e, const bool consider_overlongs)
+                       __attribute__warn_unused_result__;
+#define PERL_ARGS_ASSERT_IS_UTF8_CP_ABOVE_31_BITS      \
+       assert(s); assert(e)
+
+#  endif
+#endif
 #if !defined(WIN32)
 PERL_CALLCONV bool     Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report);
 #define PERL_ARGS_ASSERT_DO_EXEC3      \
@@ -4166,15 +4169,16 @@ STATIC int      S_tokereport(pTHX_ I32 rv, const YYSTYPE* lvalp);
 #define PERL_ARGS_ASSERT_TOKEREPORT    \
        assert(lvalp)
 #  endif
-#  if defined(USE_LOCALE)     && (defined(PERL_IN_LOCALE_C) || defined (PERL_EXT_POSIX))
-PERL_CALLCONV char *   Perl__setlocale_debug_string(const int category, const char* const locale, const char* const retval)
-                       __attribute__warn_unused_result__;
-
-#  endif
 #  if defined(USE_LOCALE) && defined(PERL_IN_LOCALE_C)
+STATIC void    S_print_bytes_for_locale(pTHX_ const char * const s, const char * const e, const bool is_utf8);
+#define PERL_ARGS_ASSERT_PRINT_BYTES_FOR_LOCALE        \
+       assert(s); assert(e)
 STATIC void    S_print_collxfrm_input_and_return(pTHX_ const char * const s, const char * const e, const STRLEN * const xlen, const bool is_utf8);
 #define PERL_ARGS_ASSERT_PRINT_COLLXFRM_INPUT_AND_RETURN       \
        assert(s); assert(e)
+STATIC char *  S_setlocale_debug_string(const int category, const char* const locale, const char* const retval)
+                       __attribute__warn_unused_result__;
+
 #  endif
 #endif
 #if defined(DEBUGGING) && defined(ENABLE_REGEX_SETS_DEBUGGING)
@@ -4536,9 +4540,6 @@ PERL_CALLCONV void        Perl_sv_add_backref(pTHX_ SV *const tsv, SV *const sv);
 STATIC void    S_clear_placeholders(pTHX_ HV *hv, U32 items);
 #define PERL_ARGS_ASSERT_CLEAR_PLACEHOLDERS    \
        assert(hv)
-STATIC void    S_hfreeentries(pTHX_ HV *hv);
-#define PERL_ARGS_ASSERT_HFREEENTRIES  \
-       assert(hv)
 STATIC void    S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize);
 #define PERL_ARGS_ASSERT_HSPLIT        \
        assert(hv)
@@ -4552,6 +4553,9 @@ STATIC SV*        S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN k
 STATIC SV*     S_hv_free_ent_ret(pTHX_ HV *hv, HE *entry);
 #define PERL_ARGS_ASSERT_HV_FREE_ENT_RET       \
        assert(hv); assert(entry)
+STATIC void    S_hv_free_entries(pTHX_ HV *hv);
+#define PERL_ARGS_ASSERT_HV_FREE_ENTRIES       \
+       assert(hv)
 STATIC void    S_hv_magic_check(HV *hv, bool *needs_copy, bool *needs_store);
 #define PERL_ARGS_ASSERT_HV_MAGIC_CHECK        \
        assert(hv); assert(needs_copy); assert(needs_store)
@@ -4575,7 +4579,7 @@ STATIC HEK*       S_save_hek_flags(const char *str, I32 len, U32 hash, int flags)
 #define PERL_ARGS_ASSERT_SAVE_HEK_FLAGS        \
        assert(str)
 
-STATIC HEK*    S_share_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags)
+STATIC HEK*    S_share_hek_flags(pTHX_ const char *str, STRLEN len, U32 hash, int flags)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_SHARE_HEK_FLAGS       \
        assert(str)
@@ -4848,7 +4852,7 @@ STATIC void       S_destroy_matcher(pTHX_ PMOP* matcher);
 #define PERL_ARGS_ASSERT_DESTROY_MATCHER       \
        assert(matcher)
 STATIC OP*     S_do_smartmatch(pTHX_ HV* seen_this, HV* seen_other, const bool copied);
-STATIC OP*     S_docatch(pTHX_ OP *o)
+STATIC OP*     S_docatch(pTHX_ Perl_ppaddr_t firstpp)
                        __attribute__warn_unused_result__;
 
 STATIC bool    S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV* hh);
@@ -5138,6 +5142,11 @@ STATIC U32       S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, UV *min_
 STATIC I32     S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *first, regnode *last, regnode *tail, U32 word_count, U32 flags, U32 depth);
 #define PERL_ARGS_ASSERT_MAKE_TRIE     \
        assert(pRExC_state); assert(startbranch); assert(first); assert(last); assert(tail)
+STATIC bool    S_new_regcurly(const char *s, const char *e)
+                       __attribute__warn_unused_result__;
+#define PERL_ARGS_ASSERT_NEW_REGCURLY  \
+       assert(s); assert(e)
+
 STATIC void    S_nextchar(pTHX_ RExC_state_t *pRExC_state);
 #define PERL_ARGS_ASSERT_NEXTCHAR      \
        assert(pRExC_state)
@@ -5554,7 +5563,7 @@ STATIC void       S_assert_uft8_cache_coherent(pTHX_ const char *const func, STRLEN fr
 STATIC bool    S_curse(pTHX_ SV * const sv, const bool check_refcnt);
 #define PERL_ARGS_ASSERT_CURSE \
        assert(sv)
-STATIC I32     S_expect_number(pTHX_ char **const pattern)
+STATIC STRLEN  S_expect_number(pTHX_ const char **const pattern)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_EXPECT_NUMBER \
        assert(pattern)
@@ -5801,14 +5810,14 @@ STATIC UV       S_check_locale_boundary_crossing(pTHX_ const U8* const p, const UV res
        assert(p); assert(ustrp); assert(lenp)
 
 #ifndef PERL_NO_INLINE_FUNCTIONS
-PERL_STATIC_INLINE bool        S_does_utf8_overflow(const U8 * const s, const U8 * e)
+PERL_STATIC_INLINE int S_does_utf8_overflow(const U8 * const s, const U8 * e, const bool consider_overlongs)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_DOES_UTF8_OVERFLOW    \
        assert(s); assert(e)
 #endif
 
 #ifndef PERL_NO_INLINE_FUNCTIONS
-PERL_STATIC_INLINE bool        S_isFF_OVERLONG(const U8 * const s, const STRLEN len)
+PERL_STATIC_INLINE int S_isFF_OVERLONG(const U8 * const s, const STRLEN len)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_ISFF_OVERLONG \
        assert(s)
@@ -5829,14 +5838,7 @@ PERL_STATIC_INLINE bool  S_is_utf8_common_with_len(pTHX_ const U8 *const p, const
 #endif
 
 #ifndef PERL_NO_INLINE_FUNCTIONS
-PERL_STATIC_INLINE bool        S_is_utf8_cp_above_31_bits(const U8 * const s, const U8 * const e)
-                       __attribute__warn_unused_result__;
-#define PERL_ARGS_ASSERT_IS_UTF8_CP_ABOVE_31_BITS      \
-       assert(s); assert(e)
-#endif
-
-#ifndef PERL_NO_INLINE_FUNCTIONS
-PERL_STATIC_INLINE bool        S_is_utf8_overlong_given_start_byte_ok(const U8 * const s, const STRLEN len)
+PERL_STATIC_INLINE int S_is_utf8_overlong_given_start_byte_ok(const U8 * const s, const STRLEN len)
                        __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_IS_UTF8_OVERLONG_GIVEN_START_BYTE_OK  \
        assert(s)
@@ -6047,9 +6049,17 @@ PERL_CALLCONV SV*        Perl_sv_dup_inc(pTHX_ const SV *const sstr, CLONE_PARAMS *cons
 PERL_CALLCONV bool     Perl__is_cur_LC_category_utf8(pTHX_ int category);
 #endif
 #if defined(USE_LOCALE) && defined(PERL_IN_LOCALE_C)
+STATIC void    S_new_collate(pTHX_ const char* newcoll);
+STATIC void    S_new_ctype(pTHX_ const char* newctype);
+#define PERL_ARGS_ASSERT_NEW_CTYPE     \
+       assert(newctype)
+STATIC void    S_set_numeric_radix(pTHX);
 STATIC char*   S_stdize_locale(pTHX_ char* locs);
 #define PERL_ARGS_ASSERT_STDIZE_LOCALE \
        assert(locs)
+#  if defined(WIN32)
+STATIC char*   S_my_setlocale(pTHX_ int category, const char* locale);
+#  endif
 #endif
 #if defined(USE_LOCALE_COLLATE)
 PERL_CALLCONV int      Perl_magic_setcollxfrm(pTHX_ SV* sv, MAGIC* mg);
@@ -6116,7 +6126,6 @@ PERL_CALLCONV const char* Perl_quadmath_format_single(const char* format);
        assert(format)
 #endif
 #if defined(WIN32)
-PERL_CALLCONV char*    Perl_my_setlocale(pTHX_ int category, const char* locale);
 PERL_CALLCONV_NO_RET void      win32_croak_not_implemented(const char * fname)
                        __attribute__noreturn__;
 #define PERL_ARGS_ASSERT_WIN32_CROAK_NOT_IMPLEMENTED   \