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