1850e2753Smillert /* mathoms.c
2850e2753Smillert *
3898184e3Ssthen * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4898184e3Ssthen * 2011, 2012 by Larry Wall and others
5850e2753Smillert *
6850e2753Smillert * You may distribute under the terms of either the GNU General Public
7850e2753Smillert * License or the Artistic License, as specified in the README file.
8850e2753Smillert *
9850e2753Smillert */
10850e2753Smillert
11850e2753Smillert /*
1243003dfeSmillert * Anything that Hobbits had no immediate use for, but were unwilling to
13850e2753Smillert * throw away, they called a mathom. Their dwellings were apt to become
14850e2753Smillert * rather crowded with mathoms, and many of the presents that passed from
1543003dfeSmillert * hand to hand were of that sort.
1643003dfeSmillert *
1743003dfeSmillert * [p.5 of _The Lord of the Rings_: "Prologue"]
18850e2753Smillert */
19850e2753Smillert
2043003dfeSmillert
21850e2753Smillert
22850e2753Smillert /*
23850e2753Smillert * This file contains mathoms, various binary artifacts from previous
249f11ffb7Safresh1 * versions of Perl which we cannot completely remove from the core
259f11ffb7Safresh1 * code. There are two reasons functions should be here:
26850e2753Smillert *
2756d68f1eSafresh1 * 1) A function has been replaced by a macro within a minor release,
289f11ffb7Safresh1 * so XS modules compiled against an older release will expect to
299f11ffb7Safresh1 * still be able to link against the function
309f11ffb7Safresh1 * 2) A function Perl_foo(...) with #define foo Perl_foo(aTHX_ ...)
319f11ffb7Safresh1 * has been replaced by a macro, e.g. #define foo(...) foo_flags(...,0)
329f11ffb7Safresh1 * but XS code may still explicitly use the long form, i.e.
339f11ffb7Safresh1 * Perl_foo(aTHX_ ...)
34b8851fccSafresh1 *
35eac174f2Safresh1 * This file can't just be cleaned out periodically, because that would break
36eac174f2Safresh1 * builds with -DPERL_NO_SHORT_NAMES
37eac174f2Safresh1 *
389f11ffb7Safresh1 * NOTE: ALL FUNCTIONS IN THIS FILE should have an entry with the 'b' flag in
399f11ffb7Safresh1 * embed.fnc.
409f11ffb7Safresh1 *
419f11ffb7Safresh1 * To move a function to this file, simply cut and paste it here, and change
429f11ffb7Safresh1 * its embed.fnc entry to additionally have the 'b' flag. If, for some reason
439f11ffb7Safresh1 * a function you'd like to be treated as mathoms can't be moved from its
449f11ffb7Safresh1 * current place, simply enclose it between
459f11ffb7Safresh1 *
469f11ffb7Safresh1 * #ifndef NO_MATHOMS
479f11ffb7Safresh1 * ...
489f11ffb7Safresh1 * #endif
499f11ffb7Safresh1 *
509f11ffb7Safresh1 * and add the 'b' flag in embed.fnc.
51850e2753Smillert *
5291f110e0Safresh1 * The compilation of this file can be suppressed; see INSTALL
5391f110e0Safresh1 *
549f11ffb7Safresh1 * Some blurb for perlapi.pod:
559f11ffb7Safresh1
56eac174f2Safresh1 head1 Obsolete backwards compatibility functions
579f11ffb7Safresh1
58b8851fccSafresh1 Some of these are also deprecated. You can exclude these from
59b8851fccSafresh1 your compiled Perl by adding this option to Configure:
60b8851fccSafresh1 C<-Accflags='-DNO_MATHOMS'>
61b8851fccSafresh1
62b8851fccSafresh1 =cut
63b8851fccSafresh1
64850e2753Smillert */
65850e2753Smillert
66b8851fccSafresh1
67850e2753Smillert #include "EXTERN.h"
68850e2753Smillert #define PERL_IN_MATHOMS_C
69850e2753Smillert #include "perl.h"
70850e2753Smillert
7143003dfeSmillert #ifdef NO_MATHOMS
7243003dfeSmillert /* ..." warning: ISO C forbids an empty source file"
7343003dfeSmillert So make sure we have something in here by processing the headers anyway.
7443003dfeSmillert */
7543003dfeSmillert #else
7643003dfeSmillert
7756d68f1eSafresh1 /* The functions in this file should be able to call other deprecated functions
7856d68f1eSafresh1 * without a compiler warning */
7956d68f1eSafresh1 GCC_DIAG_IGNORE(-Wdeprecated-declarations)
8056d68f1eSafresh1
81850e2753Smillert /* ref() is now a macro using Perl_doref;
82850e2753Smillert * this version provided for binary compatibility only.
83850e2753Smillert */
84850e2753Smillert OP *
Perl_ref(pTHX_ OP * o,I32 type)85850e2753Smillert Perl_ref(pTHX_ OP *o, I32 type)
86850e2753Smillert {
87850e2753Smillert return doref(o, type, TRUE);
88850e2753Smillert }
89850e2753Smillert
90850e2753Smillert /*
91eac174f2Safresh1 =for apidoc_section $SV
92850e2753Smillert =for apidoc sv_unref
93850e2753Smillert
94850e2753Smillert Unsets the RV status of the SV, and decrements the reference count of
95850e2753Smillert whatever was being referenced by the RV. This can almost be thought of
96850e2753Smillert as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
97b8851fccSafresh1 being zero. See C<L</SvROK_off>>.
98850e2753Smillert
99850e2753Smillert =cut
100850e2753Smillert */
101850e2753Smillert
102850e2753Smillert void
Perl_sv_unref(pTHX_ SV * sv)103850e2753Smillert Perl_sv_unref(pTHX_ SV *sv)
104850e2753Smillert {
10543003dfeSmillert PERL_ARGS_ASSERT_SV_UNREF;
10643003dfeSmillert
107850e2753Smillert sv_unref_flags(sv, 0);
108850e2753Smillert }
109850e2753Smillert
110850e2753Smillert /*
111eac174f2Safresh1 =for apidoc_section $tainting
112850e2753Smillert =for apidoc sv_taint
113850e2753Smillert
114850e2753Smillert Taint an SV. Use C<SvTAINTED_on> instead.
115898184e3Ssthen
116850e2753Smillert =cut
117850e2753Smillert */
118850e2753Smillert
119850e2753Smillert void
Perl_sv_taint(pTHX_ SV * sv)120850e2753Smillert Perl_sv_taint(pTHX_ SV *sv)
121850e2753Smillert {
12243003dfeSmillert PERL_ARGS_ASSERT_SV_TAINT;
12343003dfeSmillert
124850e2753Smillert sv_magic((sv), NULL, PERL_MAGIC_taint, NULL, 0);
125850e2753Smillert }
126850e2753Smillert
127850e2753Smillert /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
128850e2753Smillert * this function provided for binary compatibility only
129850e2753Smillert */
130850e2753Smillert
131850e2753Smillert IV
Perl_sv_2iv(pTHX_ SV * sv)13291f110e0Safresh1 Perl_sv_2iv(pTHX_ SV *sv)
133850e2753Smillert {
1346fb12b70Safresh1 PERL_ARGS_ASSERT_SV_2IV;
1356fb12b70Safresh1
136850e2753Smillert return sv_2iv_flags(sv, SV_GMAGIC);
137850e2753Smillert }
138850e2753Smillert
139850e2753Smillert /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
140850e2753Smillert * this function provided for binary compatibility only
141850e2753Smillert */
142850e2753Smillert
143850e2753Smillert UV
Perl_sv_2uv(pTHX_ SV * sv)14491f110e0Safresh1 Perl_sv_2uv(pTHX_ SV *sv)
145850e2753Smillert {
1466fb12b70Safresh1 PERL_ARGS_ASSERT_SV_2UV;
1476fb12b70Safresh1
148850e2753Smillert return sv_2uv_flags(sv, SV_GMAGIC);
149850e2753Smillert }
150850e2753Smillert
151898184e3Ssthen /* sv_2nv() is now a macro using Perl_sv_2nv_flags();
152898184e3Ssthen * this function provided for binary compatibility only
153898184e3Ssthen */
154898184e3Ssthen
155898184e3Ssthen NV
Perl_sv_2nv(pTHX_ SV * sv)15691f110e0Safresh1 Perl_sv_2nv(pTHX_ SV *sv)
157898184e3Ssthen {
158898184e3Ssthen return sv_2nv_flags(sv, SV_GMAGIC);
159898184e3Ssthen }
160898184e3Ssthen
161898184e3Ssthen
162850e2753Smillert /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
163850e2753Smillert * this function provided for binary compatibility only
164850e2753Smillert */
165850e2753Smillert
166850e2753Smillert char *
Perl_sv_2pv(pTHX_ SV * sv,STRLEN * lp)16791f110e0Safresh1 Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp)
168850e2753Smillert {
1696fb12b70Safresh1 PERL_ARGS_ASSERT_SV_2PV;
1706fb12b70Safresh1
171850e2753Smillert return sv_2pv_flags(sv, lp, SV_GMAGIC);
172850e2753Smillert }
173850e2753Smillert
174850e2753Smillert /*
175eac174f2Safresh1 =for apidoc_section $SV
176850e2753Smillert =for apidoc sv_2pv_nolen
177850e2753Smillert
178850e2753Smillert Like C<sv_2pv()>, but doesn't return the length too. You should usually
179850e2753Smillert use the macro wrapper C<SvPV_nolen(sv)> instead.
180898184e3Ssthen
181850e2753Smillert =cut
182850e2753Smillert */
183850e2753Smillert
184850e2753Smillert char *
Perl_sv_2pv_nolen(pTHX_ SV * sv)18591f110e0Safresh1 Perl_sv_2pv_nolen(pTHX_ SV *sv)
186850e2753Smillert {
187898184e3Ssthen PERL_ARGS_ASSERT_SV_2PV_NOLEN;
188850e2753Smillert return sv_2pv(sv, NULL);
189850e2753Smillert }
190850e2753Smillert
191850e2753Smillert /*
192eac174f2Safresh1 =for apidoc_section $SV
193850e2753Smillert =for apidoc sv_2pvbyte_nolen
194850e2753Smillert
195850e2753Smillert Return a pointer to the byte-encoded representation of the SV.
196850e2753Smillert May cause the SV to be downgraded from UTF-8 as a side-effect.
197850e2753Smillert
198850e2753Smillert Usually accessed via the C<SvPVbyte_nolen> macro.
199850e2753Smillert
200850e2753Smillert =cut
201850e2753Smillert */
202850e2753Smillert
203850e2753Smillert char *
Perl_sv_2pvbyte_nolen(pTHX_ SV * sv)20491f110e0Safresh1 Perl_sv_2pvbyte_nolen(pTHX_ SV *sv)
205850e2753Smillert {
20643003dfeSmillert PERL_ARGS_ASSERT_SV_2PVBYTE_NOLEN;
20743003dfeSmillert
208850e2753Smillert return sv_2pvbyte(sv, NULL);
209850e2753Smillert }
210850e2753Smillert
211850e2753Smillert /*
212eac174f2Safresh1 =for apidoc_section $SV
213850e2753Smillert =for apidoc sv_2pvutf8_nolen
214850e2753Smillert
215850e2753Smillert Return a pointer to the UTF-8-encoded representation of the SV.
216850e2753Smillert May cause the SV to be upgraded to UTF-8 as a side-effect.
217850e2753Smillert
218850e2753Smillert Usually accessed via the C<SvPVutf8_nolen> macro.
219850e2753Smillert
220850e2753Smillert =cut
221850e2753Smillert */
222850e2753Smillert
223850e2753Smillert char *
Perl_sv_2pvutf8_nolen(pTHX_ SV * sv)22491f110e0Safresh1 Perl_sv_2pvutf8_nolen(pTHX_ SV *sv)
225850e2753Smillert {
22643003dfeSmillert PERL_ARGS_ASSERT_SV_2PVUTF8_NOLEN;
22743003dfeSmillert
228850e2753Smillert return sv_2pvutf8(sv, NULL);
229850e2753Smillert }
230850e2753Smillert
231850e2753Smillert /*
232eac174f2Safresh1 =for apidoc_section $SV
233850e2753Smillert =for apidoc sv_force_normal
234850e2753Smillert
235850e2753Smillert Undo various types of fakery on an SV: if the PV is a shared string, make
236850e2753Smillert a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
237b8851fccSafresh1 an C<xpvmg>. See also C<L</sv_force_normal_flags>>.
238850e2753Smillert
239850e2753Smillert =cut
240850e2753Smillert */
241850e2753Smillert
242850e2753Smillert void
Perl_sv_force_normal(pTHX_ SV * sv)24391f110e0Safresh1 Perl_sv_force_normal(pTHX_ SV *sv)
244850e2753Smillert {
24543003dfeSmillert PERL_ARGS_ASSERT_SV_FORCE_NORMAL;
24643003dfeSmillert
247850e2753Smillert sv_force_normal_flags(sv, 0);
248850e2753Smillert }
249850e2753Smillert
250850e2753Smillert /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
251850e2753Smillert * this function provided for binary compatibility only
252850e2753Smillert */
253850e2753Smillert
254850e2753Smillert void
Perl_sv_setsv(pTHX_ SV * dsv,SV * ssv)255eac174f2Safresh1 Perl_sv_setsv(pTHX_ SV *dsv, SV *ssv)
256850e2753Smillert {
25743003dfeSmillert PERL_ARGS_ASSERT_SV_SETSV;
25843003dfeSmillert
259eac174f2Safresh1 sv_setsv_flags(dsv, ssv, SV_GMAGIC);
260850e2753Smillert }
261850e2753Smillert
262850e2753Smillert /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
263850e2753Smillert * this function provided for binary compatibility only
264850e2753Smillert */
265850e2753Smillert
266850e2753Smillert void
Perl_sv_catpvn(pTHX_ SV * dsv,const char * sstr,STRLEN slen)267850e2753Smillert Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
268850e2753Smillert {
26943003dfeSmillert PERL_ARGS_ASSERT_SV_CATPVN;
27043003dfeSmillert
271850e2753Smillert sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
272850e2753Smillert }
273850e2753Smillert
274850e2753Smillert void
Perl_sv_catpvn_mg(pTHX_ SV * dsv,const char * sstr,STRLEN len)275eac174f2Safresh1 Perl_sv_catpvn_mg(pTHX_ SV *dsv, const char *sstr, STRLEN len)
276850e2753Smillert {
27743003dfeSmillert PERL_ARGS_ASSERT_SV_CATPVN_MG;
27843003dfeSmillert
279eac174f2Safresh1 sv_catpvn_flags(dsv,sstr,len,SV_GMAGIC|SV_SMAGIC);
280850e2753Smillert }
281850e2753Smillert
282850e2753Smillert /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
283850e2753Smillert * this function provided for binary compatibility only
284850e2753Smillert */
285850e2753Smillert
286850e2753Smillert void
Perl_sv_catsv(pTHX_ SV * dsv,SV * sstr)287eac174f2Safresh1 Perl_sv_catsv(pTHX_ SV *dsv, SV *sstr)
288850e2753Smillert {
28943003dfeSmillert PERL_ARGS_ASSERT_SV_CATSV;
29043003dfeSmillert
291eac174f2Safresh1 sv_catsv_flags(dsv, sstr, SV_GMAGIC);
292850e2753Smillert }
293850e2753Smillert
294850e2753Smillert void
Perl_sv_catsv_mg(pTHX_ SV * dsv,SV * sstr)295eac174f2Safresh1 Perl_sv_catsv_mg(pTHX_ SV *dsv, SV *sstr)
296850e2753Smillert {
29743003dfeSmillert PERL_ARGS_ASSERT_SV_CATSV_MG;
29843003dfeSmillert
299eac174f2Safresh1 sv_catsv_flags(dsv,sstr,SV_GMAGIC|SV_SMAGIC);
300850e2753Smillert }
301850e2753Smillert
302850e2753Smillert /*
303eac174f2Safresh1 =for apidoc_section $SV
304850e2753Smillert =for apidoc sv_pv
305850e2753Smillert
306850e2753Smillert Use the C<SvPV_nolen> macro instead
307850e2753Smillert
308850e2753Smillert =cut
309850e2753Smillert */
310850e2753Smillert
311850e2753Smillert /* sv_pv() is now a macro using SvPV_nolen();
312850e2753Smillert * this function provided for binary compatibility only
313850e2753Smillert */
314850e2753Smillert
315850e2753Smillert char *
Perl_sv_pv(pTHX_ SV * sv)316850e2753Smillert Perl_sv_pv(pTHX_ SV *sv)
317850e2753Smillert {
31843003dfeSmillert PERL_ARGS_ASSERT_SV_PV;
31943003dfeSmillert
320850e2753Smillert if (SvPOK(sv))
321850e2753Smillert return SvPVX(sv);
322850e2753Smillert
323850e2753Smillert return sv_2pv(sv, NULL);
324850e2753Smillert }
325850e2753Smillert
326850e2753Smillert /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
327850e2753Smillert * this function provided for binary compatibility only
328850e2753Smillert */
329850e2753Smillert
330850e2753Smillert char *
Perl_sv_pvn_force(pTHX_ SV * sv,STRLEN * lp)331850e2753Smillert Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
332850e2753Smillert {
33343003dfeSmillert PERL_ARGS_ASSERT_SV_PVN_FORCE;
33443003dfeSmillert
335850e2753Smillert return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
336850e2753Smillert }
337850e2753Smillert
338850e2753Smillert /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
339850e2753Smillert * this function provided for binary compatibility only
340850e2753Smillert */
341850e2753Smillert
342850e2753Smillert char *
Perl_sv_pvbyte(pTHX_ SV * sv)343850e2753Smillert Perl_sv_pvbyte(pTHX_ SV *sv)
344850e2753Smillert {
34543003dfeSmillert PERL_ARGS_ASSERT_SV_PVBYTE;
34643003dfeSmillert
347*e0680481Safresh1 (void)sv_utf8_downgrade(sv, FALSE);
348850e2753Smillert return sv_pv(sv);
349850e2753Smillert }
350850e2753Smillert
351850e2753Smillert /*
352eac174f2Safresh1 =for apidoc_section $SV
353850e2753Smillert =for apidoc sv_pvbyte
354850e2753Smillert
355850e2753Smillert Use C<SvPVbyte_nolen> instead.
356850e2753Smillert
357*e0680481Safresh1 =cut
358*e0680481Safresh1 */
359850e2753Smillert
360*e0680481Safresh1 /*
361*e0680481Safresh1 =for apidoc_section $SV
362*e0680481Safresh1 =for apidoc sv_pvutf8
363*e0680481Safresh1
364*e0680481Safresh1 Use the C<SvPVutf8_nolen> macro instead
365850e2753Smillert
366850e2753Smillert =cut
367850e2753Smillert */
368850e2753Smillert
369850e2753Smillert
370850e2753Smillert char *
Perl_sv_pvutf8(pTHX_ SV * sv)371850e2753Smillert Perl_sv_pvutf8(pTHX_ SV *sv)
372850e2753Smillert {
37343003dfeSmillert PERL_ARGS_ASSERT_SV_PVUTF8;
37443003dfeSmillert
375850e2753Smillert sv_utf8_upgrade(sv);
376850e2753Smillert return sv_pv(sv);
377850e2753Smillert }
378850e2753Smillert
379850e2753Smillert /* sv_utf8_upgrade() is now a macro using sv_utf8_upgrade_flags();
380850e2753Smillert * this function provided for binary compatibility only
381850e2753Smillert */
382850e2753Smillert
383850e2753Smillert STRLEN
Perl_sv_utf8_upgrade(pTHX_ SV * sv)38491f110e0Safresh1 Perl_sv_utf8_upgrade(pTHX_ SV *sv)
385850e2753Smillert {
38643003dfeSmillert PERL_ARGS_ASSERT_SV_UTF8_UPGRADE;
38743003dfeSmillert
388850e2753Smillert return sv_utf8_upgrade_flags(sv, SV_GMAGIC);
389850e2753Smillert }
390850e2753Smillert
391850e2753Smillert #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
392850e2753Smillert /*
393850e2753Smillert * This hack is to force load of "huge" support from libm.a
394850e2753Smillert * So it is in perl for (say) POSIX to use.
395850e2753Smillert * Needed for SunOS with Sun's 'acc' for example.
396850e2753Smillert */
397850e2753Smillert NV
Perl_huge(void)398850e2753Smillert Perl_huge(void)
399850e2753Smillert {
400850e2753Smillert # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
401850e2753Smillert return HUGE_VALL;
402850e2753Smillert # else
403850e2753Smillert return HUGE_VAL;
404850e2753Smillert # endif
405850e2753Smillert }
406850e2753Smillert #endif
407850e2753Smillert
408850e2753Smillert void
Perl_gv_fullname3(pTHX_ SV * sv,const GV * gv,const char * prefix)409850e2753Smillert Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
410850e2753Smillert {
41143003dfeSmillert PERL_ARGS_ASSERT_GV_FULLNAME3;
41243003dfeSmillert
413850e2753Smillert gv_fullname4(sv, gv, prefix, TRUE);
414850e2753Smillert }
415850e2753Smillert
416850e2753Smillert void
Perl_gv_efullname3(pTHX_ SV * sv,const GV * gv,const char * prefix)417850e2753Smillert Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
418850e2753Smillert {
41943003dfeSmillert PERL_ARGS_ASSERT_GV_EFULLNAME3;
42043003dfeSmillert
421850e2753Smillert gv_efullname4(sv, gv, prefix, TRUE);
422850e2753Smillert }
423850e2753Smillert
424850e2753Smillert /*
425eac174f2Safresh1 =for apidoc_section $GV
426850e2753Smillert =for apidoc gv_fetchmethod
427850e2753Smillert
428898184e3Ssthen See L</gv_fetchmethod_autoload>.
429850e2753Smillert
430850e2753Smillert =cut
431850e2753Smillert */
432850e2753Smillert
433850e2753Smillert GV *
Perl_gv_fetchmethod(pTHX_ HV * stash,const char * name)434850e2753Smillert Perl_gv_fetchmethod(pTHX_ HV *stash, const char *name)
435850e2753Smillert {
43643003dfeSmillert PERL_ARGS_ASSERT_GV_FETCHMETHOD;
43743003dfeSmillert
438850e2753Smillert return gv_fetchmethod_autoload(stash, name, TRUE);
439850e2753Smillert }
440850e2753Smillert
441850e2753Smillert HE *
Perl_hv_iternext(pTHX_ HV * hv)442850e2753Smillert Perl_hv_iternext(pTHX_ HV *hv)
443850e2753Smillert {
44443003dfeSmillert PERL_ARGS_ASSERT_HV_ITERNEXT;
44543003dfeSmillert
446850e2753Smillert return hv_iternext_flags(hv, 0);
447850e2753Smillert }
448850e2753Smillert
449850e2753Smillert void
Perl_hv_magic(pTHX_ HV * hv,GV * gv,int how)450850e2753Smillert Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
451850e2753Smillert {
45243003dfeSmillert PERL_ARGS_ASSERT_HV_MAGIC;
45343003dfeSmillert
45443003dfeSmillert sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
455850e2753Smillert }
456850e2753Smillert
457850e2753Smillert bool
Perl_do_open(pTHX_ GV * gv,const char * name,I32 len,int as_raw,int rawmode,int rawperm,PerlIO * supplied_fp)45891f110e0Safresh1 Perl_do_open(pTHX_ GV *gv, const char *name, I32 len, int as_raw,
459850e2753Smillert int rawmode, int rawperm, PerlIO *supplied_fp)
460850e2753Smillert {
46143003dfeSmillert PERL_ARGS_ASSERT_DO_OPEN;
46243003dfeSmillert
463850e2753Smillert return do_openn(gv, name, len, as_raw, rawmode, rawperm,
464850e2753Smillert supplied_fp, (SV **) NULL, 0);
465850e2753Smillert }
466850e2753Smillert
467850e2753Smillert #ifndef OS2
468850e2753Smillert bool
Perl_do_aexec(pTHX_ SV * really,SV ** mark,SV ** sp)46991f110e0Safresh1 Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp)
470850e2753Smillert {
47143003dfeSmillert PERL_ARGS_ASSERT_DO_AEXEC;
47243003dfeSmillert
473850e2753Smillert return do_aexec5(really, mark, sp, 0, 0);
474850e2753Smillert }
475850e2753Smillert #endif
476850e2753Smillert
477850e2753Smillert bool
Perl_is_utf8_string_loc(const U8 * s,const STRLEN len,const U8 ** ep)4789f11ffb7Safresh1 Perl_is_utf8_string_loc(const U8 *s, const STRLEN len, const U8 **ep)
479850e2753Smillert {
48043003dfeSmillert PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC;
48143003dfeSmillert
482850e2753Smillert return is_utf8_string_loclen(s, len, ep, 0);
483850e2753Smillert }
484850e2753Smillert
485850e2753Smillert /*
486eac174f2Safresh1 =for apidoc_section $SV
487850e2753Smillert =for apidoc sv_nolocking
488850e2753Smillert
489850e2753Smillert Dummy routine which "locks" an SV when there is no locking module present.
490b8851fccSafresh1 Exists to avoid test for a C<NULL> function pointer and because it could
491850e2753Smillert potentially warn under some level of strict-ness.
492850e2753Smillert
493b8851fccSafresh1 "Superseded" by C<sv_nosharing()>.
494850e2753Smillert
495850e2753Smillert =cut
496850e2753Smillert */
497850e2753Smillert
498850e2753Smillert void
Perl_sv_nolocking(pTHX_ SV * sv)499850e2753Smillert Perl_sv_nolocking(pTHX_ SV *sv)
500850e2753Smillert {
501850e2753Smillert PERL_UNUSED_CONTEXT;
502850e2753Smillert PERL_UNUSED_ARG(sv);
503850e2753Smillert }
504850e2753Smillert
505850e2753Smillert
506850e2753Smillert /*
507eac174f2Safresh1 =for apidoc_section $SV
508850e2753Smillert =for apidoc sv_nounlocking
509850e2753Smillert
510850e2753Smillert Dummy routine which "unlocks" an SV when there is no locking module present.
511b8851fccSafresh1 Exists to avoid test for a C<NULL> function pointer and because it could
512850e2753Smillert potentially warn under some level of strict-ness.
513850e2753Smillert
514b8851fccSafresh1 "Superseded" by C<sv_nosharing()>.
515850e2753Smillert
516850e2753Smillert =cut
51756d68f1eSafresh1
51856d68f1eSafresh1 PERL_UNLOCK_HOOK in intrpvar.h is the macro that refers to this, and guarantees
51956d68f1eSafresh1 that mathoms gets loaded.
52056d68f1eSafresh1
521850e2753Smillert */
522850e2753Smillert
523850e2753Smillert void
Perl_sv_nounlocking(pTHX_ SV * sv)524850e2753Smillert Perl_sv_nounlocking(pTHX_ SV *sv)
525850e2753Smillert {
526850e2753Smillert PERL_UNUSED_CONTEXT;
527850e2753Smillert PERL_UNUSED_ARG(sv);
528850e2753Smillert }
529850e2753Smillert
530850e2753Smillert void
Perl_sv_usepvn_mg(pTHX_ SV * sv,char * ptr,STRLEN len)531850e2753Smillert Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len)
532850e2753Smillert {
53343003dfeSmillert PERL_ARGS_ASSERT_SV_USEPVN_MG;
53443003dfeSmillert
535850e2753Smillert sv_usepvn_flags(sv,ptr,len, SV_SMAGIC);
536850e2753Smillert }
537850e2753Smillert
538850e2753Smillert
539850e2753Smillert void
Perl_sv_usepvn(pTHX_ SV * sv,char * ptr,STRLEN len)540850e2753Smillert Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
541850e2753Smillert {
54243003dfeSmillert PERL_ARGS_ASSERT_SV_USEPVN;
54343003dfeSmillert
544850e2753Smillert sv_usepvn_flags(sv,ptr,len, 0);
545850e2753Smillert }
546850e2753Smillert
547850e2753Smillert HE *
Perl_hv_store_ent(pTHX_ HV * hv,SV * keysv,SV * val,U32 hash)548850e2753Smillert Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash)
549850e2753Smillert {
550850e2753Smillert return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash);
551850e2753Smillert }
552850e2753Smillert
553850e2753Smillert bool
Perl_hv_exists_ent(pTHX_ HV * hv,SV * keysv,U32 hash)554850e2753Smillert Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash)
555850e2753Smillert {
55643003dfeSmillert PERL_ARGS_ASSERT_HV_EXISTS_ENT;
55743003dfeSmillert
5589f11ffb7Safresh1 return cBOOL(hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash));
559850e2753Smillert }
560850e2753Smillert
561850e2753Smillert HE *
Perl_hv_fetch_ent(pTHX_ HV * hv,SV * keysv,I32 lval,U32 hash)562850e2753Smillert Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash)
563850e2753Smillert {
56443003dfeSmillert PERL_ARGS_ASSERT_HV_FETCH_ENT;
56543003dfeSmillert
566850e2753Smillert return (HE *)hv_common(hv, keysv, NULL, 0, 0,
567850e2753Smillert (lval ? HV_FETCH_LVALUE : 0), NULL, hash);
568850e2753Smillert }
569850e2753Smillert
570850e2753Smillert SV *
Perl_hv_delete_ent(pTHX_ HV * hv,SV * keysv,I32 flags,U32 hash)571850e2753Smillert Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
572850e2753Smillert {
57343003dfeSmillert PERL_ARGS_ASSERT_HV_DELETE_ENT;
57443003dfeSmillert
57543003dfeSmillert return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
57643003dfeSmillert hash));
577850e2753Smillert }
578850e2753Smillert
579850e2753Smillert SV**
Perl_hv_store_flags(pTHX_ HV * hv,const char * key,I32 klen,SV * val,U32 hash,int flags)580850e2753Smillert Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash,
581850e2753Smillert int flags)
582850e2753Smillert {
583850e2753Smillert return (SV**) hv_common(hv, NULL, key, klen, flags,
584850e2753Smillert (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
585850e2753Smillert }
586850e2753Smillert
587850e2753Smillert SV**
Perl_hv_store(pTHX_ HV * hv,const char * key,I32 klen_i32,SV * val,U32 hash)588850e2753Smillert Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash)
589850e2753Smillert {
590850e2753Smillert STRLEN klen;
591850e2753Smillert int flags;
592850e2753Smillert
593850e2753Smillert if (klen_i32 < 0) {
594850e2753Smillert klen = -klen_i32;
595850e2753Smillert flags = HVhek_UTF8;
596850e2753Smillert } else {
597850e2753Smillert klen = klen_i32;
598850e2753Smillert flags = 0;
599850e2753Smillert }
600850e2753Smillert return (SV **) hv_common(hv, NULL, key, klen, flags,
601850e2753Smillert (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash);
602850e2753Smillert }
603850e2753Smillert
604850e2753Smillert bool
Perl_hv_exists(pTHX_ HV * hv,const char * key,I32 klen_i32)605850e2753Smillert Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32)
606850e2753Smillert {
607850e2753Smillert STRLEN klen;
608850e2753Smillert int flags;
609850e2753Smillert
61043003dfeSmillert PERL_ARGS_ASSERT_HV_EXISTS;
61143003dfeSmillert
612850e2753Smillert if (klen_i32 < 0) {
613850e2753Smillert klen = -klen_i32;
614850e2753Smillert flags = HVhek_UTF8;
615850e2753Smillert } else {
616850e2753Smillert klen = klen_i32;
617850e2753Smillert flags = 0;
618850e2753Smillert }
6199f11ffb7Safresh1 return cBOOL(hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0));
620850e2753Smillert }
621850e2753Smillert
622850e2753Smillert SV**
Perl_hv_fetch(pTHX_ HV * hv,const char * key,I32 klen_i32,I32 lval)623850e2753Smillert Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval)
624850e2753Smillert {
625850e2753Smillert STRLEN klen;
626850e2753Smillert int flags;
627850e2753Smillert
62843003dfeSmillert PERL_ARGS_ASSERT_HV_FETCH;
62943003dfeSmillert
630850e2753Smillert if (klen_i32 < 0) {
631850e2753Smillert klen = -klen_i32;
632850e2753Smillert flags = HVhek_UTF8;
633850e2753Smillert } else {
634850e2753Smillert klen = klen_i32;
635850e2753Smillert flags = 0;
636850e2753Smillert }
637850e2753Smillert return (SV **) hv_common(hv, NULL, key, klen, flags,
638850e2753Smillert lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE)
639850e2753Smillert : HV_FETCH_JUST_SV, NULL, 0);
640850e2753Smillert }
641850e2753Smillert
642850e2753Smillert SV *
Perl_hv_delete(pTHX_ HV * hv,const char * key,I32 klen_i32,I32 flags)643850e2753Smillert Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
644850e2753Smillert {
645850e2753Smillert STRLEN klen;
646850e2753Smillert int k_flags;
647850e2753Smillert
64843003dfeSmillert PERL_ARGS_ASSERT_HV_DELETE;
64943003dfeSmillert
650850e2753Smillert if (klen_i32 < 0) {
651850e2753Smillert klen = -klen_i32;
652850e2753Smillert k_flags = HVhek_UTF8;
653850e2753Smillert } else {
654850e2753Smillert klen = klen_i32;
655850e2753Smillert k_flags = 0;
656850e2753Smillert }
65743003dfeSmillert return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
65843003dfeSmillert NULL, 0));
65943003dfeSmillert }
66043003dfeSmillert
66143003dfeSmillert AV *
Perl_newAV(pTHX)66243003dfeSmillert Perl_newAV(pTHX)
66343003dfeSmillert {
66443003dfeSmillert return MUTABLE_AV(newSV_type(SVt_PVAV));
66543003dfeSmillert /* sv_upgrade does AvREAL_only():
66643003dfeSmillert AvALLOC(av) = 0;
66743003dfeSmillert AvARRAY(av) = NULL;
66843003dfeSmillert AvMAX(av) = AvFILLp(av) = -1; */
66943003dfeSmillert }
67043003dfeSmillert
67143003dfeSmillert HV *
Perl_newHV(pTHX)67243003dfeSmillert Perl_newHV(pTHX)
67343003dfeSmillert {
67443003dfeSmillert HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
67543003dfeSmillert assert(!SvOK(hv));
67643003dfeSmillert
67743003dfeSmillert return hv;
67843003dfeSmillert }
67943003dfeSmillert
68043003dfeSmillert void
Perl_sv_insert(pTHX_ SV * const bigstr,const STRLEN offset,const STRLEN len,const char * const little,const STRLEN littlelen)681b39c5158Smillert Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
682b39c5158Smillert const char *const little, const STRLEN littlelen)
68343003dfeSmillert {
68443003dfeSmillert PERL_ARGS_ASSERT_SV_INSERT;
68543003dfeSmillert sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
68643003dfeSmillert }
68743003dfeSmillert
68843003dfeSmillert void
Perl_save_freesv(pTHX_ SV * sv)68943003dfeSmillert Perl_save_freesv(pTHX_ SV *sv)
69043003dfeSmillert {
69143003dfeSmillert save_freesv(sv);
69243003dfeSmillert }
69343003dfeSmillert
69443003dfeSmillert void
Perl_save_mortalizesv(pTHX_ SV * sv)69543003dfeSmillert Perl_save_mortalizesv(pTHX_ SV *sv)
69643003dfeSmillert {
69743003dfeSmillert PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
69843003dfeSmillert
69943003dfeSmillert save_mortalizesv(sv);
70043003dfeSmillert }
70143003dfeSmillert
70243003dfeSmillert void
Perl_save_freeop(pTHX_ OP * o)70343003dfeSmillert Perl_save_freeop(pTHX_ OP *o)
70443003dfeSmillert {
70543003dfeSmillert save_freeop(o);
70643003dfeSmillert }
70743003dfeSmillert
70843003dfeSmillert void
Perl_save_freepv(pTHX_ char * pv)70943003dfeSmillert Perl_save_freepv(pTHX_ char *pv)
71043003dfeSmillert {
71143003dfeSmillert save_freepv(pv);
71243003dfeSmillert }
71343003dfeSmillert
71443003dfeSmillert void
Perl_save_op(pTHX)71543003dfeSmillert Perl_save_op(pTHX)
71643003dfeSmillert {
71743003dfeSmillert save_op();
718850e2753Smillert }
719850e2753Smillert
720b39c5158Smillert #ifdef PERL_DONT_CREATE_GVSV
721b39c5158Smillert GV *
Perl_gv_SVadd(pTHX_ GV * gv)722b39c5158Smillert Perl_gv_SVadd(pTHX_ GV *gv)
723b39c5158Smillert {
724b39c5158Smillert return gv_SVadd(gv);
725b39c5158Smillert }
726b39c5158Smillert #endif
727b39c5158Smillert
728b39c5158Smillert GV *
Perl_gv_AVadd(pTHX_ GV * gv)729b39c5158Smillert Perl_gv_AVadd(pTHX_ GV *gv)
730b39c5158Smillert {
731b39c5158Smillert return gv_AVadd(gv);
732b39c5158Smillert }
733b39c5158Smillert
734b39c5158Smillert GV *
Perl_gv_HVadd(pTHX_ GV * gv)73591f110e0Safresh1 Perl_gv_HVadd(pTHX_ GV *gv)
736b39c5158Smillert {
737b39c5158Smillert return gv_HVadd(gv);
738b39c5158Smillert }
739b39c5158Smillert
740b39c5158Smillert GV *
Perl_gv_IOadd(pTHX_ GV * gv)74191f110e0Safresh1 Perl_gv_IOadd(pTHX_ GV *gv)
742b39c5158Smillert {
743b39c5158Smillert return gv_IOadd(gv);
744b39c5158Smillert }
745b39c5158Smillert
746b39c5158Smillert IO *
Perl_newIO(pTHX)747b39c5158Smillert Perl_newIO(pTHX)
748b39c5158Smillert {
749b39c5158Smillert return MUTABLE_IO(newSV_type(SVt_PVIO));
750b39c5158Smillert }
751b39c5158Smillert
752898184e3Ssthen I32
Perl_my_stat(pTHX)753898184e3Ssthen Perl_my_stat(pTHX)
754898184e3Ssthen {
755898184e3Ssthen return my_stat_flags(SV_GMAGIC);
756898184e3Ssthen }
757898184e3Ssthen
758898184e3Ssthen I32
Perl_my_lstat(pTHX)759898184e3Ssthen Perl_my_lstat(pTHX)
760898184e3Ssthen {
761898184e3Ssthen return my_lstat_flags(SV_GMAGIC);
762898184e3Ssthen }
763898184e3Ssthen
764898184e3Ssthen I32
Perl_sv_eq(pTHX_ SV * sv1,SV * sv2)76591f110e0Safresh1 Perl_sv_eq(pTHX_ SV *sv1, SV *sv2)
766898184e3Ssthen {
767898184e3Ssthen return sv_eq_flags(sv1, sv2, SV_GMAGIC);
768898184e3Ssthen }
769898184e3Ssthen
770898184e3Ssthen #ifdef USE_LOCALE_COLLATE
771898184e3Ssthen char *
Perl_sv_collxfrm(pTHX_ SV * const sv,STRLEN * const nxp)772898184e3Ssthen Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp)
773898184e3Ssthen {
7749f11ffb7Safresh1 PERL_ARGS_ASSERT_SV_COLLXFRM;
775898184e3Ssthen return sv_collxfrm_flags(sv, nxp, SV_GMAGIC);
776898184e3Ssthen }
7779f11ffb7Safresh1
778898184e3Ssthen #endif
779898184e3Ssthen
780898184e3Ssthen bool
Perl_sv_2bool(pTHX_ SV * const sv)78191f110e0Safresh1 Perl_sv_2bool(pTHX_ SV *const sv)
782898184e3Ssthen {
7839f11ffb7Safresh1 PERL_ARGS_ASSERT_SV_2BOOL;
784898184e3Ssthen return sv_2bool_flags(sv, SV_GMAGIC);
785898184e3Ssthen }
786898184e3Ssthen
787898184e3Ssthen CV *
Perl_newSUB(pTHX_ I32 floor,OP * o,OP * proto,OP * block)788898184e3Ssthen Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block)
789898184e3Ssthen {
7906fb12b70Safresh1 return newATTRSUB(floor, o, proto, NULL, block);
791898184e3Ssthen }
792898184e3Ssthen
79391f110e0Safresh1 SV *
Perl_sv_mortalcopy(pTHX_ SV * const oldsv)794eac174f2Safresh1 Perl_sv_mortalcopy(pTHX_ SV *const oldsv)
79591f110e0Safresh1 {
796eac174f2Safresh1 return Perl_sv_mortalcopy_flags(aTHX_ oldsv, SV_GMAGIC);
79791f110e0Safresh1 }
79891f110e0Safresh1
799b8851fccSafresh1 void
Perl_sv_copypv(pTHX_ SV * const dsv,SV * const ssv)800b8851fccSafresh1 Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv)
801b8851fccSafresh1 {
802b8851fccSafresh1 PERL_ARGS_ASSERT_SV_COPYPV;
803b8851fccSafresh1
8049f11ffb7Safresh1 sv_copypv_flags(dsv, ssv, SV_GMAGIC);
805b8851fccSafresh1 }
806b8851fccSafresh1
807b8851fccSafresh1 /*
808eac174f2Safresh1 =for apidoc_section $unicode
809b8851fccSafresh1 =for apidoc is_utf8_char_buf
810b8851fccSafresh1
81156d68f1eSafresh1 This is identical to the macro L<perlapi/isUTF8_CHAR>.
812b8851fccSafresh1
813b8851fccSafresh1 =cut */
814b8851fccSafresh1
815b8851fccSafresh1 STRLEN
Perl_is_utf8_char_buf(const U8 * buf,const U8 * buf_end)816b8851fccSafresh1 Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end)
817b8851fccSafresh1 {
818b8851fccSafresh1
819b8851fccSafresh1 PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF;
820b8851fccSafresh1
821b8851fccSafresh1 return isUTF8_CHAR(buf, buf_end);
822b8851fccSafresh1 }
823b8851fccSafresh1
824b8851fccSafresh1 /*
825eac174f2Safresh1 =for apidoc_section $unicode
826b8851fccSafresh1 =for apidoc utf8_to_uvuni
827b8851fccSafresh1
828b8851fccSafresh1 Returns the Unicode code point of the first character in the string C<s>
829b8851fccSafresh1 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
830b8851fccSafresh1 length, in bytes, of that character.
831b8851fccSafresh1
832b8851fccSafresh1 Some, but not all, UTF-8 malformations are detected, and in fact, some
833b8851fccSafresh1 malformed input could cause reading beyond the end of the input buffer, which
834b8851fccSafresh1 is one reason why this function is deprecated. The other is that only in
835b8851fccSafresh1 extremely limited circumstances should the Unicode versus native code point be
836*e0680481Safresh1 of any interest to you.
837b8851fccSafresh1
838b8851fccSafresh1 If C<s> points to one of the detected malformations, and UTF8 warnings are
839b8851fccSafresh1 enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
840b8851fccSafresh1 NULL) to -1. If those warnings are off, the computed value if well-defined (or
841b8851fccSafresh1 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
842b8851fccSafresh1 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
843b8851fccSafresh1 next possible position in C<s> that could begin a non-malformed character.
84456d68f1eSafresh1 See L<perlapi/utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
845b8851fccSafresh1
846b8851fccSafresh1 =cut
847b8851fccSafresh1 */
848b8851fccSafresh1
849b8851fccSafresh1 UV
Perl_utf8_to_uvuni(pTHX_ const U8 * s,STRLEN * retlen)850b8851fccSafresh1 Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen)
851b8851fccSafresh1 {
8529f11ffb7Safresh1 PERL_UNUSED_CONTEXT;
853b8851fccSafresh1 PERL_ARGS_ASSERT_UTF8_TO_UVUNI;
854b8851fccSafresh1
855b8851fccSafresh1 return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen));
856b8851fccSafresh1 }
857b8851fccSafresh1
8589f11ffb7Safresh1 /* return ptr to little string in big string, NULL if not found */
8599f11ffb7Safresh1 /* The original version of this routine was donated by Corey Satten. */
860b8851fccSafresh1
8619f11ffb7Safresh1 char *
Perl_instr(const char * big,const char * little)8629f11ffb7Safresh1 Perl_instr(const char *big, const char *little)
8639f11ffb7Safresh1 {
8649f11ffb7Safresh1 PERL_ARGS_ASSERT_INSTR;
8659f11ffb7Safresh1
866eac174f2Safresh1 return instr(big, little);
8679f11ffb7Safresh1 }
86891f110e0Safresh1
869b46d8ef2Safresh1 SV *
Perl_newSVsv(pTHX_ SV * const old)870b46d8ef2Safresh1 Perl_newSVsv(pTHX_ SV *const old)
871b46d8ef2Safresh1 {
872b46d8ef2Safresh1 return newSVsv(old);
873b46d8ef2Safresh1 }
874b46d8ef2Safresh1
87556d68f1eSafresh1 bool
Perl_sv_utf8_downgrade(pTHX_ SV * const sv,const bool fail_ok)87656d68f1eSafresh1 Perl_sv_utf8_downgrade(pTHX_ SV *const sv, const bool fail_ok)
87756d68f1eSafresh1 {
87856d68f1eSafresh1 PERL_ARGS_ASSERT_SV_UTF8_DOWNGRADE;
87956d68f1eSafresh1
88056d68f1eSafresh1 return sv_utf8_downgrade(sv, fail_ok);
88156d68f1eSafresh1 }
88256d68f1eSafresh1
88356d68f1eSafresh1 char *
Perl_sv_2pvutf8(pTHX_ SV * sv,STRLEN * const lp)88456d68f1eSafresh1 Perl_sv_2pvutf8(pTHX_ SV *sv, STRLEN *const lp)
88556d68f1eSafresh1 {
88656d68f1eSafresh1 PERL_ARGS_ASSERT_SV_2PVUTF8;
88756d68f1eSafresh1
88856d68f1eSafresh1 return sv_2pvutf8(sv, lp);
88956d68f1eSafresh1 }
89056d68f1eSafresh1
89156d68f1eSafresh1 char *
Perl_sv_2pvbyte(pTHX_ SV * sv,STRLEN * const lp)89256d68f1eSafresh1 Perl_sv_2pvbyte(pTHX_ SV *sv, STRLEN *const lp)
89356d68f1eSafresh1 {
89456d68f1eSafresh1 PERL_ARGS_ASSERT_SV_2PVBYTE;
89556d68f1eSafresh1
89656d68f1eSafresh1 return sv_2pvbyte(sv, lp);
89756d68f1eSafresh1 }
89856d68f1eSafresh1
89956d68f1eSafresh1 U8 *
Perl_uvuni_to_utf8(pTHX_ U8 * d,UV uv)90056d68f1eSafresh1 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
90156d68f1eSafresh1 {
90256d68f1eSafresh1 PERL_ARGS_ASSERT_UVUNI_TO_UTF8;
90356d68f1eSafresh1
90456d68f1eSafresh1 return uvoffuni_to_utf8_flags(d, uv, 0);
90556d68f1eSafresh1 }
90656d68f1eSafresh1
90756d68f1eSafresh1 /*
908eac174f2Safresh1 =for apidoc_section $unicode
90956d68f1eSafresh1 =for apidoc utf8n_to_uvuni
91056d68f1eSafresh1
91156d68f1eSafresh1 Instead use L<perlapi/utf8_to_uvchr_buf>, or rarely, L<perlapi/utf8n_to_uvchr>.
91256d68f1eSafresh1
91356d68f1eSafresh1 This function was useful for code that wanted to handle both EBCDIC and
91456d68f1eSafresh1 ASCII platforms with Unicode properties, but starting in Perl v5.20, the
91556d68f1eSafresh1 distinctions between the platforms have mostly been made invisible to most
91656d68f1eSafresh1 code, so this function is quite unlikely to be what you want. If you do need
91756d68f1eSafresh1 this precise functionality, use instead
91856d68f1eSafresh1 C<L<NATIVE_TO_UNI(utf8_to_uvchr_buf(...))|perlapi/utf8_to_uvchr_buf>>
91956d68f1eSafresh1 or C<L<NATIVE_TO_UNI(utf8n_to_uvchr(...))|perlapi/utf8n_to_uvchr>>.
92056d68f1eSafresh1
92156d68f1eSafresh1 =cut
92256d68f1eSafresh1 */
92356d68f1eSafresh1
92456d68f1eSafresh1 UV
Perl_utf8n_to_uvuni(pTHX_ const U8 * s,STRLEN curlen,STRLEN * retlen,U32 flags)92556d68f1eSafresh1 Perl_utf8n_to_uvuni(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
92656d68f1eSafresh1 {
92756d68f1eSafresh1 PERL_ARGS_ASSERT_UTF8N_TO_UVUNI;
92856d68f1eSafresh1
92956d68f1eSafresh1 return NATIVE_TO_UNI(utf8n_to_uvchr(s, curlen, retlen, flags));
93056d68f1eSafresh1 }
93156d68f1eSafresh1
93256d68f1eSafresh1 /*
933eac174f2Safresh1 =for apidoc_section $unicode
93456d68f1eSafresh1 =for apidoc utf8_to_uvchr
93556d68f1eSafresh1
93656d68f1eSafresh1 Returns the native code point of the first character in the string C<s>
93756d68f1eSafresh1 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
93856d68f1eSafresh1 length, in bytes, of that character.
93956d68f1eSafresh1
94056d68f1eSafresh1 Some, but not all, UTF-8 malformations are detected, and in fact, some
94156d68f1eSafresh1 malformed input could cause reading beyond the end of the input buffer, which
94256d68f1eSafresh1 is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
94356d68f1eSafresh1
94456d68f1eSafresh1 If C<s> points to one of the detected malformations, and UTF8 warnings are
94556d68f1eSafresh1 enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
94656d68f1eSafresh1 C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or
94756d68f1eSafresh1 the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
94856d68f1eSafresh1 is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
94956d68f1eSafresh1 next possible position in C<s> that could begin a non-malformed character.
95056d68f1eSafresh1 See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned.
95156d68f1eSafresh1
95256d68f1eSafresh1 =cut
95356d68f1eSafresh1 */
95456d68f1eSafresh1
95556d68f1eSafresh1 UV
Perl_utf8_to_uvchr(pTHX_ const U8 * s,STRLEN * retlen)95656d68f1eSafresh1 Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
95756d68f1eSafresh1 {
95856d68f1eSafresh1 PERL_ARGS_ASSERT_UTF8_TO_UVCHR;
95956d68f1eSafresh1
96056d68f1eSafresh1 /* This function is unsafe if malformed UTF-8 input is given it, which is
96156d68f1eSafresh1 * why the function is deprecated. If the first byte of the input
96256d68f1eSafresh1 * indicates that there are more bytes remaining in the sequence that forms
96356d68f1eSafresh1 * the character than there are in the input buffer, it can read past the
96456d68f1eSafresh1 * end. But we can make it safe if the input string happens to be
96556d68f1eSafresh1 * NUL-terminated, as many strings in Perl are, by refusing to read past a
96656d68f1eSafresh1 * NUL, which is what UTF8_CHK_SKIP() does. A NUL indicates the start of
96756d68f1eSafresh1 * the next character anyway. If the input isn't NUL-terminated, the
96856d68f1eSafresh1 * function remains unsafe, as it always has been. */
96956d68f1eSafresh1
97056d68f1eSafresh1 return utf8_to_uvchr_buf(s, s + UTF8_CHK_SKIP(s), retlen);
97156d68f1eSafresh1 }
97256d68f1eSafresh1
97356d68f1eSafresh1 GCC_DIAG_RESTORE
97456d68f1eSafresh1
975850e2753Smillert #endif /* NO_MATHOMS */
976850e2753Smillert
977850e2753Smillert /*
97891f110e0Safresh1 * ex: set ts=8 sts=4 sw=4 et:
979850e2753Smillert */
980