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