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 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 * REMEMBER to update makedef.pl when adding a function to mathoms.c whose
36 * name doesn't begin with "Perl_".
40 * The compilation of this file can be suppressed; see INSTALL
42 =head1 Obsolete backwards compatibility functions
43 Some of these are also deprecated. You can exclude these from
44 your compiled Perl by adding this option to Configure:
45 C<-Accflags='-DNO_MATHOMS'>
53 #define PERL_IN_MATHOMS_C
57 /* ..." warning: ISO C forbids an empty source file"
58 So make sure we have something in here by processing the headers anyway.
62 /* NOTE ALL FUNCTIONS IN THIS FILE should have an entry with the 'b' flag in
65 * To move a function to this file, simply cut and paste it here, and change
66 * its embed.fnc entry to additionally have the 'b' flag. If, for some reason
67 * a function you'd like to be treated as mathoms can't be moved from its
68 * current place, simply enclose it between
74 * and add the 'b' flag in embed.fnc.
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);
90 Unsets the RV status of the SV, and decrements the reference count of
91 whatever was being referenced by the RV. This can almost be thought of
92 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
93 being zero. See C<L</SvROK_off>>.
99 Perl_sv_unref(pTHX_ SV *sv)
101 PERL_ARGS_ASSERT_SV_UNREF;
103 sv_unref_flags(sv, 0);
109 Taint an SV. Use C<SvTAINTED_on> instead.
115 Perl_sv_taint(pTHX_ SV *sv)
117 PERL_ARGS_ASSERT_SV_TAINT;
119 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
122 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
123 * this function provided for binary compatibility only
127 Perl_sv_2iv(pTHX_ SV *sv)
129 PERL_ARGS_ASSERT_SV_2IV;
131 return sv_2iv_flags(sv, SV_GMAGIC);
134 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
135 * this function provided for binary compatibility only
139 Perl_sv_2uv(pTHX_ SV *sv)
141 PERL_ARGS_ASSERT_SV_2UV;
143 return sv_2uv_flags(sv, SV_GMAGIC);
146 /* sv_2nv() is now a macro using Perl_sv_2nv_flags();
147 * this function provided for binary compatibility only
151 Perl_sv_2nv(pTHX_ SV *sv)
153 return sv_2nv_flags(sv, SV_GMAGIC);
157 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
158 * this function provided for binary compatibility only
162 Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
164 PERL_ARGS_ASSERT_SV_2PV;
166 return sv_2pv_flags(sv, lp, SV_GMAGIC);
170 =for apidoc sv_2pv_nolen
172 Like C<sv_2pv()>, but doesn't return the length too. You should usually
173 use the macro wrapper C<SvPV_nolen(sv)> instead.
179 Perl_sv_2pv_nolen(pTHX_ SV *sv)
181 PERL_ARGS_ASSERT_SV_2PV_NOLEN;
182 return sv_2pv(sv, NULL);
186 =for apidoc sv_2pvbyte_nolen
188 Return a pointer to the byte-encoded representation of the SV.
189 May cause the SV to be downgraded from UTF-8 as a side-effect.
191 Usually accessed via the C<SvPVbyte_nolen> macro.
197 Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
199 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
201 return sv_2pvbyte(sv, NULL);
205 =for apidoc sv_2pvutf8_nolen
207 Return a pointer to the UTF-8-encoded representation of the SV.
208 May cause the SV to be upgraded to UTF-8 as a side-effect.
210 Usually accessed via the C<SvPVutf8_nolen> macro.
216 Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
218 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
220 return sv_2pvutf8(sv, NULL);
224 =for apidoc sv_force_normal
226 Undo various types of fakery on an SV: if the PV is a shared string, make
227 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
228 an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
234 Perl_sv_force_normal(pTHX_ SV *sv)
236 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
238 sv_force_normal_flags(sv, 0);
241 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
242 * this function provided for binary compatibility only
246 Perl_sv_setsv(pTHX_ SV *dstr, SV *sstr)
248 PERL_ARGS_ASSERT_SV_SETSV;
250 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
253 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
254 * this function provided for binary compatibility only
258 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
260 PERL_ARGS_ASSERT_SV_CATPVN;
262 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
266 =for apidoc sv_catpvn_mg
268 Like C<sv_catpvn>, but also handles 'set' magic.
274 Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len)
276 PERL_ARGS_ASSERT_SV_CATPVN_MG;
278 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
281 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
282 * this function provided for binary compatibility only
286 Perl_sv_catsv(pTHX_ SV *dstr, SV *sstr)
288 PERL_ARGS_ASSERT_SV_CATSV;
290 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
294 =for apidoc sv_catsv_mg
296 Like C<sv_catsv>, but also handles 'set' magic.
302 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *ssv)
304 PERL_ARGS_ASSERT_SV_CATSV_MG;
306 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
312 A private implementation of the C<SvIVx> macro for compilers which can't
313 cope with complex macro expressions. Always use the macro instead.
319 Perl_sv_iv(pTHX_ SV *sv)
321 PERL_ARGS_ASSERT_SV_IV;
325 return (IV)SvUVX(sv);
334 A private implementation of the C<SvUVx> macro for compilers which can't
335 cope with complex macro expressions. Always use the macro instead.
341 Perl_sv_uv(pTHX_ SV *sv)
343 PERL_ARGS_ASSERT_SV_UV;
348 return (UV)SvIVX(sv);
356 A private implementation of the C<SvNVx> macro for compilers which can't
357 cope with complex macro expressions. Always use the macro instead.
363 Perl_sv_nv(pTHX_ SV *sv)
365 PERL_ARGS_ASSERT_SV_NV;
375 Use the C<SvPV_nolen> macro instead
379 A private implementation of the C<SvPV> macro for compilers which can't
380 cope with complex macro expressions. Always use the macro instead.
386 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
388 PERL_ARGS_ASSERT_SV_PVN;
394 return sv_2pv(sv, lp);
399 Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
401 PERL_ARGS_ASSERT_SV_PVN_NOMG;
407 return sv_2pv_flags(sv, lp, 0);
410 /* sv_pv() is now a macro using SvPV_nolen();
411 * this function provided for binary compatibility only
415 Perl_sv_pv(pTHX_ SV *sv)
417 PERL_ARGS_ASSERT_SV_PV;
422 return sv_2pv(sv, NULL);
425 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
426 * this function provided for binary compatibility only
430 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
432 PERL_ARGS_ASSERT_SV_PVN_FORCE;
434 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
437 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
438 * this function provided for binary compatibility only
442 Perl_sv_pvbyte(pTHX_ SV *sv)
444 PERL_ARGS_ASSERT_SV_PVBYTE;
446 sv_utf8_downgrade(sv, FALSE);
451 =for apidoc sv_pvbyte
453 Use C<SvPVbyte_nolen> instead.
455 =for apidoc sv_pvbyten
457 A private implementation of the C<SvPVbyte> macro for compilers
458 which can't cope with complex macro expressions. Always use the macro
465 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
467 PERL_ARGS_ASSERT_SV_PVBYTEN;
469 sv_utf8_downgrade(sv, FALSE);
470 return sv_pvn(sv,lp);
473 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
474 * this function provided for binary compatibility only
478 Perl_sv_pvutf8(pTHX_ SV *sv)
480 PERL_ARGS_ASSERT_SV_PVUTF8;
487 =for apidoc sv_pvutf8
489 Use the C<SvPVutf8_nolen> macro instead
491 =for apidoc sv_pvutf8n
493 A private implementation of the C<SvPVutf8> macro for compilers
494 which can't cope with complex macro expressions. Always use the macro
501 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
503 PERL_ARGS_ASSERT_SV_PVUTF8N;
506 return sv_pvn(sv,lp);
509 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
510 * this function provided for binary compatibility only
514 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
516 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
518 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
522 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
527 /* Easier to special case this here than in embed.pl. (Look at what it
528 generates for proto.h) */
529 #ifdef PERL_IMPLICIT_CONTEXT
530 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
533 va_start(arglist, format);
534 ret = PerlIO_vprintf(stream, format, arglist);
540 Perl_printf_nocontext(const char *format, ...)
546 #ifdef PERL_IMPLICIT_CONTEXT
547 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
550 va_start(arglist, format);
551 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
556 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
558 * This hack is to force load of "huge" support from libm.a
559 * So it is in perl for (say) POSIX to use.
560 * Needed for SunOS with Sun's 'acc' for example.
565 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
573 /* compatibility with versions <= 5.003. */
575 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
577 PERL_ARGS_ASSERT_GV_FULLNAME;
579 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
582 /* compatibility with versions <= 5.003. */
584 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
586 PERL_ARGS_ASSERT_GV_EFULLNAME;
588 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
592 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
594 PERL_ARGS_ASSERT_GV_FULLNAME3;
596 gv_fullname4(sv, gv, prefix, TRUE);
600 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
602 PERL_ARGS_ASSERT_GV_EFULLNAME3;
604 gv_efullname4(sv, gv, prefix, TRUE);
608 =for apidoc gv_fetchmethod
610 See L</gv_fetchmethod_autoload>.
616 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
618 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
620 return gv_fetchmethod_autoload(stash, name, TRUE);
624 Perl_hv_iternext(pTHX_ HV *hv)
626 PERL_ARGS_ASSERT_HV_ITERNEXT;
628 return hv_iternext_flags(hv, 0);
632 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
634 PERL_ARGS_ASSERT_HV_MAGIC;
636 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
640 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
641 int rawmode, int rawperm, PerlIO *supplied_fp)
643 PERL_ARGS_ASSERT_DO_OPEN;
645 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
646 supplied_fp, (SV **) NULL, 0);
650 Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
652 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
655 PERL_ARGS_ASSERT_DO_OPEN9;
657 PERL_UNUSED_ARG(num_svs);
658 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
659 supplied_fp, &svs, 1);
663 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
665 /* The old body of this is now in non-LAYER part of perlio.c
666 * This is a stub for any XS code which might have been calling it.
668 const char *name = ":raw";
670 PERL_ARGS_ASSERT_DO_BINMODE;
672 #ifdef PERLIO_USING_CRLF
673 if (!(mode & O_BINARY))
676 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
681 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
683 PERL_ARGS_ASSERT_DO_AEXEC;
685 return do_aexec5(really, mark, sp, 0, 0);
689 /* Backwards compatibility. */
691 Perl_init_i18nl14n(pTHX_ int printwarn)
693 return init_i18nl10n(printwarn);
697 Perl_is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **ep)
699 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
701 return is_utf8_string_loclen(s, len, ep, 0);
705 =for apidoc sv_nolocking
707 Dummy routine which "locks" an SV when there is no locking module present.
708 Exists to avoid test for a C<NULL> function pointer and because it could
709 potentially warn under some level of strict-ness.
711 "Superseded" by C<sv_nosharing()>.
717 Perl_sv_nolocking(pTHX_ SV *sv)
725 =for apidoc sv_nounlocking
727 Dummy routine which "unlocks" an SV when there is no locking module present.
728 Exists to avoid test for a C<NULL> function pointer and because it could
729 potentially warn under some level of strict-ness.
731 "Superseded" by C<sv_nosharing()>.
737 Perl_sv_nounlocking(pTHX_ SV *sv)
744 Perl_save_long(pTHX_ long int *longp)
746 PERL_ARGS_ASSERT_SAVE_LONG;
751 SSPUSHUV(SAVEt_LONG);
755 Perl_save_iv(pTHX_ IV *ivp)
757 PERL_ARGS_ASSERT_SAVE_IV;
766 Perl_save_nogv(pTHX_ GV *gv)
768 PERL_ARGS_ASSERT_SAVE_NOGV;
772 SSPUSHUV(SAVEt_NSTAB);
776 Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
780 PERL_ARGS_ASSERT_SAVE_LIST;
782 for (i = 1; i <= maxsarg; i++) {
786 sv_setsv_nomg(sv,sarg[i]);
788 SSPUSHPTR(sarg[i]); /* remember the pointer */
789 SSPUSHPTR(sv); /* remember the value */
790 SSPUSHUV(SAVEt_ITEM);
795 =for apidoc sv_usepvn_mg
797 Like C<sv_usepvn>, but also handles 'set' magic.
803 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
805 PERL_ARGS_ASSERT_SV_USEPVN_MG;
807 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
811 =for apidoc sv_usepvn
813 Tells an SV to use C<ptr> to find its string value. Implemented by
814 calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
815 magic. See C<L</sv_usepvn_flags>>.
821 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
823 PERL_ARGS_ASSERT_SV_USEPVN;
825 sv_usepvn_flags(sv,ptr,len, 0);
829 =for apidoc unpack_str
831 The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
832 C<new_s> and C<ocnt> are not used. This call should not be used, use
833 C<unpackstring> instead.
838 Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
839 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
842 PERL_ARGS_ASSERT_UNPACK_STR;
844 PERL_UNUSED_ARG(strbeg);
845 PERL_UNUSED_ARG(new_s);
846 PERL_UNUSED_ARG(ocnt);
848 return unpackstring(pat, patend, s, strend, flags);
854 The engine implementing C<pack()> Perl function. Note: parameters
855 C<next_in_list> and C<flags> are not used. This call should not be used; use
862 Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
864 PERL_ARGS_ASSERT_PACK_CAT;
866 PERL_UNUSED_ARG(next_in_list);
867 PERL_UNUSED_ARG(flags);
869 packlist(cat, pat, patend, beglist, endlist);
873 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
875 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
879 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
881 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
883 return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
888 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
890 PERL_ARGS_ASSERT_HV_FETCH_ENT;
892 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
893 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
897 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
899 PERL_ARGS_ASSERT_HV_DELETE_ENT;
901 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
906 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
909 return (SV**) hv_common(hv, NULL, key, klen, flags,
910 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
914 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
926 return (SV **) hv_common(hv, NULL, key, klen, flags,
927 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
931 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
936 PERL_ARGS_ASSERT_HV_EXISTS;
945 return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0)
950 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
955 PERL_ARGS_ASSERT_HV_FETCH;
964 return (SV **) hv_common(hv, NULL, key, klen, flags,
965 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
966 : HV_FETCH_JUST_SV, NULL, 0);
970 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
975 PERL_ARGS_ASSERT_HV_DELETE;
979 k_flags = HVhek_UTF8;
984 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
991 return MUTABLE_AV(newSV_type(SVt_PVAV));
992 /* sv_upgrade does AvREAL_only():
995 AvMAX(av) = AvFILLp(av) = -1; */
1001 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
1008 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
1009 const char *const little, const STRLEN littlelen)
1011 PERL_ARGS_ASSERT_SV_INSERT;
1012 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
1016 Perl_save_freesv(pTHX_ SV *sv)
1022 Perl_save_mortalizesv(pTHX_ SV *sv)
1024 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1026 save_mortalizesv(sv);
1030 Perl_save_freeop(pTHX_ OP *o)
1036 Perl_save_freepv(pTHX_ char *pv)
1047 #ifdef PERL_DONT_CREATE_GVSV
1049 Perl_gv_SVadd(pTHX_ GV *gv)
1051 return gv_SVadd(gv);
1056 Perl_gv_AVadd(pTHX_ GV *gv)
1058 return gv_AVadd(gv);
1062 Perl_gv_HVadd(pTHX_ GV *gv)
1064 return gv_HVadd(gv);
1068 Perl_gv_IOadd(pTHX_ GV *gv)
1070 return gv_IOadd(gv);
1076 return MUTABLE_IO(newSV_type(SVt_PVIO));
1082 return my_stat_flags(SV_GMAGIC);
1088 return my_lstat_flags(SV_GMAGIC);
1092 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1094 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1097 #ifdef USE_LOCALE_COLLATE
1099 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1101 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1106 Perl_sv_2bool(pTHX_ SV *const sv)
1108 return sv_2bool_flags(sv, SV_GMAGIC);
1113 =for apidoc custom_op_name
1114 Return the name for a given custom op. This was once used by the C<OP_NAME>
1115 macro, but is no longer: it has only been kept for compatibility, and
1118 =for apidoc custom_op_desc
1119 Return the description of a given custom op. This was once used by the
1120 C<OP_DESC> macro, but is no longer: it has only been kept for
1121 compatibility, and should not be used.
1127 Perl_custom_op_name(pTHX_ const OP* o)
1129 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1130 return XopENTRYCUSTOM(o, xop_name);
1134 Perl_custom_op_desc(pTHX_ const OP* o)
1136 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1137 return XopENTRYCUSTOM(o, xop_desc);
1141 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1143 return newATTRSUB(floor, o, proto, NULL, block);
1147 Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1149 PERL_ARGS_ASSERT_TO_UTF8_FOLD;
1151 return _to_utf8_fold_flags(p, ustrp, lenp, FOLD_FLAGS_FULL);
1155 Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1157 PERL_ARGS_ASSERT_TO_UTF8_LOWER;
1159 return _to_utf8_lower_flags(p, ustrp, lenp, FALSE);
1163 Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1165 PERL_ARGS_ASSERT_TO_UTF8_TITLE;
1167 return _to_utf8_title_flags(p, ustrp, lenp, FALSE);
1171 Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1173 PERL_ARGS_ASSERT_TO_UTF8_UPPER;
1175 return _to_utf8_upper_flags(p, ustrp, lenp, FALSE);
1179 Perl_sv_mortalcopy(pTHX_ SV *const oldstr)
1181 return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC);
1185 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1187 PERL_ARGS_ASSERT_SV_COPYPV;
1189 sv_copypv_flags(dsv, ssv, 0);
1192 UV /* Made into a function, so can be deprecated */
1193 NATIVE_TO_NEED(const UV enc, const UV ch)
1195 PERL_UNUSED_ARG(enc);
1199 UV /* Made into a function, so can be deprecated */
1200 ASCII_TO_NEED(const UV enc, const UV ch)
1202 PERL_UNUSED_ARG(enc);
1206 bool /* Made into a function, so can be deprecated */
1207 Perl_isIDFIRST_lazy(pTHX_ const char* p)
1209 PERL_ARGS_ASSERT_ISIDFIRST_LAZY;
1211 return isIDFIRST_lazy_if(p,1);
1214 bool /* Made into a function, so can be deprecated */
1215 Perl_isALNUM_lazy(pTHX_ const char* p)
1217 PERL_ARGS_ASSERT_ISALNUM_LAZY;
1219 return isALNUM_lazy_if(p,1);
1223 Perl_is_uni_alnum(pTHX_ UV c)
1225 return isWORDCHAR_uni(c);
1229 Perl_is_uni_alnumc(pTHX_ UV c)
1231 return isALNUM_uni(c);
1235 Perl_is_uni_alpha(pTHX_ UV c)
1237 return isALPHA_uni(c);
1241 Perl_is_uni_ascii(pTHX_ UV c)
1243 PERL_UNUSED_CONTEXT;
1244 return isASCII_uni(c);
1248 Perl_is_uni_blank(pTHX_ UV c)
1250 PERL_UNUSED_CONTEXT;
1251 return isBLANK_uni(c);
1255 Perl_is_uni_space(pTHX_ UV c)
1257 PERL_UNUSED_CONTEXT;
1258 return isSPACE_uni(c);
1262 Perl_is_uni_digit(pTHX_ UV c)
1264 PERL_UNUSED_CONTEXT;
1265 return isDIGIT_uni(c);
1269 Perl_is_uni_upper(pTHX_ UV c)
1271 PERL_UNUSED_CONTEXT;
1272 return isUPPER_uni(c);
1276 Perl_is_uni_lower(pTHX_ UV c)
1278 PERL_UNUSED_CONTEXT;
1279 return isLOWER_uni(c);
1283 Perl_is_uni_cntrl(pTHX_ UV c)
1285 PERL_UNUSED_CONTEXT;
1286 return isCNTRL_L1(c);
1290 Perl_is_uni_graph(pTHX_ UV c)
1292 PERL_UNUSED_CONTEXT;
1293 return isGRAPH_uni(c);
1297 Perl_is_uni_print(pTHX_ UV c)
1299 PERL_UNUSED_CONTEXT;
1300 return isPRINT_uni(c);
1304 Perl_is_uni_punct(pTHX_ UV c)
1306 PERL_UNUSED_CONTEXT;
1307 return isPUNCT_uni(c);
1311 Perl_is_uni_xdigit(pTHX_ UV c)
1313 PERL_UNUSED_CONTEXT;
1314 return isXDIGIT_uni(c);
1318 Perl_is_uni_alnum_lc(pTHX_ UV c)
1320 PERL_UNUSED_CONTEXT;
1321 return isWORDCHAR_LC_uvchr(c);
1325 Perl_is_uni_alnumc_lc(pTHX_ UV c)
1327 PERL_UNUSED_CONTEXT;
1328 return isALPHANUMERIC_LC_uvchr(c);
1332 Perl_is_uni_idfirst_lc(pTHX_ UV c)
1334 PERL_UNUSED_CONTEXT;
1335 /* XXX Should probably be something that resolves to the old IDFIRST, but
1336 * this function is deprecated, so not bothering */
1337 return isIDFIRST_LC_uvchr(c);
1341 Perl_is_uni_alpha_lc(pTHX_ UV c)
1343 PERL_UNUSED_CONTEXT;
1344 return isALPHA_LC_uvchr(c);
1348 Perl_is_uni_ascii_lc(pTHX_ UV c)
1350 PERL_UNUSED_CONTEXT;
1351 return isASCII_LC_uvchr(c);
1355 Perl_is_uni_blank_lc(pTHX_ UV c)
1357 PERL_UNUSED_CONTEXT;
1358 return isBLANK_LC_uvchr(c);
1362 Perl_is_uni_space_lc(pTHX_ UV c)
1364 PERL_UNUSED_CONTEXT;
1365 return isSPACE_LC_uvchr(c);
1369 Perl_is_uni_digit_lc(pTHX_ UV c)
1371 return isDIGIT_LC_uvchr(c);
1375 Perl_is_uni_idfirst(pTHX_ UV c)
1377 U8 tmpbuf[UTF8_MAXBYTES+1];
1378 uvchr_to_utf8(tmpbuf, c);
1379 return _is_utf8_idstart(tmpbuf);
1383 Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
1385 PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
1387 return _is_utf8_idstart(p);
1391 Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */
1393 PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST;
1395 return _is_utf8_xidstart(p);
1399 Perl_is_utf8_idcont(pTHX_ const U8 *p)
1401 PERL_ARGS_ASSERT_IS_UTF8_IDCONT;
1403 return _is_utf8_idcont(p);
1407 Perl_is_utf8_xidcont(pTHX_ const U8 *p)
1409 PERL_ARGS_ASSERT_IS_UTF8_XIDCONT;
1411 return _is_utf8_xidcont(p);
1415 Perl_is_uni_upper_lc(pTHX_ UV c)
1417 return isUPPER_LC_uvchr(c);
1421 Perl_is_uni_lower_lc(pTHX_ UV c)
1423 return isLOWER_LC_uvchr(c);
1427 Perl_is_uni_cntrl_lc(pTHX_ UV c)
1429 return isCNTRL_LC_uvchr(c);
1433 Perl_is_uni_graph_lc(pTHX_ UV c)
1435 return isGRAPH_LC_uvchr(c);
1439 Perl_is_uni_print_lc(pTHX_ UV c)
1441 return isPRINT_LC_uvchr(c);
1445 Perl_is_uni_punct_lc(pTHX_ UV c)
1447 return isPUNCT_LC_uvchr(c);
1451 Perl_is_uni_xdigit_lc(pTHX_ UV c)
1453 return isXDIGIT_LC_uvchr(c);
1457 Perl_to_uni_upper_lc(pTHX_ U32 c)
1459 /* XXX returns only the first character -- do not use XXX */
1460 /* XXX no locale support yet */
1462 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1463 return (U32)to_uni_upper(c, tmpbuf, &len);
1467 Perl_to_uni_title_lc(pTHX_ U32 c)
1469 /* XXX returns only the first character XXX -- do not use XXX */
1470 /* XXX no locale support yet */
1472 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1473 return (U32)to_uni_title(c, tmpbuf, &len);
1477 Perl_to_uni_lower_lc(pTHX_ U32 c)
1479 /* XXX returns only the first character -- do not use XXX */
1480 /* XXX no locale support yet */
1482 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1483 return (U32)to_uni_lower(c, tmpbuf, &len);
1487 Perl_is_utf8_alnum(pTHX_ const U8 *p)
1489 PERL_ARGS_ASSERT_IS_UTF8_ALNUM;
1491 /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
1492 * descendant of isalnum(3), in other words, it doesn't
1493 * contain the '_'. --jhi */
1494 return isWORDCHAR_utf8(p);
1498 Perl_is_utf8_alnumc(pTHX_ const U8 *p)
1500 PERL_ARGS_ASSERT_IS_UTF8_ALNUMC;
1502 return isALPHANUMERIC_utf8(p);
1506 Perl_is_utf8_alpha(pTHX_ const U8 *p)
1508 PERL_ARGS_ASSERT_IS_UTF8_ALPHA;
1510 return isALPHA_utf8(p);
1514 Perl_is_utf8_ascii(pTHX_ const U8 *p)
1516 PERL_ARGS_ASSERT_IS_UTF8_ASCII;
1517 PERL_UNUSED_CONTEXT;
1519 return isASCII_utf8(p);
1523 Perl_is_utf8_blank(pTHX_ const U8 *p)
1525 PERL_ARGS_ASSERT_IS_UTF8_BLANK;
1526 PERL_UNUSED_CONTEXT;
1528 return isBLANK_utf8(p);
1532 Perl_is_utf8_space(pTHX_ const U8 *p)
1534 PERL_ARGS_ASSERT_IS_UTF8_SPACE;
1535 PERL_UNUSED_CONTEXT;
1537 return isSPACE_utf8(p);
1541 Perl_is_utf8_perl_space(pTHX_ const U8 *p)
1543 PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE;
1544 PERL_UNUSED_CONTEXT;
1546 /* Only true if is an ASCII space-like character, and ASCII is invariant
1547 * under utf8, so can just use the macro */
1548 return isSPACE_A(*p);
1552 Perl_is_utf8_perl_word(pTHX_ const U8 *p)
1554 PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD;
1555 PERL_UNUSED_CONTEXT;
1557 /* Only true if is an ASCII word character, and ASCII is invariant
1558 * under utf8, so can just use the macro */
1559 return isWORDCHAR_A(*p);
1563 Perl_is_utf8_digit(pTHX_ const U8 *p)
1565 PERL_ARGS_ASSERT_IS_UTF8_DIGIT;
1567 return isDIGIT_utf8(p);
1571 Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
1573 PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT;
1574 PERL_UNUSED_CONTEXT;
1576 /* Only true if is an ASCII digit character, and ASCII is invariant
1577 * under utf8, so can just use the macro */
1578 return isDIGIT_A(*p);
1582 Perl_is_utf8_upper(pTHX_ const U8 *p)
1584 PERL_ARGS_ASSERT_IS_UTF8_UPPER;
1586 return isUPPER_utf8(p);
1590 Perl_is_utf8_lower(pTHX_ const U8 *p)
1592 PERL_ARGS_ASSERT_IS_UTF8_LOWER;
1594 return isLOWER_utf8(p);
1598 Perl_is_utf8_cntrl(pTHX_ const U8 *p)
1600 PERL_ARGS_ASSERT_IS_UTF8_CNTRL;
1601 PERL_UNUSED_CONTEXT;
1603 return isCNTRL_utf8(p);
1607 Perl_is_utf8_graph(pTHX_ const U8 *p)
1609 PERL_ARGS_ASSERT_IS_UTF8_GRAPH;
1611 return isGRAPH_utf8(p);
1615 Perl_is_utf8_print(pTHX_ const U8 *p)
1617 PERL_ARGS_ASSERT_IS_UTF8_PRINT;
1619 return isPRINT_utf8(p);
1623 Perl_is_utf8_punct(pTHX_ const U8 *p)
1625 PERL_ARGS_ASSERT_IS_UTF8_PUNCT;
1627 return isPUNCT_utf8(p);
1631 Perl_is_utf8_xdigit(pTHX_ const U8 *p)
1633 PERL_ARGS_ASSERT_IS_UTF8_XDIGIT;
1634 PERL_UNUSED_CONTEXT;
1636 return isXDIGIT_utf8(p);
1640 Perl_is_utf8_mark(pTHX_ const U8 *p)
1642 PERL_ARGS_ASSERT_IS_UTF8_MARK;
1644 return _is_utf8_mark(p);
1648 =for apidoc is_utf8_char
1650 Tests if some arbitrary number of bytes begins in a valid UTF-8
1651 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1652 character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1653 character will be returned if it is valid, otherwise 0.
1655 This function is deprecated due to the possibility that malformed input could
1656 cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1662 Perl_is_utf8_char(const U8 *s)
1664 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1666 /* Assumes we have enough space, which is why this is deprecated */
1667 return isUTF8_CHAR(s, s + UTF8SKIP(s));
1671 =for apidoc is_utf8_char_buf
1673 This is identical to the macro L</isUTF8_CHAR>.
1678 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1681 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1683 return isUTF8_CHAR(buf, buf_end);
1687 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1688 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1689 * non-character code points, and non-Unicode code points are allowed */
1692 Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1694 PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1696 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1700 =for apidoc utf8_to_uvchr
1702 Returns the native code point of the first character in the string C<s>
1703 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1704 length, in bytes, of that character.
1706 Some, but not all, UTF-8 malformations are detected, and in fact, some
1707 malformed input could cause reading beyond the end of the input buffer, which
1708 is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
1710 If C<s> points to one of the detected malformations, and UTF8 warnings are
1711 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1712 C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
1713 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1714 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1715 next possible position in C<s> that could begin a non-malformed character.
1716 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1722 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1724 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1726 return utf8_to_uvchr_buf(s, s + UTF8_MAXBYTES, retlen);
1730 =for apidoc utf8_to_uvuni
1732 Returns the Unicode code point of the first character in the string C<s>
1733 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1734 length, in bytes, of that character.
1736 Some, but not all, UTF-8 malformations are detected, and in fact, some
1737 malformed input could cause reading beyond the end of the input buffer, which
1738 is one reason why this function is deprecated. The other is that only in
1739 extremely limited circumstances should the Unicode versus native code point be
1740 of any interest to you. See L</utf8_to_uvuni_buf> for alternatives.
1742 If C<s> points to one of the detected malformations, and UTF8 warnings are
1743 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1744 NULL) to -1. If those warnings are off, the computed value if well-defined (or
1745 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1746 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1747 next possible position in C<s> that could begin a non-malformed character.
1748 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1754 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1756 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1758 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1762 =for apidoc Am|HV *|pad_compname_type|PADOFFSET po
1764 Looks up the type of the lexical variable at position C<po> in the
1765 currently-compiling pad. If the variable is typed, the stash of the
1766 class to which it is typed is returned. If not, C<NULL> is returned.
1772 Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1774 return PAD_COMPNAME_TYPE(po);
1777 /* return ptr to little string in big string, NULL if not found */
1778 /* The original version of this routine was donated by Corey Satten. */
1781 Perl_instr(const char *big, const char *little)
1783 PERL_ARGS_ASSERT_INSTR;
1785 return instr((char *) big, (char *) little);
1788 #endif /* NO_MATHOMS */
1791 * ex: set ts=8 sts=4 sw=4 et: