3 * Copyright (C) 2005, 2006, by Larry Wall and others
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "Anything that Hobbits had no immediate use for, but were unwilling to
12 * throw away, they called a mathom. Their dwellings were apt to become
13 * rather crowded with mathoms, and many of the presents that passed from
14 * hand to hand were of that sort."
20 * This file contains mathoms, various binary artifacts from previous
21 * versions of Perl. For binary or source compatibility reasons, though,
22 * we cannot completely remove them from the core code.
29 #define PERL_IN_MATHOMS_C
32 /* ref() is now a macro using Perl_doref;
33 * this version provided for binary compatibility only.
36 Perl_ref(pTHX_ OP *o, I32 type)
38 return doref(o, type, TRUE);
44 Unsets the RV status of the SV, and decrements the reference count of
45 whatever was being referenced by the RV. This can almost be thought of
46 as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
47 being zero. See C<SvROK_off>.
53 Perl_sv_unref(pTHX_ SV *sv)
55 sv_unref_flags(sv, 0);
61 Taint an SV. Use C<SvTAINTED_on> instead.
66 Perl_sv_taint(pTHX_ SV *sv)
68 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
71 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
72 * this function provided for binary compatibility only
76 Perl_sv_2iv(pTHX_ register SV *sv)
78 return sv_2iv_flags(sv, SV_GMAGIC);
81 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
82 * this function provided for binary compatibility only
86 Perl_sv_2uv(pTHX_ register SV *sv)
88 return sv_2uv_flags(sv, SV_GMAGIC);
91 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
92 * this function provided for binary compatibility only
96 Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
98 return sv_2pv_flags(sv, lp, SV_GMAGIC);
102 =for apidoc sv_2pv_nolen
104 Like C<sv_2pv()>, but doesn't return the length too. You should usually
105 use the macro wrapper C<SvPV_nolen(sv)> instead.
110 Perl_sv_2pv_nolen(pTHX_ register SV *sv)
112 return sv_2pv(sv, 0);
116 =for apidoc sv_2pvbyte_nolen
118 Return a pointer to the byte-encoded representation of the SV.
119 May cause the SV to be downgraded from UTF-8 as a side-effect.
121 Usually accessed via the C<SvPVbyte_nolen> macro.
127 Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
129 return sv_2pvbyte(sv, 0);
133 =for apidoc sv_2pvutf8_nolen
135 Return a pointer to the UTF-8-encoded representation of the SV.
136 May cause the SV to be upgraded to UTF-8 as a side-effect.
138 Usually accessed via the C<SvPVutf8_nolen> macro.
144 Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv)
146 return sv_2pvutf8(sv, 0);
150 =for apidoc sv_force_normal
152 Undo various types of fakery on an SV: if the PV is a shared string, make
153 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
154 an xpvmg. See also C<sv_force_normal_flags>.
160 Perl_sv_force_normal(pTHX_ register SV *sv)
162 sv_force_normal_flags(sv, 0);
165 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
166 * this function provided for binary compatibility only
170 Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
172 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
175 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
176 * this function provided for binary compatibility only
180 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
182 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
186 =for apidoc sv_catpvn_mg
188 Like C<sv_catpvn>, but also handles 'set' magic.
194 Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len)
196 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
199 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
200 * this function provided for binary compatibility only
204 Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
206 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
210 =for apidoc sv_catsv_mg
212 Like C<sv_catsv>, but also handles 'set' magic.
218 Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv)
220 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
226 A private implementation of the C<SvIVx> macro for compilers which can't
227 cope with complex macro expressions. Always use the macro instead.
233 Perl_sv_iv(pTHX_ register SV *sv)
237 return (IV)SvUVX(sv);
246 A private implementation of the C<SvUVx> macro for compilers which can't
247 cope with complex macro expressions. Always use the macro instead.
253 Perl_sv_uv(pTHX_ register SV *sv)
258 return (UV)SvIVX(sv);
266 A private implementation of the C<SvNVx> macro for compilers which can't
267 cope with complex macro expressions. Always use the macro instead.
273 Perl_sv_nv(pTHX_ register SV *sv)
283 Use the C<SvPV_nolen> macro instead
287 A private implementation of the C<SvPV> macro for compilers which can't
288 cope with complex macro expressions. Always use the macro instead.
294 Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
300 return sv_2pv(sv, lp);
305 Perl_sv_pvn_nomg(pTHX_ register SV *sv, STRLEN *lp)
311 return sv_2pv_flags(sv, lp, 0);
314 /* sv_pv() is now a macro using SvPV_nolen();
315 * this function provided for binary compatibility only
319 Perl_sv_pv(pTHX_ SV *sv)
324 return sv_2pv(sv, 0);
327 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
328 * this function provided for binary compatibility only
332 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
334 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
337 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
338 * this function provided for binary compatibility only
342 Perl_sv_pvbyte(pTHX_ SV *sv)
344 sv_utf8_downgrade(sv,0);
349 =for apidoc sv_pvbyte
351 Use C<SvPVbyte_nolen> instead.
353 =for apidoc sv_pvbyten
355 A private implementation of the C<SvPVbyte> macro for compilers
356 which can't cope with complex macro expressions. Always use the macro
363 Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
365 sv_utf8_downgrade(sv,0);
366 return sv_pvn(sv,lp);
369 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
370 * this function provided for binary compatibility only
374 Perl_sv_pvutf8(pTHX_ SV *sv)
381 =for apidoc sv_pvutf8
383 Use the C<SvPVutf8_nolen> macro instead
385 =for apidoc sv_pvutf8n
387 A private implementation of the C<SvPVutf8> macro for compilers
388 which can't cope with complex macro expressions. Always use the macro
395 Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
398 return sv_pvn(sv,lp);
401 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
402 * this function provided for binary compatibility only
406 Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
408 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
412 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
416 va_start(arglist, format);
417 return PerlIO_vprintf(stream, format, arglist);
421 Perl_printf_nocontext(const char *format, ...)
425 va_start(arglist, format);
426 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
429 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
431 * This hack is to force load of "huge" support from libm.a
432 * So it is in perl for (say) POSIX to use.
433 * Needed for SunOS with Sun's 'acc' for example.
438 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
445 /* compatibility with versions <= 5.003. */
447 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
449 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
452 /* compatibility with versions <= 5.003. */
454 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
456 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
460 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
462 gv_fullname4(sv, gv, prefix, TRUE);
466 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
468 gv_efullname4(sv, gv, prefix, TRUE);
472 =for apidoc gv_fetchmethod
474 See L<gv_fetchmethod_autoload>.
480 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
482 return gv_fetchmethod_autoload(stash, name, TRUE);
486 Perl_hv_iternext(pTHX_ HV *hv)
488 return hv_iternext_flags(hv, 0);
492 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
494 sv_magic((SV*)hv, (SV*)gv, how, NULL, 0);
497 #if 0 /* use the macro from hv.h instead */
500 Perl_sharepvn(pTHX_ const char *sv, I32 len, U32 hash)
502 return HEK_KEY(share_hek(sv, len, hash));
508 Perl_av_fake(pTHX_ register I32 size, register SV **strp)
511 register AV * const av = (AV*)newSV(0);
513 sv_upgrade((SV *)av, SVt_PVAV);
514 Newx(ary,size+1,SV*);
516 Copy(strp,ary,size,SV*);
518 SvPV_set(av, (char*)ary);
519 AvFILLp(av) = size - 1;
520 AvMAX(av) = size - 1;
530 Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw,
531 int rawmode, int rawperm, PerlIO *supplied_fp)
533 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
534 supplied_fp, (SV **) NULL, 0);
538 Perl_do_open9(pTHX_ GV *gv, register const char *name, I32 len, int
540 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
543 PERL_UNUSED_ARG(num_svs);
544 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
545 supplied_fp, &svs, 1);
549 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
551 /* The old body of this is now in non-LAYER part of perlio.c
552 * This is a stub for any XS code which might have been calling it.
554 const char *name = ":raw";
555 #ifdef PERLIO_USING_CRLF
556 if (!(mode & O_BINARY))
559 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
564 Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp)
566 return do_aexec5(really, mark, sp, 0, 0);
570 #ifdef PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION
572 Perl_do_exec(pTHX_ const char *cmd)
574 return do_exec3(cmd,0,0);
580 Perl_do_pipe(pTHX_ SV *sv, GV *rgv, GV *wgv)
600 if (PerlProc_pipe(fd) < 0)
602 IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"PIPE_OPEN_MODE);
603 IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"PIPE_OPEN_MODE);
604 IoOFP(rstio) = IoIFP(rstio);
605 IoIFP(wstio) = IoOFP(wstio);
606 IoTYPE(rstio) = IoTYPE_RDONLY;
607 IoTYPE(wstio) = IoTYPE_WRONLY;
608 if (!IoIFP(rstio) || !IoOFP(wstio)) {
609 if (IoIFP(rstio)) PerlIO_close(IoIFP(rstio));
610 else PerlLIO_close(fd[0]);
611 if (IoOFP(wstio)) PerlIO_close(IoOFP(wstio));
612 else PerlLIO_close(fd[1]);
616 sv_setsv(sv,&PL_sv_yes);
620 sv_setsv(sv,&PL_sv_undef);
625 /* Backwards compatibility. */
627 Perl_init_i18nl14n(pTHX_ int printwarn)
629 return init_i18nl10n(printwarn);
632 /* XXX kept for BINCOMPAT only */
634 Perl_save_hints(pTHX)
636 Perl_croak(aTHX_ "internal error: obsolete function save_hints() called");
641 Perl_ck_retarget(pTHX_ OP *o)
643 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
650 Perl_oopsCV(pTHX_ OP *o)
652 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
655 NORETURN_FUNCTION_END;
660 DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
665 DIE(aTHX_ "tried to access per-thread data in non-threaded perl");
670 DIE(aTHX_ "panic: mapstart"); /* uses grepstart */
673 /* These ops all have the same body as pp_null. */
698 /* Ops that are calls to do_kv. */
709 /* Ops that are simply calls to other ops. */
748 return pp_ssockopt();
753 return pp_getpeername();
763 return pp_ftrowned();
788 return pp_shmwrite();
803 return pp_ghostent();
808 return pp_ghostent();
823 return pp_gprotoent();
828 return pp_gprotoent();
833 return pp_gservent();
838 return pp_gservent();
883 return pp_ftrowned();
888 return pp_ftrowned();
893 return pp_ftrowned();
898 return pp_ftrowned();
903 return pp_ftrowned();
908 return pp_ftrowned();
913 return pp_ftrowned();
918 return pp_ftrowned();
923 return pp_ftrowned();
928 return pp_ftrowned();
983 return pp_shmwrite();
988 return pp_shmwrite();
998 return pp_shmwrite();
1003 return pp_defined();
1018 return pp_defined();
1023 return pp_ucfirst();
1042 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
1044 return Perl_uvuni_to_utf8_flags(aTHX_ d, uv, 0);
1048 Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep)
1050 return is_utf8_string_loclen(s, len, ep, 0);
1054 =for apidoc sv_nolocking
1056 Dummy routine which "locks" an SV when there is no locking module present.
1057 Exists to avoid test for a NULL function pointer and because it could
1058 potentially warn under some level of strict-ness.
1060 "Superseded" by sv_nosharing().
1066 Perl_sv_nolocking(pTHX_ SV *sv)
1068 PERL_UNUSED_ARG(sv);
1073 =for apidoc sv_nounlocking
1075 Dummy routine which "unlocks" an SV when there is no locking module present.
1076 Exists to avoid test for a NULL function pointer and because it could
1077 potentially warn under some level of strict-ness.
1079 "Superseded" by sv_nosharing().
1085 Perl_sv_nounlocking(pTHX_ SV *sv)
1087 PERL_UNUSED_ARG(sv);
1090 #endif /* NO_MATHOMS */
1094 * c-indentation-style: bsd
1096 * indent-tabs-mode: t
1099 * ex: set ts=8 sts=4 sw=4 noet: