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