This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Renée Bäcker will be doing the October release, 5.25.10
[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 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
55 Some of these are also deprecated.  You can exclude these from
56 your compiled Perl by adding this option to Configure:
57 C<-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  */
77 OP *
78 Perl_ref(pTHX_ OP *o, I32 type)
79 {
80     return doref(o, type, TRUE);
81 }
82
83 /*
84 =for apidoc sv_unref
85
86 Unsets the RV status of the SV, and decrements the reference count of
87 whatever was being referenced by the RV.  This can almost be thought of
88 as a reversal of C<newSVrv>.  This is C<sv_unref_flags> with the C<flag>
89 being zero.  See C<L</SvROK_off>>.
90
91 =cut
92 */
93
94 void
95 Perl_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
105 Taint an SV.  Use C<SvTAINTED_on> instead.
106
107 =cut
108 */
109
110 void
111 Perl_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
122 IV
123 Perl_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
134 UV
135 Perl_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
146 NV
147 Perl_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
157 char *
158 Perl_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
168 Like C<sv_2pv()>, but doesn't return the length too.  You should usually
169 use the macro wrapper C<SvPV_nolen(sv)> instead.
170
171 =cut
172 */
173
174 char *
175 Perl_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
184 Return a pointer to the byte-encoded representation of the SV.
185 May cause the SV to be downgraded from UTF-8 as a side-effect.
186
187 Usually accessed via the C<SvPVbyte_nolen> macro.
188
189 =cut
190 */
191
192 char *
193 Perl_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
203 Return a pointer to the UTF-8-encoded representation of the SV.
204 May cause the SV to be upgraded to UTF-8 as a side-effect.
205
206 Usually accessed via the C<SvPVutf8_nolen> macro.
207
208 =cut
209 */
210
211 char *
212 Perl_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
222 Undo various types of fakery on an SV: if the PV is a shared string, make
223 a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
224 an C<xpvmg>.  See also C<L</sv_force_normal_flags>>.
225
226 =cut
227 */
228
229 void
230 Perl_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
241 void
242 Perl_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
253 void
254 Perl_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
264 Like C<sv_catpvn>, but also handles 'set' magic.
265
266 =cut
267 */
268
269 void
270 Perl_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
281 void
282 Perl_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
292 Like C<sv_catsv>, but also handles 'set' magic.
293
294 =cut
295 */
296
297 void
298 Perl_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
308 A private implementation of the C<SvIVx> macro for compilers which can't
309 cope with complex macro expressions.  Always use the macro instead.
310
311 =cut
312 */
313
314 IV
315 Perl_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
330 A private implementation of the C<SvUVx> macro for compilers which can't
331 cope with complex macro expressions.  Always use the macro instead.
332
333 =cut
334 */
335
336 UV
337 Perl_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
352 A private implementation of the C<SvNVx> macro for compilers which can't
353 cope with complex macro expressions.  Always use the macro instead.
354
355 =cut
356 */
357
358 NV
359 Perl_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
371 Use the C<SvPV_nolen> macro instead
372
373 =for apidoc sv_pvn
374
375 A private implementation of the C<SvPV> macro for compilers which can't
376 cope with complex macro expressions.  Always use the macro instead.
377
378 =cut
379 */
380
381 char *
382 Perl_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
394 char *
395 Perl_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
410 char *
411 Perl_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
425 char *
426 Perl_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
437 char *
438 Perl_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
449 Use C<SvPVbyte_nolen> instead.
450
451 =for apidoc sv_pvbyten
452
453 A private implementation of the C<SvPVbyte> macro for compilers
454 which can't cope with complex macro expressions.  Always use the macro
455 instead.
456
457 =cut
458 */
459
460 char *
461 Perl_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
473 char *
474 Perl_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
485 Use the C<SvPVutf8_nolen> macro instead
486
487 =for apidoc sv_pvutf8n
488
489 A private implementation of the C<SvPVutf8> macro for compilers
490 which can't cope with complex macro expressions.  Always use the macro
491 instead.
492
493 =cut
494 */
495
496 char *
497 Perl_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
509 STRLEN
510 Perl_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
517 int
518 Perl_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
535 int
536 Perl_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  */
558 NV
559 Perl_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. */
570 void
571 Perl_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. */
579 void
580 Perl_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
587 void
588 Perl_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
595 void
596 Perl_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
606 See L</gv_fetchmethod_autoload>.
607
608 =cut
609 */
610
611 GV *
612 Perl_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
619 HE *
620 Perl_hv_iternext(pTHX_ HV *hv)
621 {
622     PERL_ARGS_ASSERT_HV_ITERNEXT;
623
624     return hv_iternext_flags(hv, 0);
625 }
626
627 void
628 Perl_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
635 bool
636 Perl_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
645 bool
646 Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
647 as_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
658 int
659 Perl_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
676 bool
677 Perl_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. */
686 int
687 Perl_init_i18nl14n(pTHX_ int printwarn)
688 {
689     return init_i18nl10n(printwarn);
690 }
691
692 bool
693 Perl_is_utf8_string_loc(const U8 *s, 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
703 Dummy routine which "locks" an SV when there is no locking module present.
704 Exists to avoid test for a C<NULL> function pointer and because it could
705 potentially warn under some level of strict-ness.
706
707 "Superseded" by C<sv_nosharing()>.
708
709 =cut
710 */
711
712 void
713 Perl_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
723 Dummy routine which "unlocks" an SV when there is no locking module present.
724 Exists to avoid test for a C<NULL> function pointer and because it could
725 potentially warn under some level of strict-ness.
726
727 "Superseded" by C<sv_nosharing()>.
728
729 =cut
730 */
731
732 void
733 Perl_sv_nounlocking(pTHX_ SV *sv)
734 {
735     PERL_UNUSED_CONTEXT;
736     PERL_UNUSED_ARG(sv);
737 }
738
739 void
740 Perl_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
750 void
751 Perl_save_iv(pTHX_ IV *ivp)
752 {
753     PERL_ARGS_ASSERT_SAVE_IV;
754
755     SSCHECK(3);
756     SSPUSHIV(*ivp);
757     SSPUSHPTR(ivp);
758     SSPUSHUV(SAVEt_IV);
759 }
760
761 void
762 Perl_save_nogv(pTHX_ GV *gv)
763 {
764     PERL_ARGS_ASSERT_SAVE_NOGV;
765
766     SSCHECK(2);
767     SSPUSHPTR(gv);
768     SSPUSHUV(SAVEt_NSTAB);
769 }
770
771 void
772 Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
773 {
774     I32 i;
775
776     PERL_ARGS_ASSERT_SAVE_LIST;
777
778     for (i = 1; i <= maxsarg; i++) {
779         SV *sv;
780         SvGETMAGIC(sarg[i]);
781         sv = newSV(0);
782         sv_setsv_nomg(sv,sarg[i]);
783         SSCHECK(3);
784         SSPUSHPTR(sarg[i]);             /* remember the pointer */
785         SSPUSHPTR(sv);                  /* remember the value */
786         SSPUSHUV(SAVEt_ITEM);
787     }
788 }
789
790 /*
791 =for apidoc sv_usepvn_mg
792
793 Like C<sv_usepvn>, but also handles 'set' magic.
794
795 =cut
796 */
797
798 void
799 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
800 {
801     PERL_ARGS_ASSERT_SV_USEPVN_MG;
802
803     sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
804 }
805
806 /*
807 =for apidoc sv_usepvn
808
809 Tells an SV to use C<ptr> to find its string value.  Implemented by
810 calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
811 magic.  See C<L</sv_usepvn_flags>>.
812
813 =cut
814 */
815
816 void
817 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
818 {
819     PERL_ARGS_ASSERT_SV_USEPVN;
820
821     sv_usepvn_flags(sv,ptr,len, 0);
822 }
823
824 /*
825 =for apidoc unpack_str
826
827 The engine implementing C<unpack()> Perl function.  Note: parameters C<strbeg>,
828 C<new_s> and C<ocnt> are not used.  This call should not be used, use
829 C<unpackstring> instead.
830
831 =cut */
832
833 I32
834 Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s,
835                 const char *strbeg, const char *strend, char **new_s, I32 ocnt,
836                 U32 flags)
837 {
838     PERL_ARGS_ASSERT_UNPACK_STR;
839
840     PERL_UNUSED_ARG(strbeg);
841     PERL_UNUSED_ARG(new_s);
842     PERL_UNUSED_ARG(ocnt);
843
844     return unpackstring(pat, patend, s, strend, flags);
845 }
846
847 /*
848 =for apidoc pack_cat
849
850 The engine implementing C<pack()> Perl function.  Note: parameters
851 C<next_in_list> and C<flags> are not used.  This call should not be used; use
852 C<packlist> instead.
853
854 =cut
855 */
856
857 void
858 Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
859 {
860     PERL_ARGS_ASSERT_PACK_CAT;
861
862     PERL_UNUSED_ARG(next_in_list);
863     PERL_UNUSED_ARG(flags);
864
865     packlist(cat, pat, patend, beglist, endlist);
866 }
867
868 HE *
869 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
870 {
871   return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
872 }
873
874 bool
875 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
876 {
877     PERL_ARGS_ASSERT_HV_EXISTS_ENT;
878
879     return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
880         ? TRUE : FALSE;
881 }
882
883 HE *
884 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
885 {
886     PERL_ARGS_ASSERT_HV_FETCH_ENT;
887
888     return (HE *)hv_common(hv, keysv, NULL, 0, 0, 
889                      (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
890 }
891
892 SV *
893 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
894 {
895     PERL_ARGS_ASSERT_HV_DELETE_ENT;
896
897     return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
898                                 hash));
899 }
900
901 SV**
902 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
903                     int flags)
904 {
905     return (SV**) hv_common(hv, NULL, key, klen, flags,
906                             (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
907 }
908
909 SV**
910 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
911 {
912     STRLEN klen;
913     int flags;
914
915     if (klen_i32 < 0) {
916         klen = -klen_i32;
917         flags = HVhek_UTF8;
918     } else {
919         klen = klen_i32;
920         flags = 0;
921     }
922     return (SV **) hv_common(hv, NULL, key, klen, flags,
923                              (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
924 }
925
926 bool
927 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
928 {
929     STRLEN klen;
930     int flags;
931
932     PERL_ARGS_ASSERT_HV_EXISTS;
933
934     if (klen_i32 < 0) {
935         klen = -klen_i32;
936         flags = HVhek_UTF8;
937     } else {
938         klen = klen_i32;
939         flags = 0;
940     }
941     return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0)
942         ? TRUE : FALSE;
943 }
944
945 SV**
946 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
947 {
948     STRLEN klen;
949     int flags;
950
951     PERL_ARGS_ASSERT_HV_FETCH;
952
953     if (klen_i32 < 0) {
954         klen = -klen_i32;
955         flags = HVhek_UTF8;
956     } else {
957         klen = klen_i32;
958         flags = 0;
959     }
960     return (SV **) hv_common(hv, NULL, key, klen, flags,
961                              lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
962                              : HV_FETCH_JUST_SV, NULL, 0);
963 }
964
965 SV *
966 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
967 {
968     STRLEN klen;
969     int k_flags;
970
971     PERL_ARGS_ASSERT_HV_DELETE;
972
973     if (klen_i32 < 0) {
974         klen = -klen_i32;
975         k_flags = HVhek_UTF8;
976     } else {
977         klen = klen_i32;
978         k_flags = 0;
979     }
980     return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
981                                 NULL, 0));
982 }
983
984 AV *
985 Perl_newAV(pTHX)
986 {
987     return MUTABLE_AV(newSV_type(SVt_PVAV));
988     /* sv_upgrade does AvREAL_only():
989     AvALLOC(av) = 0;
990     AvARRAY(av) = NULL;
991     AvMAX(av) = AvFILLp(av) = -1; */
992 }
993
994 HV *
995 Perl_newHV(pTHX)
996 {
997     HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
998     assert(!SvOK(hv));
999
1000     return hv;
1001 }
1002
1003 void
1004 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len, 
1005               const char *const little, const STRLEN littlelen)
1006 {
1007     PERL_ARGS_ASSERT_SV_INSERT;
1008     sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
1009 }
1010
1011 void
1012 Perl_save_freesv(pTHX_ SV *sv)
1013 {
1014     save_freesv(sv);
1015 }
1016
1017 void
1018 Perl_save_mortalizesv(pTHX_ SV *sv)
1019 {
1020     PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1021
1022     save_mortalizesv(sv);
1023 }
1024
1025 void
1026 Perl_save_freeop(pTHX_ OP *o)
1027 {
1028     save_freeop(o);
1029 }
1030
1031 void
1032 Perl_save_freepv(pTHX_ char *pv)
1033 {
1034     save_freepv(pv);
1035 }
1036
1037 void
1038 Perl_save_op(pTHX)
1039 {
1040     save_op();
1041 }
1042
1043 #ifdef PERL_DONT_CREATE_GVSV
1044 GV *
1045 Perl_gv_SVadd(pTHX_ GV *gv)
1046 {
1047     return gv_SVadd(gv);
1048 }
1049 #endif
1050
1051 GV *
1052 Perl_gv_AVadd(pTHX_ GV *gv)
1053 {
1054     return gv_AVadd(gv);
1055 }
1056
1057 GV *
1058 Perl_gv_HVadd(pTHX_ GV *gv)
1059 {
1060     return gv_HVadd(gv);
1061 }
1062
1063 GV *
1064 Perl_gv_IOadd(pTHX_ GV *gv)
1065 {
1066     return gv_IOadd(gv);
1067 }
1068
1069 IO *
1070 Perl_newIO(pTHX)
1071 {
1072     return MUTABLE_IO(newSV_type(SVt_PVIO));
1073 }
1074
1075 I32
1076 Perl_my_stat(pTHX)
1077 {
1078     return my_stat_flags(SV_GMAGIC);
1079 }
1080
1081 I32
1082 Perl_my_lstat(pTHX)
1083 {
1084     return my_lstat_flags(SV_GMAGIC);
1085 }
1086
1087 I32
1088 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
1089 {
1090     return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1091 }
1092
1093 #ifdef USE_LOCALE_COLLATE
1094 char *
1095 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1096 {
1097     return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1098 }
1099
1100 char *
1101 Perl_mem_collxfrm(pTHX_ const char *input_string, STRLEN len, STRLEN *xlen)
1102 {
1103     /* This function is retained for compatibility in case someone outside core
1104      * is using this (but it is undocumented) */
1105
1106     PERL_ARGS_ASSERT_MEM_COLLXFRM;
1107
1108     return _mem_collxfrm(input_string, len, xlen, FALSE);
1109 }
1110
1111 #endif
1112
1113 bool
1114 Perl_sv_2bool(pTHX_ SV *const sv)
1115 {
1116     return sv_2bool_flags(sv, SV_GMAGIC);
1117 }
1118
1119
1120 /*
1121 =for apidoc custom_op_name
1122 Return the name for a given custom op.  This was once used by the C<OP_NAME>
1123 macro, but is no longer: it has only been kept for compatibility, and
1124 should not be used.
1125
1126 =for apidoc custom_op_desc
1127 Return the description of a given custom op.  This was once used by the
1128 C<OP_DESC> macro, but is no longer: it has only been kept for
1129 compatibility, and should not be used.
1130
1131 =cut
1132 */
1133
1134 const char*
1135 Perl_custom_op_name(pTHX_ const OP* o)
1136 {
1137     PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
1138     return XopENTRYCUSTOM(o, xop_name);
1139 }
1140
1141 const char*
1142 Perl_custom_op_desc(pTHX_ const OP* o)
1143 {
1144     PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
1145     return XopENTRYCUSTOM(o, xop_desc);
1146 }
1147
1148 CV *
1149 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1150 {
1151     return newATTRSUB(floor, o, proto, NULL, block);
1152 }
1153
1154 UV
1155 Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1156 {
1157     PERL_ARGS_ASSERT_TO_UTF8_FOLD;
1158
1159     return _to_utf8_fold_flags(p, ustrp, lenp, FOLD_FLAGS_FULL);
1160 }
1161
1162 UV
1163 Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1164 {
1165     PERL_ARGS_ASSERT_TO_UTF8_LOWER;
1166
1167     return _to_utf8_lower_flags(p, ustrp, lenp, FALSE);
1168 }
1169
1170 UV
1171 Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1172 {
1173     PERL_ARGS_ASSERT_TO_UTF8_TITLE;
1174
1175     return _to_utf8_title_flags(p, ustrp, lenp, FALSE);
1176 }
1177
1178 UV
1179 Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1180 {
1181     PERL_ARGS_ASSERT_TO_UTF8_UPPER;
1182
1183     return _to_utf8_upper_flags(p, ustrp, lenp, FALSE);
1184 }
1185
1186 SV *
1187 Perl_sv_mortalcopy(pTHX_ SV *const oldstr)
1188 {
1189     return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC);
1190 }
1191
1192 void
1193 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1194 {
1195     PERL_ARGS_ASSERT_SV_COPYPV;
1196
1197     sv_copypv_flags(dsv, ssv, 0);
1198 }
1199
1200 UV      /* Made into a function, so can be deprecated */
1201 NATIVE_TO_NEED(const UV enc, const UV ch)
1202 {
1203     PERL_UNUSED_ARG(enc);
1204     return ch;
1205 }
1206
1207 UV      /* Made into a function, so can be deprecated */
1208 ASCII_TO_NEED(const UV enc, const UV ch)
1209 {
1210     PERL_UNUSED_ARG(enc);
1211     return ch;
1212 }
1213
1214 bool      /* Made into a function, so can be deprecated */
1215 Perl_isIDFIRST_lazy(pTHX_ const char* p)
1216 {
1217     PERL_ARGS_ASSERT_ISIDFIRST_LAZY;
1218
1219     return isIDFIRST_lazy_if(p,1);
1220 }
1221
1222 bool      /* Made into a function, so can be deprecated */
1223 Perl_isALNUM_lazy(pTHX_ const char* p)
1224 {
1225     PERL_ARGS_ASSERT_ISALNUM_LAZY;
1226
1227     return isALNUM_lazy_if(p,1);
1228 }
1229
1230 bool
1231 Perl_is_uni_alnum(pTHX_ UV c)
1232 {
1233     return isWORDCHAR_uni(c);
1234 }
1235
1236 bool
1237 Perl_is_uni_alnumc(pTHX_ UV c)
1238 {
1239     return isALNUM_uni(c);
1240 }
1241
1242 bool
1243 Perl_is_uni_alpha(pTHX_ UV c)
1244 {
1245     return isALPHA_uni(c);
1246 }
1247
1248 bool
1249 Perl_is_uni_ascii(pTHX_ UV c)
1250 {
1251     PERL_UNUSED_CONTEXT;
1252     return isASCII_uni(c);
1253 }
1254
1255 bool
1256 Perl_is_uni_blank(pTHX_ UV c)
1257 {
1258     PERL_UNUSED_CONTEXT;
1259     return isBLANK_uni(c);
1260 }
1261
1262 bool
1263 Perl_is_uni_space(pTHX_ UV c)
1264 {
1265     PERL_UNUSED_CONTEXT;
1266     return isSPACE_uni(c);
1267 }
1268
1269 bool
1270 Perl_is_uni_digit(pTHX_ UV c)
1271 {
1272     PERL_UNUSED_CONTEXT;
1273     return isDIGIT_uni(c);
1274 }
1275
1276 bool
1277 Perl_is_uni_upper(pTHX_ UV c)
1278 {
1279     PERL_UNUSED_CONTEXT;
1280     return isUPPER_uni(c);
1281 }
1282
1283 bool
1284 Perl_is_uni_lower(pTHX_ UV c)
1285 {
1286     PERL_UNUSED_CONTEXT;
1287     return isLOWER_uni(c);
1288 }
1289
1290 bool
1291 Perl_is_uni_cntrl(pTHX_ UV c)
1292 {
1293     PERL_UNUSED_CONTEXT;
1294     return isCNTRL_L1(c);
1295 }
1296
1297 bool
1298 Perl_is_uni_graph(pTHX_ UV c)
1299 {
1300     PERL_UNUSED_CONTEXT;
1301     return isGRAPH_uni(c);
1302 }
1303
1304 bool
1305 Perl_is_uni_print(pTHX_ UV c)
1306 {
1307     PERL_UNUSED_CONTEXT;
1308     return isPRINT_uni(c);
1309 }
1310
1311 bool
1312 Perl_is_uni_punct(pTHX_ UV c)
1313 {
1314     PERL_UNUSED_CONTEXT;
1315     return isPUNCT_uni(c);
1316 }
1317
1318 bool
1319 Perl_is_uni_xdigit(pTHX_ UV c)
1320 {
1321     PERL_UNUSED_CONTEXT;
1322     return isXDIGIT_uni(c);
1323 }
1324
1325 bool
1326 Perl_is_uni_alnum_lc(pTHX_ UV c)
1327 {
1328     PERL_UNUSED_CONTEXT;
1329     return isWORDCHAR_LC_uvchr(c);
1330 }
1331
1332 bool
1333 Perl_is_uni_alnumc_lc(pTHX_ UV c)
1334 {
1335     PERL_UNUSED_CONTEXT;
1336     return isALPHANUMERIC_LC_uvchr(c);
1337 }
1338
1339 bool
1340 Perl_is_uni_idfirst_lc(pTHX_ UV c)
1341 {
1342     PERL_UNUSED_CONTEXT;
1343     /* XXX Should probably be something that resolves to the old IDFIRST, but
1344      * this function is deprecated, so not bothering */
1345     return isIDFIRST_LC_uvchr(c);
1346 }
1347
1348 bool
1349 Perl_is_uni_alpha_lc(pTHX_ UV c)
1350 {
1351     PERL_UNUSED_CONTEXT;
1352     return isALPHA_LC_uvchr(c);
1353 }
1354
1355 bool
1356 Perl_is_uni_ascii_lc(pTHX_ UV c)
1357 {
1358     PERL_UNUSED_CONTEXT;
1359     return isASCII_LC_uvchr(c);
1360 }
1361
1362 bool
1363 Perl_is_uni_blank_lc(pTHX_ UV c)
1364 {
1365     PERL_UNUSED_CONTEXT;
1366     return isBLANK_LC_uvchr(c);
1367 }
1368
1369 bool
1370 Perl_is_uni_space_lc(pTHX_ UV c)
1371 {
1372     PERL_UNUSED_CONTEXT;
1373     return isSPACE_LC_uvchr(c);
1374 }
1375
1376 bool
1377 Perl_is_uni_digit_lc(pTHX_ UV c)
1378 {
1379     return isDIGIT_LC_uvchr(c);
1380 }
1381
1382 bool
1383 Perl_is_uni_idfirst(pTHX_ UV c)
1384 {
1385     U8 tmpbuf[UTF8_MAXBYTES+1];
1386     uvchr_to_utf8(tmpbuf, c);
1387     return _is_utf8_idstart(tmpbuf);
1388 }
1389
1390 bool
1391 Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
1392 {
1393     PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
1394
1395     return _is_utf8_idstart(p);
1396 }
1397
1398 bool
1399 Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */
1400 {
1401     PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST;
1402
1403     return _is_utf8_xidstart(p);
1404 }
1405
1406 bool
1407 Perl_is_utf8_idcont(pTHX_ const U8 *p)
1408 {
1409     PERL_ARGS_ASSERT_IS_UTF8_IDCONT;
1410
1411     return _is_utf8_idcont(p);
1412 }
1413
1414 bool
1415 Perl_is_utf8_xidcont(pTHX_ const U8 *p)
1416 {
1417     PERL_ARGS_ASSERT_IS_UTF8_XIDCONT;
1418
1419     return _is_utf8_xidcont(p);
1420 }
1421
1422 bool
1423 Perl_is_uni_upper_lc(pTHX_ UV c)
1424 {
1425     return isUPPER_LC_uvchr(c);
1426 }
1427
1428 bool
1429 Perl_is_uni_lower_lc(pTHX_ UV c)
1430 {
1431     return isLOWER_LC_uvchr(c);
1432 }
1433
1434 bool
1435 Perl_is_uni_cntrl_lc(pTHX_ UV c)
1436 {
1437     return isCNTRL_LC_uvchr(c);
1438 }
1439
1440 bool
1441 Perl_is_uni_graph_lc(pTHX_ UV c)
1442 {
1443     return isGRAPH_LC_uvchr(c);
1444 }
1445
1446 bool
1447 Perl_is_uni_print_lc(pTHX_ UV c)
1448 {
1449     return isPRINT_LC_uvchr(c);
1450 }
1451
1452 bool
1453 Perl_is_uni_punct_lc(pTHX_ UV c)
1454 {
1455     return isPUNCT_LC_uvchr(c);
1456 }
1457
1458 bool
1459 Perl_is_uni_xdigit_lc(pTHX_ UV c)
1460 {
1461     return isXDIGIT_LC_uvchr(c);
1462 }
1463
1464 U32
1465 Perl_to_uni_upper_lc(pTHX_ U32 c)
1466 {
1467     /* XXX returns only the first character -- do not use XXX */
1468     /* XXX no locale support yet */
1469     STRLEN len;
1470     U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1471     return (U32)to_uni_upper(c, tmpbuf, &len);
1472 }
1473
1474 U32
1475 Perl_to_uni_title_lc(pTHX_ U32 c)
1476 {
1477     /* XXX returns only the first character XXX -- do not use XXX */
1478     /* XXX no locale support yet */
1479     STRLEN len;
1480     U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1481     return (U32)to_uni_title(c, tmpbuf, &len);
1482 }
1483
1484 U32
1485 Perl_to_uni_lower_lc(pTHX_ U32 c)
1486 {
1487     /* XXX returns only the first character -- do not use XXX */
1488     /* XXX no locale support yet */
1489     STRLEN len;
1490     U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1491     return (U32)to_uni_lower(c, tmpbuf, &len);
1492 }
1493
1494 bool
1495 Perl_is_utf8_alnum(pTHX_ const U8 *p)
1496 {
1497     PERL_ARGS_ASSERT_IS_UTF8_ALNUM;
1498
1499     /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
1500      * descendant of isalnum(3), in other words, it doesn't
1501      * contain the '_'. --jhi */
1502     return isWORDCHAR_utf8(p);
1503 }
1504
1505 bool
1506 Perl_is_utf8_alnumc(pTHX_ const U8 *p)
1507 {
1508     PERL_ARGS_ASSERT_IS_UTF8_ALNUMC;
1509
1510     return isALPHANUMERIC_utf8(p);
1511 }
1512
1513 bool
1514 Perl_is_utf8_alpha(pTHX_ const U8 *p)
1515 {
1516     PERL_ARGS_ASSERT_IS_UTF8_ALPHA;
1517
1518     return isALPHA_utf8(p);
1519 }
1520
1521 bool
1522 Perl_is_utf8_ascii(pTHX_ const U8 *p)
1523 {
1524     PERL_ARGS_ASSERT_IS_UTF8_ASCII;
1525     PERL_UNUSED_CONTEXT;
1526
1527     return isASCII_utf8(p);
1528 }
1529
1530 bool
1531 Perl_is_utf8_blank(pTHX_ const U8 *p)
1532 {
1533     PERL_ARGS_ASSERT_IS_UTF8_BLANK;
1534     PERL_UNUSED_CONTEXT;
1535
1536     return isBLANK_utf8(p);
1537 }
1538
1539 bool
1540 Perl_is_utf8_space(pTHX_ const U8 *p)
1541 {
1542     PERL_ARGS_ASSERT_IS_UTF8_SPACE;
1543     PERL_UNUSED_CONTEXT;
1544
1545     return isSPACE_utf8(p);
1546 }
1547
1548 bool
1549 Perl_is_utf8_perl_space(pTHX_ const U8 *p)
1550 {
1551     PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE;
1552     PERL_UNUSED_CONTEXT;
1553
1554     /* Only true if is an ASCII space-like character, and ASCII is invariant
1555      * under utf8, so can just use the macro */
1556     return isSPACE_A(*p);
1557 }
1558
1559 bool
1560 Perl_is_utf8_perl_word(pTHX_ const U8 *p)
1561 {
1562     PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD;
1563     PERL_UNUSED_CONTEXT;
1564
1565     /* Only true if is an ASCII word character, and ASCII is invariant
1566      * under utf8, so can just use the macro */
1567     return isWORDCHAR_A(*p);
1568 }
1569
1570 bool
1571 Perl_is_utf8_digit(pTHX_ const U8 *p)
1572 {
1573     PERL_ARGS_ASSERT_IS_UTF8_DIGIT;
1574
1575     return isDIGIT_utf8(p);
1576 }
1577
1578 bool
1579 Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
1580 {
1581     PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT;
1582     PERL_UNUSED_CONTEXT;
1583
1584     /* Only true if is an ASCII digit character, and ASCII is invariant
1585      * under utf8, so can just use the macro */
1586     return isDIGIT_A(*p);
1587 }
1588
1589 bool
1590 Perl_is_utf8_upper(pTHX_ const U8 *p)
1591 {
1592     PERL_ARGS_ASSERT_IS_UTF8_UPPER;
1593
1594     return isUPPER_utf8(p);
1595 }
1596
1597 bool
1598 Perl_is_utf8_lower(pTHX_ const U8 *p)
1599 {
1600     PERL_ARGS_ASSERT_IS_UTF8_LOWER;
1601
1602     return isLOWER_utf8(p);
1603 }
1604
1605 bool
1606 Perl_is_utf8_cntrl(pTHX_ const U8 *p)
1607 {
1608     PERL_ARGS_ASSERT_IS_UTF8_CNTRL;
1609     PERL_UNUSED_CONTEXT;
1610
1611     return isCNTRL_utf8(p);
1612 }
1613
1614 bool
1615 Perl_is_utf8_graph(pTHX_ const U8 *p)
1616 {
1617     PERL_ARGS_ASSERT_IS_UTF8_GRAPH;
1618
1619     return isGRAPH_utf8(p);
1620 }
1621
1622 bool
1623 Perl_is_utf8_print(pTHX_ const U8 *p)
1624 {
1625     PERL_ARGS_ASSERT_IS_UTF8_PRINT;
1626
1627     return isPRINT_utf8(p);
1628 }
1629
1630 bool
1631 Perl_is_utf8_punct(pTHX_ const U8 *p)
1632 {
1633     PERL_ARGS_ASSERT_IS_UTF8_PUNCT;
1634
1635     return isPUNCT_utf8(p);
1636 }
1637
1638 bool
1639 Perl_is_utf8_xdigit(pTHX_ const U8 *p)
1640 {
1641     PERL_ARGS_ASSERT_IS_UTF8_XDIGIT;
1642     PERL_UNUSED_CONTEXT;
1643
1644     return isXDIGIT_utf8(p);
1645 }
1646
1647 bool
1648 Perl_is_utf8_mark(pTHX_ const U8 *p)
1649 {
1650     PERL_ARGS_ASSERT_IS_UTF8_MARK;
1651
1652     return _is_utf8_mark(p);
1653 }
1654
1655 /*
1656 =for apidoc is_utf8_char
1657
1658 Tests if some arbitrary number of bytes begins in a valid UTF-8
1659 character.  Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1660 character is a valid UTF-8 character.  The actual number of bytes in the UTF-8
1661 character will be returned if it is valid, otherwise 0.
1662
1663 This function is deprecated due to the possibility that malformed input could
1664 cause reading beyond the end of the input buffer.  Use L</isUTF8_CHAR>
1665 instead.
1666
1667 =cut */
1668
1669 STRLEN
1670 Perl_is_utf8_char(const U8 *s)
1671 {
1672     PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1673
1674     /* Assumes we have enough space, which is why this is deprecated */
1675     return isUTF8_CHAR(s, s + UTF8SKIP(s));
1676 }
1677
1678 /*
1679 =for apidoc is_utf8_char_buf
1680
1681 This is identical to the macro L</isUTF8_CHAR>.
1682
1683 =cut */
1684
1685 STRLEN
1686 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1687 {
1688
1689     PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1690
1691     return isUTF8_CHAR(buf, buf_end);
1692 }
1693
1694 /* DEPRECATED!
1695  * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1696  * there are no malformations in the input UTF-8 string C<s>.  Surrogates,
1697  * non-character code points, and non-Unicode code points are allowed */
1698
1699 UV
1700 Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1701 {
1702     PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI;
1703
1704     return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1705 }
1706
1707 /*
1708 =for apidoc utf8_to_uvchr
1709
1710 Returns the native code point of the first character in the string C<s>
1711 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1712 length, in bytes, of that character.
1713
1714 Some, but not all, UTF-8 malformations are detected, and in fact, some
1715 malformed input could cause reading beyond the end of the input buffer, which
1716 is why this function is deprecated.  Use L</utf8_to_uvchr_buf> instead.
1717
1718 If C<s> points to one of the detected malformations, and UTF8 warnings are
1719 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
1720 C<NULL>) to -1.  If those warnings are off, the computed value if well-defined (or
1721 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1722 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1723 next possible position in C<s> that could begin a non-malformed character.
1724 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1725
1726 =cut
1727 */
1728
1729 UV
1730 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
1731 {
1732     PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
1733
1734     return utf8_to_uvchr_buf(s, s + UTF8_MAXBYTES, retlen);
1735 }
1736
1737 /*
1738 =for apidoc utf8_to_uvuni
1739
1740 Returns the Unicode code point of the first character in the string C<s>
1741 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1742 length, in bytes, of that character.
1743
1744 Some, but not all, UTF-8 malformations are detected, and in fact, some
1745 malformed input could cause reading beyond the end of the input buffer, which
1746 is one reason why this function is deprecated.  The other is that only in
1747 extremely limited circumstances should the Unicode versus native code point be
1748 of any interest to you.  See L</utf8_to_uvuni_buf> for alternatives.
1749
1750 If C<s> points to one of the detected malformations, and UTF8 warnings are
1751 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
1752 NULL) to -1.  If those warnings are off, the computed value if well-defined (or
1753 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
1754 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
1755 next possible position in C<s> that could begin a non-malformed character.
1756 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
1757
1758 =cut
1759 */
1760
1761 UV
1762 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1763 {
1764     PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
1765
1766     return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1767 }
1768
1769 /*
1770 =for apidoc Am|HV *|pad_compname_type|PADOFFSET po
1771
1772 Looks up the type of the lexical variable at position C<po> in the
1773 currently-compiling pad.  If the variable is typed, the stash of the
1774 class to which it is typed is returned.  If not, C<NULL> is returned.
1775
1776 =cut
1777 */
1778
1779 HV *
1780 Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1781 {
1782     return PAD_COMPNAME_TYPE(po);
1783 }
1784
1785 /* return ptr to little string in big string, NULL if not found */
1786 /* The original version of this routine was donated by Corey Satten. */
1787
1788 char *
1789 Perl_instr(const char *big, const char *little)
1790 {
1791     PERL_ARGS_ASSERT_INSTR;
1792
1793     return instr((char *) big, (char *) little);
1794 }
1795
1796 #endif /* NO_MATHOMS */
1797
1798 /*
1799  * ex: set ts=8 sts=4 sw=4 et:
1800  */