This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Do better locale collation in UTF-8 locales
[perl5.git] / mathoms.c
CommitLineData
7ee2227d
SP
1/* mathoms.c
2 *
2eee27d7
SS
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4 * 2011, 2012 by Larry Wall and others
7ee2227d
SP
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/*
4ac71550
TC
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"]
7ee2227d
SP
18 */
19
359d40ba 20
20fac488 21
7832ad85 22/*
7ee2227d 23 * This file contains mathoms, various binary artifacts from previous
d7244c9a
DM
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_ ...)
7ee2227d 34 *
8687a6e6
DM
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 *
55cb5ee0
KW
49 * The compilation of this file can be suppressed; see INSTALL
50 *
8687a6e6
DM
51 * Some blurb for perlapi.pod:
52
dcccc8ff 53=head1 Obsolete backwards compatibility functions
8687a6e6 54
dcccc8ff
KW
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
7ee2227d
SP
61 */
62
dcccc8ff 63
7ee2227d
SP
64#include "EXTERN.h"
65#define PERL_IN_MATHOMS_C
66#include "perl.h"
67
359d40ba
NC
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
7ee2227d
SP
74/* ref() is now a macro using Perl_doref;
75 * this version provided for binary compatibility only.
76 */
77OP *
78Perl_ref(pTHX_ OP *o, I32 type)
79{
80 return doref(o, type, TRUE);
81}
82
aae9cea0 83/*
174c73e3
NC
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>
fbe13c60 89being zero. See C<L</SvROK_off>>.
174c73e3
NC
90
91=cut
92*/
93
94void
95Perl_sv_unref(pTHX_ SV *sv)
96{
7918f24d
NC
97 PERL_ARGS_ASSERT_SV_UNREF;
98
174c73e3
NC
99 sv_unref_flags(sv, 0);
100}
101
102/*
aae9cea0
NC
103=for apidoc sv_taint
104
72d33970 105Taint an SV. Use C<SvTAINTED_on> instead.
dff47061 106
aae9cea0
NC
107=cut
108*/
109
110void
111Perl_sv_taint(pTHX_ SV *sv)
112{
7918f24d
NC
113 PERL_ARGS_ASSERT_SV_TAINT;
114
a0714e2c 115 sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
aae9cea0
NC
116}
117
7ee2227d
SP
118/* sv_2iv() is now a macro using Perl_sv_2iv_flags();
119 * this function provided for binary compatibility only
120 */
121
122IV
5aaab254 123Perl_sv_2iv(pTHX_ SV *sv)
7ee2227d 124{
1061065f
DD
125 PERL_ARGS_ASSERT_SV_2IV;
126
7ee2227d
SP
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
5aaab254 135Perl_sv_2uv(pTHX_ SV *sv)
7ee2227d 136{
1061065f
DD
137 PERL_ARGS_ASSERT_SV_2UV;
138
7ee2227d
SP
139 return sv_2uv_flags(sv, SV_GMAGIC);
140}
141
39d5de13
DM
142/* sv_2nv() is now a macro using Perl_sv_2nv_flags();
143 * this function provided for binary compatibility only
144 */
145
146NV
5aaab254 147Perl_sv_2nv(pTHX_ SV *sv)
39d5de13
DM
148{
149 return sv_2nv_flags(sv, SV_GMAGIC);
150}
151
152
7ee2227d
SP
153/* sv_2pv() is now a macro using Perl_sv_2pv_flags();
154 * this function provided for binary compatibility only
155 */
156
157char *
5aaab254 158Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
7ee2227d 159{
1061065f
DD
160 PERL_ARGS_ASSERT_SV_2PV;
161
7ee2227d
SP
162 return sv_2pv_flags(sv, lp, SV_GMAGIC);
163}
164
5abc721d 165/*
cb2f1b7b
NC
166=for apidoc sv_2pv_nolen
167
72d33970 168Like C<sv_2pv()>, but doesn't return the length too. You should usually
cb2f1b7b 169use the macro wrapper C<SvPV_nolen(sv)> instead.
dff47061 170
cb2f1b7b
NC
171=cut
172*/
173
174char *
5aaab254 175Perl_sv_2pv_nolen(pTHX_ SV *sv)
cb2f1b7b 176{
c85ae797 177 PERL_ARGS_ASSERT_SV_2PV_NOLEN;
b5445a23 178 return sv_2pv(sv, NULL);
cb2f1b7b
NC
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 *
5aaab254 193Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
cb2f1b7b 194{
7918f24d
NC
195 PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
196
b5445a23 197 return sv_2pvbyte(sv, NULL);
cb2f1b7b
NC
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 *
5aaab254 212Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
cb2f1b7b 213{
7918f24d
NC
214 PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
215
b5445a23 216 return sv_2pvutf8(sv, NULL);
cb2f1b7b
NC
217}
218
219/*
5abc721d
NC
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
796b6530 224an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
5abc721d
NC
225
226=cut
227*/
228
229void
5aaab254 230Perl_sv_force_normal(pTHX_ SV *sv)
5abc721d 231{
7918f24d
NC
232 PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
233
5abc721d
NC
234 sv_force_normal_flags(sv, 0);
235}
7ee2227d
SP
236
237/* sv_setsv() is now a macro using Perl_sv_setsv_flags();
238 * this function provided for binary compatibility only
239 */
240
241void
5aaab254 242Perl_sv_setsv(pTHX_ SV *dstr, SV *sstr)
7ee2227d 243{
7918f24d
NC
244 PERL_ARGS_ASSERT_SV_SETSV;
245
7ee2227d
SP
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{
7918f24d
NC
256 PERL_ARGS_ASSERT_SV_CATPVN;
257
7ee2227d
SP
258 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
259}
260
b347df82
NC
261/*
262=for apidoc sv_catpvn_mg
263
264Like C<sv_catpvn>, but also handles 'set' magic.
265
266=cut
267*/
268
269void
5aaab254 270Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len)
b347df82 271{
7918f24d
NC
272 PERL_ARGS_ASSERT_SV_CATPVN_MG;
273
b347df82
NC
274 sv_catpvn_flags(sv,ptr,len,SV_GMAGIC|SV_SMAGIC);
275}
276
7ee2227d
SP
277/* sv_catsv() is now a macro using Perl_sv_catsv_flags();
278 * this function provided for binary compatibility only
279 */
280
281void
5aaab254 282Perl_sv_catsv(pTHX_ SV *dstr, SV *sstr)
7ee2227d 283{
7918f24d
NC
284 PERL_ARGS_ASSERT_SV_CATSV;
285
7ee2227d
SP
286 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
287}
288
0feed65a 289/*
b347df82
NC
290=for apidoc sv_catsv_mg
291
292Like C<sv_catsv>, but also handles 'set' magic.
293
294=cut
295*/
296
297void
5aaab254 298Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *ssv)
b347df82 299{
7918f24d
NC
300 PERL_ARGS_ASSERT_SV_CATSV_MG;
301
b347df82
NC
302 sv_catsv_flags(dsv,ssv,SV_GMAGIC|SV_SMAGIC);
303}
304
305/*
0feed65a
NC
306=for apidoc sv_iv
307
308A private implementation of the C<SvIVx> macro for compilers which can't
72d33970 309cope with complex macro expressions. Always use the macro instead.
0feed65a
NC
310
311=cut
312*/
313
314IV
5aaab254 315Perl_sv_iv(pTHX_ SV *sv)
0feed65a 316{
7918f24d
NC
317 PERL_ARGS_ASSERT_SV_IV;
318
0feed65a
NC
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
72d33970 331cope with complex macro expressions. Always use the macro instead.
0feed65a
NC
332
333=cut
334*/
335
336UV
5aaab254 337Perl_sv_uv(pTHX_ SV *sv)
0feed65a 338{
7918f24d
NC
339 PERL_ARGS_ASSERT_SV_UV;
340
0feed65a
NC
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
72d33970 353cope with complex macro expressions. Always use the macro instead.
0feed65a
NC
354
355=cut
356*/
357
358NV
5aaab254 359Perl_sv_nv(pTHX_ SV *sv)
0feed65a 360{
7918f24d
NC
361 PERL_ARGS_ASSERT_SV_NV;
362
0feed65a
NC
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
72d33970 376cope with complex macro expressions. Always use the macro instead.
0feed65a
NC
377
378=cut
379*/
380
381char *
382Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp)
383{
7918f24d
NC
384 PERL_ARGS_ASSERT_SV_PVN;
385
0feed65a
NC
386 if (SvPOK(sv)) {
387 *lp = SvCUR(sv);
388 return SvPVX(sv);
389 }
390 return sv_2pv(sv, lp);
391}
392
393
394char *
5aaab254 395Perl_sv_pvn_nomg(pTHX_ SV *sv, STRLEN *lp)
0feed65a 396{
7918f24d
NC
397 PERL_ARGS_ASSERT_SV_PVN_NOMG;
398
0feed65a
NC
399 if (SvPOK(sv)) {
400 *lp = SvCUR(sv);
401 return SvPVX(sv);
402 }
403 return sv_2pv_flags(sv, lp, 0);
404}
405
7ee2227d
SP
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{
7918f24d
NC
413 PERL_ARGS_ASSERT_SV_PV;
414
7ee2227d
SP
415 if (SvPOK(sv))
416 return SvPVX(sv);
417
b5445a23 418 return sv_2pv(sv, NULL);
7ee2227d
SP
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{
7918f24d
NC
428 PERL_ARGS_ASSERT_SV_PVN_FORCE;
429
7ee2227d
SP
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{
7918f24d
NC
440 PERL_ARGS_ASSERT_SV_PVBYTE;
441
b5445a23 442 sv_utf8_downgrade(sv, FALSE);
7ee2227d
SP
443 return sv_pv(sv);
444}
445
0feed65a
NC
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
72d33970 454which can't cope with complex macro expressions. Always use the macro
0feed65a
NC
455instead.
456
457=cut
458*/
459
460char *
461Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp)
462{
7918f24d
NC
463 PERL_ARGS_ASSERT_SV_PVBYTEN;
464
b5445a23 465 sv_utf8_downgrade(sv, FALSE);
0feed65a
NC
466 return sv_pvn(sv,lp);
467}
468
7ee2227d
SP
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{
7918f24d
NC
476 PERL_ARGS_ASSERT_SV_PVUTF8;
477
7ee2227d
SP
478 sv_utf8_upgrade(sv);
479 return sv_pv(sv);
480}
481
0feed65a
NC
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
72d33970 490which can't cope with complex macro expressions. Always use the macro
0feed65a
NC
491instead.
492
493=cut
494*/
495
496char *
497Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *lp)
498{
7918f24d
NC
499 PERL_ARGS_ASSERT_SV_PVUTF8N;
500
0feed65a
NC
501 sv_utf8_upgrade(sv);
502 return sv_pvn(sv,lp);
503}
504
205c02c2
NC
505/* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
506 * this function provided for binary compatibility only
507 */
508
509STRLEN
5aaab254 510Perl_sv_utf8_upgrade(pTHX_ SV *sv)
205c02c2 511{
7918f24d
NC
512 PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
513
205c02c2
NC
514 return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
515}
516
7ee2227d
SP
517int
518Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
519{
3ed3a8af 520 int ret = 0;
7ee2227d 521 va_list(arglist);
7918f24d
NC
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
7ee2227d 529 va_start(arglist, format);
3ed3a8af
JH
530 ret = PerlIO_vprintf(stream, format, arglist);
531 va_end(arglist);
532 return ret;
7ee2227d
SP
533}
534
535int
536Perl_printf_nocontext(const char *format, ...)
537{
538 dTHX;
539 va_list(arglist);
3ed3a8af 540 int ret = 0;
7918f24d
NC
541
542#ifdef PERL_IMPLICIT_CONTEXT
543 PERL_ARGS_ASSERT_PRINTF_NOCONTEXT;
544#endif
545
7ee2227d 546 va_start(arglist, format);
3ed3a8af
JH
547 ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist);
548 va_end(arglist);
549 return ret;
7ee2227d
SP
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{
c773ee7a 561# if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
7ee2227d 562 return HUGE_VALL;
c773ee7a 563# else
7ee2227d 564 return HUGE_VAL;
c773ee7a 565# endif
7ee2227d
SP
566}
567#endif
568
f2f0f092
NC
569/* compatibility with versions <= 5.003. */
570void
571Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
572{
7918f24d
NC
573 PERL_ARGS_ASSERT_GV_FULLNAME;
574
666ea192 575 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
f2f0f092
NC
576}
577
578/* compatibility with versions <= 5.003. */
579void
580Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
581{
7918f24d
NC
582 PERL_ARGS_ASSERT_GV_EFULLNAME;
583
666ea192 584 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
f2f0f092
NC
585}
586
2674aeec
NC
587void
588Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
589{
7918f24d
NC
590 PERL_ARGS_ASSERT_GV_FULLNAME3;
591
2674aeec
NC
592 gv_fullname4(sv, gv, prefix, TRUE);
593}
594
595void
596Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
597{
7918f24d
NC
598 PERL_ARGS_ASSERT_GV_EFULLNAME3;
599
2674aeec
NC
600 gv_efullname4(sv, gv, prefix, TRUE);
601}
602
887986eb
NC
603/*
604=for apidoc gv_fetchmethod
605
ca8b95d7 606See L</gv_fetchmethod_autoload>.
887986eb
NC
607
608=cut
609*/
610
611GV *
612Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
613{
7918f24d
NC
614 PERL_ARGS_ASSERT_GV_FETCHMETHOD;
615
887986eb
NC
616 return gv_fetchmethod_autoload(stash, name, TRUE);
617}
618
7a7b9979
NC
619HE *
620Perl_hv_iternext(pTHX_ HV *hv)
621{
7918f24d
NC
622 PERL_ARGS_ASSERT_HV_ITERNEXT;
623
7a7b9979
NC
624 return hv_iternext_flags(hv, 0);
625}
626
bc5cdc23
NC
627void
628Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
629{
7918f24d
NC
630 PERL_ARGS_ASSERT_HV_MAGIC;
631
ad64d0ec 632 sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
bc5cdc23
NC
633}
634
34d367cd 635bool
5aaab254 636Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
e4dba786
NC
637 int rawmode, int rawperm, PerlIO *supplied_fp)
638{
7918f24d
NC
639 PERL_ARGS_ASSERT_DO_OPEN;
640
e4dba786
NC
641 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
642 supplied_fp, (SV **) NULL, 0);
643}
644
645bool
5aaab254 646Perl_do_open9(pTHX_ GV *gv, const char *name, I32 len, int
34d367cd
SP
647as_raw,
648 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
649 I32 num_svs)
650{
7918f24d
NC
651 PERL_ARGS_ASSERT_DO_OPEN9;
652
34d367cd
SP
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";
7918f24d
NC
665
666 PERL_ARGS_ASSERT_DO_BINMODE;
667
34d367cd
SP
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
a9f96b3f
NC
675#ifndef OS2
676bool
5aaab254 677Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
a9f96b3f 678{
7918f24d
NC
679 PERL_ARGS_ASSERT_DO_AEXEC;
680
a9f96b3f
NC
681 return do_aexec5(really, mark, sp, 0, 0);
682}
683#endif
684
89552e80
NC
685/* Backwards compatibility. */
686int
687Perl_init_i18nl14n(pTHX_ int printwarn)
688{
689 return init_i18nl10n(printwarn);
690}
691
814fafa7 692bool
2d825fd9 693Perl_is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **ep)
814fafa7 694{
7918f24d
NC
695 PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
696
814fafa7
NC
697 return is_utf8_string_loclen(s, len, ep, 0);
698}
699
7ee2227d 700/*
d5b2b27b
NC
701=for apidoc sv_nolocking
702
703Dummy routine which "locks" an SV when there is no locking module present.
796b6530 704Exists to avoid test for a C<NULL> function pointer and because it could
d5b2b27b
NC
705potentially warn under some level of strict-ness.
706
796b6530 707"Superseded" by C<sv_nosharing()>.
d5b2b27b
NC
708
709=cut
710*/
711
712void
713Perl_sv_nolocking(pTHX_ SV *sv)
714{
96a5add6 715 PERL_UNUSED_CONTEXT;
d5b2b27b
NC
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.
796b6530 724Exists to avoid test for a C<NULL> function pointer and because it could
d5b2b27b
NC
725potentially warn under some level of strict-ness.
726
796b6530 727"Superseded" by C<sv_nosharing()>.
d5b2b27b
NC
728
729=cut
730*/
731
732void
733Perl_sv_nounlocking(pTHX_ SV *sv)
734{
96a5add6 735 PERL_UNUSED_CONTEXT;
d5b2b27b
NC
736 PERL_UNUSED_ARG(sv);
737}
738
2053acbf
NC
739void
740Perl_save_long(pTHX_ long int *longp)
741{
7918f24d
NC
742 PERL_ARGS_ASSERT_SAVE_LONG;
743
2053acbf
NC
744 SSCHECK(3);
745 SSPUSHLONG(*longp);
746 SSPUSHPTR(longp);
c6bf6a65 747 SSPUSHUV(SAVEt_LONG);
2053acbf
NC
748}
749
750void
2053acbf
NC
751Perl_save_iv(pTHX_ IV *ivp)
752{
7918f24d
NC
753 PERL_ARGS_ASSERT_SAVE_IV;
754
2053acbf
NC
755 SSCHECK(3);
756 SSPUSHIV(*ivp);
757 SSPUSHPTR(ivp);
c6bf6a65 758 SSPUSHUV(SAVEt_IV);
2053acbf
NC
759}
760
761void
762Perl_save_nogv(pTHX_ GV *gv)
763{
7918f24d
NC
764 PERL_ARGS_ASSERT_SAVE_NOGV;
765
2053acbf
NC
766 SSCHECK(2);
767 SSPUSHPTR(gv);
c6bf6a65 768 SSPUSHUV(SAVEt_NSTAB);
2053acbf
NC
769}
770
771void
5aaab254 772Perl_save_list(pTHX_ SV **sarg, I32 maxsarg)
2053acbf 773{
eb578fdb 774 I32 i;
2053acbf 775
7918f24d
NC
776 PERL_ARGS_ASSERT_SAVE_LIST;
777
2053acbf 778 for (i = 1; i <= maxsarg; i++) {
3ed356df
FC
779 SV *sv;
780 SvGETMAGIC(sarg[i]);
781 sv = newSV(0);
782 sv_setsv_nomg(sv,sarg[i]);
2053acbf
NC
783 SSCHECK(3);
784 SSPUSHPTR(sarg[i]); /* remember the pointer */
785 SSPUSHPTR(sv); /* remember the value */
c6bf6a65 786 SSPUSHUV(SAVEt_ITEM);
2053acbf
NC
787 }
788}
789
47518d95
NC
790/*
791=for apidoc sv_usepvn_mg
792
793Like C<sv_usepvn>, but also handles 'set' magic.
794
795=cut
796*/
797
798void
799Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
800{
7918f24d
NC
801 PERL_ARGS_ASSERT_SV_USEPVN_MG;
802
47518d95
NC
803 sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
804}
805
806/*
807=for apidoc sv_usepvn
808
72d33970 809Tells an SV to use C<ptr> to find its string value. Implemented by
47518d95 810calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set'
fbe13c60 811magic. See C<L</sv_usepvn_flags>>.
47518d95
NC
812
813=cut
814*/
815
816void
817Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
818{
7918f24d
NC
819 PERL_ARGS_ASSERT_SV_USEPVN;
820
47518d95
NC
821 sv_usepvn_flags(sv,ptr,len, 0);
822}
823
c03e83bf
NC
824/*
825=for apidoc unpack_str
826
796b6530
KW
827The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>,
828C<new_s> and C<ocnt> are not used. This call should not be used, use
829C<unpackstring> instead.
c03e83bf
NC
830
831=cut */
832
833I32
834Perl_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{
7918f24d
NC
838 PERL_ARGS_ASSERT_UNPACK_STR;
839
c03e83bf
NC
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}
b47163a2
NC
846
847/*
848=for apidoc pack_cat
849
796b6530
KW
850The engine implementing C<pack()> Perl function. Note: parameters
851C<next_in_list> and C<flags> are not used. This call should not be used; use
852C<packlist> instead.
b47163a2
NC
853
854=cut
855*/
856
857void
5aaab254 858Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
b47163a2 859{
7918f24d
NC
860 PERL_ARGS_ASSERT_PACK_CAT;
861
b47163a2
NC
862 PERL_UNUSED_ARG(next_in_list);
863 PERL_UNUSED_ARG(flags);
864
865 packlist(cat, pat, patend, beglist, endlist);
866}
4c2df08c
NC
867
868HE *
869Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
870{
59af68cc 871 return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
4c2df08c
NC
872}
873
874bool
875Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
876{
7918f24d
NC
877 PERL_ARGS_ASSERT_HV_EXISTS_ENT;
878
4c2df08c
NC
879 return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash)
880 ? TRUE : FALSE;
881}
882
883HE *
884Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
885{
7918f24d
NC
886 PERL_ARGS_ASSERT_HV_FETCH_ENT;
887
59af68cc 888 return (HE *)hv_common(hv, keysv, NULL, 0, 0,
4c2df08c
NC
889 (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
890}
891
892SV *
893Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
894{
7918f24d
NC
895 PERL_ARGS_ASSERT_HV_DELETE_ENT;
896
ad64d0ec
NC
897 return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
898 hash));
4c2df08c
NC
899}
900
a038e571
NC
901SV**
902Perl_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
909SV**
910Perl_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
926bool
927Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
928{
929 STRLEN klen;
930 int flags;
931
7918f24d
NC
932 PERL_ARGS_ASSERT_HV_EXISTS;
933
a038e571
NC
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
945SV**
946Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
947{
948 STRLEN klen;
949 int flags;
950
7918f24d
NC
951 PERL_ARGS_ASSERT_HV_FETCH;
952
a038e571
NC
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
965SV *
966Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
967{
968 STRLEN klen;
969 int k_flags;
970
7918f24d
NC
971 PERL_ARGS_ASSERT_HV_DELETE;
972
a038e571
NC
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 }
ad64d0ec
NC
980 return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
981 NULL, 0));
a038e571
NC
982}
983
ac572bf4
NC
984AV *
985Perl_newAV(pTHX)
986{
502c6561 987 return MUTABLE_AV(newSV_type(SVt_PVAV));
ac572bf4
NC
988 /* sv_upgrade does AvREAL_only():
989 AvALLOC(av) = 0;
990 AvARRAY(av) = NULL;
991 AvMAX(av) = AvFILLp(av) = -1; */
992}
993
78ac7dd9
NC
994HV *
995Perl_newHV(pTHX)
996{
85fbaab2 997 HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
78ac7dd9
NC
998 assert(!SvOK(hv));
999
1000 return hv;
1001}
1002
84335ee9
NC
1003void
1004Perl_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
2fd8beea
NC
1011void
1012Perl_save_freesv(pTHX_ SV *sv)
1013{
2fd8beea
NC
1014 save_freesv(sv);
1015}
1016
1017void
1018Perl_save_mortalizesv(pTHX_ SV *sv)
1019{
2fd8beea
NC
1020 PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
1021
1022 save_mortalizesv(sv);
1023}
1024
1025void
1026Perl_save_freeop(pTHX_ OP *o)
1027{
2fd8beea
NC
1028 save_freeop(o);
1029}
1030
1031void
1032Perl_save_freepv(pTHX_ char *pv)
1033{
2fd8beea
NC
1034 save_freepv(pv);
1035}
1036
1037void
1038Perl_save_op(pTHX)
1039{
2fd8beea
NC
1040 save_op();
1041}
1042
d5713896
NC
1043#ifdef PERL_DONT_CREATE_GVSV
1044GV *
1045Perl_gv_SVadd(pTHX_ GV *gv)
1046{
d5713896
NC
1047 return gv_SVadd(gv);
1048}
1049#endif
1050
1051GV *
1052Perl_gv_AVadd(pTHX_ GV *gv)
1053{
d5713896
NC
1054 return gv_AVadd(gv);
1055}
1056
1057GV *
5aaab254 1058Perl_gv_HVadd(pTHX_ GV *gv)
d5713896 1059{
d5713896
NC
1060 return gv_HVadd(gv);
1061}
1062
bb85b28a 1063GV *
5aaab254 1064Perl_gv_IOadd(pTHX_ GV *gv)
bb85b28a
NC
1065{
1066 return gv_IOadd(gv);
1067}
1068
85dca89a
NC
1069IO *
1070Perl_newIO(pTHX)
1071{
1072 return MUTABLE_IO(newSV_type(SVt_PVIO));
1073}
1074
0d7d409d
DM
1075I32
1076Perl_my_stat(pTHX)
1077{
1078 return my_stat_flags(SV_GMAGIC);
1079}
1080
1081I32
1082Perl_my_lstat(pTHX)
1083{
1084 return my_lstat_flags(SV_GMAGIC);
1085}
1086
078504b2 1087I32
5aaab254 1088Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
078504b2
FC
1089{
1090 return sv_eq_flags(sv1, sv2, SV_GMAGIC);
1091}
1092
6129b56c 1093#ifdef USE_LOCALE_COLLATE
078504b2
FC
1094char *
1095Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
1096{
1097 return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
1098}
6129b56c 1099#endif
078504b2 1100
06c841cf 1101bool
5aaab254 1102Perl_sv_2bool(pTHX_ SV *const sv)
06c841cf
FC
1103{
1104 return sv_2bool_flags(sv, SV_GMAGIC);
1105}
1106
1830b3d9 1107
9733086d
BM
1108/*
1109=for apidoc custom_op_name
796b6530 1110Return the name for a given custom op. This was once used by the C<OP_NAME>
9733086d
BM
1111macro, but is no longer: it has only been kept for compatibility, and
1112should not be used.
1113
1114=for apidoc custom_op_desc
72d33970 1115Return the description of a given custom op. This was once used by the
796b6530 1116C<OP_DESC> macro, but is no longer: it has only been kept for
9733086d
BM
1117compatibility, and should not be used.
1118
1119=cut
1120*/
1121
1830b3d9
BM
1122const char*
1123Perl_custom_op_name(pTHX_ const OP* o)
1124{
1125 PERL_ARGS_ASSERT_CUSTOM_OP_NAME;
ae103e09 1126 return XopENTRYCUSTOM(o, xop_name);
1830b3d9
BM
1127}
1128
1129const char*
1130Perl_custom_op_desc(pTHX_ const OP* o)
1131{
1132 PERL_ARGS_ASSERT_CUSTOM_OP_DESC;
ae103e09 1133 return XopENTRYCUSTOM(o, xop_desc);
1830b3d9 1134}
7bff8c33
NC
1135
1136CV *
1137Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
1138{
e8f91c91 1139 return newATTRSUB(floor, o, proto, NULL, block);
7bff8c33 1140}
0c9b0438
KW
1141
1142UV
1143Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1144{
1145 PERL_ARGS_ASSERT_TO_UTF8_FOLD;
1146
445bf929 1147 return _to_utf8_fold_flags(p, ustrp, lenp, FOLD_FLAGS_FULL);
0c9b0438
KW
1148}
1149
1150UV
1151Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1152{
1153 PERL_ARGS_ASSERT_TO_UTF8_LOWER;
1154
445bf929 1155 return _to_utf8_lower_flags(p, ustrp, lenp, FALSE);
0c9b0438
KW
1156}
1157
1158UV
1159Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1160{
1161 PERL_ARGS_ASSERT_TO_UTF8_TITLE;
1162
445bf929 1163 return _to_utf8_title_flags(p, ustrp, lenp, FALSE);
0c9b0438
KW
1164}
1165
1166UV
1167Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
1168{
1169 PERL_ARGS_ASSERT_TO_UTF8_UPPER;
1170
445bf929 1171 return _to_utf8_upper_flags(p, ustrp, lenp, FALSE);
0c9b0438
KW
1172}
1173
108cb980
FC
1174SV *
1175Perl_sv_mortalcopy(pTHX_ SV *const oldstr)
1176{
33971c01 1177 return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC);
108cb980
FC
1178}
1179
e4524c4c
DD
1180void
1181Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
1182{
1183 PERL_ARGS_ASSERT_SV_COPYPV;
1184
1185 sv_copypv_flags(dsv, ssv, 0);
1186}
1187
3d81eea6
KW
1188UV /* Made into a function, so can be deprecated */
1189NATIVE_TO_NEED(const UV enc, const UV ch)
1190{
1191 PERL_UNUSED_ARG(enc);
1192 return ch;
1193}
1194
1195UV /* Made into a function, so can be deprecated */
1196ASCII_TO_NEED(const UV enc, const UV ch)
1197{
1198 PERL_UNUSED_ARG(enc);
1199 return ch;
1200}
1201
f2645549
KW
1202bool /* Made into a function, so can be deprecated */
1203Perl_isIDFIRST_lazy(pTHX_ const char* p)
1204{
1205 PERL_ARGS_ASSERT_ISIDFIRST_LAZY;
1206
1207 return isIDFIRST_lazy_if(p,1);
1208}
1209
1210bool /* Made into a function, so can be deprecated */
1211Perl_isALNUM_lazy(pTHX_ const char* p)
1212{
1213 PERL_ARGS_ASSERT_ISALNUM_LAZY;
1214
1215 return isALNUM_lazy_if(p,1);
1216}
1217
dc2e544e
KW
1218bool
1219Perl_is_uni_alnum(pTHX_ UV c)
1220{
1221 return isWORDCHAR_uni(c);
1222}
1223
1224bool
1225Perl_is_uni_alnumc(pTHX_ UV c)
1226{
1227 return isALNUM_uni(c);
1228}
1229
1230bool
1231Perl_is_uni_alpha(pTHX_ UV c)
1232{
1233 return isALPHA_uni(c);
1234}
1235
1236bool
1237Perl_is_uni_ascii(pTHX_ UV c)
1238{
81611534 1239 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1240 return isASCII_uni(c);
1241}
1242
1243bool
1244Perl_is_uni_blank(pTHX_ UV c)
1245{
81611534 1246 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1247 return isBLANK_uni(c);
1248}
1249
1250bool
1251Perl_is_uni_space(pTHX_ UV c)
1252{
81611534 1253 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1254 return isSPACE_uni(c);
1255}
1256
1257bool
1258Perl_is_uni_digit(pTHX_ UV c)
1259{
81611534 1260 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1261 return isDIGIT_uni(c);
1262}
1263
1264bool
1265Perl_is_uni_upper(pTHX_ UV c)
1266{
81611534 1267 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1268 return isUPPER_uni(c);
1269}
1270
1271bool
1272Perl_is_uni_lower(pTHX_ UV c)
1273{
81611534 1274 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1275 return isLOWER_uni(c);
1276}
1277
1278bool
1279Perl_is_uni_cntrl(pTHX_ UV c)
1280{
81611534 1281 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1282 return isCNTRL_L1(c);
1283}
1284
1285bool
1286Perl_is_uni_graph(pTHX_ UV c)
1287{
81611534 1288 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1289 return isGRAPH_uni(c);
1290}
1291
1292bool
1293Perl_is_uni_print(pTHX_ UV c)
1294{
81611534 1295 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1296 return isPRINT_uni(c);
1297}
1298
1299bool
1300Perl_is_uni_punct(pTHX_ UV c)
1301{
81611534 1302 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1303 return isPUNCT_uni(c);
1304}
1305
1306bool
1307Perl_is_uni_xdigit(pTHX_ UV c)
1308{
81611534 1309 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1310 return isXDIGIT_uni(c);
1311}
1312
1313bool
1314Perl_is_uni_alnum_lc(pTHX_ UV c)
1315{
81611534 1316 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1317 return isWORDCHAR_LC_uvchr(c);
1318}
1319
1320bool
1321Perl_is_uni_alnumc_lc(pTHX_ UV c)
1322{
81611534 1323 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1324 return isALPHANUMERIC_LC_uvchr(c);
1325}
1326
1327bool
1328Perl_is_uni_idfirst_lc(pTHX_ UV c)
1329{
81611534 1330 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1331 /* XXX Should probably be something that resolves to the old IDFIRST, but
1332 * this function is deprecated, so not bothering */
1333 return isIDFIRST_LC_uvchr(c);
1334}
1335
1336bool
1337Perl_is_uni_alpha_lc(pTHX_ UV c)
1338{
81611534 1339 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1340 return isALPHA_LC_uvchr(c);
1341}
1342
1343bool
1344Perl_is_uni_ascii_lc(pTHX_ UV c)
1345{
81611534 1346 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1347 return isASCII_LC_uvchr(c);
1348}
1349
1350bool
1351Perl_is_uni_blank_lc(pTHX_ UV c)
1352{
81611534 1353 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1354 return isBLANK_LC_uvchr(c);
1355}
1356
1357bool
1358Perl_is_uni_space_lc(pTHX_ UV c)
1359{
81611534 1360 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1361 return isSPACE_LC_uvchr(c);
1362}
1363
1364bool
1365Perl_is_uni_digit_lc(pTHX_ UV c)
1366{
1367 return isDIGIT_LC_uvchr(c);
1368}
1369
1370bool
f2645549
KW
1371Perl_is_uni_idfirst(pTHX_ UV c)
1372{
1373 U8 tmpbuf[UTF8_MAXBYTES+1];
1374 uvchr_to_utf8(tmpbuf, c);
1375 return _is_utf8_idstart(tmpbuf);
1376}
1377
1378bool
1379Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */
1380{
f2645549
KW
1381 PERL_ARGS_ASSERT_IS_UTF8_IDFIRST;
1382
1383 return _is_utf8_idstart(p);
1384}
1385
1386bool
1387Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */
1388{
f2645549
KW
1389 PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST;
1390
1391 return _is_utf8_xidstart(p);
1392}
1393
1394bool
1395Perl_is_utf8_idcont(pTHX_ const U8 *p)
1396{
f2645549
KW
1397 PERL_ARGS_ASSERT_IS_UTF8_IDCONT;
1398
1399 return _is_utf8_idcont(p);
1400}
1401
1402bool
1403Perl_is_utf8_xidcont(pTHX_ const U8 *p)
1404{
f2645549
KW
1405 PERL_ARGS_ASSERT_IS_UTF8_XIDCONT;
1406
1407 return _is_utf8_xidcont(p);
1408}
1409
1410bool
dc2e544e
KW
1411Perl_is_uni_upper_lc(pTHX_ UV c)
1412{
1413 return isUPPER_LC_uvchr(c);
1414}
1415
1416bool
1417Perl_is_uni_lower_lc(pTHX_ UV c)
1418{
1419 return isLOWER_LC_uvchr(c);
1420}
1421
1422bool
1423Perl_is_uni_cntrl_lc(pTHX_ UV c)
1424{
1425 return isCNTRL_LC_uvchr(c);
1426}
1427
1428bool
1429Perl_is_uni_graph_lc(pTHX_ UV c)
1430{
1431 return isGRAPH_LC_uvchr(c);
1432}
1433
1434bool
1435Perl_is_uni_print_lc(pTHX_ UV c)
1436{
1437 return isPRINT_LC_uvchr(c);
1438}
1439
1440bool
1441Perl_is_uni_punct_lc(pTHX_ UV c)
1442{
1443 return isPUNCT_LC_uvchr(c);
1444}
1445
1446bool
1447Perl_is_uni_xdigit_lc(pTHX_ UV c)
1448{
1449 return isXDIGIT_LC_uvchr(c);
1450}
1451
1452U32
1453Perl_to_uni_upper_lc(pTHX_ U32 c)
1454{
1455 /* XXX returns only the first character -- do not use XXX */
1456 /* XXX no locale support yet */
1457 STRLEN len;
1458 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1459 return (U32)to_uni_upper(c, tmpbuf, &len);
1460}
1461
1462U32
1463Perl_to_uni_title_lc(pTHX_ U32 c)
1464{
1465 /* XXX returns only the first character XXX -- do not use XXX */
1466 /* XXX no locale support yet */
1467 STRLEN len;
1468 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1469 return (U32)to_uni_title(c, tmpbuf, &len);
1470}
1471
1472U32
1473Perl_to_uni_lower_lc(pTHX_ U32 c)
1474{
1475 /* XXX returns only the first character -- do not use XXX */
1476 /* XXX no locale support yet */
1477 STRLEN len;
1478 U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
1479 return (U32)to_uni_lower(c, tmpbuf, &len);
1480}
1481
1482bool
1483Perl_is_utf8_alnum(pTHX_ const U8 *p)
1484{
dc2e544e
KW
1485 PERL_ARGS_ASSERT_IS_UTF8_ALNUM;
1486
1487 /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
1488 * descendant of isalnum(3), in other words, it doesn't
1489 * contain the '_'. --jhi */
1490 return isWORDCHAR_utf8(p);
1491}
1492
1493bool
1494Perl_is_utf8_alnumc(pTHX_ const U8 *p)
1495{
dc2e544e
KW
1496 PERL_ARGS_ASSERT_IS_UTF8_ALNUMC;
1497
1498 return isALPHANUMERIC_utf8(p);
1499}
1500
1501bool
1502Perl_is_utf8_alpha(pTHX_ const U8 *p)
1503{
dc2e544e
KW
1504 PERL_ARGS_ASSERT_IS_UTF8_ALPHA;
1505
1506 return isALPHA_utf8(p);
1507}
1508
1509bool
1510Perl_is_utf8_ascii(pTHX_ const U8 *p)
1511{
dc2e544e 1512 PERL_ARGS_ASSERT_IS_UTF8_ASCII;
81611534 1513 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1514
1515 return isASCII_utf8(p);
1516}
1517
1518bool
1519Perl_is_utf8_blank(pTHX_ const U8 *p)
1520{
dc2e544e 1521 PERL_ARGS_ASSERT_IS_UTF8_BLANK;
81611534 1522 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1523
1524 return isBLANK_utf8(p);
1525}
1526
1527bool
1528Perl_is_utf8_space(pTHX_ const U8 *p)
1529{
dc2e544e 1530 PERL_ARGS_ASSERT_IS_UTF8_SPACE;
81611534 1531 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1532
1533 return isSPACE_utf8(p);
1534}
1535
1536bool
1537Perl_is_utf8_perl_space(pTHX_ const U8 *p)
1538{
dc2e544e 1539 PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE;
81611534 1540 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1541
1542 /* Only true if is an ASCII space-like character, and ASCII is invariant
1543 * under utf8, so can just use the macro */
1544 return isSPACE_A(*p);
1545}
1546
1547bool
1548Perl_is_utf8_perl_word(pTHX_ const U8 *p)
1549{
dc2e544e 1550 PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD;
81611534 1551 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1552
1553 /* Only true if is an ASCII word character, and ASCII is invariant
1554 * under utf8, so can just use the macro */
1555 return isWORDCHAR_A(*p);
1556}
1557
1558bool
1559Perl_is_utf8_digit(pTHX_ const U8 *p)
1560{
dc2e544e
KW
1561 PERL_ARGS_ASSERT_IS_UTF8_DIGIT;
1562
1563 return isDIGIT_utf8(p);
1564}
1565
1566bool
1567Perl_is_utf8_posix_digit(pTHX_ const U8 *p)
1568{
dc2e544e 1569 PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT;
81611534 1570 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1571
1572 /* Only true if is an ASCII digit character, and ASCII is invariant
1573 * under utf8, so can just use the macro */
1574 return isDIGIT_A(*p);
1575}
1576
1577bool
1578Perl_is_utf8_upper(pTHX_ const U8 *p)
1579{
dc2e544e
KW
1580 PERL_ARGS_ASSERT_IS_UTF8_UPPER;
1581
1582 return isUPPER_utf8(p);
1583}
1584
1585bool
1586Perl_is_utf8_lower(pTHX_ const U8 *p)
1587{
dc2e544e
KW
1588 PERL_ARGS_ASSERT_IS_UTF8_LOWER;
1589
1590 return isLOWER_utf8(p);
1591}
1592
1593bool
1594Perl_is_utf8_cntrl(pTHX_ const U8 *p)
1595{
dc2e544e 1596 PERL_ARGS_ASSERT_IS_UTF8_CNTRL;
81611534 1597 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1598
1599 return isCNTRL_utf8(p);
1600}
1601
1602bool
1603Perl_is_utf8_graph(pTHX_ const U8 *p)
1604{
dc2e544e
KW
1605 PERL_ARGS_ASSERT_IS_UTF8_GRAPH;
1606
1607 return isGRAPH_utf8(p);
1608}
1609
1610bool
1611Perl_is_utf8_print(pTHX_ const U8 *p)
1612{
dc2e544e
KW
1613 PERL_ARGS_ASSERT_IS_UTF8_PRINT;
1614
1615 return isPRINT_utf8(p);
1616}
1617
1618bool
1619Perl_is_utf8_punct(pTHX_ const U8 *p)
1620{
dc2e544e
KW
1621 PERL_ARGS_ASSERT_IS_UTF8_PUNCT;
1622
1623 return isPUNCT_utf8(p);
1624}
1625
1626bool
1627Perl_is_utf8_xdigit(pTHX_ const U8 *p)
1628{
dc2e544e 1629 PERL_ARGS_ASSERT_IS_UTF8_XDIGIT;
81611534 1630 PERL_UNUSED_CONTEXT;
dc2e544e
KW
1631
1632 return isXDIGIT_utf8(p);
1633}
1634
1635bool
1636Perl_is_utf8_mark(pTHX_ const U8 *p)
1637{
dc2e544e
KW
1638 PERL_ARGS_ASSERT_IS_UTF8_MARK;
1639
1640 return _is_utf8_mark(p);
1641}
1642
f2645549
KW
1643/*
1644=for apidoc is_utf8_char
1645
1646Tests if some arbitrary number of bytes begins in a valid UTF-8
1647character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
1648character is a valid UTF-8 character. The actual number of bytes in the UTF-8
1649character will be returned if it is valid, otherwise 0.
1650
1651This function is deprecated due to the possibility that malformed input could
1652cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR>
1653instead.
1654
1655=cut */
1656
1657STRLEN
1658Perl_is_utf8_char(const U8 *s)
1659{
1660 PERL_ARGS_ASSERT_IS_UTF8_CHAR;
1661
1662 /* Assumes we have enough space, which is why this is deprecated */
1663 return isUTF8_CHAR(s, s + UTF8SKIP(s));
1664}
1665
e4524c4c
DD
1666/*
1667=for apidoc is_utf8_char_buf
1668
1669This is identical to the macro L</isUTF8_CHAR>.
1670
1671=cut */
1672
1673STRLEN
1674Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
1675{
1676
1677 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
1678
1679 return isUTF8_CHAR(buf, buf_end);
1680}
1681
f2645549
KW
1682/* DEPRECATED!
1683 * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that
1684 * there are no malformations in the input UTF-8 string C<s>. Surrogates,
1685 * non-character code points, and non-Unicode code points are allowed */
1686
1687UV
1688Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
1689{
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
796b6530 1708C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
f2645549
KW
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_ARGS_ASSERT_UTF8_TO_UVUNI;
1753
1754 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
1755}
1756
09d7a3ba
FC
1757/*
1758=for apidoc Am|HV *|pad_compname_type|PADOFFSET po
1759
2d7f6611 1760Looks up the type of the lexical variable at position C<po> in the
09d7a3ba
FC
1761currently-compiling pad. If the variable is typed, the stash of the
1762class to which it is typed is returned. If not, C<NULL> is returned.
1763
1764=cut
1765*/
1766
1767HV *
1768Perl_pad_compname_type(pTHX_ const PADOFFSET po)
1769{
1770 return PAD_COMPNAME_TYPE(po);
1771}
1772
534dad48 1773/* return ptr to little string in big string, NULL if not found */
fb245905 1774/* The original version of this routine was donated by Corey Satten. */
534dad48
CB
1775
1776char *
1777Perl_instr(const char *big, const char *little)
1778{
534dad48 1779 PERL_ARGS_ASSERT_INSTR;
534dad48 1780
fb245905 1781 return instr((char *) big, (char *) little);
534dad48 1782}
0ddd4a5b 1783
20fac488
GA
1784#endif /* NO_MATHOMS */
1785
d5b2b27b 1786/*
14d04a33 1787 * ex: set ts=8 sts=4 sw=4 et:
7ee2227d 1788 */