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