Some deprecated warnings were also in the syntax category
[p5sagit/p5-mst-13.2.git] / mathoms.c
CommitLineData
7ee2227d 1/* mathoms.c
2 *
1129b882 3 * Copyright (C) 2005, 2006, 2007, 2008 by Larry Wall and others
7ee2227d 4 *
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.
7 *
8 */
9
10/*
4ac71550 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.
15 *
16 * [p.5 of _The Lord of the Rings_: "Prologue"]
7ee2227d 17 */
18
20fac488 19#ifndef NO_MATHOMS
20
7ee2227d 21/*
22 * This file contains mathoms, various binary artifacts from previous
f2f0f092 23 * versions of Perl. For binary or source compatibility reasons, though,
24 * we cannot completely remove them from the core code.
7ee2227d 25 *
26 * SMP - Oct. 24, 2005
27 *
28 */
29
30#include "EXTERN.h"
31#define PERL_IN_MATHOMS_C
32#include "perl.h"
33
a0c21aa1 34PERL_CALLCONV OP * Perl_ref(pTHX_ OP *o, I32 type);
35PERL_CALLCONV void Perl_sv_unref(pTHX_ SV *sv);
36PERL_CALLCONV void Perl_sv_taint(pTHX_ SV *sv);
37PERL_CALLCONV IV Perl_sv_2iv(pTHX_ register SV *sv);
38PERL_CALLCONV UV Perl_sv_2uv(pTHX_ register SV *sv);
39PERL_CALLCONV char * Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp);
40PERL_CALLCONV char * Perl_sv_2pv_nolen(pTHX_ register SV *sv);
41PERL_CALLCONV char * Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv);
42PERL_CALLCONV char * Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv);
43PERL_CALLCONV void Perl_sv_force_normal(pTHX_ register SV *sv);
44PERL_CALLCONV void Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr);
45PERL_CALLCONV void Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen);
46PERL_CALLCONV void Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len);
47PERL_CALLCONV void Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr);
48PERL_CALLCONV void Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv);
49PERL_CALLCONV char * Perl_sv_pv(pTHX_ SV *sv);
50PERL_CALLCONV char * Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp);
51PERL_CALLCONV char * Perl_sv_pvbyte(pTHX_ SV *sv);
52PERL_CALLCONV char * Perl_sv_pvutf8(pTHX_ SV *sv);
53PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade(pTHX_ register SV *sv);
54PERL_CALLCONV NV Perl_huge(void);
55PERL_CALLCONV void Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix);
56PERL_CALLCONV void Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix);
57PERL_CALLCONV GV * Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name);
58PERL_CALLCONV HE * Perl_hv_iternext(pTHX_ HV *hv);
59PERL_CALLCONV void Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how);
60PERL_CALLCONV bool Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw, int rawmode, int rawperm, PerlIO *supplied_fp);
61PERL_CALLCONV bool Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp);
62PERL_CALLCONV bool Perl_do_exec(pTHX_ const char *cmd);
63PERL_CALLCONV U8 * Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv);
64PERL_CALLCONV bool Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep);
65PERL_CALLCONV void Perl_sv_nolocking(pTHX_ SV *sv);
66PERL_CALLCONV void Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len);
67PERL_CALLCONV void Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len);
68PERL_CALLCONV int Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...);
69PERL_CALLCONV int Perl_printf_nocontext(const char *format, ...);
56d7a086 70PERL_CALLCONV int Perl_magic_setglob(pTHX_ SV* sv, MAGIC* mg);
ac572bf4 71PERL_CALLCONV AV * Perl_newAV(pTHX);
78ac7dd9 72PERL_CALLCONV HV * Perl_newHV(pTHX);
b5445a23 73
7ee2227d 74/* ref() is now a macro using Perl_doref;
75 * this version provided for binary compatibility only.
76 */
77OP *
78Perl_ref(pTHX_ OP *o, I32 type)
79{
80 return doref(o, type, TRUE);
81}
82
aae9cea0 83/*
174c73e3 84=for apidoc sv_unref
85
86Unsets the RV status of the SV, and decrements the reference count of
87whatever was being referenced by the RV. This can almost be thought of
88as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
89being zero. See C<SvROK_off>.
90
91=cut
92*/
93
94void
95Perl_sv_unref(pTHX_ SV *sv)
96{
7918f24d 97 PERL_ARGS_ASSERT_SV_UNREF;
98
174c73e3 99 sv_unref_flags(sv, 0);
100}
101
102/*
aae9cea0 103=for apidoc sv_taint
104
105Taint an SV. Use C<SvTAINTED_on> instead.
106=cut
107*/
108
109void
110Perl_sv_taint(pTHX_ SV *sv)
111{
7918f24d 112 PERL_ARGS_ASSERT_SV_TAINT;
113
a0714e2c 114 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
aae9cea0 115}
116
7ee2227d 117/* sv_2iv() is now a macro using Perl_sv_2iv_flags();
118 * this function provided for binary compatibility only
119 */
120
121IV
122Perl_sv_2iv(pTHX_ register SV *sv)
123{
124 return sv_2iv_flags(sv, SV_GMAGIC);
125}
126
127/* sv_2uv() is now a macro using Perl_sv_2uv_flags();
128 * this function provided for binary compatibility only
129 */
130
131UV
132Perl_sv_2uv(pTHX_ register SV *sv)
133{
134 return sv_2uv_flags(sv, SV_GMAGIC);
135}
136
137/* sv_2pv() is now a macro using Perl_sv_2pv_flags();
138 * this function provided for binary compatibility only
139 */
140
141char *
142Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
143{
144 return sv_2pv_flags(sv, lp, SV_GMAGIC);
145}
146
5abc721d 147/*
cb2f1b7b 148=for apidoc sv_2pv_nolen
149
150Like C<sv_2pv()>, but doesn't return the length too. You should usually
151use the macro wrapper C<SvPV_nolen(sv)> instead.
152=cut
153*/
154
155char *
156Perl_sv_2pv_nolen(pTHX_ register SV *sv)
157{
b5445a23 158 return sv_2pv(sv, NULL);
cb2f1b7b 159}
160
161/*
162=for apidoc sv_2pvbyte_nolen
163
164Return a pointer to the byte-encoded representation of the SV.
165May cause the SV to be downgraded from UTF-8 as a side-effect.
166
167Usually accessed via the C<SvPVbyte_nolen> macro.
168
169=cut
170*/
171
172char *
173Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv)
174{
7918f24d 175 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
176
b5445a23 177 return sv_2pvbyte(sv, NULL);
cb2f1b7b 178}
179
180/*
181=for apidoc sv_2pvutf8_nolen
182
183Return a pointer to the UTF-8-encoded representation of the SV.
184May cause the SV to be upgraded to UTF-8 as a side-effect.
185
186Usually accessed via the C<SvPVutf8_nolen> macro.
187
188=cut
189*/
190
191char *
192Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv)
193{
7918f24d 194 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
195
b5445a23 196 return sv_2pvutf8(sv, NULL);
cb2f1b7b 197}
198
199/*
5abc721d 200=for apidoc sv_force_normal
201
202Undo various types of fakery on an SV: if the PV is a shared string, make
203a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
204an xpvmg. See also C<sv_force_normal_flags>.
205
206=cut
207*/
208
209void
210Perl_sv_force_normal(pTHX_ register SV *sv)
211{
7918f24d 212 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
213
5abc721d 214 sv_force_normal_flags(sv, 0);
215}
7ee2227d 216
217/* sv_setsv() is now a macro using Perl_sv_setsv_flags();
218 * this function provided for binary compatibility only
219 */
220
221void
222Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
223{
7918f24d 224 PERL_ARGS_ASSERT_SV_SETSV;
225
7ee2227d 226 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
227}
228
229/* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
230 * this function provided for binary compatibility only
231 */
232
233void
234Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
235{
7918f24d 236 PERL_ARGS_ASSERT_SV_CATPVN;
237
7ee2227d 238 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
239}
240
b347df82 241/*
242=for apidoc sv_catpvn_mg
243
244Like C<sv_catpvn>, but also handles 'set' magic.
245
246=cut
247*/
248
249void
250Perl_sv_catpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len)
251{
7918f24d 252 PERL_ARGS_ASSERT_SV_CATPVN_MG;
253
b347df82 254 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
255}
256
7ee2227d 257/* sv_catsv() is now a macro using Perl_sv_catsv_flags();
258 * this function provided for binary compatibility only
259 */
260
261void
262Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
263{
7918f24d 264 PERL_ARGS_ASSERT_SV_CATSV;
265
7ee2227d 266 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
267}
268
0feed65a 269/*
b347df82 270=for apidoc sv_catsv_mg
271
272Like C<sv_catsv>, but also handles 'set' magic.
273
274=cut
275*/
276
277void
278Perl_sv_catsv_mg(pTHX_ SV *dsv, register SV *ssv)
279{
7918f24d 280 PERL_ARGS_ASSERT_SV_CATSV_MG;
281
b347df82 282 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
283}
284
285/*
0feed65a 286=for apidoc sv_iv
287
288A private implementation of the C<SvIVx> macro for compilers which can't
289cope with complex macro expressions. Always use the macro instead.
290
291=cut
292*/
293
294IV
295Perl_sv_iv(pTHX_ register SV *sv)
296{
7918f24d 297 PERL_ARGS_ASSERT_SV_IV;
298
0feed65a 299 if (SvIOK(sv)) {
300 if (SvIsUV(sv))
301 return (IV)SvUVX(sv);
302 return SvIVX(sv);
303 }
304 return sv_2iv(sv);
305}
306
307/*
308=for apidoc sv_uv
309
310A private implementation of the C<SvUVx> macro for compilers which can't
311cope with complex macro expressions. Always use the macro instead.
312
313=cut
314*/
315
316UV
317Perl_sv_uv(pTHX_ register SV *sv)
318{
7918f24d 319 PERL_ARGS_ASSERT_SV_UV;
320
0feed65a 321 if (SvIOK(sv)) {
322 if (SvIsUV(sv))
323 return SvUVX(sv);
324 return (UV)SvIVX(sv);
325 }
326 return sv_2uv(sv);
327}
328
329/*
330=for apidoc sv_nv
331
332A private implementation of the C<SvNVx> macro for compilers which can't
333cope with complex macro expressions. Always use the macro instead.
334
335=cut
336*/
337
338NV
339Perl_sv_nv(pTHX_ register SV *sv)
340{
7918f24d 341 PERL_ARGS_ASSERT_SV_NV;
342
0feed65a 343 if (SvNOK(sv))
344 return SvNVX(sv);
345 return sv_2nv(sv);
346}
347
348/*
349=for apidoc sv_pv
350
351Use the C<SvPV_nolen> macro instead
352
353=for apidoc sv_pvn
354
355A private implementation of the C<SvPV> macro for compilers which can't
356cope with complex macro expressions. Always use the macro instead.
357
358=cut
359*/
360
361char *
362Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
363{
7918f24d 364 PERL_ARGS_ASSERT_SV_PVN;
365
0feed65a 366 if (SvPOK(sv)) {
367 *lp = SvCUR(sv);
368 return SvPVX(sv);
369 }
370 return sv_2pv(sv, lp);
371}
372
373
374char *
375Perl_sv_pvn_nomg(pTHX_ register SV *sv, STRLEN *lp)
376{
7918f24d 377 PERL_ARGS_ASSERT_SV_PVN_NOMG;
378
0feed65a 379 if (SvPOK(sv)) {
380 *lp = SvCUR(sv);
381 return SvPVX(sv);
382 }
383 return sv_2pv_flags(sv, lp, 0);
384}
385
7ee2227d 386/* sv_pv() is now a macro using SvPV_nolen();
387 * this function provided for binary compatibility only
388 */
389
390char *
391Perl_sv_pv(pTHX_ SV *sv)
392{
7918f24d 393 PERL_ARGS_ASSERT_SV_PV;
394
7ee2227d 395 if (SvPOK(sv))
396 return SvPVX(sv);
397
b5445a23 398 return sv_2pv(sv, NULL);
7ee2227d 399}
400
401/* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
402 * this function provided for binary compatibility only
403 */
404
405char *
406Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
407{
7918f24d 408 PERL_ARGS_ASSERT_SV_PVN_FORCE;
409
7ee2227d 410 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
411}
412
413/* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
414 * this function provided for binary compatibility only
415 */
416
417char *
418Perl_sv_pvbyte(pTHX_ SV *sv)
419{
7918f24d 420 PERL_ARGS_ASSERT_SV_PVBYTE;
421
b5445a23 422 sv_utf8_downgrade(sv, FALSE);
7ee2227d 423 return sv_pv(sv);
424}
425
0feed65a 426/*
427=for apidoc sv_pvbyte
428
429Use C<SvPVbyte_nolen> instead.
430
431=for apidoc sv_pvbyten
432
433A private implementation of the C<SvPVbyte> macro for compilers
434which can't cope with complex macro expressions. Always use the macro
435instead.
436
437=cut
438*/
439
440char *
441Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
442{
7918f24d 443 PERL_ARGS_ASSERT_SV_PVBYTEN;
444
b5445a23 445 sv_utf8_downgrade(sv, FALSE);
0feed65a 446 return sv_pvn(sv,lp);
447}
448
7ee2227d 449/* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
450 * this function provided for binary compatibility only
451 */
452
453char *
454Perl_sv_pvutf8(pTHX_ SV *sv)
455{
7918f24d 456 PERL_ARGS_ASSERT_SV_PVUTF8;
457
7ee2227d 458 sv_utf8_upgrade(sv);
459 return sv_pv(sv);
460}
461
0feed65a 462/*
463=for apidoc sv_pvutf8
464
465Use the C<SvPVutf8_nolen> macro instead
466
467=for apidoc sv_pvutf8n
468
469A private implementation of the C<SvPVutf8> macro for compilers
470which can't cope with complex macro expressions. Always use the macro
471instead.
472
473=cut
474*/
475
476char *
477Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
478{
7918f24d 479 PERL_ARGS_ASSERT_SV_PVUTF8N;
480
0feed65a 481 sv_utf8_upgrade(sv);
482 return sv_pvn(sv,lp);
483}
484
205c02c2 485/* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
486 * this function provided for binary compatibility only
487 */
488
489STRLEN
490Perl_sv_utf8_upgrade(pTHX_ register SV *sv)
491{
7918f24d 492 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
493
205c02c2 494 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
495}
496
7ee2227d 497int
498Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
499{
500 dTHXs;
501 va_list(arglist);
7918f24d 502
503 /* Easier to special case this here than in embed.pl. (Look at what it
504 generates for proto.h) */
505#ifdef PERL_IMPLICIT_CONTEXT
506 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
507#endif
508
7ee2227d 509 va_start(arglist, format);
510 return PerlIO_vprintf(stream, format, arglist);
511}
512
513int
514Perl_printf_nocontext(const char *format, ...)
515{
516 dTHX;
517 va_list(arglist);
7918f24d 518
519#ifdef PERL_IMPLICIT_CONTEXT
520 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
521#endif
522
7ee2227d 523 va_start(arglist, format);
524 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
525}
526
527#if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
528/*
529 * This hack is to force load of "huge" support from libm.a
530 * So it is in perl for (say) POSIX to use.
531 * Needed for SunOS with Sun's 'acc' for example.
532 */
533NV
534Perl_huge(void)
535{
c773ee7a 536# if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
7ee2227d 537 return HUGE_VALL;
c773ee7a 538# else
7ee2227d 539 return HUGE_VAL;
c773ee7a 540# endif
7ee2227d 541}
542#endif
543
f2f0f092 544/* compatibility with versions <= 5.003. */
545void
546Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
547{
7918f24d 548 PERL_ARGS_ASSERT_GV_FULLNAME;
549
666ea192 550 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
f2f0f092 551}
552
553/* compatibility with versions <= 5.003. */
554void
555Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
556{
7918f24d 557 PERL_ARGS_ASSERT_GV_EFULLNAME;
558
666ea192 559 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
f2f0f092 560}
561
2674aeec 562void
563Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
564{
7918f24d 565 PERL_ARGS_ASSERT_GV_FULLNAME3;
566
2674aeec 567 gv_fullname4(sv, gv, prefix, TRUE);
568}
569
570void
571Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
572{
7918f24d 573 PERL_ARGS_ASSERT_GV_EFULLNAME3;
574
2674aeec 575 gv_efullname4(sv, gv, prefix, TRUE);
576}
577
887986eb 578/*
579=for apidoc gv_fetchmethod
580
581See L<gv_fetchmethod_autoload>.
582
583=cut
584*/
585
586GV *
587Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
588{
7918f24d 589 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
590
887986eb 591 return gv_fetchmethod_autoload(stash, name, TRUE);
592}
593
7a7b9979 594HE *
595Perl_hv_iternext(pTHX_ HV *hv)
596{
7918f24d 597 PERL_ARGS_ASSERT_HV_ITERNEXT;
598
7a7b9979 599 return hv_iternext_flags(hv, 0);
600}
601
bc5cdc23 602void
603Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
604{
7918f24d 605 PERL_ARGS_ASSERT_HV_MAGIC;
606
ad64d0ec 607 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
bc5cdc23 608}
609
b966a812 610AV *
611Perl_av_fake(pTHX_ register I32 size, register SV **strp)
612{
613 register SV** ary;
502c6561 614 register AV * const av = MUTABLE_AV(newSV_type(SVt_PVAV));
7918f24d 615
616 PERL_ARGS_ASSERT_AV_FAKE;
617
b966a812 618 Newx(ary,size+1,SV*);
619 AvALLOC(av) = ary;
620 Copy(strp,ary,size,SV*);
621 AvREIFY_only(av);
9c6bc640 622 AvARRAY(av) = ary;
b966a812 623 AvFILLp(av) = size - 1;
624 AvMAX(av) = size - 1;
625 while (size--) {
626 assert (*strp);
627 SvTEMP_off(*strp);
628 strp++;
629 }
630 return av;
631}
632
34d367cd 633bool
e4dba786 634Perl_do_open(pTHX_ GV *gv, register const char *name, I32 len, int as_raw,
635 int rawmode, int rawperm, PerlIO *supplied_fp)
636{
7918f24d 637 PERL_ARGS_ASSERT_DO_OPEN;
638
e4dba786 639 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
640 supplied_fp, (SV **) NULL, 0);
641}
642
643bool
34d367cd 644Perl_do_open9(pTHX_ GV *gv, register const char *name, I32 len, int
645as_raw,
646 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
647 I32 num_svs)
648{
7918f24d 649 PERL_ARGS_ASSERT_DO_OPEN9;
650
34d367cd 651 PERL_UNUSED_ARG(num_svs);
652 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
653 supplied_fp, &svs, 1);
654}
655
656int
657Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
658{
659 /* The old body of this is now in non-LAYER part of perlio.c
660 * This is a stub for any XS code which might have been calling it.
661 */
662 const char *name = ":raw";
7918f24d 663
664 PERL_ARGS_ASSERT_DO_BINMODE;
665
34d367cd 666#ifdef PERLIO_USING_CRLF
667 if (!(mode & O_BINARY))
668 name = ":crlf";
669#endif
670 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
671}
672
a9f96b3f 673#ifndef OS2
674bool
675Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp)
676{
7918f24d 677 PERL_ARGS_ASSERT_DO_AEXEC;
678
a9f96b3f 679 return do_aexec5(really, mark, sp, 0, 0);
680}
681#endif
682
9555a685 683#ifdef PERL_DEFAULT_DO_EXEC3_IMPLEMENTATION
684bool
685Perl_do_exec(pTHX_ const char *cmd)
686{
7918f24d 687 PERL_ARGS_ASSERT_DO_EXEC;
688
9555a685 689 return do_exec3(cmd,0,0);
690}
691#endif
692
89552e80 693/* Backwards compatibility. */
694int
695Perl_init_i18nl14n(pTHX_ int printwarn)
696{
697 return init_i18nl10n(printwarn);
698}
699
c78ff979 700OP *
701Perl_oopsCV(pTHX_ OP *o)
702{
7918f24d 703 PERL_ARGS_ASSERT_OOPSCV;
704
c78ff979 705 Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
706 /* STUB */
707 PERL_UNUSED_ARG(o);
708 NORETURN_FUNCTION_END;
709}
710
711PP(pp_padany)
712{
713 DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
c78ff979 714}
715
716PP(pp_mapstart)
717{
718 DIE(aTHX_ "panic: mapstart"); /* uses grepstart */
719}
720
0b612f93 721/* These ops all have the same body as pp_null. */
722PP(pp_scalar)
723{
97aff369 724 dVAR;
0b612f93 725 return NORMAL;
726}
727
728PP(pp_regcmaybe)
729{
97aff369 730 dVAR;
0b612f93 731 return NORMAL;
732}
733
734PP(pp_lineseq)
735{
97aff369 736 dVAR;
0b612f93 737 return NORMAL;
738}
739
740PP(pp_scope)
741{
97aff369 742 dVAR;
0b612f93 743 return NORMAL;
744}
745
746/* Ops that are calls to do_kv. */
747PP(pp_values)
748{
749 return do_kv();
750}
751
752PP(pp_keys)
753{
754 return do_kv();
755}
756
757/* Ops that are simply calls to other ops. */
758PP(pp_dump)
759{
760 return pp_goto();
761 /*NOTREACHED*/
762}
763
764PP(pp_dofile)
765{
766 return pp_require();
767}
768
769PP(pp_dbmclose)
770{
771 return pp_untie();
772}
773
774PP(pp_read)
775{
776 return pp_sysread();
777}
778
779PP(pp_recv)
780{
781 return pp_sysread();
782}
783
784PP(pp_seek)
785{
786 return pp_sysseek();
787}
788
789PP(pp_fcntl)
790{
791 return pp_ioctl();
792}
793
794PP(pp_gsockopt)
795{
796 return pp_ssockopt();
797}
798
799PP(pp_getsockname)
800{
801 return pp_getpeername();
802}
803
804PP(pp_lstat)
805{
806 return pp_stat();
807}
808
809PP(pp_fteowned)
810{
811 return pp_ftrowned();
812}
813
814PP(pp_ftbinary)
815{
816 return pp_fttext();
817}
818
819PP(pp_localtime)
820{
821 return pp_gmtime();
822}
823
824PP(pp_shmget)
825{
826 return pp_semget();
827}
828
829PP(pp_shmctl)
830{
831 return pp_semctl();
832}
833
834PP(pp_shmread)
835{
836 return pp_shmwrite();
837}
838
839PP(pp_msgget)
840{
841 return pp_semget();
842}
843
844PP(pp_msgctl)
845{
846 return pp_semctl();
847}
848
849PP(pp_ghbyname)
850{
851 return pp_ghostent();
852}
853
854PP(pp_ghbyaddr)
855{
856 return pp_ghostent();
857}
858
859PP(pp_gnbyname)
860{
861 return pp_gnetent();
862}
863
864PP(pp_gnbyaddr)
865{
866 return pp_gnetent();
867}
868
869PP(pp_gpbyname)
870{
871 return pp_gprotoent();
872}
873
874PP(pp_gpbynumber)
875{
876 return pp_gprotoent();
877}
878
879PP(pp_gsbyname)
880{
881 return pp_gservent();
882}
883
884PP(pp_gsbyport)
885{
886 return pp_gservent();
887}
888
889PP(pp_gpwnam)
890{
891 return pp_gpwent();
892}
893
894PP(pp_gpwuid)
895{
896 return pp_gpwent();
897}
898
899PP(pp_ggrnam)
900{
901 return pp_ggrent();
902}
903
904PP(pp_ggrgid)
905{
906 return pp_ggrent();
907}
908
957b0e1d 909PP(pp_ftsize)
910{
4992681b 911 return pp_ftis();
957b0e1d 912}
913
914PP(pp_ftmtime)
915{
4992681b 916 return pp_ftis();
957b0e1d 917}
918
919PP(pp_ftatime)
920{
4992681b 921 return pp_ftis();
957b0e1d 922}
923
924PP(pp_ftctime)
925{
4992681b 926 return pp_ftis();
957b0e1d 927}
928
f1cb2d48 929PP(pp_ftzero)
930{
931 return pp_ftrowned();
932}
933
934PP(pp_ftsock)
935{
936 return pp_ftrowned();
937}
938
939PP(pp_ftchr)
940{
941 return pp_ftrowned();
942}
943
944PP(pp_ftblk)
945{
946 return pp_ftrowned();
947}
948
949PP(pp_ftfile)
950{
951 return pp_ftrowned();
952}
953
954PP(pp_ftdir)
955{
956 return pp_ftrowned();
957}
958
959PP(pp_ftpipe)
960{
961 return pp_ftrowned();
962}
963
17ad201a 964PP(pp_ftsuid)
965{
966 return pp_ftrowned();
967}
968
969PP(pp_ftsgid)
970{
971 return pp_ftrowned();
972}
973
974PP(pp_ftsvtx)
975{
976 return pp_ftrowned();
977}
978
605b9385 979PP(pp_unlink)
980{
981 return pp_chown();
982}
983
984PP(pp_chmod)
985{
986 return pp_chown();
987}
988
989PP(pp_utime)
990{
991 return pp_chown();
992}
993
994PP(pp_kill)
995{
996 return pp_chown();
997}
998
ce6987d0 999PP(pp_symlink)
1000{
1001 return pp_link();
1002}
1003
af9e49b4 1004PP(pp_ftrwrite)
1005{
1006 return pp_ftrread();
1007}
1008
1009PP(pp_ftrexec)
1010{
1011 return pp_ftrread();
1012}
1013
1014PP(pp_fteread)
1015{
1016 return pp_ftrread();
1017}
1018
1019PP(pp_ftewrite)
1020{
1021 return pp_ftrread();
1022}
1023
1024PP(pp_fteexec)
1025{
1026 return pp_ftrread();
1027}
1028
c9f7ac20 1029PP(pp_msgsnd)
1030{
1031 return pp_shmwrite();
1032}
1033
1034PP(pp_msgrcv)
1035{
1036 return pp_shmwrite();
1037}
1038
64a1bc8e 1039PP(pp_syswrite)
1040{
1041 return pp_send();
1042}
1043
ca563b4e 1044PP(pp_semop)
1045{
1046 return pp_shmwrite();
1047}
1048
25a55bd7 1049PP(pp_dor)
1050{
f6a64177 1051 return pp_defined();
25a55bd7 1052}
1053
c960fc3b 1054PP(pp_andassign)
1055{
1056 return pp_and();
1057}
1058
1059PP(pp_orassign)
1060{
1061 return pp_or();
1062}
1063
1064PP(pp_dorassign)
1065{
1066 return pp_defined();
1067}
1068
12e9c124 1069PP(pp_lcfirst)
1070{
1071 return pp_ucfirst();
1072}
1073
afd9910b 1074PP(pp_slt)
1075{
1076 return pp_sle();
1077}
1078
1079PP(pp_sgt)
1080{
1081 return pp_sle();
1082}
1083
1084PP(pp_sge)
1085{
1086 return pp_sle();
1087}
1088
2723d216 1089PP(pp_rindex)
1090{
1091 return pp_index();
1092}
1093
daa2adfd 1094PP(pp_hex)
1095{
1096 return pp_oct();
1097}
1098
789b4bc9 1099PP(pp_pop)
1100{
1101 return pp_shift();
1102}
1103
71302fe3 1104PP(pp_cos)
1105{
1106 return pp_sin();
1107}
1108
1109PP(pp_exp)
1110{
1111 return pp_sin();
1112}
1113
1114PP(pp_log)
1115{
1116 return pp_sin();
1117}
1118
1119PP(pp_sqrt)
1120{
1121 return pp_sin();
1122}
1123
3658c1f1 1124PP(pp_bit_xor)
1125{
1126 return pp_bit_or();
1127}
1128
17ab7946 1129PP(pp_rv2hv)
1130{
1131 return Perl_pp_rv2av(aTHX);
1132}
1133
038e8d3c 1134U8 *
1135Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
1136{
7918f24d 1137 PERL_ARGS_ASSERT_UVUNI_TO_UTF8;
1138
038e8d3c 1139 return Perl_uvuni_to_utf8_flags(aTHX_ d, uv, 0);
1140}
1141
814fafa7 1142bool
1143Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const U8 **ep)
1144{
7918f24d 1145 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
1146
814fafa7 1147 return is_utf8_string_loclen(s, len, ep, 0);
1148}
1149
7ee2227d 1150/*
d5b2b27b 1151=for apidoc sv_nolocking
1152
1153Dummy routine which "locks" an SV when there is no locking module present.
1154Exists to avoid test for a NULL function pointer and because it could
1155potentially warn under some level of strict-ness.
1156
1157"Superseded" by sv_nosharing().
1158
1159=cut
1160*/
1161
1162void
1163Perl_sv_nolocking(pTHX_ SV *sv)
1164{
96a5add6 1165 PERL_UNUSED_CONTEXT;
d5b2b27b 1166 PERL_UNUSED_ARG(sv);
1167}
1168
1169
1170/*
1171=for apidoc sv_nounlocking
1172
1173Dummy routine which "unlocks" an SV when there is no locking module present.
1174Exists to avoid test for a NULL function pointer and because it could
1175potentially warn under some level of strict-ness.
1176
1177"Superseded" by sv_nosharing().
1178
1179=cut
1180*/
1181
1182void
1183Perl_sv_nounlocking(pTHX_ SV *sv)
1184{
96a5add6 1185 PERL_UNUSED_CONTEXT;
d5b2b27b 1186 PERL_UNUSED_ARG(sv);
1187}
1188
2053acbf 1189void
1190Perl_save_long(pTHX_ long int *longp)
1191{
1192 dVAR;
7918f24d 1193
1194 PERL_ARGS_ASSERT_SAVE_LONG;
1195
2053acbf 1196 SSCHECK(3);
1197 SSPUSHLONG(*longp);
1198 SSPUSHPTR(longp);
1199 SSPUSHINT(SAVEt_LONG);
1200}
1201
1202void
2053acbf 1203Perl_save_iv(pTHX_ IV *ivp)
1204{
1205 dVAR;
7918f24d 1206
1207 PERL_ARGS_ASSERT_SAVE_IV;
1208
2053acbf 1209 SSCHECK(3);
1210 SSPUSHIV(*ivp);
1211 SSPUSHPTR(ivp);
1212 SSPUSHINT(SAVEt_IV);
1213}
1214
1215void
1216Perl_save_nogv(pTHX_ GV *gv)
1217{
1218 dVAR;
7918f24d 1219
1220 PERL_ARGS_ASSERT_SAVE_NOGV;
1221
2053acbf 1222 SSCHECK(2);
1223 SSPUSHPTR(gv);
1224 SSPUSHINT(SAVEt_NSTAB);
1225}
1226
1227void
1228Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
1229{
1230 dVAR;
1231 register I32 i;
1232
7918f24d 1233 PERL_ARGS_ASSERT_SAVE_LIST;
1234
2053acbf 1235 for (i = 1; i <= maxsarg; i++) {
1236 register SV * const sv = newSV(0);
1237 sv_setsv(sv,sarg[i]);
1238 SSCHECK(3);
1239 SSPUSHPTR(sarg[i]); /* remember the pointer */
1240 SSPUSHPTR(sv); /* remember the value */
1241 SSPUSHINT(SAVEt_ITEM);
1242 }
1243}
1244
47518d95 1245/*
1246=for apidoc sv_usepvn_mg
1247
1248Like C<sv_usepvn>, but also handles 'set' magic.
1249
1250=cut
1251*/
1252
1253void
1254Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
1255{
7918f24d 1256 PERL_ARGS_ASSERT_SV_USEPVN_MG;
1257
47518d95 1258 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
1259}
1260
1261/*
1262=for apidoc sv_usepvn
1263
1264Tells an SV to use C<ptr> to find its string value. Implemented by
1265calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
1266magic. See C<sv_usepvn_flags>.
1267
1268=cut
1269*/
1270
1271void
1272Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
1273{
7918f24d 1274 PERL_ARGS_ASSERT_SV_USEPVN;
1275
47518d95 1276 sv_usepvn_flags(sv,ptr,len, 0);
1277}
1278
cbf82dd0 1279void
1280Perl_cv_ckproto(pTHX_ const CV *cv, const GV *gv, const char *p)
1281{
7918f24d 1282 PERL_ARGS_ASSERT_CV_CKPROTO;
1283
cbf82dd0 1284 cv_ckproto_len(cv, gv, p, p ? strlen(p) : 0);
1285}
c03e83bf 1286
1287/*
1288=for apidoc unpack_str
1289
1290The engine implementing unpack() Perl function. Note: parameters strbeg, new_s
1291and ocnt are not used. This call should not be used, use unpackstring instead.
1292
1293=cut */
1294
1295I32
1296Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
1297 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
1298 U32 flags)
1299{
7918f24d 1300 PERL_ARGS_ASSERT_UNPACK_STR;
1301
c03e83bf 1302 PERL_UNUSED_ARG(strbeg);
1303 PERL_UNUSED_ARG(new_s);
1304 PERL_UNUSED_ARG(ocnt);
1305
1306 return unpackstring(pat, patend, s, strend, flags);
1307}
b47163a2 1308
1309/*
1310=for apidoc pack_cat
1311
1312The engine implementing pack() Perl function. Note: parameters next_in_list and
1313flags are not used. This call should not be used; use packlist instead.
1314
1315=cut
1316*/
1317
1318void
1319Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, register SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
1320{
7918f24d 1321 PERL_ARGS_ASSERT_PACK_CAT;
1322
b47163a2 1323 PERL_UNUSED_ARG(next_in_list);
1324 PERL_UNUSED_ARG(flags);
1325
1326 packlist(cat, pat, patend, beglist, endlist);
1327}
4c2df08c 1328
1329HE *
1330Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
1331{
59af68cc 1332 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
4c2df08c 1333}
1334
1335bool
1336Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
1337{
7918f24d 1338 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
1339
4c2df08c 1340 return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
1341 ? TRUE : FALSE;
1342}
1343
1344HE *
1345Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
1346{
7918f24d 1347 PERL_ARGS_ASSERT_HV_FETCH_ENT;
1348
59af68cc 1349 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
4c2df08c 1350 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
1351}
1352
1353SV *
1354Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
1355{
7918f24d 1356 PERL_ARGS_ASSERT_HV_DELETE_ENT;
1357
ad64d0ec 1358 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
1359 hash));
4c2df08c 1360}
1361
a038e571 1362SV**
1363Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
1364 int flags)
1365{
1366 return (SV**) hv_common(hv, NULL, key, klen, flags,
1367 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
1368}
1369
1370SV**
1371Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
1372{
1373 STRLEN klen;
1374 int flags;
1375
1376 if (klen_i32 < 0) {
1377 klen = -klen_i32;
1378 flags = HVhek_UTF8;
1379 } else {
1380 klen = klen_i32;
1381 flags = 0;
1382 }
1383 return (SV **) hv_common(hv, NULL, key, klen, flags,
1384 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
1385}
1386
1387bool
1388Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
1389{
1390 STRLEN klen;
1391 int flags;
1392
7918f24d 1393 PERL_ARGS_ASSERT_HV_EXISTS;
1394
a038e571 1395 if (klen_i32 < 0) {
1396 klen = -klen_i32;
1397 flags = HVhek_UTF8;
1398 } else {
1399 klen = klen_i32;
1400 flags = 0;
1401 }
1402 return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0)
1403 ? TRUE : FALSE;
1404}
1405
1406SV**
1407Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
1408{
1409 STRLEN klen;
1410 int flags;
1411
7918f24d 1412 PERL_ARGS_ASSERT_HV_FETCH;
1413
a038e571 1414 if (klen_i32 < 0) {
1415 klen = -klen_i32;
1416 flags = HVhek_UTF8;
1417 } else {
1418 klen = klen_i32;
1419 flags = 0;
1420 }
1421 return (SV **) hv_common(hv, NULL, key, klen, flags,
1422 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
1423 : HV_FETCH_JUST_SV, NULL, 0);
1424}
1425
1426SV *
1427Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
1428{
1429 STRLEN klen;
1430 int k_flags;
1431
7918f24d 1432 PERL_ARGS_ASSERT_HV_DELETE;
1433
a038e571 1434 if (klen_i32 < 0) {
1435 klen = -klen_i32;
1436 k_flags = HVhek_UTF8;
1437 } else {
1438 klen = klen_i32;
1439 k_flags = 0;
1440 }
ad64d0ec 1441 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
1442 NULL, 0));
a038e571 1443}
1444
56d7a086 1445/* Functions after here were made mathoms post 5.10.0 but pre 5.8.9 */
56d7a086 1446
ac572bf4 1447AV *
1448Perl_newAV(pTHX)
1449{
502c6561 1450 return MUTABLE_AV(newSV_type(SVt_PVAV));
ac572bf4 1451 /* sv_upgrade does AvREAL_only():
1452 AvALLOC(av) = 0;
1453 AvARRAY(av) = NULL;
1454 AvMAX(av) = AvFILLp(av) = -1; */
1455}
1456
78ac7dd9 1457HV *
1458Perl_newHV(pTHX)
1459{
85fbaab2 1460 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
78ac7dd9 1461 assert(!SvOK(hv));
1462
1463 return hv;
1464}
1465
84335ee9 1466void
1467Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
1468 const char *const little, const STRLEN littlelen)
1469{
1470 PERL_ARGS_ASSERT_SV_INSERT;
1471 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
1472}
1473
20fac488 1474#endif /* NO_MATHOMS */
1475
d5b2b27b 1476/*
7ee2227d 1477 * Local variables:
1478 * c-indentation-style: bsd
1479 * c-basic-offset: 4
1480 * indent-tabs-mode: t
1481 * End:
1482 *
1483 * ex: set ts=8 sts=4 sw=4 noet:
1484 */