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 =for apidoc sv_catsv_mg
289 Like C<sv_catsv>, but also handles 'set' magic.
295 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *sstr)
297 PERL_ARGS_ASSERT_SV_CATSV_MG;
299 sv_catsv_flags(dsv,sstr,SV_GMAGIC|SV_SMAGIC);
305 A private implementation of the C<SvIVx> macro for compilers which can't
306 cope with complex macro expressions. Always use the macro instead.
312 Perl_sv_iv(pTHX_ SV *sv)
314 PERL_ARGS_ASSERT_SV_IV;
318 return (IV)SvUVX(sv);
327 A private implementation of the C<SvUVx> macro for compilers which can't
328 cope with complex macro expressions. Always use the macro instead.
334 Perl_sv_uv(pTHX_ SV *sv)
336 PERL_ARGS_ASSERT_SV_UV;
341 return (UV)SvIVX(sv);
349 A private implementation of the C<SvNVx> macro for compilers which can't
350 cope with complex macro expressions. Always use the macro instead.
356 Perl_sv_nv(pTHX_ SV *sv)
358 PERL_ARGS_ASSERT_SV_NV;
368 Use the C<SvPV_nolen> macro instead
372 A private implementation of the C<SvPV> macro for compilers which can't
373 cope with complex macro expressions. Always use the macro instead.
379 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
381 PERL_ARGS_ASSERT_SV_PVN;
387 return sv_2pv(sv, lp);
392 Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
394 PERL_ARGS_ASSERT_SV_PVN_NOMG;
400 return sv_2pv_flags(sv, lp, 0);
403 /* sv_pv() is now a macro using SvPV_nolen();
404 * this function provided for binary compatibility only
408 Perl_sv_pv(pTHX_ SV *sv)
410 PERL_ARGS_ASSERT_SV_PV;
415 return sv_2pv(sv, NULL);
418 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
419 * this function provided for binary compatibility only
423 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
425 PERL_ARGS_ASSERT_SV_PVN_FORCE;
427 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
430 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
431 * this function provided for binary compatibility only
435 Perl_sv_pvbyte(pTHX_ SV *sv)
437 PERL_ARGS_ASSERT_SV_PVBYTE;
439 sv_utf8_downgrade(sv, FALSE);
444 =for apidoc sv_pvbyte
446 Use C<SvPVbyte_nolen> instead.
448 =for apidoc sv_pvbyten
450 A private implementation of the C<SvPVbyte> macro for compilers
451 which can't cope with complex macro expressions. Always use the macro
458 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
460 PERL_ARGS_ASSERT_SV_PVBYTEN;
462 sv_utf8_downgrade(sv, FALSE);
463 return sv_pvn(sv,lp);
466 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
467 * this function provided for binary compatibility only
471 Perl_sv_pvutf8(pTHX_ SV *sv)
473 PERL_ARGS_ASSERT_SV_PVUTF8;
480 =for apidoc sv_pvutf8
482 Use the C<SvPVutf8_nolen> macro instead
484 =for apidoc sv_pvutf8n
486 A private implementation of the C<SvPVutf8> macro for compilers
487 which can't cope with complex macro expressions. Always use the macro
494 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
496 PERL_ARGS_ASSERT_SV_PVUTF8N;
499 return sv_pvn(sv,lp);
502 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
503 * this function provided for binary compatibility only
507 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
509 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
511 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
515 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
520 /* Easier to special case this here than in embed.pl. (Look at what it
521 generates for proto.h) */
522 #ifdef PERL_IMPLICIT_CONTEXT
523 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
526 va_start(arglist, format);
527 ret = PerlIO_vprintf(stream, format, arglist);
533 Perl_printf_nocontext(const char *format, ...)
539 #ifdef PERL_IMPLICIT_CONTEXT
540 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
543 va_start(arglist, format);
544 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
549 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
551 * This hack is to force load of "huge" support from libm.a
552 * So it is in perl for (say) POSIX to use.
553 * Needed for SunOS with Sun's 'acc' for example.
558 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
566 /* compatibility with versions <= 5.003. */
568 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
570 PERL_ARGS_ASSERT_GV_FULLNAME;
572 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
575 /* compatibility with versions <= 5.003. */
577 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
579 PERL_ARGS_ASSERT_GV_EFULLNAME;
581 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
585 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
587 PERL_ARGS_ASSERT_GV_FULLNAME3;
589 gv_fullname4(sv, gv, prefix, TRUE);
593 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
595 PERL_ARGS_ASSERT_GV_EFULLNAME3;
597 gv_efullname4(sv, gv, prefix, TRUE);
601 =for apidoc_section $GV
602 =for apidoc gv_fetchmethod
604 See L</gv_fetchmethod_autoload>.
610 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
612 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
614 return gv_fetchmethod_autoload(stash, name, TRUE);
618 Perl_hv_iternext(pTHX_ HV *hv)
620 PERL_ARGS_ASSERT_HV_ITERNEXT;
622 return hv_iternext_flags(hv, 0);
626 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
628 PERL_ARGS_ASSERT_HV_MAGIC;
630 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
634 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
635 int rawmode, int rawperm, PerlIO *supplied_fp)
637 PERL_ARGS_ASSERT_DO_OPEN;
639 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
640 supplied_fp, (SV **) NULL, 0);
644 Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
646 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
649 PERL_ARGS_ASSERT_DO_OPEN9;
651 PERL_UNUSED_ARG(num_svs);
652 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
653 supplied_fp, &svs, 1);
657 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
659 /* The old body of this is now in non-LAYER part of perlio.c
660 * This is a stub for any XS code which might have been calling it.
662 const char *name = ":raw";
664 PERL_ARGS_ASSERT_DO_BINMODE;
666 #ifdef PERLIO_USING_CRLF
667 if (!(mode & O_BINARY))
670 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
675 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
677 PERL_ARGS_ASSERT_DO_AEXEC;
679 return do_aexec5(really, mark, sp, 0, 0);
683 /* Backwards compatibility. */
685 Perl_init_i18nl14n(pTHX_ int printwarn)
687 return init_i18nl10n(printwarn);
691 Perl_is_utf8_string_loc(const U8 *s, const STRLEN len, const U8 **ep)
693 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
695 return is_utf8_string_loclen(s, len, ep, 0);
699 =for apidoc_section $SV
700 =for apidoc sv_nolocking
702 Dummy routine which "locks" an SV when there is no locking module present.
703 Exists to avoid test for a C<NULL> function pointer and because it could
704 potentially warn under some level of strict-ness.
706 "Superseded" by C<sv_nosharing()>.
712 Perl_sv_nolocking(pTHX_ SV *sv)
720 =for apidoc sv_nounlocking
722 Dummy routine which "unlocks" an SV when there is no locking module present.
723 Exists to avoid test for a C<NULL> function pointer and because it could
724 potentially warn under some level of strict-ness.
726 "Superseded" by C<sv_nosharing()>.
730 PERL_UNLOCK_HOOK in intrpvar.h is the macro that refers to this, and guarantees
731 that mathoms gets loaded.
736 Perl_sv_nounlocking(pTHX_ SV *sv)
743 Perl_save_long(pTHX_ long int *longp)
745 PERL_ARGS_ASSERT_SAVE_LONG;
750 SSPUSHUV(SAVEt_LONG);
754 Perl_save_nogv(pTHX_ GV *gv)
756 PERL_ARGS_ASSERT_SAVE_NOGV;
760 SSPUSHUV(SAVEt_NSTAB);
764 Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
768 PERL_ARGS_ASSERT_SAVE_LIST;
770 for (i = 1; i <= maxsarg; i++) {
774 sv_setsv_nomg(sv,sarg[i]);
776 SSPUSHPTR(sarg[i]); /* remember the pointer */
777 SSPUSHPTR(sv); /* remember the value */
778 SSPUSHUV(SAVEt_ITEM);
783 =for apidoc sv_usepvn_mg
785 Like C<sv_usepvn>, but also handles 'set' magic.
791 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
793 PERL_ARGS_ASSERT_SV_USEPVN_MG;
795 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
799 =for apidoc sv_usepvn
801 Tells an SV to use C<ptr> to find its string value. Implemented by
802 calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
803 magic. See C<L</sv_usepvn_flags>>.
809 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
811 PERL_ARGS_ASSERT_SV_USEPVN;
813 sv_usepvn_flags(sv,ptr,len, 0);
817 =for apidoc_section $pack
818 =for apidoc unpack_str
820 The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
821 C<new_s> and C<ocnt> are not used. This call should not be used, use
822 C<unpackstring> instead.
827 Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
828 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
831 PERL_ARGS_ASSERT_UNPACK_STR;
833 PERL_UNUSED_ARG(strbeg);
834 PERL_UNUSED_ARG(new_s);
835 PERL_UNUSED_ARG(ocnt);
837 return unpackstring(pat, patend, s, strend, flags);
843 The engine implementing C<pack()> Perl function. Note: parameters
844 C<next_in_list> and C<flags> are not used. This call should not be used; use
845 C<L</packlist>> instead.
851 Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
853 PERL_ARGS_ASSERT_PACK_CAT;
855 PERL_UNUSED_ARG(next_in_list);
856 PERL_UNUSED_ARG(flags);
858 packlist(cat, pat, patend, beglist, endlist);
862 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
864 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
868 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
870 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
872 return cBOOL(hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash));
876 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
878 PERL_ARGS_ASSERT_HV_FETCH_ENT;
880 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
881 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
885 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
887 PERL_ARGS_ASSERT_HV_DELETE_ENT;
889 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
894 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
897 return (SV**) hv_common(hv, NULL, key, klen, flags,
898 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
902 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
914 return (SV **) hv_common(hv, NULL, key, klen, flags,
915 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
919 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
924 PERL_ARGS_ASSERT_HV_EXISTS;
933 return cBOOL(hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0));
937 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
942 PERL_ARGS_ASSERT_HV_FETCH;
951 return (SV **) hv_common(hv, NULL, key, klen, flags,
952 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
953 : HV_FETCH_JUST_SV, NULL, 0);
957 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
962 PERL_ARGS_ASSERT_HV_DELETE;
966 k_flags = HVhek_UTF8;
971 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
978 return MUTABLE_AV(newSV_type(SVt_PVAV));
979 /* sv_upgrade does AvREAL_only():
982 AvMAX(av) = AvFILLp(av) = -1; */
988 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
995 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
996 const char *const little, const STRLEN littlelen)
998 PERL_ARGS_ASSERT_SV_INSERT;
999 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
1003 Perl_save_freesv(pTHX_ SV *sv)
1009 Perl_save_mortalizesv(pTHX_ SV *sv)
1011 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1013 save_mortalizesv(sv);
1017 Perl_save_freeop(pTHX_ OP *o)
1023 Perl_save_freepv(pTHX_ char *pv)
1034 #ifdef PERL_DONT_CREATE_GVSV
1036 Perl_gv_SVadd(pTHX_ GV *gv)
1038 return gv_SVadd(gv);
1043 Perl_gv_AVadd(pTHX_ GV *gv)
1045 return gv_AVadd(gv);
1049 Perl_gv_HVadd(pTHX_ GV *gv)
1051 return gv_HVadd(gv);
1055 Perl_gv_IOadd(pTHX_ GV *gv)
1057 return gv_IOadd(gv);
1063 return MUTABLE_IO(newSV_type(SVt_PVIO));
1069 return my_stat_flags(SV_GMAGIC);
1075 return my_lstat_flags(SV_GMAGIC);
1079 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1081 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1084 #ifdef USE_LOCALE_COLLATE
1086 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1088 PERL_ARGS_ASSERT_SV_COLLXFRM;
1089 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1093 Perl_mem_collxfrm(pTHX_ const char *input_string, STRLEN len, STRLEN *xlen)
1095 /* This function is retained for compatibility in case someone outside core
1096 * is using this (but it is undocumented) */
1098 PERL_ARGS_ASSERT_MEM_COLLXFRM;
1100 return _mem_collxfrm(input_string, len, xlen, FALSE);
1106 Perl_sv_2bool(pTHX_ SV *const sv)
1108 PERL_ARGS_ASSERT_SV_2BOOL;
1109 return sv_2bool_flags(sv, SV_GMAGIC);
1114 =for apidoc_section $custom
1115 =for apidoc custom_op_name
1116 Return the name for a given custom op. This was once used by the C<OP_NAME>
1117 macro, but is no longer: it has only been kept for compatibility, and
1120 =for apidoc custom_op_desc
1121 Return the description of a given custom op. This was once used by the
1122 C<OP_DESC> macro, but is no longer: it has only been kept for
1123 compatibility, and should not be used.
1129 Perl_custom_op_name(pTHX_ const OP* o)
1131 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1132 return XopENTRYCUSTOM(o, xop_name);
1136 Perl_custom_op_desc(pTHX_ const OP* o)
1138 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1139 return XopENTRYCUSTOM(o, xop_desc);
1143 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1145 return newATTRSUB(floor, o, proto, NULL, block);
1149 Perl_sv_mortalcopy(pTHX_ SV *const oldsv)
1151 return Perl_sv_mortalcopy_flags(aTHX_ oldsv, SV_GMAGIC);
1155 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1157 PERL_ARGS_ASSERT_SV_COPYPV;
1159 sv_copypv_flags(dsv, ssv, SV_GMAGIC);
1162 UV /* Made into a function, so can be deprecated */
1163 NATIVE_TO_NEED(const UV enc, const UV ch)
1165 PERL_UNUSED_ARG(enc);
1169 UV /* Made into a function, so can be deprecated */
1170 ASCII_TO_NEED(const UV enc, const UV ch)
1172 PERL_UNUSED_ARG(enc);
1177 =for apidoc_section $unicode
1178 =for apidoc is_utf8_char
1180 Tests if some arbitrary number of bytes begins in a valid UTF-8
1181 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1182 character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1183 character will be returned if it is valid, otherwise 0.
1185 This function is deprecated due to the possibility that malformed input could
1186 cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1192 Perl_is_utf8_char(const U8 *s)
1194 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1196 /* Assumes we have enough space, which is why this is deprecated. But the
1197 * UTF8_CHK_SKIP(s)) makes it safe for the common case of NUL-terminated
1199 return isUTF8_CHAR(s, s + UTF8_CHK_SKIP(s));
1203 =for apidoc is_utf8_char_buf
1205 This is identical to the macro L<perlapi/isUTF8_CHAR>.
1210 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1213 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1215 return isUTF8_CHAR(buf, buf_end);
1219 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1220 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1221 * non-character code points, and non-Unicode code points are allowed */
1224 Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1226 PERL_UNUSED_CONTEXT;
1227 PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1229 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1233 =for apidoc utf8_to_uvuni
1235 Returns the Unicode code point of the first character in the string C<s>
1236 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1237 length, in bytes, of that character.
1239 Some, but not all, UTF-8 malformations are detected, and in fact, some
1240 malformed input could cause reading beyond the end of the input buffer, which
1241 is one reason why this function is deprecated. The other is that only in
1242 extremely limited circumstances should the Unicode versus native code point be
1243 of any interest to you. See L</utf8_to_uvuni_buf> for alternatives.
1245 If C<s> points to one of the detected malformations, and UTF8 warnings are
1246 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1247 NULL) to -1. If those warnings are off, the computed value if well-defined (or
1248 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1249 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1250 next possible position in C<s> that could begin a non-malformed character.
1251 See L<perlapi/utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1257 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1259 PERL_UNUSED_CONTEXT;
1260 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1262 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1266 =for apidoc pad_compname_type
1268 Looks up the type of the lexical variable at position C<po> in the
1269 currently-compiling pad. If the variable is typed, the stash of the
1270 class to which it is typed is returned. If not, C<NULL> is returned.
1276 Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1278 return PAD_COMPNAME_TYPE(po);
1281 /* return ptr to little string in big string, NULL if not found */
1282 /* The original version of this routine was donated by Corey Satten. */
1285 Perl_instr(const char *big, const char *little)
1287 PERL_ARGS_ASSERT_INSTR;
1289 return instr(big, little);
1293 Perl_newSVsv(pTHX_ SV *const old)
1295 return newSVsv(old);
1299 Perl_sv_utf8_downgrade(pTHX_ SV *const sv, const bool fail_ok)
1301 PERL_ARGS_ASSERT_SV_UTF8_DOWNGRADE;
1303 return sv_utf8_downgrade(sv, fail_ok);
1307 Perl_sv_2pvutf8(pTHX_ SV *sv, STRLEN *const lp)
1309 PERL_ARGS_ASSERT_SV_2PVUTF8;
1311 return sv_2pvutf8(sv, lp);
1315 Perl_sv_2pvbyte(pTHX_ SV *sv, STRLEN *const lp)
1317 PERL_ARGS_ASSERT_SV_2PVBYTE;
1319 return sv_2pvbyte(sv, lp);
1323 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
1325 PERL_ARGS_ASSERT_UVUNI_TO_UTF8;
1327 return uvoffuni_to_utf8_flags(d, uv, 0);
1331 =for apidoc utf8n_to_uvuni
1333 Instead use L<perlapi/utf8_to_uvchr_buf>, or rarely, L<perlapi/utf8n_to_uvchr>.
1335 This function was useful for code that wanted to handle both EBCDIC and
1336 ASCII platforms with Unicode properties, but starting in Perl v5.20, the
1337 distinctions between the platforms have mostly been made invisible to most
1338 code, so this function is quite unlikely to be what you want. If you do need
1339 this precise functionality, use instead
1340 C<L<NATIVE_TO_UNI(utf8_to_uvchr_buf(...))|perlapi/utf8_to_uvchr_buf>>
1341 or C<L<NATIVE_TO_UNI(utf8n_to_uvchr(...))|perlapi/utf8n_to_uvchr>>.
1347 Perl_utf8n_to_uvuni(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
1349 PERL_ARGS_ASSERT_UTF8N_TO_UVUNI;
1351 return NATIVE_TO_UNI(utf8n_to_uvchr(s, curlen, retlen, flags));
1355 =for apidoc uvuni_to_utf8_flags
1357 Instead you almost certainly want to use L<perlapi/uvchr_to_utf8> or
1358 L<perlapi/uvchr_to_utf8_flags>.
1360 This function is a deprecated synonym for L</uvoffuni_to_utf8_flags>,
1361 which itself, while not deprecated, should be used only in isolated
1362 circumstances. These functions were useful for code that wanted to handle
1363 both EBCDIC and ASCII platforms with Unicode properties, but starting in Perl
1364 v5.20, the distinctions between the platforms have mostly been made invisible
1365 to most code, so this function is quite unlikely to be what you want.
1371 Perl_uvuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
1373 PERL_ARGS_ASSERT_UVUNI_TO_UTF8_FLAGS;
1375 return uvoffuni_to_utf8_flags(d, uv, flags);
1379 =for apidoc utf8_to_uvchr
1381 Returns the native code point of the first character in the string C<s>
1382 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1383 length, in bytes, of that character.
1385 Some, but not all, UTF-8 malformations are detected, and in fact, some
1386 malformed input could cause reading beyond the end of the input buffer, which
1387 is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
1389 If C<s> points to one of the detected malformations, and UTF8 warnings are
1390 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1391 C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
1392 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1393 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1394 next possible position in C<s> that could begin a non-malformed character.
1395 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1401 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1403 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1405 /* This function is unsafe if malformed UTF-8 input is given it, which is
1406 * why the function is deprecated. If the first byte of the input
1407 * indicates that there are more bytes remaining in the sequence that forms
1408 * the character than there are in the input buffer, it can read past the
1409 * end. But we can make it safe if the input string happens to be
1410 * NUL-terminated, as many strings in Perl are, by refusing to read past a
1411 * NUL, which is what UTF8_CHK_SKIP() does. A NUL indicates the start of
1412 * the next character anyway. If the input isn't NUL-terminated, the
1413 * function remains unsafe, as it always has been. */
1415 return utf8_to_uvchr_buf(s, s + UTF8_CHK_SKIP(s), retlen);
1420 #endif /* NO_MATHOMS */
1423 * ex: set ts=8 sts=4 sw=4 et: