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