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. For binary or source compatibility reasons, though,
25 * we cannot completely remove them from the core code.
27 * REMEMBER to update makedef.pl when adding a function to mathoms.c whose
28 * name doesn't begin with "Perl_".
32 * The compilation of this file can be suppressed; see INSTALL
34 =head1 Obsolete backwards compatibility functions
35 Some of these are also deprecated. You can exclude these from
36 your compiled Perl by adding this option to Configure:
37 C<-Accflags='-DNO_MATHOMS'>
45 #define PERL_IN_MATHOMS_C
49 /* ..." warning: ISO C forbids an empty source file"
50 So make sure we have something in here by processing the headers anyway.
54 /* All functions in this file should have an entry with the 'b' flag in embed.fnc */
56 /* ref() is now a macro using Perl_doref;
57 * this version provided for binary compatibility only.
60 Perl_ref(pTHX_ OP *o, I32 type)
62 return doref(o, type, TRUE);
68 Unsets the RV status of the SV, and decrements the reference count of
69 whatever was being referenced by the RV. This can almost be thought of
70 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
71 being zero. See C<L</SvROK_off>>.
77 Perl_sv_unref(pTHX_ SV *sv)
79 PERL_ARGS_ASSERT_SV_UNREF;
81 sv_unref_flags(sv, 0);
87 Taint an SV. Use C<SvTAINTED_on> instead.
93 Perl_sv_taint(pTHX_ SV *sv)
95 PERL_ARGS_ASSERT_SV_TAINT;
97 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
100 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
101 * this function provided for binary compatibility only
105 Perl_sv_2iv(pTHX_ SV *sv)
107 PERL_ARGS_ASSERT_SV_2IV;
109 return sv_2iv_flags(sv, SV_GMAGIC);
112 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
113 * this function provided for binary compatibility only
117 Perl_sv_2uv(pTHX_ SV *sv)
119 PERL_ARGS_ASSERT_SV_2UV;
121 return sv_2uv_flags(sv, SV_GMAGIC);
124 /* sv_2nv() is now a macro using Perl_sv_2nv_flags();
125 * this function provided for binary compatibility only
129 Perl_sv_2nv(pTHX_ SV *sv)
131 return sv_2nv_flags(sv, SV_GMAGIC);
135 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
136 * this function provided for binary compatibility only
140 Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
142 PERL_ARGS_ASSERT_SV_2PV;
144 return sv_2pv_flags(sv, lp, SV_GMAGIC);
148 =for apidoc sv_2pv_nolen
150 Like C<sv_2pv()>, but doesn't return the length too. You should usually
151 use the macro wrapper C<SvPV_nolen(sv)> instead.
157 Perl_sv_2pv_nolen(pTHX_ SV *sv)
159 PERL_ARGS_ASSERT_SV_2PV_NOLEN;
160 return sv_2pv(sv, NULL);
164 =for apidoc sv_2pvbyte_nolen
166 Return a pointer to the byte-encoded representation of the SV.
167 May cause the SV to be downgraded from UTF-8 as a side-effect.
169 Usually accessed via the C<SvPVbyte_nolen> macro.
175 Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
177 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
179 return sv_2pvbyte(sv, NULL);
183 =for apidoc sv_2pvutf8_nolen
185 Return a pointer to the UTF-8-encoded representation of the SV.
186 May cause the SV to be upgraded to UTF-8 as a side-effect.
188 Usually accessed via the C<SvPVutf8_nolen> macro.
194 Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
196 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
198 return sv_2pvutf8(sv, NULL);
202 =for apidoc sv_force_normal
204 Undo various types of fakery on an SV: if the PV is a shared string, make
205 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
206 an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
212 Perl_sv_force_normal(pTHX_ SV *sv)
214 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
216 sv_force_normal_flags(sv, 0);
219 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
220 * this function provided for binary compatibility only
224 Perl_sv_setsv(pTHX_ SV *dstr, SV *sstr)
226 PERL_ARGS_ASSERT_SV_SETSV;
228 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
231 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
232 * this function provided for binary compatibility only
236 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
238 PERL_ARGS_ASSERT_SV_CATPVN;
240 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
244 =for apidoc sv_catpvn_mg
246 Like C<sv_catpvn>, but also handles 'set' magic.
252 Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len)
254 PERL_ARGS_ASSERT_SV_CATPVN_MG;
256 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
259 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
260 * this function provided for binary compatibility only
264 Perl_sv_catsv(pTHX_ SV *dstr, SV *sstr)
266 PERL_ARGS_ASSERT_SV_CATSV;
268 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
272 =for apidoc sv_catsv_mg
274 Like C<sv_catsv>, but also handles 'set' magic.
280 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *ssv)
282 PERL_ARGS_ASSERT_SV_CATSV_MG;
284 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
290 A private implementation of the C<SvIVx> macro for compilers which can't
291 cope with complex macro expressions. Always use the macro instead.
297 Perl_sv_iv(pTHX_ SV *sv)
299 PERL_ARGS_ASSERT_SV_IV;
303 return (IV)SvUVX(sv);
312 A private implementation of the C<SvUVx> macro for compilers which can't
313 cope with complex macro expressions. Always use the macro instead.
319 Perl_sv_uv(pTHX_ SV *sv)
321 PERL_ARGS_ASSERT_SV_UV;
326 return (UV)SvIVX(sv);
334 A private implementation of the C<SvNVx> macro for compilers which can't
335 cope with complex macro expressions. Always use the macro instead.
341 Perl_sv_nv(pTHX_ SV *sv)
343 PERL_ARGS_ASSERT_SV_NV;
353 Use the C<SvPV_nolen> macro instead
357 A private implementation of the C<SvPV> macro for compilers which can't
358 cope with complex macro expressions. Always use the macro instead.
364 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
366 PERL_ARGS_ASSERT_SV_PVN;
372 return sv_2pv(sv, lp);
377 Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
379 PERL_ARGS_ASSERT_SV_PVN_NOMG;
385 return sv_2pv_flags(sv, lp, 0);
388 /* sv_pv() is now a macro using SvPV_nolen();
389 * this function provided for binary compatibility only
393 Perl_sv_pv(pTHX_ SV *sv)
395 PERL_ARGS_ASSERT_SV_PV;
400 return sv_2pv(sv, NULL);
403 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
404 * this function provided for binary compatibility only
408 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
410 PERL_ARGS_ASSERT_SV_PVN_FORCE;
412 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
415 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
416 * this function provided for binary compatibility only
420 Perl_sv_pvbyte(pTHX_ SV *sv)
422 PERL_ARGS_ASSERT_SV_PVBYTE;
424 sv_utf8_downgrade(sv, FALSE);
429 =for apidoc sv_pvbyte
431 Use C<SvPVbyte_nolen> instead.
433 =for apidoc sv_pvbyten
435 A private implementation of the C<SvPVbyte> macro for compilers
436 which can't cope with complex macro expressions. Always use the macro
443 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
445 PERL_ARGS_ASSERT_SV_PVBYTEN;
447 sv_utf8_downgrade(sv, FALSE);
448 return sv_pvn(sv,lp);
451 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
452 * this function provided for binary compatibility only
456 Perl_sv_pvutf8(pTHX_ SV *sv)
458 PERL_ARGS_ASSERT_SV_PVUTF8;
465 =for apidoc sv_pvutf8
467 Use the C<SvPVutf8_nolen> macro instead
469 =for apidoc sv_pvutf8n
471 A private implementation of the C<SvPVutf8> macro for compilers
472 which can't cope with complex macro expressions. Always use the macro
479 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
481 PERL_ARGS_ASSERT_SV_PVUTF8N;
484 return sv_pvn(sv,lp);
487 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
488 * this function provided for binary compatibility only
492 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
494 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
496 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
500 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
505 /* Easier to special case this here than in embed.pl. (Look at what it
506 generates for proto.h) */
507 #ifdef PERL_IMPLICIT_CONTEXT
508 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
511 va_start(arglist, format);
512 ret = PerlIO_vprintf(stream, format, arglist);
518 Perl_printf_nocontext(const char *format, ...)
524 #ifdef PERL_IMPLICIT_CONTEXT
525 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
528 va_start(arglist, format);
529 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
534 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
536 * This hack is to force load of "huge" support from libm.a
537 * So it is in perl for (say) POSIX to use.
538 * Needed for SunOS with Sun's 'acc' for example.
543 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
551 /* compatibility with versions <= 5.003. */
553 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
555 PERL_ARGS_ASSERT_GV_FULLNAME;
557 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
560 /* compatibility with versions <= 5.003. */
562 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
564 PERL_ARGS_ASSERT_GV_EFULLNAME;
566 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
570 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
572 PERL_ARGS_ASSERT_GV_FULLNAME3;
574 gv_fullname4(sv, gv, prefix, TRUE);
578 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
580 PERL_ARGS_ASSERT_GV_EFULLNAME3;
582 gv_efullname4(sv, gv, prefix, TRUE);
586 =for apidoc gv_fetchmethod
588 See L</gv_fetchmethod_autoload>.
594 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
596 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
598 return gv_fetchmethod_autoload(stash, name, TRUE);
602 Perl_hv_iternext(pTHX_ HV *hv)
604 PERL_ARGS_ASSERT_HV_ITERNEXT;
606 return hv_iternext_flags(hv, 0);
610 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
612 PERL_ARGS_ASSERT_HV_MAGIC;
614 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
618 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
619 int rawmode, int rawperm, PerlIO *supplied_fp)
621 PERL_ARGS_ASSERT_DO_OPEN;
623 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
624 supplied_fp, (SV **) NULL, 0);
628 Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
630 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
633 PERL_ARGS_ASSERT_DO_OPEN9;
635 PERL_UNUSED_ARG(num_svs);
636 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
637 supplied_fp, &svs, 1);
641 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
643 /* The old body of this is now in non-LAYER part of perlio.c
644 * This is a stub for any XS code which might have been calling it.
646 const char *name = ":raw";
648 PERL_ARGS_ASSERT_DO_BINMODE;
650 #ifdef PERLIO_USING_CRLF
651 if (!(mode & O_BINARY))
654 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
659 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
661 PERL_ARGS_ASSERT_DO_AEXEC;
663 return do_aexec5(really, mark, sp, 0, 0);
667 /* Backwards compatibility. */
669 Perl_init_i18nl14n(pTHX_ int printwarn)
671 return init_i18nl10n(printwarn);
675 Perl_is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **ep)
677 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
679 return is_utf8_string_loclen(s, len, ep, 0);
683 =for apidoc sv_nolocking
685 Dummy routine which "locks" an SV when there is no locking module present.
686 Exists to avoid test for a C<NULL> function pointer and because it could
687 potentially warn under some level of strict-ness.
689 "Superseded" by C<sv_nosharing()>.
695 Perl_sv_nolocking(pTHX_ SV *sv)
703 =for apidoc sv_nounlocking
705 Dummy routine which "unlocks" an SV when there is no locking module present.
706 Exists to avoid test for a C<NULL> function pointer and because it could
707 potentially warn under some level of strict-ness.
709 "Superseded" by C<sv_nosharing()>.
715 Perl_sv_nounlocking(pTHX_ SV *sv)
722 Perl_save_long(pTHX_ long int *longp)
724 PERL_ARGS_ASSERT_SAVE_LONG;
729 SSPUSHUV(SAVEt_LONG);
733 Perl_save_iv(pTHX_ IV *ivp)
735 PERL_ARGS_ASSERT_SAVE_IV;
744 Perl_save_nogv(pTHX_ GV *gv)
746 PERL_ARGS_ASSERT_SAVE_NOGV;
750 SSPUSHUV(SAVEt_NSTAB);
754 Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
758 PERL_ARGS_ASSERT_SAVE_LIST;
760 for (i = 1; i <= maxsarg; i++) {
764 sv_setsv_nomg(sv,sarg[i]);
766 SSPUSHPTR(sarg[i]); /* remember the pointer */
767 SSPUSHPTR(sv); /* remember the value */
768 SSPUSHUV(SAVEt_ITEM);
773 =for apidoc sv_usepvn_mg
775 Like C<sv_usepvn>, but also handles 'set' magic.
781 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
783 PERL_ARGS_ASSERT_SV_USEPVN_MG;
785 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
789 =for apidoc sv_usepvn
791 Tells an SV to use C<ptr> to find its string value. Implemented by
792 calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
793 magic. See C<L</sv_usepvn_flags>>.
799 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
801 PERL_ARGS_ASSERT_SV_USEPVN;
803 sv_usepvn_flags(sv,ptr,len, 0);
807 =for apidoc unpack_str
809 The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
810 C<new_s> and C<ocnt> are not used. This call should not be used, use
811 C<unpackstring> instead.
816 Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
817 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
820 PERL_ARGS_ASSERT_UNPACK_STR;
822 PERL_UNUSED_ARG(strbeg);
823 PERL_UNUSED_ARG(new_s);
824 PERL_UNUSED_ARG(ocnt);
826 return unpackstring(pat, patend, s, strend, flags);
832 The engine implementing C<pack()> Perl function. Note: parameters
833 C<next_in_list> and C<flags> are not used. This call should not be used; use
840 Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
842 PERL_ARGS_ASSERT_PACK_CAT;
844 PERL_UNUSED_ARG(next_in_list);
845 PERL_UNUSED_ARG(flags);
847 packlist(cat, pat, patend, beglist, endlist);
851 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
853 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
857 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
859 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
861 return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
866 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
868 PERL_ARGS_ASSERT_HV_FETCH_ENT;
870 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
871 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
875 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
877 PERL_ARGS_ASSERT_HV_DELETE_ENT;
879 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
884 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
887 return (SV**) hv_common(hv, NULL, key, klen, flags,
888 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
892 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
904 return (SV **) hv_common(hv, NULL, key, klen, flags,
905 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
909 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
914 PERL_ARGS_ASSERT_HV_EXISTS;
923 return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0)
928 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
933 PERL_ARGS_ASSERT_HV_FETCH;
942 return (SV **) hv_common(hv, NULL, key, klen, flags,
943 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
944 : HV_FETCH_JUST_SV, NULL, 0);
948 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
953 PERL_ARGS_ASSERT_HV_DELETE;
957 k_flags = HVhek_UTF8;
962 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
969 return MUTABLE_AV(newSV_type(SVt_PVAV));
970 /* sv_upgrade does AvREAL_only():
973 AvMAX(av) = AvFILLp(av) = -1; */
979 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
986 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
987 const char *const little, const STRLEN littlelen)
989 PERL_ARGS_ASSERT_SV_INSERT;
990 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
994 Perl_save_freesv(pTHX_ SV *sv)
1000 Perl_save_mortalizesv(pTHX_ SV *sv)
1002 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1004 save_mortalizesv(sv);
1008 Perl_save_freeop(pTHX_ OP *o)
1014 Perl_save_freepv(pTHX_ char *pv)
1025 #ifdef PERL_DONT_CREATE_GVSV
1027 Perl_gv_SVadd(pTHX_ GV *gv)
1029 return gv_SVadd(gv);
1034 Perl_gv_AVadd(pTHX_ GV *gv)
1036 return gv_AVadd(gv);
1040 Perl_gv_HVadd(pTHX_ GV *gv)
1042 return gv_HVadd(gv);
1046 Perl_gv_IOadd(pTHX_ GV *gv)
1048 return gv_IOadd(gv);
1054 return MUTABLE_IO(newSV_type(SVt_PVIO));
1060 return my_stat_flags(SV_GMAGIC);
1066 return my_lstat_flags(SV_GMAGIC);
1070 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1072 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1075 #ifdef USE_LOCALE_COLLATE
1077 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1079 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1084 Perl_sv_2bool(pTHX_ SV *const sv)
1086 return sv_2bool_flags(sv, SV_GMAGIC);
1091 =for apidoc custom_op_name
1092 Return the name for a given custom op. This was once used by the C<OP_NAME>
1093 macro, but is no longer: it has only been kept for compatibility, and
1096 =for apidoc custom_op_desc
1097 Return the description of a given custom op. This was once used by the
1098 C<OP_DESC> macro, but is no longer: it has only been kept for
1099 compatibility, and should not be used.
1105 Perl_custom_op_name(pTHX_ const OP* o)
1107 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1108 return XopENTRYCUSTOM(o, xop_name);
1112 Perl_custom_op_desc(pTHX_ const OP* o)
1114 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1115 return XopENTRYCUSTOM(o, xop_desc);
1119 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1121 return newATTRSUB(floor, o, proto, NULL, block);
1125 Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1127 PERL_ARGS_ASSERT_TO_UTF8_FOLD;
1129 return _to_utf8_fold_flags(p, ustrp, lenp, FOLD_FLAGS_FULL);
1133 Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1135 PERL_ARGS_ASSERT_TO_UTF8_LOWER;
1137 return _to_utf8_lower_flags(p, ustrp, lenp, FALSE);
1141 Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1143 PERL_ARGS_ASSERT_TO_UTF8_TITLE;
1145 return _to_utf8_title_flags(p, ustrp, lenp, FALSE);
1149 Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1151 PERL_ARGS_ASSERT_TO_UTF8_UPPER;
1153 return _to_utf8_upper_flags(p, ustrp, lenp, FALSE);
1157 Perl_sv_mortalcopy(pTHX_ SV *const oldstr)
1159 return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC);
1163 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1165 PERL_ARGS_ASSERT_SV_COPYPV;
1167 sv_copypv_flags(dsv, ssv, 0);
1170 UV /* Made into a function, so can be deprecated */
1171 NATIVE_TO_NEED(const UV enc, const UV ch)
1173 PERL_UNUSED_ARG(enc);
1177 UV /* Made into a function, so can be deprecated */
1178 ASCII_TO_NEED(const UV enc, const UV ch)
1180 PERL_UNUSED_ARG(enc);
1184 bool /* Made into a function, so can be deprecated */
1185 Perl_isIDFIRST_lazy(pTHX_ const char* p)
1187 PERL_ARGS_ASSERT_ISIDFIRST_LAZY;
1189 return isIDFIRST_lazy_if(p,1);
1192 bool /* Made into a function, so can be deprecated */
1193 Perl_isALNUM_lazy(pTHX_ const char* p)
1195 PERL_ARGS_ASSERT_ISALNUM_LAZY;
1197 return isALNUM_lazy_if(p,1);
1201 Perl_is_uni_alnum(pTHX_ UV c)
1203 return isWORDCHAR_uni(c);
1207 Perl_is_uni_alnumc(pTHX_ UV c)
1209 return isALNUM_uni(c);
1213 Perl_is_uni_alpha(pTHX_ UV c)
1215 return isALPHA_uni(c);
1219 Perl_is_uni_ascii(pTHX_ UV c)
1221 PERL_UNUSED_CONTEXT;
1222 return isASCII_uni(c);
1226 Perl_is_uni_blank(pTHX_ UV c)
1228 PERL_UNUSED_CONTEXT;
1229 return isBLANK_uni(c);
1233 Perl_is_uni_space(pTHX_ UV c)
1235 PERL_UNUSED_CONTEXT;
1236 return isSPACE_uni(c);
1240 Perl_is_uni_digit(pTHX_ UV c)
1242 PERL_UNUSED_CONTEXT;
1243 return isDIGIT_uni(c);
1247 Perl_is_uni_upper(pTHX_ UV c)
1249 PERL_UNUSED_CONTEXT;
1250 return isUPPER_uni(c);
1254 Perl_is_uni_lower(pTHX_ UV c)
1256 PERL_UNUSED_CONTEXT;
1257 return isLOWER_uni(c);
1261 Perl_is_uni_cntrl(pTHX_ UV c)
1263 PERL_UNUSED_CONTEXT;
1264 return isCNTRL_L1(c);
1268 Perl_is_uni_graph(pTHX_ UV c)
1270 PERL_UNUSED_CONTEXT;
1271 return isGRAPH_uni(c);
1275 Perl_is_uni_print(pTHX_ UV c)
1277 PERL_UNUSED_CONTEXT;
1278 return isPRINT_uni(c);
1282 Perl_is_uni_punct(pTHX_ UV c)
1284 PERL_UNUSED_CONTEXT;
1285 return isPUNCT_uni(c);
1289 Perl_is_uni_xdigit(pTHX_ UV c)
1291 PERL_UNUSED_CONTEXT;
1292 return isXDIGIT_uni(c);
1296 Perl_is_uni_alnum_lc(pTHX_ UV c)
1298 PERL_UNUSED_CONTEXT;
1299 return isWORDCHAR_LC_uvchr(c);
1303 Perl_is_uni_alnumc_lc(pTHX_ UV c)
1305 PERL_UNUSED_CONTEXT;
1306 return isALPHANUMERIC_LC_uvchr(c);
1310 Perl_is_uni_idfirst_lc(pTHX_ UV c)
1312 PERL_UNUSED_CONTEXT;
1313 /* XXX Should probably be something that resolves to the old IDFIRST, but
1314 * this function is deprecated, so not bothering */
1315 return isIDFIRST_LC_uvchr(c);
1319 Perl_is_uni_alpha_lc(pTHX_ UV c)
1321 PERL_UNUSED_CONTEXT;
1322 return isALPHA_LC_uvchr(c);
1326 Perl_is_uni_ascii_lc(pTHX_ UV c)
1328 PERL_UNUSED_CONTEXT;
1329 return isASCII_LC_uvchr(c);
1333 Perl_is_uni_blank_lc(pTHX_ UV c)
1335 PERL_UNUSED_CONTEXT;
1336 return isBLANK_LC_uvchr(c);
1340 Perl_is_uni_space_lc(pTHX_ UV c)
1342 PERL_UNUSED_CONTEXT;
1343 return isSPACE_LC_uvchr(c);
1347 Perl_is_uni_digit_lc(pTHX_ UV c)
1349 return isDIGIT_LC_uvchr(c);
1353 Perl_is_uni_idfirst(pTHX_ UV c)
1355 U8 tmpbuf[UTF8_MAXBYTES+1];
1356 uvchr_to_utf8(tmpbuf, c);
1357 return _is_utf8_idstart(tmpbuf);
1361 Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
1363 PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
1365 return _is_utf8_idstart(p);
1369 Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */
1371 PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST;
1373 return _is_utf8_xidstart(p);
1377 Perl_is_utf8_idcont(pTHX_ const U8 *p)
1379 PERL_ARGS_ASSERT_IS_UTF8_IDCONT;
1381 return _is_utf8_idcont(p);
1385 Perl_is_utf8_xidcont(pTHX_ const U8 *p)
1387 PERL_ARGS_ASSERT_IS_UTF8_XIDCONT;
1389 return _is_utf8_xidcont(p);
1393 Perl_is_uni_upper_lc(pTHX_ UV c)
1395 return isUPPER_LC_uvchr(c);
1399 Perl_is_uni_lower_lc(pTHX_ UV c)
1401 return isLOWER_LC_uvchr(c);
1405 Perl_is_uni_cntrl_lc(pTHX_ UV c)
1407 return isCNTRL_LC_uvchr(c);
1411 Perl_is_uni_graph_lc(pTHX_ UV c)
1413 return isGRAPH_LC_uvchr(c);
1417 Perl_is_uni_print_lc(pTHX_ UV c)
1419 return isPRINT_LC_uvchr(c);
1423 Perl_is_uni_punct_lc(pTHX_ UV c)
1425 return isPUNCT_LC_uvchr(c);
1429 Perl_is_uni_xdigit_lc(pTHX_ UV c)
1431 return isXDIGIT_LC_uvchr(c);
1435 Perl_to_uni_upper_lc(pTHX_ U32 c)
1437 /* XXX returns only the first character -- do not use XXX */
1438 /* XXX no locale support yet */
1440 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1441 return (U32)to_uni_upper(c, tmpbuf, &len);
1445 Perl_to_uni_title_lc(pTHX_ U32 c)
1447 /* XXX returns only the first character XXX -- do not use XXX */
1448 /* XXX no locale support yet */
1450 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1451 return (U32)to_uni_title(c, tmpbuf, &len);
1455 Perl_to_uni_lower_lc(pTHX_ U32 c)
1457 /* XXX returns only the first character -- do not use XXX */
1458 /* XXX no locale support yet */
1460 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1461 return (U32)to_uni_lower(c, tmpbuf, &len);
1465 Perl_is_utf8_alnum(pTHX_ const U8 *p)
1467 PERL_ARGS_ASSERT_IS_UTF8_ALNUM;
1469 /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
1470 * descendant of isalnum(3), in other words, it doesn't
1471 * contain the '_'. --jhi */
1472 return isWORDCHAR_utf8(p);
1476 Perl_is_utf8_alnumc(pTHX_ const U8 *p)
1478 PERL_ARGS_ASSERT_IS_UTF8_ALNUMC;
1480 return isALPHANUMERIC_utf8(p);
1484 Perl_is_utf8_alpha(pTHX_ const U8 *p)
1486 PERL_ARGS_ASSERT_IS_UTF8_ALPHA;
1488 return isALPHA_utf8(p);
1492 Perl_is_utf8_ascii(pTHX_ const U8 *p)
1494 PERL_ARGS_ASSERT_IS_UTF8_ASCII;
1495 PERL_UNUSED_CONTEXT;
1497 return isASCII_utf8(p);
1501 Perl_is_utf8_blank(pTHX_ const U8 *p)
1503 PERL_ARGS_ASSERT_IS_UTF8_BLANK;
1504 PERL_UNUSED_CONTEXT;
1506 return isBLANK_utf8(p);
1510 Perl_is_utf8_space(pTHX_ const U8 *p)
1512 PERL_ARGS_ASSERT_IS_UTF8_SPACE;
1513 PERL_UNUSED_CONTEXT;
1515 return isSPACE_utf8(p);
1519 Perl_is_utf8_perl_space(pTHX_ const U8 *p)
1521 PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE;
1522 PERL_UNUSED_CONTEXT;
1524 /* Only true if is an ASCII space-like character, and ASCII is invariant
1525 * under utf8, so can just use the macro */
1526 return isSPACE_A(*p);
1530 Perl_is_utf8_perl_word(pTHX_ const U8 *p)
1532 PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD;
1533 PERL_UNUSED_CONTEXT;
1535 /* Only true if is an ASCII word character, and ASCII is invariant
1536 * under utf8, so can just use the macro */
1537 return isWORDCHAR_A(*p);
1541 Perl_is_utf8_digit(pTHX_ const U8 *p)
1543 PERL_ARGS_ASSERT_IS_UTF8_DIGIT;
1545 return isDIGIT_utf8(p);
1549 Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
1551 PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT;
1552 PERL_UNUSED_CONTEXT;
1554 /* Only true if is an ASCII digit character, and ASCII is invariant
1555 * under utf8, so can just use the macro */
1556 return isDIGIT_A(*p);
1560 Perl_is_utf8_upper(pTHX_ const U8 *p)
1562 PERL_ARGS_ASSERT_IS_UTF8_UPPER;
1564 return isUPPER_utf8(p);
1568 Perl_is_utf8_lower(pTHX_ const U8 *p)
1570 PERL_ARGS_ASSERT_IS_UTF8_LOWER;
1572 return isLOWER_utf8(p);
1576 Perl_is_utf8_cntrl(pTHX_ const U8 *p)
1578 PERL_ARGS_ASSERT_IS_UTF8_CNTRL;
1579 PERL_UNUSED_CONTEXT;
1581 return isCNTRL_utf8(p);
1585 Perl_is_utf8_graph(pTHX_ const U8 *p)
1587 PERL_ARGS_ASSERT_IS_UTF8_GRAPH;
1589 return isGRAPH_utf8(p);
1593 Perl_is_utf8_print(pTHX_ const U8 *p)
1595 PERL_ARGS_ASSERT_IS_UTF8_PRINT;
1597 return isPRINT_utf8(p);
1601 Perl_is_utf8_punct(pTHX_ const U8 *p)
1603 PERL_ARGS_ASSERT_IS_UTF8_PUNCT;
1605 return isPUNCT_utf8(p);
1609 Perl_is_utf8_xdigit(pTHX_ const U8 *p)
1611 PERL_ARGS_ASSERT_IS_UTF8_XDIGIT;
1612 PERL_UNUSED_CONTEXT;
1614 return isXDIGIT_utf8(p);
1618 Perl_is_utf8_mark(pTHX_ const U8 *p)
1620 PERL_ARGS_ASSERT_IS_UTF8_MARK;
1622 return _is_utf8_mark(p);
1626 =for apidoc is_utf8_char
1628 Tests if some arbitrary number of bytes begins in a valid UTF-8
1629 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1630 character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1631 character will be returned if it is valid, otherwise 0.
1633 This function is deprecated due to the possibility that malformed input could
1634 cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1640 Perl_is_utf8_char(const U8 *s)
1642 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1644 /* Assumes we have enough space, which is why this is deprecated */
1645 return isUTF8_CHAR(s, s + UTF8SKIP(s));
1649 =for apidoc is_utf8_char_buf
1651 This is identical to the macro L</isUTF8_CHAR>.
1656 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1659 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1661 return isUTF8_CHAR(buf, buf_end);
1665 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1666 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1667 * non-character code points, and non-Unicode code points are allowed */
1670 Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1672 PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1674 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1678 =for apidoc utf8_to_uvchr
1680 Returns the native code point of the first character in the string C<s>
1681 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1682 length, in bytes, of that character.
1684 Some, but not all, UTF-8 malformations are detected, and in fact, some
1685 malformed input could cause reading beyond the end of the input buffer, which
1686 is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
1688 If C<s> points to one of the detected malformations, and UTF8 warnings are
1689 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1690 C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
1691 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1692 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1693 next possible position in C<s> that could begin a non-malformed character.
1694 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1700 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1702 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1704 return utf8_to_uvchr_buf(s, s + UTF8_MAXBYTES, retlen);
1708 =for apidoc utf8_to_uvuni
1710 Returns the Unicode code point of the first character in the string C<s>
1711 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1712 length, in bytes, of that character.
1714 Some, but not all, UTF-8 malformations are detected, and in fact, some
1715 malformed input could cause reading beyond the end of the input buffer, which
1716 is one reason why this function is deprecated. The other is that only in
1717 extremely limited circumstances should the Unicode versus native code point be
1718 of any interest to you. See L</utf8_to_uvuni_buf> for alternatives.
1720 If C<s> points to one of the detected malformations, and UTF8 warnings are
1721 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1722 NULL) to -1. If those warnings are off, the computed value if well-defined (or
1723 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1724 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1725 next possible position in C<s> that could begin a non-malformed character.
1726 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1732 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1734 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1736 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1740 =for apidoc Am|HV *|pad_compname_type|PADOFFSET po
1742 Looks up the type of the lexical variable at position C<po> in the
1743 currently-compiling pad. If the variable is typed, the stash of the
1744 class to which it is typed is returned. If not, C<NULL> is returned.
1750 Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1752 return PAD_COMPNAME_TYPE(po);
1755 /* return ptr to little string in big string, NULL if not found */
1756 /* The original version of this routine was donated by Corey Satten. */
1759 Perl_instr(const char *big, const char *little)
1761 PERL_ARGS_ASSERT_INSTR;
1763 return instr((char *) big, (char *) little);
1766 #endif /* NO_MATHOMS */
1769 * ex: set ts=8 sts=4 sw=4 et: