This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
put shadowing warnings in their own category
[perl5.git] / mathoms.c
... / ...
CommitLineData
1/* mathoms.c
2 *
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4 * 2011, 2012 by Larry Wall and others
5 *
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.
8 *
9 */
10
11/*
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.
16 *
17 * [p.5 of _The Lord of the Rings_: "Prologue"]
18 */
19
20
21
22/*
23 * This file contains mathoms, various binary artifacts from previous
24 * versions of Perl which we cannot completely remove from the core
25 * code. There are two reasons functions should be here:
26 *
27 * 1) A function has been been replaced by a macro within a minor release,
28 * so XS modules compiled against an older release will expect to
29 * still be able to link against the function
30 * 2) A function Perl_foo(...) with #define foo Perl_foo(aTHX_ ...)
31 * has been replaced by a macro, e.g. #define foo(...) foo_flags(...,0)
32 * but XS code may still explicitly use the long form, i.e.
33 * Perl_foo(aTHX_ ...)
34 *
35 * NOTE: ALL FUNCTIONS IN THIS FILE should have an entry with the 'b' flag in
36 * embed.fnc.
37 *
38 * To move a function to this file, simply cut and paste it here, and change
39 * its embed.fnc entry to additionally have the 'b' flag. If, for some reason
40 * a function you'd like to be treated as mathoms can't be moved from its
41 * current place, simply enclose it between
42 *
43 * #ifndef NO_MATHOMS
44 * ...
45 * #endif
46 *
47 * and add the 'b' flag in embed.fnc.
48 *
49 * The compilation of this file can be suppressed; see INSTALL
50 *
51 * Some blurb for perlapi.pod:
52
53=head1 Obsolete backwards compatibility functions
54
55Some of these are also deprecated. You can exclude these from
56your compiled Perl by adding this option to Configure:
57C<-Accflags='-DNO_MATHOMS'>
58
59=cut
60
61 */
62
63
64#include "EXTERN.h"
65#define PERL_IN_MATHOMS_C
66#include "perl.h"
67
68#ifdef NO_MATHOMS
69/* ..." warning: ISO C forbids an empty source file"
70 So make sure we have something in here by processing the headers anyway.
71 */
72#else
73
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
83/*
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<L</SvROK_off>>.
90
91=cut
92*/
93
94void
95Perl_sv_unref(pTHX_ SV *sv)
96{
97 PERL_ARGS_ASSERT_SV_UNREF;
98
99 sv_unref_flags(sv, 0);
100}
101
102/*
103=for apidoc sv_taint
104
105Taint an SV. Use C<SvTAINTED_on> instead.
106
107=cut
108*/
109
110void
111Perl_sv_taint(pTHX_ SV *sv)
112{
113 PERL_ARGS_ASSERT_SV_TAINT;
114
115 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
116}
117
118/* sv_2iv() is now a macro using Perl_sv_2iv_flags();
119 * this function provided for binary compatibility only
120 */
121
122IV
123Perl_sv_2iv(pTHX_ SV *sv)
124{
125 PERL_ARGS_ASSERT_SV_2IV;
126
127 return sv_2iv_flags(sv, SV_GMAGIC);
128}
129
130/* sv_2uv() is now a macro using Perl_sv_2uv_flags();
131 * this function provided for binary compatibility only
132 */
133
134UV
135Perl_sv_2uv(pTHX_ SV *sv)
136{
137 PERL_ARGS_ASSERT_SV_2UV;
138
139 return sv_2uv_flags(sv, SV_GMAGIC);
140}
141
142/* sv_2nv() is now a macro using Perl_sv_2nv_flags();
143 * this function provided for binary compatibility only
144 */
145
146NV
147Perl_sv_2nv(pTHX_ SV *sv)
148{
149 return sv_2nv_flags(sv, SV_GMAGIC);
150}
151
152
153/* sv_2pv() is now a macro using Perl_sv_2pv_flags();
154 * this function provided for binary compatibility only
155 */
156
157char *
158Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
159{
160 PERL_ARGS_ASSERT_SV_2PV;
161
162 return sv_2pv_flags(sv, lp, SV_GMAGIC);
163}
164
165/*
166=for apidoc sv_2pv_nolen
167
168Like C<sv_2pv()>, but doesn't return the length too. You should usually
169use the macro wrapper C<SvPV_nolen(sv)> instead.
170
171=cut
172*/
173
174char *
175Perl_sv_2pv_nolen(pTHX_ SV *sv)
176{
177 PERL_ARGS_ASSERT_SV_2PV_NOLEN;
178 return sv_2pv(sv, NULL);
179}
180
181/*
182=for apidoc sv_2pvbyte_nolen
183
184Return a pointer to the byte-encoded representation of the SV.
185May cause the SV to be downgraded from UTF-8 as a side-effect.
186
187Usually accessed via the C<SvPVbyte_nolen> macro.
188
189=cut
190*/
191
192char *
193Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
194{
195 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
196
197 return sv_2pvbyte(sv, NULL);
198}
199
200/*
201=for apidoc sv_2pvutf8_nolen
202
203Return a pointer to the UTF-8-encoded representation of the SV.
204May cause the SV to be upgraded to UTF-8 as a side-effect.
205
206Usually accessed via the C<SvPVutf8_nolen> macro.
207
208=cut
209*/
210
211char *
212Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
213{
214 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
215
216 return sv_2pvutf8(sv, NULL);
217}
218
219/*
220=for apidoc sv_force_normal
221
222Undo various types of fakery on an SV: if the PV is a shared string, make
223a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
224an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
225
226=cut
227*/
228
229void
230Perl_sv_force_normal(pTHX_ SV *sv)
231{
232 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
233
234 sv_force_normal_flags(sv, 0);
235}
236
237/* sv_setsv() is now a macro using Perl_sv_setsv_flags();
238 * this function provided for binary compatibility only
239 */
240
241void
242Perl_sv_setsv(pTHX_ SV *dstr, SV *sstr)
243{
244 PERL_ARGS_ASSERT_SV_SETSV;
245
246 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
247}
248
249/* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
250 * this function provided for binary compatibility only
251 */
252
253void
254Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
255{
256 PERL_ARGS_ASSERT_SV_CATPVN;
257
258 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
259}
260
261/*
262=for apidoc sv_catpvn_mg
263
264Like C<sv_catpvn>, but also handles 'set' magic.
265
266=cut
267*/
268
269void
270Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len)
271{
272 PERL_ARGS_ASSERT_SV_CATPVN_MG;
273
274 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
275}
276
277/* sv_catsv() is now a macro using Perl_sv_catsv_flags();
278 * this function provided for binary compatibility only
279 */
280
281void
282Perl_sv_catsv(pTHX_ SV *dstr, SV *sstr)
283{
284 PERL_ARGS_ASSERT_SV_CATSV;
285
286 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
287}
288
289/*
290=for apidoc sv_catsv_mg
291
292Like C<sv_catsv>, but also handles 'set' magic.
293
294=cut
295*/
296
297void
298Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *ssv)
299{
300 PERL_ARGS_ASSERT_SV_CATSV_MG;
301
302 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
303}
304
305/*
306=for apidoc sv_iv
307
308A private implementation of the C<SvIVx> macro for compilers which can't
309cope with complex macro expressions. Always use the macro instead.
310
311=cut
312*/
313
314IV
315Perl_sv_iv(pTHX_ SV *sv)
316{
317 PERL_ARGS_ASSERT_SV_IV;
318
319 if (SvIOK(sv)) {
320 if (SvIsUV(sv))
321 return (IV)SvUVX(sv);
322 return SvIVX(sv);
323 }
324 return sv_2iv(sv);
325}
326
327/*
328=for apidoc sv_uv
329
330A private implementation of the C<SvUVx> macro for compilers which can't
331cope with complex macro expressions. Always use the macro instead.
332
333=cut
334*/
335
336UV
337Perl_sv_uv(pTHX_ SV *sv)
338{
339 PERL_ARGS_ASSERT_SV_UV;
340
341 if (SvIOK(sv)) {
342 if (SvIsUV(sv))
343 return SvUVX(sv);
344 return (UV)SvIVX(sv);
345 }
346 return sv_2uv(sv);
347}
348
349/*
350=for apidoc sv_nv
351
352A private implementation of the C<SvNVx> macro for compilers which can't
353cope with complex macro expressions. Always use the macro instead.
354
355=cut
356*/
357
358NV
359Perl_sv_nv(pTHX_ SV *sv)
360{
361 PERL_ARGS_ASSERT_SV_NV;
362
363 if (SvNOK(sv))
364 return SvNVX(sv);
365 return sv_2nv(sv);
366}
367
368/*
369=for apidoc sv_pv
370
371Use the C<SvPV_nolen> macro instead
372
373=for apidoc sv_pvn
374
375A private implementation of the C<SvPV> macro for compilers which can't
376cope with complex macro expressions. Always use the macro instead.
377
378=cut
379*/
380
381char *
382Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
383{
384 PERL_ARGS_ASSERT_SV_PVN;
385
386 if (SvPOK(sv)) {
387 *lp = SvCUR(sv);
388 return SvPVX(sv);
389 }
390 return sv_2pv(sv, lp);
391}
392
393
394char *
395Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
396{
397 PERL_ARGS_ASSERT_SV_PVN_NOMG;
398
399 if (SvPOK(sv)) {
400 *lp = SvCUR(sv);
401 return SvPVX(sv);
402 }
403 return sv_2pv_flags(sv, lp, 0);
404}
405
406/* sv_pv() is now a macro using SvPV_nolen();
407 * this function provided for binary compatibility only
408 */
409
410char *
411Perl_sv_pv(pTHX_ SV *sv)
412{
413 PERL_ARGS_ASSERT_SV_PV;
414
415 if (SvPOK(sv))
416 return SvPVX(sv);
417
418 return sv_2pv(sv, NULL);
419}
420
421/* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
422 * this function provided for binary compatibility only
423 */
424
425char *
426Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
427{
428 PERL_ARGS_ASSERT_SV_PVN_FORCE;
429
430 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
431}
432
433/* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
434 * this function provided for binary compatibility only
435 */
436
437char *
438Perl_sv_pvbyte(pTHX_ SV *sv)
439{
440 PERL_ARGS_ASSERT_SV_PVBYTE;
441
442 sv_utf8_downgrade(sv, FALSE);
443 return sv_pv(sv);
444}
445
446/*
447=for apidoc sv_pvbyte
448
449Use C<SvPVbyte_nolen> instead.
450
451=for apidoc sv_pvbyten
452
453A private implementation of the C<SvPVbyte> macro for compilers
454which can't cope with complex macro expressions. Always use the macro
455instead.
456
457=cut
458*/
459
460char *
461Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
462{
463 PERL_ARGS_ASSERT_SV_PVBYTEN;
464
465 sv_utf8_downgrade(sv, FALSE);
466 return sv_pvn(sv,lp);
467}
468
469/* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
470 * this function provided for binary compatibility only
471 */
472
473char *
474Perl_sv_pvutf8(pTHX_ SV *sv)
475{
476 PERL_ARGS_ASSERT_SV_PVUTF8;
477
478 sv_utf8_upgrade(sv);
479 return sv_pv(sv);
480}
481
482/*
483=for apidoc sv_pvutf8
484
485Use the C<SvPVutf8_nolen> macro instead
486
487=for apidoc sv_pvutf8n
488
489A private implementation of the C<SvPVutf8> macro for compilers
490which can't cope with complex macro expressions. Always use the macro
491instead.
492
493=cut
494*/
495
496char *
497Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
498{
499 PERL_ARGS_ASSERT_SV_PVUTF8N;
500
501 sv_utf8_upgrade(sv);
502 return sv_pvn(sv,lp);
503}
504
505/* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
506 * this function provided for binary compatibility only
507 */
508
509STRLEN
510Perl_sv_utf8_upgrade(pTHX_ SV *sv)
511{
512 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
513
514 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
515}
516
517int
518Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
519{
520 int ret = 0;
521 va_list(arglist);
522
523 /* Easier to special case this here than in embed.pl. (Look at what it
524 generates for proto.h) */
525#ifdef PERL_IMPLICIT_CONTEXT
526 PERL_ARGS_ASSERT_FPRINTF_NOCONTEXT;
527#endif
528
529 va_start(arglist, format);
530 ret = PerlIO_vprintf(stream, format, arglist);
531 va_end(arglist);
532 return ret;
533}
534
535int
536Perl_printf_nocontext(const char *format, ...)
537{
538 dTHX;
539 va_list(arglist);
540 int ret = 0;
541
542#ifdef PERL_IMPLICIT_CONTEXT
543 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
544#endif
545
546 va_start(arglist, format);
547 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
548 va_end(arglist);
549 return ret;
550}
551
552#if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
553/*
554 * This hack is to force load of "huge" support from libm.a
555 * So it is in perl for (say) POSIX to use.
556 * Needed for SunOS with Sun's 'acc' for example.
557 */
558NV
559Perl_huge(void)
560{
561# if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
562 return HUGE_VALL;
563# else
564 return HUGE_VAL;
565# endif
566}
567#endif
568
569/* compatibility with versions <= 5.003. */
570void
571Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
572{
573 PERL_ARGS_ASSERT_GV_FULLNAME;
574
575 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
576}
577
578/* compatibility with versions <= 5.003. */
579void
580Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
581{
582 PERL_ARGS_ASSERT_GV_EFULLNAME;
583
584 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
585}
586
587void
588Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
589{
590 PERL_ARGS_ASSERT_GV_FULLNAME3;
591
592 gv_fullname4(sv, gv, prefix, TRUE);
593}
594
595void
596Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
597{
598 PERL_ARGS_ASSERT_GV_EFULLNAME3;
599
600 gv_efullname4(sv, gv, prefix, TRUE);
601}
602
603/*
604=for apidoc gv_fetchmethod
605
606See L</gv_fetchmethod_autoload>.
607
608=cut
609*/
610
611GV *
612Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
613{
614 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
615
616 return gv_fetchmethod_autoload(stash, name, TRUE);
617}
618
619HE *
620Perl_hv_iternext(pTHX_ HV *hv)
621{
622 PERL_ARGS_ASSERT_HV_ITERNEXT;
623
624 return hv_iternext_flags(hv, 0);
625}
626
627void
628Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
629{
630 PERL_ARGS_ASSERT_HV_MAGIC;
631
632 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
633}
634
635bool
636Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
637 int rawmode, int rawperm, PerlIO *supplied_fp)
638{
639 PERL_ARGS_ASSERT_DO_OPEN;
640
641 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
642 supplied_fp, (SV **) NULL, 0);
643}
644
645bool
646Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
647as_raw,
648 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
649 I32 num_svs)
650{
651 PERL_ARGS_ASSERT_DO_OPEN9;
652
653 PERL_UNUSED_ARG(num_svs);
654 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
655 supplied_fp, &svs, 1);
656}
657
658int
659Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
660{
661 /* The old body of this is now in non-LAYER part of perlio.c
662 * This is a stub for any XS code which might have been calling it.
663 */
664 const char *name = ":raw";
665
666 PERL_ARGS_ASSERT_DO_BINMODE;
667
668#ifdef PERLIO_USING_CRLF
669 if (!(mode & O_BINARY))
670 name = ":crlf";
671#endif
672 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
673}
674
675#ifndef OS2
676bool
677Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
678{
679 PERL_ARGS_ASSERT_DO_AEXEC;
680
681 return do_aexec5(really, mark, sp, 0, 0);
682}
683#endif
684
685/* Backwards compatibility. */
686int
687Perl_init_i18nl14n(pTHX_ int printwarn)
688{
689 return init_i18nl10n(printwarn);
690}
691
692bool
693Perl_is_utf8_string_loc(const U8 *s, const STRLEN len, const U8 **ep)
694{
695 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
696
697 return is_utf8_string_loclen(s, len, ep, 0);
698}
699
700/*
701=for apidoc sv_nolocking
702
703Dummy routine which "locks" an SV when there is no locking module present.
704Exists to avoid test for a C<NULL> function pointer and because it could
705potentially warn under some level of strict-ness.
706
707"Superseded" by C<sv_nosharing()>.
708
709=cut
710*/
711
712void
713Perl_sv_nolocking(pTHX_ SV *sv)
714{
715 PERL_UNUSED_CONTEXT;
716 PERL_UNUSED_ARG(sv);
717}
718
719
720/*
721=for apidoc sv_nounlocking
722
723Dummy routine which "unlocks" an SV when there is no locking module present.
724Exists to avoid test for a C<NULL> function pointer and because it could
725potentially warn under some level of strict-ness.
726
727"Superseded" by C<sv_nosharing()>.
728
729=cut
730*/
731
732void
733Perl_sv_nounlocking(pTHX_ SV *sv)
734{
735 PERL_UNUSED_CONTEXT;
736 PERL_UNUSED_ARG(sv);
737}
738
739void
740Perl_save_long(pTHX_ long int *longp)
741{
742 PERL_ARGS_ASSERT_SAVE_LONG;
743
744 SSCHECK(3);
745 SSPUSHLONG(*longp);
746 SSPUSHPTR(longp);
747 SSPUSHUV(SAVEt_LONG);
748}
749
750void
751Perl_save_nogv(pTHX_ GV *gv)
752{
753 PERL_ARGS_ASSERT_SAVE_NOGV;
754
755 SSCHECK(2);
756 SSPUSHPTR(gv);
757 SSPUSHUV(SAVEt_NSTAB);
758}
759
760void
761Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
762{
763 I32 i;
764
765 PERL_ARGS_ASSERT_SAVE_LIST;
766
767 for (i = 1; i <= maxsarg; i++) {
768 SV *sv;
769 SvGETMAGIC(sarg[i]);
770 sv = newSV(0);
771 sv_setsv_nomg(sv,sarg[i]);
772 SSCHECK(3);
773 SSPUSHPTR(sarg[i]); /* remember the pointer */
774 SSPUSHPTR(sv); /* remember the value */
775 SSPUSHUV(SAVEt_ITEM);
776 }
777}
778
779/*
780=for apidoc sv_usepvn_mg
781
782Like C<sv_usepvn>, but also handles 'set' magic.
783
784=cut
785*/
786
787void
788Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
789{
790 PERL_ARGS_ASSERT_SV_USEPVN_MG;
791
792 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
793}
794
795/*
796=for apidoc sv_usepvn
797
798Tells an SV to use C<ptr> to find its string value. Implemented by
799calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
800magic. See C<L</sv_usepvn_flags>>.
801
802=cut
803*/
804
805void
806Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
807{
808 PERL_ARGS_ASSERT_SV_USEPVN;
809
810 sv_usepvn_flags(sv,ptr,len, 0);
811}
812
813/*
814=for apidoc unpack_str
815
816The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
817C<new_s> and C<ocnt> are not used. This call should not be used, use
818C<unpackstring> instead.
819
820=cut */
821
822I32
823Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
824 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
825 U32 flags)
826{
827 PERL_ARGS_ASSERT_UNPACK_STR;
828
829 PERL_UNUSED_ARG(strbeg);
830 PERL_UNUSED_ARG(new_s);
831 PERL_UNUSED_ARG(ocnt);
832
833 return unpackstring(pat, patend, s, strend, flags);
834}
835
836/*
837=for apidoc pack_cat
838
839The engine implementing C<pack()> Perl function. Note: parameters
840C<next_in_list> and C<flags> are not used. This call should not be used; use
841C<packlist> instead.
842
843=cut
844*/
845
846void
847Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
848{
849 PERL_ARGS_ASSERT_PACK_CAT;
850
851 PERL_UNUSED_ARG(next_in_list);
852 PERL_UNUSED_ARG(flags);
853
854 packlist(cat, pat, patend, beglist, endlist);
855}
856
857HE *
858Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
859{
860 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
861}
862
863bool
864Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
865{
866 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
867
868 return cBOOL(hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash));
869}
870
871HE *
872Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
873{
874 PERL_ARGS_ASSERT_HV_FETCH_ENT;
875
876 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
877 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
878}
879
880SV *
881Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
882{
883 PERL_ARGS_ASSERT_HV_DELETE_ENT;
884
885 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
886 hash));
887}
888
889SV**
890Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
891 int flags)
892{
893 return (SV**) hv_common(hv, NULL, key, klen, flags,
894 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
895}
896
897SV**
898Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
899{
900 STRLEN klen;
901 int flags;
902
903 if (klen_i32 < 0) {
904 klen = -klen_i32;
905 flags = HVhek_UTF8;
906 } else {
907 klen = klen_i32;
908 flags = 0;
909 }
910 return (SV **) hv_common(hv, NULL, key, klen, flags,
911 (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
912}
913
914bool
915Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
916{
917 STRLEN klen;
918 int flags;
919
920 PERL_ARGS_ASSERT_HV_EXISTS;
921
922 if (klen_i32 < 0) {
923 klen = -klen_i32;
924 flags = HVhek_UTF8;
925 } else {
926 klen = klen_i32;
927 flags = 0;
928 }
929 return cBOOL(hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0));
930}
931
932SV**
933Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
934{
935 STRLEN klen;
936 int flags;
937
938 PERL_ARGS_ASSERT_HV_FETCH;
939
940 if (klen_i32 < 0) {
941 klen = -klen_i32;
942 flags = HVhek_UTF8;
943 } else {
944 klen = klen_i32;
945 flags = 0;
946 }
947 return (SV **) hv_common(hv, NULL, key, klen, flags,
948 lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
949 : HV_FETCH_JUST_SV, NULL, 0);
950}
951
952SV *
953Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
954{
955 STRLEN klen;
956 int k_flags;
957
958 PERL_ARGS_ASSERT_HV_DELETE;
959
960 if (klen_i32 < 0) {
961 klen = -klen_i32;
962 k_flags = HVhek_UTF8;
963 } else {
964 klen = klen_i32;
965 k_flags = 0;
966 }
967 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
968 NULL, 0));
969}
970
971AV *
972Perl_newAV(pTHX)
973{
974 return MUTABLE_AV(newSV_type(SVt_PVAV));
975 /* sv_upgrade does AvREAL_only():
976 AvALLOC(av) = 0;
977 AvARRAY(av) = NULL;
978 AvMAX(av) = AvFILLp(av) = -1; */
979}
980
981HV *
982Perl_newHV(pTHX)
983{
984 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
985 assert(!SvOK(hv));
986
987 return hv;
988}
989
990void
991Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
992 const char *const little, const STRLEN littlelen)
993{
994 PERL_ARGS_ASSERT_SV_INSERT;
995 sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
996}
997
998void
999Perl_save_freesv(pTHX_ SV *sv)
1000{
1001 save_freesv(sv);
1002}
1003
1004void
1005Perl_save_mortalizesv(pTHX_ SV *sv)
1006{
1007 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1008
1009 save_mortalizesv(sv);
1010}
1011
1012void
1013Perl_save_freeop(pTHX_ OP *o)
1014{
1015 save_freeop(o);
1016}
1017
1018void
1019Perl_save_freepv(pTHX_ char *pv)
1020{
1021 save_freepv(pv);
1022}
1023
1024void
1025Perl_save_op(pTHX)
1026{
1027 save_op();
1028}
1029
1030#ifdef PERL_DONT_CREATE_GVSV
1031GV *
1032Perl_gv_SVadd(pTHX_ GV *gv)
1033{
1034 return gv_SVadd(gv);
1035}
1036#endif
1037
1038GV *
1039Perl_gv_AVadd(pTHX_ GV *gv)
1040{
1041 return gv_AVadd(gv);
1042}
1043
1044GV *
1045Perl_gv_HVadd(pTHX_ GV *gv)
1046{
1047 return gv_HVadd(gv);
1048}
1049
1050GV *
1051Perl_gv_IOadd(pTHX_ GV *gv)
1052{
1053 return gv_IOadd(gv);
1054}
1055
1056IO *
1057Perl_newIO(pTHX)
1058{
1059 return MUTABLE_IO(newSV_type(SVt_PVIO));
1060}
1061
1062I32
1063Perl_my_stat(pTHX)
1064{
1065 return my_stat_flags(SV_GMAGIC);
1066}
1067
1068I32
1069Perl_my_lstat(pTHX)
1070{
1071 return my_lstat_flags(SV_GMAGIC);
1072}
1073
1074I32
1075Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1076{
1077 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1078}
1079
1080#ifdef USE_LOCALE_COLLATE
1081char *
1082Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1083{
1084 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1085}
1086
1087char *
1088Perl_mem_collxfrm(pTHX_ const char *input_string, STRLEN len, STRLEN *xlen)
1089{
1090 /* This function is retained for compatibility in case someone outside core
1091 * is using this (but it is undocumented) */
1092
1093 PERL_ARGS_ASSERT_MEM_COLLXFRM;
1094
1095 return _mem_collxfrm(input_string, len, xlen, FALSE);
1096}
1097
1098#endif
1099
1100bool
1101Perl_sv_2bool(pTHX_ SV *const sv)
1102{
1103 return sv_2bool_flags(sv, SV_GMAGIC);
1104}
1105
1106
1107/*
1108=for apidoc custom_op_name
1109Return the name for a given custom op. This was once used by the C<OP_NAME>
1110macro, but is no longer: it has only been kept for compatibility, and
1111should not be used.
1112
1113=for apidoc custom_op_desc
1114Return the description of a given custom op. This was once used by the
1115C<OP_DESC> macro, but is no longer: it has only been kept for
1116compatibility, and should not be used.
1117
1118=cut
1119*/
1120
1121const char*
1122Perl_custom_op_name(pTHX_ const OP* o)
1123{
1124 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1125 return XopENTRYCUSTOM(o, xop_name);
1126}
1127
1128const char*
1129Perl_custom_op_desc(pTHX_ const OP* o)
1130{
1131 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1132 return XopENTRYCUSTOM(o, xop_desc);
1133}
1134
1135CV *
1136Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1137{
1138 return newATTRSUB(floor, o, proto, NULL, block);
1139}
1140
1141UV
1142Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1143{
1144 PERL_ARGS_ASSERT_TO_UTF8_FOLD;
1145
1146 return toFOLD_utf8(p, ustrp, lenp);
1147}
1148
1149UV
1150Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1151{
1152 PERL_ARGS_ASSERT_TO_UTF8_LOWER;
1153
1154 return toLOWER_utf8(p, ustrp, lenp);
1155}
1156
1157UV
1158Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1159{
1160 PERL_ARGS_ASSERT_TO_UTF8_TITLE;
1161
1162 return toTITLE_utf8(p, ustrp, lenp);
1163}
1164
1165UV
1166Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1167{
1168 PERL_ARGS_ASSERT_TO_UTF8_UPPER;
1169
1170 return toUPPER_utf8(p, ustrp, lenp);
1171}
1172
1173SV *
1174Perl_sv_mortalcopy(pTHX_ SV *const oldstr)
1175{
1176 return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC);
1177}
1178
1179void
1180Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1181{
1182 PERL_ARGS_ASSERT_SV_COPYPV;
1183
1184 sv_copypv_flags(dsv, ssv, SV_GMAGIC);
1185}
1186
1187UV /* Made into a function, so can be deprecated */
1188NATIVE_TO_NEED(const UV enc, const UV ch)
1189{
1190 PERL_UNUSED_ARG(enc);
1191 return ch;
1192}
1193
1194UV /* Made into a function, so can be deprecated */
1195ASCII_TO_NEED(const UV enc, const UV ch)
1196{
1197 PERL_UNUSED_ARG(enc);
1198 return ch;
1199}
1200
1201bool /* Made into a function, so can be deprecated */
1202Perl_isIDFIRST_lazy(pTHX_ const char* p)
1203{
1204 PERL_ARGS_ASSERT_ISIDFIRST_LAZY;
1205
1206 return isIDFIRST_lazy_if(p,1);
1207}
1208
1209bool /* Made into a function, so can be deprecated */
1210Perl_isALNUM_lazy(pTHX_ const char* p)
1211{
1212 PERL_ARGS_ASSERT_ISALNUM_LAZY;
1213
1214 return isALNUM_lazy_if(p,1);
1215}
1216
1217bool
1218Perl_is_uni_alnum(pTHX_ UV c)
1219{
1220 return isWORDCHAR_uni(c);
1221}
1222
1223bool
1224Perl_is_uni_alnumc(pTHX_ UV c)
1225{
1226 return isALNUM_uni(c);
1227}
1228
1229bool
1230Perl_is_uni_alpha(pTHX_ UV c)
1231{
1232 return isALPHA_uni(c);
1233}
1234
1235bool
1236Perl_is_uni_ascii(pTHX_ UV c)
1237{
1238 PERL_UNUSED_CONTEXT;
1239 return isASCII_uni(c);
1240}
1241
1242bool
1243Perl_is_uni_blank(pTHX_ UV c)
1244{
1245 PERL_UNUSED_CONTEXT;
1246 return isBLANK_uni(c);
1247}
1248
1249bool
1250Perl_is_uni_space(pTHX_ UV c)
1251{
1252 PERL_UNUSED_CONTEXT;
1253 return isSPACE_uni(c);
1254}
1255
1256bool
1257Perl_is_uni_digit(pTHX_ UV c)
1258{
1259 PERL_UNUSED_CONTEXT;
1260 return isDIGIT_uni(c);
1261}
1262
1263bool
1264Perl_is_uni_upper(pTHX_ UV c)
1265{
1266 PERL_UNUSED_CONTEXT;
1267 return isUPPER_uni(c);
1268}
1269
1270bool
1271Perl_is_uni_lower(pTHX_ UV c)
1272{
1273 PERL_UNUSED_CONTEXT;
1274 return isLOWER_uni(c);
1275}
1276
1277bool
1278Perl_is_uni_cntrl(pTHX_ UV c)
1279{
1280 PERL_UNUSED_CONTEXT;
1281 return isCNTRL_L1(c);
1282}
1283
1284bool
1285Perl_is_uni_graph(pTHX_ UV c)
1286{
1287 PERL_UNUSED_CONTEXT;
1288 return isGRAPH_uni(c);
1289}
1290
1291bool
1292Perl_is_uni_print(pTHX_ UV c)
1293{
1294 PERL_UNUSED_CONTEXT;
1295 return isPRINT_uni(c);
1296}
1297
1298bool
1299Perl_is_uni_punct(pTHX_ UV c)
1300{
1301 PERL_UNUSED_CONTEXT;
1302 return isPUNCT_uni(c);
1303}
1304
1305bool
1306Perl_is_uni_xdigit(pTHX_ UV c)
1307{
1308 PERL_UNUSED_CONTEXT;
1309 return isXDIGIT_uni(c);
1310}
1311
1312bool
1313Perl_is_uni_alnum_lc(pTHX_ UV c)
1314{
1315 PERL_UNUSED_CONTEXT;
1316 return isWORDCHAR_LC_uvchr(c);
1317}
1318
1319bool
1320Perl_is_uni_alnumc_lc(pTHX_ UV c)
1321{
1322 PERL_UNUSED_CONTEXT;
1323 return isALPHANUMERIC_LC_uvchr(c);
1324}
1325
1326bool
1327Perl_is_uni_idfirst_lc(pTHX_ UV c)
1328{
1329 PERL_UNUSED_CONTEXT;
1330 /* XXX Should probably be something that resolves to the old IDFIRST, but
1331 * this function is deprecated, so not bothering */
1332 return isIDFIRST_LC_uvchr(c);
1333}
1334
1335bool
1336Perl_is_uni_alpha_lc(pTHX_ UV c)
1337{
1338 PERL_UNUSED_CONTEXT;
1339 return isALPHA_LC_uvchr(c);
1340}
1341
1342bool
1343Perl_is_uni_ascii_lc(pTHX_ UV c)
1344{
1345 PERL_UNUSED_CONTEXT;
1346 return isASCII_LC_uvchr(c);
1347}
1348
1349bool
1350Perl_is_uni_blank_lc(pTHX_ UV c)
1351{
1352 PERL_UNUSED_CONTEXT;
1353 return isBLANK_LC_uvchr(c);
1354}
1355
1356bool
1357Perl_is_uni_space_lc(pTHX_ UV c)
1358{
1359 PERL_UNUSED_CONTEXT;
1360 return isSPACE_LC_uvchr(c);
1361}
1362
1363bool
1364Perl_is_uni_digit_lc(pTHX_ UV c)
1365{
1366 return isDIGIT_LC_uvchr(c);
1367}
1368
1369bool
1370Perl_is_uni_idfirst(pTHX_ UV c)
1371{
1372 U8 tmpbuf[UTF8_MAXBYTES+1];
1373 uvchr_to_utf8(tmpbuf, c);
1374 return _is_utf8_idstart(tmpbuf);
1375}
1376
1377bool
1378Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
1379{
1380 PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
1381
1382 return _is_utf8_idstart(p);
1383}
1384
1385bool
1386Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */
1387{
1388 PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST;
1389
1390 return _is_utf8_xidstart(p);
1391}
1392
1393bool
1394Perl_is_utf8_idcont(pTHX_ const U8 *p)
1395{
1396 PERL_ARGS_ASSERT_IS_UTF8_IDCONT;
1397
1398 return _is_utf8_idcont(p);
1399}
1400
1401bool
1402Perl_is_utf8_xidcont(pTHX_ const U8 *p)
1403{
1404 PERL_ARGS_ASSERT_IS_UTF8_XIDCONT;
1405
1406 return _is_utf8_xidcont(p);
1407}
1408
1409bool
1410Perl_is_uni_upper_lc(pTHX_ UV c)
1411{
1412 return isUPPER_LC_uvchr(c);
1413}
1414
1415bool
1416Perl_is_uni_lower_lc(pTHX_ UV c)
1417{
1418 return isLOWER_LC_uvchr(c);
1419}
1420
1421bool
1422Perl_is_uni_cntrl_lc(pTHX_ UV c)
1423{
1424 return isCNTRL_LC_uvchr(c);
1425}
1426
1427bool
1428Perl_is_uni_graph_lc(pTHX_ UV c)
1429{
1430 return isGRAPH_LC_uvchr(c);
1431}
1432
1433bool
1434Perl_is_uni_print_lc(pTHX_ UV c)
1435{
1436 return isPRINT_LC_uvchr(c);
1437}
1438
1439bool
1440Perl_is_uni_punct_lc(pTHX_ UV c)
1441{
1442 return isPUNCT_LC_uvchr(c);
1443}
1444
1445bool
1446Perl_is_uni_xdigit_lc(pTHX_ UV c)
1447{
1448 return isXDIGIT_LC_uvchr(c);
1449}
1450
1451U32
1452Perl_to_uni_upper_lc(pTHX_ U32 c)
1453{
1454 /* XXX returns only the first character -- do not use XXX */
1455 /* XXX no locale support yet */
1456 STRLEN len;
1457 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1458 return (U32)to_uni_upper(c, tmpbuf, &len);
1459}
1460
1461U32
1462Perl_to_uni_title_lc(pTHX_ U32 c)
1463{
1464 /* XXX returns only the first character XXX -- do not use XXX */
1465 /* XXX no locale support yet */
1466 STRLEN len;
1467 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1468 return (U32)to_uni_title(c, tmpbuf, &len);
1469}
1470
1471U32
1472Perl_to_uni_lower_lc(pTHX_ U32 c)
1473{
1474 /* XXX returns only the first character -- do not use XXX */
1475 /* XXX no locale support yet */
1476 STRLEN len;
1477 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1478 return (U32)to_uni_lower(c, tmpbuf, &len);
1479}
1480
1481bool
1482Perl_is_utf8_alnum(pTHX_ const U8 *p)
1483{
1484 PERL_ARGS_ASSERT_IS_UTF8_ALNUM;
1485
1486 /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
1487 * descendant of isalnum(3), in other words, it doesn't
1488 * contain the '_'. --jhi */
1489 return isWORDCHAR_utf8(p);
1490}
1491
1492bool
1493Perl_is_utf8_alnumc(pTHX_ const U8 *p)
1494{
1495 PERL_ARGS_ASSERT_IS_UTF8_ALNUMC;
1496
1497 return isALPHANUMERIC_utf8(p);
1498}
1499
1500bool
1501Perl_is_utf8_alpha(pTHX_ const U8 *p)
1502{
1503 PERL_ARGS_ASSERT_IS_UTF8_ALPHA;
1504
1505 return isALPHA_utf8(p);
1506}
1507
1508bool
1509Perl_is_utf8_ascii(pTHX_ const U8 *p)
1510{
1511 PERL_ARGS_ASSERT_IS_UTF8_ASCII;
1512 PERL_UNUSED_CONTEXT;
1513
1514 return isASCII_utf8(p);
1515}
1516
1517bool
1518Perl_is_utf8_blank(pTHX_ const U8 *p)
1519{
1520 PERL_ARGS_ASSERT_IS_UTF8_BLANK;
1521 PERL_UNUSED_CONTEXT;
1522
1523 return isBLANK_utf8(p);
1524}
1525
1526bool
1527Perl_is_utf8_space(pTHX_ const U8 *p)
1528{
1529 PERL_ARGS_ASSERT_IS_UTF8_SPACE;
1530 PERL_UNUSED_CONTEXT;
1531
1532 return isSPACE_utf8(p);
1533}
1534
1535bool
1536Perl_is_utf8_perl_space(pTHX_ const U8 *p)
1537{
1538 PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE;
1539 PERL_UNUSED_CONTEXT;
1540
1541 /* Only true if is an ASCII space-like character, and ASCII is invariant
1542 * under utf8, so can just use the macro */
1543 return isSPACE_A(*p);
1544}
1545
1546bool
1547Perl_is_utf8_perl_word(pTHX_ const U8 *p)
1548{
1549 PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD;
1550 PERL_UNUSED_CONTEXT;
1551
1552 /* Only true if is an ASCII word character, and ASCII is invariant
1553 * under utf8, so can just use the macro */
1554 return isWORDCHAR_A(*p);
1555}
1556
1557bool
1558Perl_is_utf8_digit(pTHX_ const U8 *p)
1559{
1560 PERL_ARGS_ASSERT_IS_UTF8_DIGIT;
1561
1562 return isDIGIT_utf8(p);
1563}
1564
1565bool
1566Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
1567{
1568 PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT;
1569 PERL_UNUSED_CONTEXT;
1570
1571 /* Only true if is an ASCII digit character, and ASCII is invariant
1572 * under utf8, so can just use the macro */
1573 return isDIGIT_A(*p);
1574}
1575
1576bool
1577Perl_is_utf8_upper(pTHX_ const U8 *p)
1578{
1579 PERL_ARGS_ASSERT_IS_UTF8_UPPER;
1580
1581 return isUPPER_utf8(p);
1582}
1583
1584bool
1585Perl_is_utf8_lower(pTHX_ const U8 *p)
1586{
1587 PERL_ARGS_ASSERT_IS_UTF8_LOWER;
1588
1589 return isLOWER_utf8(p);
1590}
1591
1592bool
1593Perl_is_utf8_cntrl(pTHX_ const U8 *p)
1594{
1595 PERL_ARGS_ASSERT_IS_UTF8_CNTRL;
1596 PERL_UNUSED_CONTEXT;
1597
1598 return isCNTRL_utf8(p);
1599}
1600
1601bool
1602Perl_is_utf8_graph(pTHX_ const U8 *p)
1603{
1604 PERL_ARGS_ASSERT_IS_UTF8_GRAPH;
1605
1606 return isGRAPH_utf8(p);
1607}
1608
1609bool
1610Perl_is_utf8_print(pTHX_ const U8 *p)
1611{
1612 PERL_ARGS_ASSERT_IS_UTF8_PRINT;
1613
1614 return isPRINT_utf8(p);
1615}
1616
1617bool
1618Perl_is_utf8_punct(pTHX_ const U8 *p)
1619{
1620 PERL_ARGS_ASSERT_IS_UTF8_PUNCT;
1621
1622 return isPUNCT_utf8(p);
1623}
1624
1625bool
1626Perl_is_utf8_xdigit(pTHX_ const U8 *p)
1627{
1628 PERL_ARGS_ASSERT_IS_UTF8_XDIGIT;
1629 PERL_UNUSED_CONTEXT;
1630
1631 return isXDIGIT_utf8(p);
1632}
1633
1634bool
1635Perl_is_utf8_mark(pTHX_ const U8 *p)
1636{
1637 PERL_ARGS_ASSERT_IS_UTF8_MARK;
1638
1639 return _is_utf8_mark(p);
1640}
1641
1642/*
1643=for apidoc is_utf8_char
1644
1645Tests if some arbitrary number of bytes begins in a valid UTF-8
1646character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1647character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1648character will be returned if it is valid, otherwise 0.
1649
1650This function is deprecated due to the possibility that malformed input could
1651cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1652instead.
1653
1654=cut */
1655
1656STRLEN
1657Perl_is_utf8_char(const U8 *s)
1658{
1659 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1660
1661 /* Assumes we have enough space, which is why this is deprecated */
1662 return isUTF8_CHAR(s, s + UTF8SKIP(s));
1663}
1664
1665/*
1666=for apidoc is_utf8_char_buf
1667
1668This is identical to the macro L</isUTF8_CHAR>.
1669
1670=cut */
1671
1672STRLEN
1673Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1674{
1675
1676 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1677
1678 return isUTF8_CHAR(buf, buf_end);
1679}
1680
1681/* DEPRECATED!
1682 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1683 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1684 * non-character code points, and non-Unicode code points are allowed */
1685
1686UV
1687Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1688{
1689 PERL_UNUSED_CONTEXT;
1690 PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1691
1692 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1693}
1694
1695/*
1696=for apidoc utf8_to_uvchr
1697
1698Returns the native code point of the first character in the string C<s>
1699which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1700length, in bytes, of that character.
1701
1702Some, but not all, UTF-8 malformations are detected, and in fact, some
1703malformed input could cause reading beyond the end of the input buffer, which
1704is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
1705
1706If C<s> points to one of the detected malformations, and UTF8 warnings are
1707enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1708C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
1709the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1710is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1711next possible position in C<s> that could begin a non-malformed character.
1712See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1713
1714=cut
1715*/
1716
1717UV
1718Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1719{
1720 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1721
1722 return utf8_to_uvchr_buf(s, s + UTF8_MAXBYTES, retlen);
1723}
1724
1725/*
1726=for apidoc utf8_to_uvuni
1727
1728Returns the Unicode code point of the first character in the string C<s>
1729which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1730length, in bytes, of that character.
1731
1732Some, but not all, UTF-8 malformations are detected, and in fact, some
1733malformed input could cause reading beyond the end of the input buffer, which
1734is one reason why this function is deprecated. The other is that only in
1735extremely limited circumstances should the Unicode versus native code point be
1736of any interest to you. See L</utf8_to_uvuni_buf> for alternatives.
1737
1738If C<s> points to one of the detected malformations, and UTF8 warnings are
1739enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1740NULL) to -1. If those warnings are off, the computed value if well-defined (or
1741the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1742is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1743next possible position in C<s> that could begin a non-malformed character.
1744See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1745
1746=cut
1747*/
1748
1749UV
1750Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1751{
1752 PERL_UNUSED_CONTEXT;
1753 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1754
1755 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1756}
1757
1758/*
1759=for apidoc Am|HV *|pad_compname_type|PADOFFSET po
1760
1761Looks up the type of the lexical variable at position C<po> in the
1762currently-compiling pad. If the variable is typed, the stash of the
1763class to which it is typed is returned. If not, C<NULL> is returned.
1764
1765=cut
1766*/
1767
1768HV *
1769Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1770{
1771 return PAD_COMPNAME_TYPE(po);
1772}
1773
1774/* return ptr to little string in big string, NULL if not found */
1775/* The original version of this routine was donated by Corey Satten. */
1776
1777char *
1778Perl_instr(const char *big, const char *little)
1779{
1780 PERL_ARGS_ASSERT_INSTR;
1781
1782 return instr((char *) big, (char *) little);
1783}
1784
1785#endif /* NO_MATHOMS */
1786
1787/*
1788 * ex: set ts=8 sts=4 sw=4 et:
1789 */