3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4 * 2011, 2012 by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
12 * Anything that Hobbits had no immediate use for, but were unwilling to
13 * throw away, they called a mathom. Their dwellings were apt to become
14 * rather crowded with mathoms, and many of the presents that passed from
15 * hand to hand were of that sort.
17 * [p.5 of _The Lord of the Rings_: "Prologue"]
23 * This file contains mathoms, various binary artifacts from previous
24 * versions of Perl which we cannot completely remove from the core
25 * code. There are two reasons functions should be here:
27 * 1) A function has been replaced by a macro within a minor release,
28 * so XS modules compiled against an older release will expect to
29 * still be able to link against the function
30 * 2) A function Perl_foo(...) with #define foo Perl_foo(aTHX_ ...)
31 * has been replaced by a macro, e.g. #define foo(...) foo_flags(...,0)
32 * but XS code may still explicitly use the long form, i.e.
35 * NOTE: ALL FUNCTIONS IN THIS FILE should have an entry with the 'b' flag in
38 * To move a function to this file, simply cut and paste it here, and change
39 * its embed.fnc entry to additionally have the 'b' flag. If, for some reason
40 * a function you'd like to be treated as mathoms can't be moved from its
41 * current place, simply enclose it between
47 * and add the 'b' flag in embed.fnc.
49 * The compilation of this file can be suppressed; see INSTALL
51 * Some blurb for perlapi.pod:
53 head1 Obsolete backwards compatibility functions
55 Some of these are also deprecated. You can exclude these from
56 your compiled Perl by adding this option to Configure:
57 C<-Accflags='-DNO_MATHOMS'>
65 #define PERL_IN_MATHOMS_C
69 /* ..." warning: ISO C forbids an empty source file"
70 So make sure we have something in here by processing the headers anyway.
74 /* The functions in this file should be able to call other deprecated functions
75 * without a compiler warning */
76 GCC_DIAG_IGNORE(-Wdeprecated-declarations)
78 /* ref() is now a macro using Perl_doref;
79 * this version provided for binary compatibility only.
82 Perl_ref(pTHX_ OP *o, I32 type)
84 return doref(o, type, TRUE);
88 =for apidoc_section $SV
91 Unsets the RV status of the SV, and decrements the reference count of
92 whatever was being referenced by the RV. This can almost be thought of
93 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
94 being zero. See C<L</SvROK_off>>.
100 Perl_sv_unref(pTHX_ SV *sv)
102 PERL_ARGS_ASSERT_SV_UNREF;
104 sv_unref_flags(sv, 0);
110 Taint an SV. Use C<SvTAINTED_on> instead.
116 Perl_sv_taint(pTHX_ SV *sv)
118 PERL_ARGS_ASSERT_SV_TAINT;
120 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
123 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
124 * this function provided for binary compatibility only
128 Perl_sv_2iv(pTHX_ SV *sv)
130 PERL_ARGS_ASSERT_SV_2IV;
132 return sv_2iv_flags(sv, SV_GMAGIC);
135 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
136 * this function provided for binary compatibility only
140 Perl_sv_2uv(pTHX_ SV *sv)
142 PERL_ARGS_ASSERT_SV_2UV;
144 return sv_2uv_flags(sv, SV_GMAGIC);
147 /* sv_2nv() is now a macro using Perl_sv_2nv_flags();
148 * this function provided for binary compatibility only
152 Perl_sv_2nv(pTHX_ SV *sv)
154 return sv_2nv_flags(sv, SV_GMAGIC);
158 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
159 * this function provided for binary compatibility only
163 Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
165 PERL_ARGS_ASSERT_SV_2PV;
167 return sv_2pv_flags(sv, lp, SV_GMAGIC);
171 =for apidoc sv_2pv_nolen
173 Like C<sv_2pv()>, but doesn't return the length too. You should usually
174 use the macro wrapper C<SvPV_nolen(sv)> instead.
180 Perl_sv_2pv_nolen(pTHX_ SV *sv)
182 PERL_ARGS_ASSERT_SV_2PV_NOLEN;
183 return sv_2pv(sv, NULL);
187 =for apidoc sv_2pvbyte_nolen
189 Return a pointer to the byte-encoded representation of the SV.
190 May cause the SV to be downgraded from UTF-8 as a side-effect.
192 Usually accessed via the C<SvPVbyte_nolen> macro.
198 Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
200 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
202 return sv_2pvbyte(sv, NULL);
206 =for apidoc sv_2pvutf8_nolen
208 Return a pointer to the UTF-8-encoded representation of the SV.
209 May cause the SV to be upgraded to UTF-8 as a side-effect.
211 Usually accessed via the C<SvPVutf8_nolen> macro.
217 Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
219 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
221 return sv_2pvutf8(sv, NULL);
225 =for apidoc sv_force_normal
227 Undo various types of fakery on an SV: if the PV is a shared string, make
228 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
229 an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
235 Perl_sv_force_normal(pTHX_ SV *sv)
237 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
239 sv_force_normal_flags(sv, 0);
242 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
243 * this function provided for binary compatibility only
247 Perl_sv_setsv(pTHX_ SV *dsv, SV *ssv)
249 PERL_ARGS_ASSERT_SV_SETSV;
251 sv_setsv_flags(dsv, ssv, SV_GMAGIC);
254 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
255 * this function provided for binary compatibility only
259 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
261 PERL_ARGS_ASSERT_SV_CATPVN;
263 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
267 Perl_sv_catpvn_mg(pTHX_ SV *dsv, const char *sstr, STRLEN len)
269 PERL_ARGS_ASSERT_SV_CATPVN_MG;
271 sv_catpvn_flags(dsv,sstr,len,SV_GMAGIC|SV_SMAGIC);
274 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
275 * this function provided for binary compatibility only
279 Perl_sv_catsv(pTHX_ SV *dsv, SV *sstr)
281 PERL_ARGS_ASSERT_SV_CATSV;
283 sv_catsv_flags(dsv, sstr, SV_GMAGIC);
287 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *sstr)
289 PERL_ARGS_ASSERT_SV_CATSV_MG;
291 sv_catsv_flags(dsv,sstr,SV_GMAGIC|SV_SMAGIC);
297 A private implementation of the C<SvIVx> macro for compilers which can't
298 cope with complex macro expressions. Always use the macro instead.
304 Perl_sv_iv(pTHX_ SV *sv)
306 PERL_ARGS_ASSERT_SV_IV;
310 return (IV)SvUVX(sv);
319 A private implementation of the C<SvUVx> macro for compilers which can't
320 cope with complex macro expressions. Always use the macro instead.
326 Perl_sv_uv(pTHX_ SV *sv)
328 PERL_ARGS_ASSERT_SV_UV;
333 return (UV)SvIVX(sv);
341 A private implementation of the C<SvNVx> macro for compilers which can't
342 cope with complex macro expressions. Always use the macro instead.
348 Perl_sv_nv(pTHX_ SV *sv)
350 PERL_ARGS_ASSERT_SV_NV;
360 Use the C<SvPV_nolen> macro instead
364 A private implementation of the C<SvPV> macro for compilers which can't
365 cope with complex macro expressions. Always use the macro instead.
371 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
373 PERL_ARGS_ASSERT_SV_PVN;
379 return sv_2pv(sv, lp);
384 Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
386 PERL_ARGS_ASSERT_SV_PVN_NOMG;
392 return sv_2pv_flags(sv, lp, 0);
395 /* sv_pv() is now a macro using SvPV_nolen();
396 * this function provided for binary compatibility only
400 Perl_sv_pv(pTHX_ SV *sv)
402 PERL_ARGS_ASSERT_SV_PV;
407 return sv_2pv(sv, NULL);
410 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
411 * this function provided for binary compatibility only
415 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
417 PERL_ARGS_ASSERT_SV_PVN_FORCE;
419 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
422 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
423 * this function provided for binary compatibility only
427 Perl_sv_pvbyte(pTHX_ SV *sv)
429 PERL_ARGS_ASSERT_SV_PVBYTE;
431 sv_utf8_downgrade(sv, FALSE);
436 =for apidoc sv_pvbyte
438 Use C<SvPVbyte_nolen> instead.
440 =for apidoc sv_pvbyten
442 A private implementation of the C<SvPVbyte> macro for compilers
443 which can't cope with complex macro expressions. Always use the macro
450 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
452 PERL_ARGS_ASSERT_SV_PVBYTEN;
454 sv_utf8_downgrade(sv, FALSE);
455 return sv_pvn(sv,lp);
458 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
459 * this function provided for binary compatibility only
463 Perl_sv_pvutf8(pTHX_ SV *sv)
465 PERL_ARGS_ASSERT_SV_PVUTF8;
472 =for apidoc sv_pvutf8
474 Use the C<SvPVutf8_nolen> macro instead
476 =for apidoc sv_pvutf8n
478 A private implementation of the C<SvPVutf8> macro for compilers
479 which can't cope with complex macro expressions. Always use the macro
486 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
488 PERL_ARGS_ASSERT_SV_PVUTF8N;
491 return sv_pvn(sv,lp);
494 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
495 * this function provided for binary compatibility only
499 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
501 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
503 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
507 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
512 /* Easier to special case this here than in embed.pl. (Look at what it
513 generates for proto.h) */
514 #ifdef PERL_IMPLICIT_CONTEXT
515 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
518 va_start(arglist, format);
519 ret = PerlIO_vprintf(stream, format, arglist);
525 Perl_printf_nocontext(const char *format, ...)
531 #ifdef PERL_IMPLICIT_CONTEXT
532 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
535 va_start(arglist, format);
536 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
541 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
543 * This hack is to force load of "huge" support from libm.a
544 * So it is in perl for (say) POSIX to use.
545 * Needed for SunOS with Sun's 'acc' for example.
550 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
558 /* compatibility with versions <= 5.003. */
560 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
562 PERL_ARGS_ASSERT_GV_FULLNAME;
564 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
567 /* compatibility with versions <= 5.003. */
569 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
571 PERL_ARGS_ASSERT_GV_EFULLNAME;
573 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
577 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
579 PERL_ARGS_ASSERT_GV_FULLNAME3;
581 gv_fullname4(sv, gv, prefix, TRUE);
585 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
587 PERL_ARGS_ASSERT_GV_EFULLNAME3;
589 gv_efullname4(sv, gv, prefix, TRUE);
593 =for apidoc_section $GV
594 =for apidoc gv_fetchmethod
596 See L</gv_fetchmethod_autoload>.
602 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
604 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
606 return gv_fetchmethod_autoload(stash, name, TRUE);
610 Perl_hv_iternext(pTHX_ HV *hv)
612 PERL_ARGS_ASSERT_HV_ITERNEXT;
614 return hv_iternext_flags(hv, 0);
618 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
620 PERL_ARGS_ASSERT_HV_MAGIC;
622 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
626 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
627 int rawmode, int rawperm, PerlIO *supplied_fp)
629 PERL_ARGS_ASSERT_DO_OPEN;
631 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
632 supplied_fp, (SV **) NULL, 0);
636 Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
638 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
641 PERL_ARGS_ASSERT_DO_OPEN9;
643 PERL_UNUSED_ARG(num_svs);
644 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
645 supplied_fp, &svs, 1);
649 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
651 /* The old body of this is now in non-LAYER part of perlio.c
652 * This is a stub for any XS code which might have been calling it.
654 const char *name = ":raw";
656 PERL_ARGS_ASSERT_DO_BINMODE;
658 #ifdef PERLIO_USING_CRLF
659 if (!(mode & O_BINARY))
662 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
667 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
669 PERL_ARGS_ASSERT_DO_AEXEC;
671 return do_aexec5(really, mark, sp, 0, 0);
675 /* Backwards compatibility. */
677 Perl_init_i18nl14n(pTHX_ int printwarn)
679 return init_i18nl10n(printwarn);
683 Perl_is_utf8_string_loc(const U8 *s, const STRLEN len, const U8 **ep)
685 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
687 return is_utf8_string_loclen(s, len, ep, 0);
691 =for apidoc_section $SV
692 =for apidoc sv_nolocking
694 Dummy routine which "locks" an SV when there is no locking module present.
695 Exists to avoid test for a C<NULL> function pointer and because it could
696 potentially warn under some level of strict-ness.
698 "Superseded" by C<sv_nosharing()>.
704 Perl_sv_nolocking(pTHX_ SV *sv)
712 =for apidoc sv_nounlocking
714 Dummy routine which "unlocks" an SV when there is no locking module present.
715 Exists to avoid test for a C<NULL> function pointer and because it could
716 potentially warn under some level of strict-ness.
718 "Superseded" by C<sv_nosharing()>.
722 PERL_UNLOCK_HOOK in intrpvar.h is the macro that refers to this, and guarantees
723 that mathoms gets loaded.
728 Perl_sv_nounlocking(pTHX_ SV *sv)
735 Perl_save_long(pTHX_ long int *longp)
737 PERL_ARGS_ASSERT_SAVE_LONG;
742 SSPUSHUV(SAVEt_LONG);
746 Perl_save_nogv(pTHX_ GV *gv)
748 PERL_ARGS_ASSERT_SAVE_NOGV;
752 SSPUSHUV(SAVEt_NSTAB);
756 Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
760 PERL_ARGS_ASSERT_SAVE_LIST;
762 for (i = 1; i <= maxsarg; i++) {
766 sv_setsv_nomg(sv,sarg[i]);
768 SSPUSHPTR(sarg[i]); /* remember the pointer */
769 SSPUSHPTR(sv); /* remember the value */
770 SSPUSHUV(SAVEt_ITEM);
775 =for apidoc sv_usepvn_mg
777 Like C<sv_usepvn>, but also handles 'set' magic.
783 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
785 PERL_ARGS_ASSERT_SV_USEPVN_MG;
787 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
791 =for apidoc sv_usepvn
793 Tells an SV to use C<ptr> to find its string value. Implemented by
794 calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
795 magic. See C<L</sv_usepvn_flags>>.
801 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
803 PERL_ARGS_ASSERT_SV_USEPVN;
805 sv_usepvn_flags(sv,ptr,len, 0);
809 =for apidoc_section $pack
810 =for apidoc unpack_str
812 The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
813 C<new_s> and C<ocnt> are not used. This call should not be used, use
814 C<unpackstring> instead.
819 Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
820 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
823 PERL_ARGS_ASSERT_UNPACK_STR;
825 PERL_UNUSED_ARG(strbeg);
826 PERL_UNUSED_ARG(new_s);
827 PERL_UNUSED_ARG(ocnt);
829 return unpackstring(pat, patend, s, strend, flags);
835 The engine implementing C<pack()> Perl function. Note: parameters
836 C<next_in_list> and C<flags> are not used. This call should not be used; use
837 C<L</packlist>> instead.
843 Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
845 PERL_ARGS_ASSERT_PACK_CAT;
847 PERL_UNUSED_ARG(next_in_list);
848 PERL_UNUSED_ARG(flags);
850 packlist(cat, pat, patend, beglist, endlist);
854 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
856 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
860 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
862 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
864 return cBOOL(hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash));
868 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
870 PERL_ARGS_ASSERT_HV_FETCH_ENT;
872 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
873 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
877 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
879 PERL_ARGS_ASSERT_HV_DELETE_ENT;
881 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
886 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
889 return (SV**) hv_common(hv, NULL, key, klen, flags,
890 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
894 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
906 return (SV **) hv_common(hv, NULL, key, klen, flags,
907 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
911 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
916 PERL_ARGS_ASSERT_HV_EXISTS;
925 return cBOOL(hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0));
929 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
934 PERL_ARGS_ASSERT_HV_FETCH;
943 return (SV **) hv_common(hv, NULL, key, klen, flags,
944 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
945 : HV_FETCH_JUST_SV, NULL, 0);
949 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
954 PERL_ARGS_ASSERT_HV_DELETE;
958 k_flags = HVhek_UTF8;
963 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
970 return MUTABLE_AV(newSV_type(SVt_PVAV));
971 /* sv_upgrade does AvREAL_only():
974 AvMAX(av) = AvFILLp(av) = -1; */
980 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
987 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
988 const char *const little, const STRLEN littlelen)
990 PERL_ARGS_ASSERT_SV_INSERT;
991 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
995 Perl_save_freesv(pTHX_ SV *sv)
1001 Perl_save_mortalizesv(pTHX_ SV *sv)
1003 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1005 save_mortalizesv(sv);
1009 Perl_save_freeop(pTHX_ OP *o)
1015 Perl_save_freepv(pTHX_ char *pv)
1026 #ifdef PERL_DONT_CREATE_GVSV
1028 Perl_gv_SVadd(pTHX_ GV *gv)
1030 return gv_SVadd(gv);
1035 Perl_gv_AVadd(pTHX_ GV *gv)
1037 return gv_AVadd(gv);
1041 Perl_gv_HVadd(pTHX_ GV *gv)
1043 return gv_HVadd(gv);
1047 Perl_gv_IOadd(pTHX_ GV *gv)
1049 return gv_IOadd(gv);
1055 return MUTABLE_IO(newSV_type(SVt_PVIO));
1061 return my_stat_flags(SV_GMAGIC);
1067 return my_lstat_flags(SV_GMAGIC);
1071 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1073 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1076 #ifdef USE_LOCALE_COLLATE
1078 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1080 PERL_ARGS_ASSERT_SV_COLLXFRM;
1081 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1085 Perl_mem_collxfrm(pTHX_ const char *input_string, STRLEN len, STRLEN *xlen)
1087 /* This function is retained for compatibility in case someone outside core
1088 * is using this (but it is undocumented) */
1090 PERL_ARGS_ASSERT_MEM_COLLXFRM;
1092 return _mem_collxfrm(input_string, len, xlen, FALSE);
1098 Perl_sv_2bool(pTHX_ SV *const sv)
1100 PERL_ARGS_ASSERT_SV_2BOOL;
1101 return sv_2bool_flags(sv, SV_GMAGIC);
1106 =for apidoc_section $custom
1107 =for apidoc custom_op_name
1108 Return the name for a given custom op. This was once used by the C<OP_NAME>
1109 macro, but is no longer: it has only been kept for compatibility, and
1112 =for apidoc custom_op_desc
1113 Return the description of a given custom op. This was once used by the
1114 C<OP_DESC> macro, but is no longer: it has only been kept for
1115 compatibility, and should not be used.
1121 Perl_custom_op_name(pTHX_ const OP* o)
1123 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1124 return XopENTRYCUSTOM(o, xop_name);
1128 Perl_custom_op_desc(pTHX_ const OP* o)
1130 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1131 return XopENTRYCUSTOM(o, xop_desc);
1135 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1137 return newATTRSUB(floor, o, proto, NULL, block);
1141 Perl_sv_mortalcopy(pTHX_ SV *const oldsv)
1143 return Perl_sv_mortalcopy_flags(aTHX_ oldsv, SV_GMAGIC);
1147 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1149 PERL_ARGS_ASSERT_SV_COPYPV;
1151 sv_copypv_flags(dsv, ssv, SV_GMAGIC);
1154 UV /* Made into a function, so can be deprecated */
1155 NATIVE_TO_NEED(const UV enc, const UV ch)
1157 PERL_UNUSED_ARG(enc);
1161 UV /* Made into a function, so can be deprecated */
1162 ASCII_TO_NEED(const UV enc, const UV ch)
1164 PERL_UNUSED_ARG(enc);
1169 =for apidoc_section $unicode
1170 =for apidoc is_utf8_char
1172 Tests if some arbitrary number of bytes begins in a valid UTF-8
1173 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1174 character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1175 character will be returned if it is valid, otherwise 0.
1177 This function is deprecated due to the possibility that malformed input could
1178 cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1184 Perl_is_utf8_char(const U8 *s)
1186 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1188 /* Assumes we have enough space, which is why this is deprecated. But the
1189 * UTF8_CHK_SKIP(s)) makes it safe for the common case of NUL-terminated
1191 return isUTF8_CHAR(s, s + UTF8_CHK_SKIP(s));
1195 =for apidoc is_utf8_char_buf
1197 This is identical to the macro L<perlapi/isUTF8_CHAR>.
1202 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1205 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1207 return isUTF8_CHAR(buf, buf_end);
1211 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1212 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1213 * non-character code points, and non-Unicode code points are allowed */
1216 Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1218 PERL_UNUSED_CONTEXT;
1219 PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1221 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1225 =for apidoc utf8_to_uvuni
1227 Returns the Unicode code point of the first character in the string C<s>
1228 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1229 length, in bytes, of that character.
1231 Some, but not all, UTF-8 malformations are detected, and in fact, some
1232 malformed input could cause reading beyond the end of the input buffer, which
1233 is one reason why this function is deprecated. The other is that only in
1234 extremely limited circumstances should the Unicode versus native code point be
1235 of any interest to you. See L</utf8_to_uvuni_buf> for alternatives.
1237 If C<s> points to one of the detected malformations, and UTF8 warnings are
1238 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1239 NULL) to -1. If those warnings are off, the computed value if well-defined (or
1240 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1241 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1242 next possible position in C<s> that could begin a non-malformed character.
1243 See L<perlapi/utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1249 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1251 PERL_UNUSED_CONTEXT;
1252 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1254 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1258 =for apidoc pad_compname_type
1260 Looks up the type of the lexical variable at position C<po> in the
1261 currently-compiling pad. If the variable is typed, the stash of the
1262 class to which it is typed is returned. If not, C<NULL> is returned.
1264 Use L<perlintern/C<PAD_COMPNAME_TYPE>> instead.
1270 Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1272 return PAD_COMPNAME_TYPE(po);
1275 /* return ptr to little string in big string, NULL if not found */
1276 /* The original version of this routine was donated by Corey Satten. */
1279 Perl_instr(const char *big, const char *little)
1281 PERL_ARGS_ASSERT_INSTR;
1283 return instr(big, little);
1287 Perl_newSVsv(pTHX_ SV *const old)
1289 return newSVsv(old);
1293 Perl_sv_utf8_downgrade(pTHX_ SV *const sv, const bool fail_ok)
1295 PERL_ARGS_ASSERT_SV_UTF8_DOWNGRADE;
1297 return sv_utf8_downgrade(sv, fail_ok);
1301 Perl_sv_2pvutf8(pTHX_ SV *sv, STRLEN *const lp)
1303 PERL_ARGS_ASSERT_SV_2PVUTF8;
1305 return sv_2pvutf8(sv, lp);
1309 Perl_sv_2pvbyte(pTHX_ SV *sv, STRLEN *const lp)
1311 PERL_ARGS_ASSERT_SV_2PVBYTE;
1313 return sv_2pvbyte(sv, lp);
1317 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
1319 PERL_ARGS_ASSERT_UVUNI_TO_UTF8;
1321 return uvoffuni_to_utf8_flags(d, uv, 0);
1325 =for apidoc utf8n_to_uvuni
1327 Instead use L<perlapi/utf8_to_uvchr_buf>, or rarely, L<perlapi/utf8n_to_uvchr>.
1329 This function was useful for code that wanted to handle both EBCDIC and
1330 ASCII platforms with Unicode properties, but starting in Perl v5.20, the
1331 distinctions between the platforms have mostly been made invisible to most
1332 code, so this function is quite unlikely to be what you want. If you do need
1333 this precise functionality, use instead
1334 C<L<NATIVE_TO_UNI(utf8_to_uvchr_buf(...))|perlapi/utf8_to_uvchr_buf>>
1335 or C<L<NATIVE_TO_UNI(utf8n_to_uvchr(...))|perlapi/utf8n_to_uvchr>>.
1341 Perl_utf8n_to_uvuni(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
1343 PERL_ARGS_ASSERT_UTF8N_TO_UVUNI;
1345 return NATIVE_TO_UNI(utf8n_to_uvchr(s, curlen, retlen, flags));
1349 =for apidoc uvuni_to_utf8_flags
1351 Instead you almost certainly want to use L<perlapi/uvchr_to_utf8> or
1352 L<perlapi/uvchr_to_utf8_flags>.
1354 This function is a deprecated synonym for L</uvoffuni_to_utf8_flags>,
1355 which itself, while not deprecated, should be used only in isolated
1356 circumstances. These functions were useful for code that wanted to handle
1357 both EBCDIC and ASCII platforms with Unicode properties, but starting in Perl
1358 v5.20, the distinctions between the platforms have mostly been made invisible
1359 to most code, so this function is quite unlikely to be what you want.
1365 Perl_uvuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
1367 PERL_ARGS_ASSERT_UVUNI_TO_UTF8_FLAGS;
1369 return uvoffuni_to_utf8_flags(d, uv, flags);
1373 =for apidoc utf8_to_uvchr
1375 Returns the native code point of the first character in the string C<s>
1376 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1377 length, in bytes, of that character.
1379 Some, but not all, UTF-8 malformations are detected, and in fact, some
1380 malformed input could cause reading beyond the end of the input buffer, which
1381 is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
1383 If C<s> points to one of the detected malformations, and UTF8 warnings are
1384 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1385 C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
1386 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1387 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1388 next possible position in C<s> that could begin a non-malformed character.
1389 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1395 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1397 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1399 /* This function is unsafe if malformed UTF-8 input is given it, which is
1400 * why the function is deprecated. If the first byte of the input
1401 * indicates that there are more bytes remaining in the sequence that forms
1402 * the character than there are in the input buffer, it can read past the
1403 * end. But we can make it safe if the input string happens to be
1404 * NUL-terminated, as many strings in Perl are, by refusing to read past a
1405 * NUL, which is what UTF8_CHK_SKIP() does. A NUL indicates the start of
1406 * the next character anyway. If the input isn't NUL-terminated, the
1407 * function remains unsafe, as it always has been. */
1409 return utf8_to_uvchr_buf(s, s + UTF8_CHK_SKIP(s), retlen);
1414 #endif /* NO_MATHOMS */
1417 * ex: set ts=8 sts=4 sw=4 et: