]> perl5.git.perl.org Git - perl5.git/blob - mathoms.c This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse: exclude two new test files
[perl5.git] / mathoms.c
1 /*    mathoms.c
2  *
3  *    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4  *    2011, 2012 by Larry Wall and others
5  *
6  *    You may distribute under the terms of either the GNU General Public
7  *    License or the Artistic License, as specified in the README file.
8  *
9  */
10
11 /*
12  *  Anything that Hobbits had no immediate use for, but were unwilling to
13  *  throw away, they called a mathom.  Their dwellings were apt to become
14  *  rather crowded with mathoms, and many of the presents that passed from
15  *  hand to hand were of that sort.
16  *
17  *     [p.5 of _The Lord of the Rings_: "Prologue"]
18  */
19
20
21
22 /*
23  * This file contains mathoms, various binary artifacts from previous
24  * versions of Perl which we cannot completely remove from the core
25  * code. There is only one reason these days for functions should be here:
26  *
27  * 1) A function has 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  *
31  * It used to be that this was the way to handle the case were a function
32  * Perl_foo(...) had been replaced by a macro.  But see the 'm' flag discussion
33  * in embed.fnc for a better way to handle this.
34  *
35  * This file can't just be cleaned out periodically, because that would break
36  * builds with -DPERL_NO_SHORT_NAMES
37  *
38  * NOTE: ALL FUNCTIONS IN THIS FILE should have an entry with the 'b' flag in
39  * embed.fnc.
40  *
41  * To move a function to this file, simply cut and paste it here, and change
42  * its embed.fnc entry to additionally have the 'b' flag.  If, for some reason
43  * a function you'd like to be treated as mathoms can't be moved from its
44  * current place, simply enclose it between
45  *
46  * #ifndef NO_MATHOMS
47  *    ...
48  * #endif
49  *
50  * and add the 'b' flag in embed.fnc.
51  *
52  * The compilation of this file and the functions within it can be suppressed
53  * by adding this option to Configure:
54  *
55  *      -Accflags='-DNO_MATHOMS'
56  *
57  * Some of the functions here are also deprecated.
58  *
59  */
60
61
62 #include "EXTERN.h"
63 #define PERL_IN_MATHOMS_C
64 #include "perl.h"
65
66 #ifdef NO_MATHOMS
67 /* ..." warning: ISO C forbids an empty source file"
68    So make sure we have something in here by processing the headers anyway.
69  */
70 #else
71
72 /* The functions in this file should be able to call other deprecated functions
73  * without a compiler warning */
74 GCC_DIAG_IGNORE(-Wdeprecated-declarations)
75
76 /* ref() is now a macro using Perl_doref;
77  * this version provided for binary compatibility only.
78  */
79 OP *
80 Perl_ref(pTHX_ OP *o, I32 type)
81 {
82     return doref(o, type, TRUE);
83 }
84
85 void
86 Perl_sv_unref(pTHX_ SV *sv)
87 {
88     PERL_ARGS_ASSERT_SV_UNREF;
89
90     sv_unref_flags(sv, 0);
91 }
92
93 /*
94 =for apidoc_section $tainting
95 =for apidoc sv_taint
96
97 Taint an SV.  Use C<SvTAINTED_on> instead.
98
99 =cut
100 */
101
102 void
103 Perl_sv_taint(pTHX_ SV *sv)
104 {
105     PERL_ARGS_ASSERT_SV_TAINT;
106
107     sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
108 }
109
110 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
111  * this function provided for binary compatibility only
112  */
113
114 IV
115 Perl_sv_2iv(pTHX_ SV *sv)
116 {
117     PERL_ARGS_ASSERT_SV_2IV;
118
119     return sv_2iv_flags(sv, SV_GMAGIC);
120 }
121
122 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
123  * this function provided for binary compatibility only
124  */
125
126 UV
127 Perl_sv_2uv(pTHX_ SV *sv)
128 {
129     PERL_ARGS_ASSERT_SV_2UV;
130
131     return sv_2uv_flags(sv, SV_GMAGIC);
132 }
133
134 /* sv_2nv() is now a macro using Perl_sv_2nv_flags();
135  * this function provided for binary compatibility only
136  */
137
138 NV
139 Perl_sv_2nv(pTHX_ SV *sv)
140 {
141     return sv_2nv_flags(sv, SV_GMAGIC);
142 }
143
144
145 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
146  * this function provided for binary compatibility only
147  */
148
149 char *
150 Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
151 {
152     PERL_ARGS_ASSERT_SV_2PV;
153
154     return sv_2pv_flags(sv, lp, SV_GMAGIC);
155 }
156
157 /*
158 =for apidoc_section $SV
159 =for apidoc sv_2pv_nolen
160
161 Like C<sv_2pv()>, but doesn't return the length too.  You should usually
162 use the macro wrapper C<SvPV_nolen(sv)> instead.
163
164 =cut
165 */
166
167 char *
168 Perl_sv_2pv_nolen(pTHX_ SV *sv)
169 {
170     PERL_ARGS_ASSERT_SV_2PV_NOLEN;
171     return sv_2pv(sv, NULL);
172 }
173
174 /*
175 =for apidoc_section $SV
176 =for apidoc sv_2pvbyte_nolen
177
178 Return a pointer to the byte-encoded representation of the SV.
179 May cause the SV to be downgraded from UTF-8 as a side-effect.
180
181 Usually accessed via the C<SvPVbyte_nolen> macro.
182
183 =cut
184 */
185
186 char *
187 Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
188 {
189     PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
190
191     return sv_2pvbyte(sv, NULL);
192 }
193
194 /*
195 =for apidoc_section $SV
196 =for apidoc sv_2pvutf8_nolen
197
198 Return a pointer to the UTF-8-encoded representation of the SV.
199 May cause the SV to be upgraded to UTF-8 as a side-effect.
200
201 Usually accessed via the C<SvPVutf8_nolen> macro.
202
203 =cut
204 */
205
206 char *
207 Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
208 {
209     PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
210
211     return sv_2pvutf8(sv, NULL);
212 }
213
214 void
215 Perl_sv_force_normal(pTHX_ SV *sv)
216 {
217     PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
218
219     sv_force_normal_flags(sv, 0);
220 }
221
222 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
223  * this function provided for binary compatibility only
224  */
225
226 void
227 Perl_sv_setsv(pTHX_ SV *dsv, SV *ssv)
228 {
229     PERL_ARGS_ASSERT_SV_SETSV;
230
231     sv_setsv_flags(dsv, ssv, SV_GMAGIC);
232 }
233
234 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
235  * this function provided for binary compatibility only
236  */
237
238 void
239 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
240 {
241     PERL_ARGS_ASSERT_SV_CATPVN;
242
243     sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
244 }
245
246 void
247 Perl_sv_catpvn_mg(pTHX_ SV *dsv, const char *sstr, STRLEN len)
248 {
249     PERL_ARGS_ASSERT_SV_CATPVN_MG;
250
251     sv_catpvn_flags(dsv,sstr,len,SV_GMAGIC|SV_SMAGIC);
252 }
253
254 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
255  * this function provided for binary compatibility only
256  */
257
258 void
259 Perl_sv_catsv(pTHX_ SV *dsv, SV * const sstr)
260 {
261     PERL_ARGS_ASSERT_SV_CATSV;
262
263     sv_catsv_flags(dsv, sstr, SV_GMAGIC);
264 }
265
266 void
267 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV * const sstr)
268 {
269     PERL_ARGS_ASSERT_SV_CATSV_MG;
270
271     sv_catsv_flags(dsv,sstr,SV_GMAGIC|SV_SMAGIC);
272 }
273
274 /*
275 =for apidoc_section $SV
276 =for apidoc sv_pv
277
278 Use the C<SvPV_nolen> macro instead
279
280 =cut
281 */
282
283 /* sv_pv() is now a macro using SvPV_nolen();
284  * this function provided for binary compatibility only
285  */
286
287 char *
288 Perl_sv_pv(pTHX_ SV *sv)
289 {
290     PERL_ARGS_ASSERT_SV_PV;
291
292     if (SvPOK(sv))
293         return SvPVX(sv);
294
295     return sv_2pv(sv, NULL);
296 }
297
298 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
299  * this function provided for binary compatibility only
300  */
301
302 char *
303 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
304 {
305     PERL_ARGS_ASSERT_SV_PVN_FORCE;
306
307     return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
308 }
309
310 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
311  * this function provided for binary compatibility only
312  */
313
314 char *
315 Perl_sv_pvbyte(pTHX_ SV *sv)
316 {
317     PERL_ARGS_ASSERT_SV_PVBYTE;
318
319     (void)sv_utf8_downgrade(sv, FALSE);
320     return sv_pv(sv);
321 }
322
323 /*
324 =for apidoc_section $SV
325 =for apidoc sv_pvbyte
326
327 Use C<SvPVbyte_nolen> instead.
328
329 =cut
330 */
331
332 /*
333 =for apidoc_section $SV
334 =for apidoc sv_pvutf8
335
336 Use the C<SvPVutf8_nolen> macro instead
337
338 =cut
339 */
340
341
342 char *
343 Perl_sv_pvutf8(pTHX_ SV *sv)
344 {
345     PERL_ARGS_ASSERT_SV_PVUTF8;
346
347     sv_utf8_upgrade(sv);
348     return sv_pv(sv);
349 }
350
351 /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
352  * this function provided for binary compatibility only
353  */
354
355 STRLEN
356 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
357 {
358     PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
359
360     return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
361 }
362
363 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
364 /*
365  * This hack is to force load of "huge" support from libm.a
366  * So it is in perl for (say) POSIX to use.
367  * Needed for SunOS with Sun's 'acc' for example.
368  */
369 NV
370 Perl_huge(void)
371 {
372 #  if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
373     return HUGE_VALL;
374 #  else
375     return HUGE_VAL;
376 #  endif
377 }
378 #endif
379
380 void
381 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
382 {
383     PERL_ARGS_ASSERT_GV_FULLNAME3;
384
385     gv_fullname4(sv, gv, prefix, TRUE);
386 }
387
388 void
389 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
390 {
391     PERL_ARGS_ASSERT_GV_EFULLNAME3;
392
393     gv_efullname4(sv, gv, prefix, TRUE);
394 }
395
396 GV *
397 Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
398 {
399     PERL_ARGS_ASSERT_GV_FETCHMETHOD;
400
401     return gv_fetchmethod_autoload(stash, name, TRUE);
402 }
403
404 HE *
405 Perl_hv_iternext(pTHX_ HV *hv)
406 {
407     PERL_ARGS_ASSERT_HV_ITERNEXT;
408
409     return hv_iternext_flags(hv, 0);
410 }
411
412 void
413 Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
414 {
415     PERL_ARGS_ASSERT_HV_MAGIC;
416
417     sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
418 }
419
420 bool
421 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
422              int rawmode, int rawperm, PerlIO *supplied_fp)
423 {
424     PERL_ARGS_ASSERT_DO_OPEN;
425
426     return do_openn(gv, name, len, as_raw, rawmode, rawperm,
427                     supplied_fp, (SV **) NULL, 0);
428 }
429
430 #ifndef OS2
431 bool
432 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
433 {
434     PERL_ARGS_ASSERT_DO_AEXEC;
435
436     return do_aexec5(really, mark, sp, 0, 0);
437 }
438 #endif
439
440 /*
441 =for apidoc_section $SV
442 =for apidoc sv_nolocking
443
444 Dummy routine which "locks" an SV when there is no locking module present.
445 Exists to avoid test for a C<NULL> function pointer and because it could
446 potentially warn under some level of strict-ness.
447
448 "Superseded" by C<sv_nosharing()>.
449
450 =cut
451 */
452
453 void
454 Perl_sv_nolocking(pTHX_ SV *sv)
455 {
456     PERL_UNUSED_CONTEXT;
457     PERL_UNUSED_ARG(sv);
458 }
459
460
461 /*
462 =for apidoc_section $SV
463 =for apidoc sv_nounlocking
464
465 Dummy routine which "unlocks" an SV when there is no locking module present.
466 Exists to avoid test for a C<NULL> function pointer and because it could
467 potentially warn under some level of strict-ness.
468
469 "Superseded" by C<sv_nosharing()>.
470
471 =cut
472
473 PERL_UNLOCK_HOOK in intrpvar.h is the macro that refers to this, and guarantees
474 that mathoms gets loaded.
475
476 */
477
478 void
479 Perl_sv_nounlocking(pTHX_ SV *sv)
480 {
481     PERL_UNUSED_CONTEXT;
482     PERL_UNUSED_ARG(sv);
483 }
484
485 void
486 Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
487 {
488     PERL_ARGS_ASSERT_SV_USEPVN_MG;
489
490     sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
491 }
492
493
494 void
495 Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
496 {
497     PERL_ARGS_ASSERT_SV_USEPVN;
498
499     sv_usepvn_flags(sv,ptr,len, 0);
500 }
501
502 HE *
503 Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
504 {
505   return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
506 }
507
508 bool
509 Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
510 {
511     PERL_ARGS_ASSERT_HV_EXISTS_ENT;
512
513     return cBOOL(hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash));
514 }
515
516 HE *
517 Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
518 {
519     PERL_ARGS_ASSERT_HV_FETCH_ENT;
520
521     return (HE *)hv_common(hv, keysv, NULL, 0, 0, 
522                      (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
523 }
524
525 SV *
526 Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
527 {
528     PERL_ARGS_ASSERT_HV_DELETE_ENT;
529
530     return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
531                                 hash));
532 }
533
534 SV**
535 Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
536                     int flags)
537 {
538     return (SV**) hv_common(hv, NULL, key, klen, flags,
539                             (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
540 }
541
542 SV**
543 Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
544 {
545     STRLEN klen;
546     int flags;
547
548     if (klen_i32 < 0) {
549         klen = -klen_i32;
550         flags = HVhek_UTF8;
551     } else {
552         klen = klen_i32;
553         flags = 0;
554     }
555     return (SV **) hv_common(hv, NULL, key, klen, flags,
556                              (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
557 }
558
559 bool
560 Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
561 {
562     STRLEN klen;
563     int flags;
564
565     PERL_ARGS_ASSERT_HV_EXISTS;
566
567     if (klen_i32 < 0) {
568         klen = -klen_i32;
569         flags = HVhek_UTF8;
570     } else {
571         klen = klen_i32;
572         flags = 0;
573     }
574     return cBOOL(hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0));
575 }
576
577 SV**
578 Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
579 {
580     STRLEN klen;
581     int flags;
582
583     PERL_ARGS_ASSERT_HV_FETCH;
584
585     if (klen_i32 < 0) {
586         klen = -klen_i32;
587         flags = HVhek_UTF8;
588     } else {
589         klen = klen_i32;
590         flags = 0;
591     }
592     return (SV **) hv_common(hv, NULL, key, klen, flags,
593                              lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
594                              : HV_FETCH_JUST_SV, NULL, 0);
595 }
596
597 SV *
598 Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
599 {
600     STRLEN klen;
601     int k_flags;
602
603     PERL_ARGS_ASSERT_HV_DELETE;
604
605     if (klen_i32 < 0) {
606         klen = -klen_i32;
607         k_flags = HVhek_UTF8;
608     } else {
609         klen = klen_i32;
610         k_flags = 0;
611     }
612     return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
613                                 NULL, 0));
614 }
615
616 AV *
617 Perl_newAV(pTHX)
618 {
619     return MUTABLE_AV(newSV_type(SVt_PVAV));
620     /* sv_upgrade does AvREAL_only():
621     AvALLOC(av) = 0;
622     AvARRAY(av) = NULL;
623     AvMAX(av) = AvFILLp(av) = -1; */
624 }
625
626 HV *
627 Perl_newHV(pTHX)
628 {
629     HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
630     assert(!SvOK(hv));
631
632     return hv;
633 }
634
635 void
636 Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len, 
637               const char *const little, const STRLEN littlelen)
638 {
639     PERL_ARGS_ASSERT_SV_INSERT;
640     sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
641 }
642
643 void
644 Perl_save_freesv(pTHX_ SV *sv)
645 {
646     save_freesv(sv);
647 }
648
649 void
650 Perl_save_mortalizesv(pTHX_ SV *sv)
651 {
652     PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
653
654     save_mortalizesv(sv);
655 }
656
657 void
658 Perl_save_freeop(pTHX_ OP *o)
659 {
660     save_freeop(o);
661 }
662
663 void
664 Perl_save_freepv(pTHX_ char *pv)
665 {
666     save_freepv(pv);
667 }
668
669 void
670 Perl_save_op(pTHX)
671 {
672     save_op();
673 }
674
675 #ifdef PERL_DONT_CREATE_GVSV
676 GV *
677 Perl_gv_SVadd(pTHX_ GV *gv)
678 {
679     return gv_SVadd(gv);
680 }
681 #endif
682
683 GV *
684 Perl_gv_AVadd(pTHX_ GV *gv)
685 {
686     return gv_AVadd(gv);
687 }
688
689 GV *
690 Perl_gv_HVadd(pTHX_ GV *gv)
691 {
692     return gv_HVadd(gv);
693 }
694
695 GV *
696 Perl_gv_IOadd(pTHX_ GV *gv)
697 {
698     return gv_IOadd(gv);
699 }
700
701 IO *
702 Perl_newIO(pTHX)
703 {
704     return MUTABLE_IO(newSV_type(SVt_PVIO));
705 }
706
707 I32
708 Perl_my_stat(pTHX)
709 {
710     return my_stat_flags(SV_GMAGIC);
711 }
712
713 I32
714 Perl_my_lstat(pTHX)
715 {
716     return my_lstat_flags(SV_GMAGIC);
717 }
718
719 I32
720 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
721 {
722     return sv_eq_flags(sv1, sv2, SV_GMAGIC);
723 }
724
725 #ifdef USE_LOCALE_COLLATE
726 char *
727 Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
728 {
729     PERL_ARGS_ASSERT_SV_COLLXFRM;
730     return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
731 }
732
733 #endif
734
735 bool
736 Perl_sv_2bool(pTHX_ SV *const sv)
737 {
738     PERL_ARGS_ASSERT_SV_2BOOL;
739     return sv_2bool_flags(sv, SV_GMAGIC);
740 }
741
742 CV *
743 Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
744 {
745     return newATTRSUB(floor, o, proto, NULL, block);
746 }
747
748 SV *
749 Perl_sv_mortalcopy(pTHX_ SV *const oldsv)
750 {
751     return Perl_sv_mortalcopy_flags(aTHX_ oldsv, SV_GMAGIC);
752 }
753
754 void
755 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
756 {
757     PERL_ARGS_ASSERT_SV_COPYPV;
758
759     sv_copypv_flags(dsv, ssv, SV_GMAGIC);
760 }
761
762 STRLEN
763 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
764 {
765
766     PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
767
768     return isUTF8_CHAR(buf, buf_end);
769 }
770
771 /*
772 =for apidoc_section $unicode
773 =for apidoc utf8_to_uvuni
774
775 Returns the Unicode code point of the first character in the string C<s>
776 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
777 length, in bytes, of that character.
778
779 Some, but not all, UTF-8 malformations are detected, and in fact, some
780 malformed input could cause reading beyond the end of the input buffer, which
781 is one reason why this function is deprecated.  The other is that only in
782 extremely limited circumstances should the Unicode versus native code point be
783 of any interest to you.
784
785 If C<s> points to one of the detected malformations, and UTF8 warnings are
786 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
787 NULL) to -1.  If those warnings are off, the computed value if well-defined (or
788 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
789 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
790 next possible position in C<s> that could begin a non-malformed character.
791 See L<perlapi/utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
792
793 =cut
794 */
795
796 UV
797 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
798 {
799     PERL_UNUSED_CONTEXT;
800     PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
801
802     return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
803 }
804
805 SV *
806 Perl_newSVsv(pTHX_ SV *const old)
807 {
808     return newSVsv(old);
809 }
810
811 bool
812 Perl_sv_utf8_downgrade(pTHX_ SV *const sv, const bool fail_ok)
813 {
814     PERL_ARGS_ASSERT_SV_UTF8_DOWNGRADE;
815
816     return sv_utf8_downgrade(sv, fail_ok);
817 }
818
819 char *
820 Perl_sv_2pvutf8(pTHX_ SV *sv, STRLEN *const lp)
821 {
822     PERL_ARGS_ASSERT_SV_2PVUTF8;
823
824     return sv_2pvutf8(sv, lp);
825 }
826
827 char *
828 Perl_sv_2pvbyte(pTHX_ SV *sv, STRLEN *const lp)
829 {
830     PERL_ARGS_ASSERT_SV_2PVBYTE;
831
832     return sv_2pvbyte(sv, lp);
833 }
834
835 U8 *
836 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
837 {
838     PERL_ARGS_ASSERT_UVUNI_TO_UTF8;
839
840     return uvoffuni_to_utf8_flags(d, uv, 0);
841 }
842
843 /*
844 =for apidoc_section $unicode
845 =for apidoc utf8n_to_uvuni
846
847 Instead use L<perlapi/utf8_to_uv>, or rarely, L<perlapi/utf8_to_uv_flags>.
848
849 This function was useful for code that wanted to handle both EBCDIC and
850 ASCII platforms with Unicode properties, but starting in Perl v5.20, the
851 distinctions between the platforms have mostly been made invisible to most
852 code, so this function is quite unlikely to be what you want.  If you do need
853 this precise functionality, use instead L<perlapi/C<utf8_to_uv>> or
854 L<perlapi/C<utf8_to_uv_flags>> to calculate the native code point, and then
855 convert to Unicode using L<perlapi/C<NATIVE_TO_UNI>>.
856
857 =cut
858 */
859
860 UV
861 Perl_utf8n_to_uvuni(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
862 {
863     PERL_ARGS_ASSERT_UTF8N_TO_UVUNI;
864
865     return NATIVE_TO_UNI(utf8n_to_uvchr(s, curlen, retlen, flags));
866 }
867
868 UV
869 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
870 {
871     PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
872
873     /* This function is unsafe if malformed UTF-8 input is given it, which is
874      * why the function is deprecated.  If the first byte of the input
875      * indicates that there are more bytes remaining in the sequence that forms
876      * the character than there are in the input buffer, it can read past the
877      * end.  But we can make it safe if the input string happens to be
878      * NUL-terminated, as many strings in Perl are, by refusing to read past a
879      * NUL, which is what UTF8_CHK_SKIP() does.  A NUL indicates the start of
880      * the next character anyway.  If the input isn't NUL-terminated, the
881      * function remains unsafe, as it always has been. */
882
883     return utf8_to_uvchr_buf(s, s + UTF8_CHK_SKIP(s), retlen);
884 }
885
886 GCC_DIAG_RESTORE
887
888 #endif /* NO_MATHOMS */
889
890 /*
891  * ex: set ts=8 sts=4 sw=4 et:
892  */