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 /* Not all of these have prototypes elsewhere, so do this to get
59 PERL_CALLCONV OP * Perl_ref(pTHX_ OP *o, I32 type);
60 PERL_CALLCONV void Perl_sv_unref(pTHX_ SV *sv);
61 PERL_CALLCONV void Perl_sv_taint(pTHX_ SV *sv);
62 PERL_CALLCONV IV Perl_sv_2iv(pTHX_ SV *sv);
63 PERL_CALLCONV UV Perl_sv_2uv(pTHX_ SV *sv);
64 PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV *sv);
65 PERL_CALLCONV char * Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp);
66 PERL_CALLCONV char * Perl_sv_2pv_nolen(pTHX_ SV *sv);
67 PERL_CALLCONV char * Perl_sv_2pvbyte_nolen(pTHX_ SV *sv);
68 PERL_CALLCONV char * Perl_sv_2pvutf8_nolen(pTHX_ SV *sv);
69 PERL_CALLCONV void Perl_sv_force_normal(pTHX_ SV *sv);
70 PERL_CALLCONV void Perl_sv_setsv(pTHX_ SV *dstr, SV *sstr);
71 PERL_CALLCONV void Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen);
72 PERL_CALLCONV void Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len);
73 PERL_CALLCONV void Perl_sv_catsv(pTHX_ SV *dstr, SV *sstr);
74 PERL_CALLCONV void Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *ssv);
75 PERL_CALLCONV char * Perl_sv_pv(pTHX_ SV *sv);
76 PERL_CALLCONV char * Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp);
77 PERL_CALLCONV char * Perl_sv_pvbyte(pTHX_ SV *sv);
78 PERL_CALLCONV char * Perl_sv_pvutf8(pTHX_ SV *sv);
79 PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade(pTHX_ SV *sv);
80 PERL_CALLCONV NV Perl_huge(void);
81 PERL_CALLCONV void Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix);
82 PERL_CALLCONV void Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix);
83 PERL_CALLCONV GV * Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name);
84 PERL_CALLCONV HE * Perl_hv_iternext(pTHX_ HV *hv);
85 PERL_CALLCONV void Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how);
86 PERL_CALLCONV bool Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw, int rawmode, int rawperm, PerlIO *supplied_fp);
87 PERL_CALLCONV bool Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp);
88 PERL_CALLCONV U8 * Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv);
89 PERL_CALLCONV bool Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep);
90 PERL_CALLCONV void Perl_sv_nolocking(pTHX_ SV *sv);
91 PERL_CALLCONV void Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len);
92 PERL_CALLCONV void Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len);
93 PERL_CALLCONV int Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...);
94 PERL_CALLCONV int Perl_printf_nocontext(const char *format, ...);
95 PERL_CALLCONV int Perl_magic_setglob(pTHX_ SV* sv, MAGIC* mg);
96 PERL_CALLCONV AV * Perl_newAV(pTHX);
97 PERL_CALLCONV HV * Perl_newHV(pTHX);
98 PERL_CALLCONV IO * Perl_newIO(pTHX);
99 PERL_CALLCONV I32 Perl_my_stat(pTHX);
100 PERL_CALLCONV I32 Perl_my_lstat(pTHX);
101 PERL_CALLCONV I32 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2);
102 PERL_CALLCONV char * Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp);
103 PERL_CALLCONV bool Perl_sv_2bool(pTHX_ SV *const sv);
104 PERL_CALLCONV CV * Perl_newSUB(pTHX_ I32 floor, OP* o, OP* proto, OP* block);
105 PERL_CALLCONV UV Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
106 PERL_CALLCONV UV Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
107 PERL_CALLCONV UV Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
108 PERL_CALLCONV UV Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
109 PERL_CALLCONV SV *Perl_sv_mortalcopy(pTHX_ SV *const oldstr);
111 /* ref() is now a macro using Perl_doref;
112 * this version provided for binary compatibility only.
115 Perl_ref(pTHX_ OP *o, I32 type)
117 return doref(o, type, TRUE);
123 Unsets the RV status of the SV, and decrements the reference count of
124 whatever was being referenced by the RV. This can almost be thought of
125 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
126 being zero. See C<L</SvROK_off>>.
132 Perl_sv_unref(pTHX_ SV *sv)
134 PERL_ARGS_ASSERT_SV_UNREF;
136 sv_unref_flags(sv, 0);
142 Taint an SV. Use C<SvTAINTED_on> instead.
148 Perl_sv_taint(pTHX_ SV *sv)
150 PERL_ARGS_ASSERT_SV_TAINT;
152 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
155 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
156 * this function provided for binary compatibility only
160 Perl_sv_2iv(pTHX_ SV *sv)
162 PERL_ARGS_ASSERT_SV_2IV;
164 return sv_2iv_flags(sv, SV_GMAGIC);
167 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
168 * this function provided for binary compatibility only
172 Perl_sv_2uv(pTHX_ SV *sv)
174 PERL_ARGS_ASSERT_SV_2UV;
176 return sv_2uv_flags(sv, SV_GMAGIC);
179 /* sv_2nv() is now a macro using Perl_sv_2nv_flags();
180 * this function provided for binary compatibility only
184 Perl_sv_2nv(pTHX_ SV *sv)
186 return sv_2nv_flags(sv, SV_GMAGIC);
190 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
191 * this function provided for binary compatibility only
195 Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
197 PERL_ARGS_ASSERT_SV_2PV;
199 return sv_2pv_flags(sv, lp, SV_GMAGIC);
203 =for apidoc sv_2pv_nolen
205 Like C<sv_2pv()>, but doesn't return the length too. You should usually
206 use the macro wrapper C<SvPV_nolen(sv)> instead.
212 Perl_sv_2pv_nolen(pTHX_ SV *sv)
214 PERL_ARGS_ASSERT_SV_2PV_NOLEN;
215 return sv_2pv(sv, NULL);
219 =for apidoc sv_2pvbyte_nolen
221 Return a pointer to the byte-encoded representation of the SV.
222 May cause the SV to be downgraded from UTF-8 as a side-effect.
224 Usually accessed via the C<SvPVbyte_nolen> macro.
230 Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
232 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
234 return sv_2pvbyte(sv, NULL);
238 =for apidoc sv_2pvutf8_nolen
240 Return a pointer to the UTF-8-encoded representation of the SV.
241 May cause the SV to be upgraded to UTF-8 as a side-effect.
243 Usually accessed via the C<SvPVutf8_nolen> macro.
249 Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
251 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
253 return sv_2pvutf8(sv, NULL);
257 =for apidoc sv_force_normal
259 Undo various types of fakery on an SV: if the PV is a shared string, make
260 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
261 an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
267 Perl_sv_force_normal(pTHX_ SV *sv)
269 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
271 sv_force_normal_flags(sv, 0);
274 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
275 * this function provided for binary compatibility only
279 Perl_sv_setsv(pTHX_ SV *dstr, SV *sstr)
281 PERL_ARGS_ASSERT_SV_SETSV;
283 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
286 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
287 * this function provided for binary compatibility only
291 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
293 PERL_ARGS_ASSERT_SV_CATPVN;
295 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
299 =for apidoc sv_catpvn_mg
301 Like C<sv_catpvn>, but also handles 'set' magic.
307 Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len)
309 PERL_ARGS_ASSERT_SV_CATPVN_MG;
311 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
314 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
315 * this function provided for binary compatibility only
319 Perl_sv_catsv(pTHX_ SV *dstr, SV *sstr)
321 PERL_ARGS_ASSERT_SV_CATSV;
323 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
327 =for apidoc sv_catsv_mg
329 Like C<sv_catsv>, but also handles 'set' magic.
335 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *ssv)
337 PERL_ARGS_ASSERT_SV_CATSV_MG;
339 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
345 A private implementation of the C<SvIVx> macro for compilers which can't
346 cope with complex macro expressions. Always use the macro instead.
352 Perl_sv_iv(pTHX_ SV *sv)
354 PERL_ARGS_ASSERT_SV_IV;
358 return (IV)SvUVX(sv);
367 A private implementation of the C<SvUVx> macro for compilers which can't
368 cope with complex macro expressions. Always use the macro instead.
374 Perl_sv_uv(pTHX_ SV *sv)
376 PERL_ARGS_ASSERT_SV_UV;
381 return (UV)SvIVX(sv);
389 A private implementation of the C<SvNVx> macro for compilers which can't
390 cope with complex macro expressions. Always use the macro instead.
396 Perl_sv_nv(pTHX_ SV *sv)
398 PERL_ARGS_ASSERT_SV_NV;
408 Use the C<SvPV_nolen> macro instead
412 A private implementation of the C<SvPV> macro for compilers which can't
413 cope with complex macro expressions. Always use the macro instead.
419 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
421 PERL_ARGS_ASSERT_SV_PVN;
427 return sv_2pv(sv, lp);
432 Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
434 PERL_ARGS_ASSERT_SV_PVN_NOMG;
440 return sv_2pv_flags(sv, lp, 0);
443 /* sv_pv() is now a macro using SvPV_nolen();
444 * this function provided for binary compatibility only
448 Perl_sv_pv(pTHX_ SV *sv)
450 PERL_ARGS_ASSERT_SV_PV;
455 return sv_2pv(sv, NULL);
458 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
459 * this function provided for binary compatibility only
463 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
465 PERL_ARGS_ASSERT_SV_PVN_FORCE;
467 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
470 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
471 * this function provided for binary compatibility only
475 Perl_sv_pvbyte(pTHX_ SV *sv)
477 PERL_ARGS_ASSERT_SV_PVBYTE;
479 sv_utf8_downgrade(sv, FALSE);
484 =for apidoc sv_pvbyte
486 Use C<SvPVbyte_nolen> instead.
488 =for apidoc sv_pvbyten
490 A private implementation of the C<SvPVbyte> macro for compilers
491 which can't cope with complex macro expressions. Always use the macro
498 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
500 PERL_ARGS_ASSERT_SV_PVBYTEN;
502 sv_utf8_downgrade(sv, FALSE);
503 return sv_pvn(sv,lp);
506 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
507 * this function provided for binary compatibility only
511 Perl_sv_pvutf8(pTHX_ SV *sv)
513 PERL_ARGS_ASSERT_SV_PVUTF8;
520 =for apidoc sv_pvutf8
522 Use the C<SvPVutf8_nolen> macro instead
524 =for apidoc sv_pvutf8n
526 A private implementation of the C<SvPVutf8> macro for compilers
527 which can't cope with complex macro expressions. Always use the macro
534 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
536 PERL_ARGS_ASSERT_SV_PVUTF8N;
539 return sv_pvn(sv,lp);
542 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
543 * this function provided for binary compatibility only
547 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
549 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
551 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
555 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
560 /* Easier to special case this here than in embed.pl. (Look at what it
561 generates for proto.h) */
562 #ifdef PERL_IMPLICIT_CONTEXT
563 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
566 va_start(arglist, format);
567 ret = PerlIO_vprintf(stream, format, arglist);
573 Perl_printf_nocontext(const char *format, ...)
579 #ifdef PERL_IMPLICIT_CONTEXT
580 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
583 va_start(arglist, format);
584 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
589 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
591 * This hack is to force load of "huge" support from libm.a
592 * So it is in perl for (say) POSIX to use.
593 * Needed for SunOS with Sun's 'acc' for example.
598 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
606 /* compatibility with versions <= 5.003. */
608 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
610 PERL_ARGS_ASSERT_GV_FULLNAME;
612 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
615 /* compatibility with versions <= 5.003. */
617 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
619 PERL_ARGS_ASSERT_GV_EFULLNAME;
621 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
625 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
627 PERL_ARGS_ASSERT_GV_FULLNAME3;
629 gv_fullname4(sv, gv, prefix, TRUE);
633 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
635 PERL_ARGS_ASSERT_GV_EFULLNAME3;
637 gv_efullname4(sv, gv, prefix, TRUE);
641 =for apidoc gv_fetchmethod
643 See L</gv_fetchmethod_autoload>.
649 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
651 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
653 return gv_fetchmethod_autoload(stash, name, TRUE);
657 Perl_hv_iternext(pTHX_ HV *hv)
659 PERL_ARGS_ASSERT_HV_ITERNEXT;
661 return hv_iternext_flags(hv, 0);
665 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
667 PERL_ARGS_ASSERT_HV_MAGIC;
669 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
673 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
674 int rawmode, int rawperm, PerlIO *supplied_fp)
676 PERL_ARGS_ASSERT_DO_OPEN;
678 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
679 supplied_fp, (SV **) NULL, 0);
683 Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
685 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
688 PERL_ARGS_ASSERT_DO_OPEN9;
690 PERL_UNUSED_ARG(num_svs);
691 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
692 supplied_fp, &svs, 1);
696 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
698 /* The old body of this is now in non-LAYER part of perlio.c
699 * This is a stub for any XS code which might have been calling it.
701 const char *name = ":raw";
703 PERL_ARGS_ASSERT_DO_BINMODE;
705 #ifdef PERLIO_USING_CRLF
706 if (!(mode & O_BINARY))
709 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
714 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
716 PERL_ARGS_ASSERT_DO_AEXEC;
718 return do_aexec5(really, mark, sp, 0, 0);
722 /* Backwards compatibility. */
724 Perl_init_i18nl14n(pTHX_ int printwarn)
726 return init_i18nl10n(printwarn);
730 Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep)
732 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
735 return is_utf8_string_loclen(s, len, ep, 0);
739 =for apidoc sv_nolocking
741 Dummy routine which "locks" an SV when there is no locking module present.
742 Exists to avoid test for a C<NULL> function pointer and because it could
743 potentially warn under some level of strict-ness.
745 "Superseded" by C<sv_nosharing()>.
751 Perl_sv_nolocking(pTHX_ SV *sv)
759 =for apidoc sv_nounlocking
761 Dummy routine which "unlocks" an SV when there is no locking module present.
762 Exists to avoid test for a C<NULL> function pointer and because it could
763 potentially warn under some level of strict-ness.
765 "Superseded" by C<sv_nosharing()>.
771 Perl_sv_nounlocking(pTHX_ SV *sv)
778 Perl_save_long(pTHX_ long int *longp)
780 PERL_ARGS_ASSERT_SAVE_LONG;
785 SSPUSHUV(SAVEt_LONG);
789 Perl_save_iv(pTHX_ IV *ivp)
791 PERL_ARGS_ASSERT_SAVE_IV;
800 Perl_save_nogv(pTHX_ GV *gv)
802 PERL_ARGS_ASSERT_SAVE_NOGV;
806 SSPUSHUV(SAVEt_NSTAB);
810 Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
814 PERL_ARGS_ASSERT_SAVE_LIST;
816 for (i = 1; i <= maxsarg; i++) {
820 sv_setsv_nomg(sv,sarg[i]);
822 SSPUSHPTR(sarg[i]); /* remember the pointer */
823 SSPUSHPTR(sv); /* remember the value */
824 SSPUSHUV(SAVEt_ITEM);
829 =for apidoc sv_usepvn_mg
831 Like C<sv_usepvn>, but also handles 'set' magic.
837 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
839 PERL_ARGS_ASSERT_SV_USEPVN_MG;
841 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
845 =for apidoc sv_usepvn
847 Tells an SV to use C<ptr> to find its string value. Implemented by
848 calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
849 magic. See C<L</sv_usepvn_flags>>.
855 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
857 PERL_ARGS_ASSERT_SV_USEPVN;
859 sv_usepvn_flags(sv,ptr,len, 0);
863 =for apidoc unpack_str
865 The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
866 C<new_s> and C<ocnt> are not used. This call should not be used, use
867 C<unpackstring> instead.
872 Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
873 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
876 PERL_ARGS_ASSERT_UNPACK_STR;
878 PERL_UNUSED_ARG(strbeg);
879 PERL_UNUSED_ARG(new_s);
880 PERL_UNUSED_ARG(ocnt);
882 return unpackstring(pat, patend, s, strend, flags);
888 The engine implementing C<pack()> Perl function. Note: parameters
889 C<next_in_list> and C<flags> are not used. This call should not be used; use
896 Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
898 PERL_ARGS_ASSERT_PACK_CAT;
900 PERL_UNUSED_ARG(next_in_list);
901 PERL_UNUSED_ARG(flags);
903 packlist(cat, pat, patend, beglist, endlist);
907 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
909 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
913 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
915 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
917 return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
922 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
924 PERL_ARGS_ASSERT_HV_FETCH_ENT;
926 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
927 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
931 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
933 PERL_ARGS_ASSERT_HV_DELETE_ENT;
935 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
940 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
943 return (SV**) hv_common(hv, NULL, key, klen, flags,
944 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
948 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
960 return (SV **) hv_common(hv, NULL, key, klen, flags,
961 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
965 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
970 PERL_ARGS_ASSERT_HV_EXISTS;
979 return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0)
984 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
989 PERL_ARGS_ASSERT_HV_FETCH;
998 return (SV **) hv_common(hv, NULL, key, klen, flags,
999 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
1000 : HV_FETCH_JUST_SV, NULL, 0);
1004 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
1009 PERL_ARGS_ASSERT_HV_DELETE;
1013 k_flags = HVhek_UTF8;
1018 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
1025 return MUTABLE_AV(newSV_type(SVt_PVAV));
1026 /* sv_upgrade does AvREAL_only():
1029 AvMAX(av) = AvFILLp(av) = -1; */
1035 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
1042 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
1043 const char *const little, const STRLEN littlelen)
1045 PERL_ARGS_ASSERT_SV_INSERT;
1046 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
1050 Perl_save_freesv(pTHX_ SV *sv)
1056 Perl_save_mortalizesv(pTHX_ SV *sv)
1058 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1060 save_mortalizesv(sv);
1064 Perl_save_freeop(pTHX_ OP *o)
1070 Perl_save_freepv(pTHX_ char *pv)
1081 #ifdef PERL_DONT_CREATE_GVSV
1083 Perl_gv_SVadd(pTHX_ GV *gv)
1085 return gv_SVadd(gv);
1090 Perl_gv_AVadd(pTHX_ GV *gv)
1092 return gv_AVadd(gv);
1096 Perl_gv_HVadd(pTHX_ GV *gv)
1098 return gv_HVadd(gv);
1102 Perl_gv_IOadd(pTHX_ GV *gv)
1104 return gv_IOadd(gv);
1110 return MUTABLE_IO(newSV_type(SVt_PVIO));
1116 return my_stat_flags(SV_GMAGIC);
1122 return my_lstat_flags(SV_GMAGIC);
1126 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1128 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1131 #ifdef USE_LOCALE_COLLATE
1133 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1135 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1140 Perl_sv_2bool(pTHX_ SV *const sv)
1142 return sv_2bool_flags(sv, SV_GMAGIC);
1147 =for apidoc custom_op_name
1148 Return the name for a given custom op. This was once used by the C<OP_NAME>
1149 macro, but is no longer: it has only been kept for compatibility, and
1152 =for apidoc custom_op_desc
1153 Return the description of a given custom op. This was once used by the
1154 C<OP_DESC> macro, but is no longer: it has only been kept for
1155 compatibility, and should not be used.
1161 Perl_custom_op_name(pTHX_ const OP* o)
1163 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1164 return XopENTRYCUSTOM(o, xop_name);
1168 Perl_custom_op_desc(pTHX_ const OP* o)
1170 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1171 return XopENTRYCUSTOM(o, xop_desc);
1175 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1177 return newATTRSUB(floor, o, proto, NULL, block);
1181 Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1183 PERL_ARGS_ASSERT_TO_UTF8_FOLD;
1185 return _to_utf8_fold_flags(p, ustrp, lenp, FOLD_FLAGS_FULL);
1189 Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1191 PERL_ARGS_ASSERT_TO_UTF8_LOWER;
1193 return _to_utf8_lower_flags(p, ustrp, lenp, FALSE);
1197 Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1199 PERL_ARGS_ASSERT_TO_UTF8_TITLE;
1201 return _to_utf8_title_flags(p, ustrp, lenp, FALSE);
1205 Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1207 PERL_ARGS_ASSERT_TO_UTF8_UPPER;
1209 return _to_utf8_upper_flags(p, ustrp, lenp, FALSE);
1213 Perl_sv_mortalcopy(pTHX_ SV *const oldstr)
1215 return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC);
1219 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1221 PERL_ARGS_ASSERT_SV_COPYPV;
1223 sv_copypv_flags(dsv, ssv, 0);
1226 UV /* Made into a function, so can be deprecated */
1227 NATIVE_TO_NEED(const UV enc, const UV ch)
1229 PERL_UNUSED_ARG(enc);
1233 UV /* Made into a function, so can be deprecated */
1234 ASCII_TO_NEED(const UV enc, const UV ch)
1236 PERL_UNUSED_ARG(enc);
1240 bool /* Made into a function, so can be deprecated */
1241 Perl_isIDFIRST_lazy(pTHX_ const char* p)
1243 PERL_ARGS_ASSERT_ISIDFIRST_LAZY;
1245 return isIDFIRST_lazy_if(p,1);
1248 bool /* Made into a function, so can be deprecated */
1249 Perl_isALNUM_lazy(pTHX_ const char* p)
1251 PERL_ARGS_ASSERT_ISALNUM_LAZY;
1253 return isALNUM_lazy_if(p,1);
1257 Perl_is_uni_alnum(pTHX_ UV c)
1259 return isWORDCHAR_uni(c);
1263 Perl_is_uni_alnumc(pTHX_ UV c)
1265 return isALNUM_uni(c);
1269 Perl_is_uni_alpha(pTHX_ UV c)
1271 return isALPHA_uni(c);
1275 Perl_is_uni_ascii(pTHX_ UV c)
1277 PERL_UNUSED_CONTEXT;
1278 return isASCII_uni(c);
1282 Perl_is_uni_blank(pTHX_ UV c)
1284 PERL_UNUSED_CONTEXT;
1285 return isBLANK_uni(c);
1289 Perl_is_uni_space(pTHX_ UV c)
1291 PERL_UNUSED_CONTEXT;
1292 return isSPACE_uni(c);
1296 Perl_is_uni_digit(pTHX_ UV c)
1298 PERL_UNUSED_CONTEXT;
1299 return isDIGIT_uni(c);
1303 Perl_is_uni_upper(pTHX_ UV c)
1305 PERL_UNUSED_CONTEXT;
1306 return isUPPER_uni(c);
1310 Perl_is_uni_lower(pTHX_ UV c)
1312 PERL_UNUSED_CONTEXT;
1313 return isLOWER_uni(c);
1317 Perl_is_uni_cntrl(pTHX_ UV c)
1319 PERL_UNUSED_CONTEXT;
1320 return isCNTRL_L1(c);
1324 Perl_is_uni_graph(pTHX_ UV c)
1326 PERL_UNUSED_CONTEXT;
1327 return isGRAPH_uni(c);
1331 Perl_is_uni_print(pTHX_ UV c)
1333 PERL_UNUSED_CONTEXT;
1334 return isPRINT_uni(c);
1338 Perl_is_uni_punct(pTHX_ UV c)
1340 PERL_UNUSED_CONTEXT;
1341 return isPUNCT_uni(c);
1345 Perl_is_uni_xdigit(pTHX_ UV c)
1347 PERL_UNUSED_CONTEXT;
1348 return isXDIGIT_uni(c);
1352 Perl_is_uni_alnum_lc(pTHX_ UV c)
1354 PERL_UNUSED_CONTEXT;
1355 return isWORDCHAR_LC_uvchr(c);
1359 Perl_is_uni_alnumc_lc(pTHX_ UV c)
1361 PERL_UNUSED_CONTEXT;
1362 return isALPHANUMERIC_LC_uvchr(c);
1366 Perl_is_uni_idfirst_lc(pTHX_ UV c)
1368 PERL_UNUSED_CONTEXT;
1369 /* XXX Should probably be something that resolves to the old IDFIRST, but
1370 * this function is deprecated, so not bothering */
1371 return isIDFIRST_LC_uvchr(c);
1375 Perl_is_uni_alpha_lc(pTHX_ UV c)
1377 PERL_UNUSED_CONTEXT;
1378 return isALPHA_LC_uvchr(c);
1382 Perl_is_uni_ascii_lc(pTHX_ UV c)
1384 PERL_UNUSED_CONTEXT;
1385 return isASCII_LC_uvchr(c);
1389 Perl_is_uni_blank_lc(pTHX_ UV c)
1391 PERL_UNUSED_CONTEXT;
1392 return isBLANK_LC_uvchr(c);
1396 Perl_is_uni_space_lc(pTHX_ UV c)
1398 PERL_UNUSED_CONTEXT;
1399 return isSPACE_LC_uvchr(c);
1403 Perl_is_uni_digit_lc(pTHX_ UV c)
1405 return isDIGIT_LC_uvchr(c);
1409 Perl_is_uni_idfirst(pTHX_ UV c)
1411 U8 tmpbuf[UTF8_MAXBYTES+1];
1412 uvchr_to_utf8(tmpbuf, c);
1413 return _is_utf8_idstart(tmpbuf);
1417 Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
1419 PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
1421 return _is_utf8_idstart(p);
1425 Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */
1427 PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST;
1429 return _is_utf8_xidstart(p);
1433 Perl_is_utf8_idcont(pTHX_ const U8 *p)
1435 PERL_ARGS_ASSERT_IS_UTF8_IDCONT;
1437 return _is_utf8_idcont(p);
1441 Perl_is_utf8_xidcont(pTHX_ const U8 *p)
1443 PERL_ARGS_ASSERT_IS_UTF8_XIDCONT;
1445 return _is_utf8_xidcont(p);
1449 Perl_is_uni_upper_lc(pTHX_ UV c)
1451 return isUPPER_LC_uvchr(c);
1455 Perl_is_uni_lower_lc(pTHX_ UV c)
1457 return isLOWER_LC_uvchr(c);
1461 Perl_is_uni_cntrl_lc(pTHX_ UV c)
1463 return isCNTRL_LC_uvchr(c);
1467 Perl_is_uni_graph_lc(pTHX_ UV c)
1469 return isGRAPH_LC_uvchr(c);
1473 Perl_is_uni_print_lc(pTHX_ UV c)
1475 return isPRINT_LC_uvchr(c);
1479 Perl_is_uni_punct_lc(pTHX_ UV c)
1481 return isPUNCT_LC_uvchr(c);
1485 Perl_is_uni_xdigit_lc(pTHX_ UV c)
1487 return isXDIGIT_LC_uvchr(c);
1491 Perl_to_uni_upper_lc(pTHX_ U32 c)
1493 /* XXX returns only the first character -- do not use XXX */
1494 /* XXX no locale support yet */
1496 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1497 return (U32)to_uni_upper(c, tmpbuf, &len);
1501 Perl_to_uni_title_lc(pTHX_ U32 c)
1503 /* XXX returns only the first character XXX -- do not use XXX */
1504 /* XXX no locale support yet */
1506 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1507 return (U32)to_uni_title(c, tmpbuf, &len);
1511 Perl_to_uni_lower_lc(pTHX_ U32 c)
1513 /* XXX returns only the first character -- do not use XXX */
1514 /* XXX no locale support yet */
1516 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1517 return (U32)to_uni_lower(c, tmpbuf, &len);
1521 Perl_is_utf8_alnum(pTHX_ const U8 *p)
1523 PERL_ARGS_ASSERT_IS_UTF8_ALNUM;
1525 /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
1526 * descendant of isalnum(3), in other words, it doesn't
1527 * contain the '_'. --jhi */
1528 return isWORDCHAR_utf8(p);
1532 Perl_is_utf8_alnumc(pTHX_ const U8 *p)
1534 PERL_ARGS_ASSERT_IS_UTF8_ALNUMC;
1536 return isALPHANUMERIC_utf8(p);
1540 Perl_is_utf8_alpha(pTHX_ const U8 *p)
1542 PERL_ARGS_ASSERT_IS_UTF8_ALPHA;
1544 return isALPHA_utf8(p);
1548 Perl_is_utf8_ascii(pTHX_ const U8 *p)
1550 PERL_ARGS_ASSERT_IS_UTF8_ASCII;
1551 PERL_UNUSED_CONTEXT;
1553 return isASCII_utf8(p);
1557 Perl_is_utf8_blank(pTHX_ const U8 *p)
1559 PERL_ARGS_ASSERT_IS_UTF8_BLANK;
1560 PERL_UNUSED_CONTEXT;
1562 return isBLANK_utf8(p);
1566 Perl_is_utf8_space(pTHX_ const U8 *p)
1568 PERL_ARGS_ASSERT_IS_UTF8_SPACE;
1569 PERL_UNUSED_CONTEXT;
1571 return isSPACE_utf8(p);
1575 Perl_is_utf8_perl_space(pTHX_ const U8 *p)
1577 PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE;
1578 PERL_UNUSED_CONTEXT;
1580 /* Only true if is an ASCII space-like character, and ASCII is invariant
1581 * under utf8, so can just use the macro */
1582 return isSPACE_A(*p);
1586 Perl_is_utf8_perl_word(pTHX_ const U8 *p)
1588 PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD;
1589 PERL_UNUSED_CONTEXT;
1591 /* Only true if is an ASCII word character, and ASCII is invariant
1592 * under utf8, so can just use the macro */
1593 return isWORDCHAR_A(*p);
1597 Perl_is_utf8_digit(pTHX_ const U8 *p)
1599 PERL_ARGS_ASSERT_IS_UTF8_DIGIT;
1601 return isDIGIT_utf8(p);
1605 Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
1607 PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT;
1608 PERL_UNUSED_CONTEXT;
1610 /* Only true if is an ASCII digit character, and ASCII is invariant
1611 * under utf8, so can just use the macro */
1612 return isDIGIT_A(*p);
1616 Perl_is_utf8_upper(pTHX_ const U8 *p)
1618 PERL_ARGS_ASSERT_IS_UTF8_UPPER;
1620 return isUPPER_utf8(p);
1624 Perl_is_utf8_lower(pTHX_ const U8 *p)
1626 PERL_ARGS_ASSERT_IS_UTF8_LOWER;
1628 return isLOWER_utf8(p);
1632 Perl_is_utf8_cntrl(pTHX_ const U8 *p)
1634 PERL_ARGS_ASSERT_IS_UTF8_CNTRL;
1635 PERL_UNUSED_CONTEXT;
1637 return isCNTRL_utf8(p);
1641 Perl_is_utf8_graph(pTHX_ const U8 *p)
1643 PERL_ARGS_ASSERT_IS_UTF8_GRAPH;
1645 return isGRAPH_utf8(p);
1649 Perl_is_utf8_print(pTHX_ const U8 *p)
1651 PERL_ARGS_ASSERT_IS_UTF8_PRINT;
1653 return isPRINT_utf8(p);
1657 Perl_is_utf8_punct(pTHX_ const U8 *p)
1659 PERL_ARGS_ASSERT_IS_UTF8_PUNCT;
1661 return isPUNCT_utf8(p);
1665 Perl_is_utf8_xdigit(pTHX_ const U8 *p)
1667 PERL_ARGS_ASSERT_IS_UTF8_XDIGIT;
1668 PERL_UNUSED_CONTEXT;
1670 return isXDIGIT_utf8(p);
1674 Perl_is_utf8_mark(pTHX_ const U8 *p)
1676 PERL_ARGS_ASSERT_IS_UTF8_MARK;
1678 return _is_utf8_mark(p);
1682 =for apidoc is_utf8_char
1684 Tests if some arbitrary number of bytes begins in a valid UTF-8
1685 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1686 character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1687 character will be returned if it is valid, otherwise 0.
1689 This function is deprecated due to the possibility that malformed input could
1690 cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1696 Perl_is_utf8_char(const U8 *s)
1698 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1700 /* Assumes we have enough space, which is why this is deprecated */
1701 return isUTF8_CHAR(s, s + UTF8SKIP(s));
1705 =for apidoc is_utf8_char_buf
1707 This is identical to the macro L</isUTF8_CHAR>.
1712 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1715 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1717 return isUTF8_CHAR(buf, buf_end);
1721 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1722 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1723 * non-character code points, and non-Unicode code points are allowed */
1726 Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1728 PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1730 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1734 =for apidoc utf8_to_uvchr
1736 Returns the native code point of the first character in the string C<s>
1737 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1738 length, in bytes, of that character.
1740 Some, but not all, UTF-8 malformations are detected, and in fact, some
1741 malformed input could cause reading beyond the end of the input buffer, which
1742 is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
1744 If C<s> points to one of the detected malformations, and UTF8 warnings are
1745 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1746 C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
1747 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1748 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1749 next possible position in C<s> that could begin a non-malformed character.
1750 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1756 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1758 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1760 return utf8_to_uvchr_buf(s, s + UTF8_MAXBYTES, retlen);
1764 =for apidoc utf8_to_uvuni
1766 Returns the Unicode code point of the first character in the string C<s>
1767 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1768 length, in bytes, of that character.
1770 Some, but not all, UTF-8 malformations are detected, and in fact, some
1771 malformed input could cause reading beyond the end of the input buffer, which
1772 is one reason why this function is deprecated. The other is that only in
1773 extremely limited circumstances should the Unicode versus native code point be
1774 of any interest to you. See L</utf8_to_uvuni_buf> for alternatives.
1776 If C<s> points to one of the detected malformations, and UTF8 warnings are
1777 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1778 NULL) to -1. If those warnings are off, the computed value if well-defined (or
1779 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1780 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1781 next possible position in C<s> that could begin a non-malformed character.
1782 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1788 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1790 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1792 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1796 =for apidoc Am|HV *|pad_compname_type|PADOFFSET po
1798 Looks up the type of the lexical variable at position C<po> in the
1799 currently-compiling pad. If the variable is typed, the stash of the
1800 class to which it is typed is returned. If not, C<NULL> is returned.
1806 Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1808 return PAD_COMPNAME_TYPE(po);
1814 #endif /* NO_MATHOMS */
1817 * ex: set ts=8 sts=4 sw=4 et: