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