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 | * |
075eb5c9 AC |
35 | * REMEMBER to update makedef.pl when adding a function to mathoms.c whose |
36 | * name doesn't begin with "Perl_". | |
083750a5 | 37 | * |
7ee2227d SP |
38 | * SMP - Oct. 24, 2005 |
39 | * | |
55cb5ee0 KW |
40 | * The compilation of this file can be suppressed; see INSTALL |
41 | * | |
dcccc8ff KW |
42 | =head1 Obsolete backwards compatibility functions |
43 | Some of these are also deprecated. You can exclude these from | |
44 | your compiled Perl by adding this option to Configure: | |
45 | C<-Accflags='-DNO_MATHOMS'> | |
46 | ||
47 | =cut | |
48 | ||
7ee2227d SP |
49 | */ |
50 | ||
dcccc8ff | 51 | |
7ee2227d SP |
52 | #include "EXTERN.h" |
53 | #define PERL_IN_MATHOMS_C | |
54 | #include "perl.h" | |
55 | ||
359d40ba NC |
56 | #ifdef NO_MATHOMS |
57 | /* ..." warning: ISO C forbids an empty source file" | |
58 | So make sure we have something in here by processing the headers anyway. | |
59 | */ | |
60 | #else | |
61 | ||
7832ad85 KW |
62 | /* NOTE ALL FUNCTIONS IN THIS FILE should have an entry with the 'b' flag in |
63 | * embed.fnc. | |
64 | * | |
65 | * To move a function to this file, simply cut and paste it here, and change | |
66 | * its embed.fnc entry to additionally have the 'b' flag. If, for some reason | |
67 | * a function you'd like to be treated as mathoms can't be moved from its | |
68 | * current place, simply enclose it between | |
69 | * | |
70 | * #ifndef NO_MATHOMS | |
71 | * ... | |
72 | * #endif | |
73 | * | |
74 | * and add the 'b' flag in embed.fnc. | |
75 | * | |
76 | * */ | |
b5445a23 | 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; |
7ee2227d | 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; | |
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 |
2d825fd9 | 697 | Perl_is_utf8_string_loc(const U8 *s, 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 | |
734 | */ | |
735 | ||
736 | void | |
737 | Perl_sv_nounlocking(pTHX_ SV *sv) | |
738 | { | |
96a5add6 | 739 | PERL_UNUSED_CONTEXT; |
d5b2b27b NC |
740 | PERL_UNUSED_ARG(sv); |
741 | } | |
742 | ||
2053acbf NC |
743 | void |
744 | Perl_save_long(pTHX_ long int *longp) | |
745 | { | |
7918f24d NC |
746 | PERL_ARGS_ASSERT_SAVE_LONG; |
747 | ||
2053acbf NC |
748 | SSCHECK(3); |
749 | SSPUSHLONG(*longp); | |
750 | SSPUSHPTR(longp); | |
c6bf6a65 | 751 | SSPUSHUV(SAVEt_LONG); |
2053acbf NC |
752 | } |
753 | ||
754 | void | |
2053acbf NC |
755 | Perl_save_iv(pTHX_ IV *ivp) |
756 | { | |
7918f24d NC |
757 | PERL_ARGS_ASSERT_SAVE_IV; |
758 | ||
2053acbf NC |
759 | SSCHECK(3); |
760 | SSPUSHIV(*ivp); | |
761 | SSPUSHPTR(ivp); | |
c6bf6a65 | 762 | SSPUSHUV(SAVEt_IV); |
2053acbf NC |
763 | } |
764 | ||
765 | void | |
766 | Perl_save_nogv(pTHX_ GV *gv) | |
767 | { | |
7918f24d NC |
768 | PERL_ARGS_ASSERT_SAVE_NOGV; |
769 | ||
2053acbf NC |
770 | SSCHECK(2); |
771 | SSPUSHPTR(gv); | |
c6bf6a65 | 772 | SSPUSHUV(SAVEt_NSTAB); |
2053acbf NC |
773 | } |
774 | ||
775 | void | |
5aaab254 | 776 | Perl_save_list(pTHX_ SV **sarg, I32 maxsarg) |
2053acbf | 777 | { |
eb578fdb | 778 | I32 i; |
2053acbf | 779 | |
7918f24d NC |
780 | PERL_ARGS_ASSERT_SAVE_LIST; |
781 | ||
2053acbf | 782 | for (i = 1; i <= maxsarg; i++) { |
3ed356df FC |
783 | SV *sv; |
784 | SvGETMAGIC(sarg[i]); | |
785 | sv = newSV(0); | |
786 | sv_setsv_nomg(sv,sarg[i]); | |
2053acbf NC |
787 | SSCHECK(3); |
788 | SSPUSHPTR(sarg[i]); /* remember the pointer */ | |
789 | SSPUSHPTR(sv); /* remember the value */ | |
c6bf6a65 | 790 | SSPUSHUV(SAVEt_ITEM); |
2053acbf NC |
791 | } |
792 | } | |
793 | ||
47518d95 NC |
794 | /* |
795 | =for apidoc sv_usepvn_mg | |
796 | ||
797 | Like C<sv_usepvn>, but also handles 'set' magic. | |
798 | ||
799 | =cut | |
800 | */ | |
801 | ||
802 | void | |
803 | Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len) | |
804 | { | |
7918f24d NC |
805 | PERL_ARGS_ASSERT_SV_USEPVN_MG; |
806 | ||
47518d95 NC |
807 | sv_usepvn_flags(sv,ptr,len, SV_SMAGIC); |
808 | } | |
809 | ||
810 | /* | |
811 | =for apidoc sv_usepvn | |
812 | ||
72d33970 | 813 | Tells an SV to use C<ptr> to find its string value. Implemented by |
47518d95 | 814 | calling C<sv_usepvn_flags> with C<flags> of 0, hence does not handle 'set' |
fbe13c60 | 815 | magic. See C<L</sv_usepvn_flags>>. |
47518d95 NC |
816 | |
817 | =cut | |
818 | */ | |
819 | ||
820 | void | |
821 | Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len) | |
822 | { | |
7918f24d NC |
823 | PERL_ARGS_ASSERT_SV_USEPVN; |
824 | ||
47518d95 NC |
825 | sv_usepvn_flags(sv,ptr,len, 0); |
826 | } | |
827 | ||
c03e83bf NC |
828 | /* |
829 | =for apidoc unpack_str | |
830 | ||
796b6530 KW |
831 | The engine implementing C<unpack()> Perl function. Note: parameters C<strbeg>, |
832 | C<new_s> and C<ocnt> are not used. This call should not be used, use | |
833 | C<unpackstring> instead. | |
c03e83bf NC |
834 | |
835 | =cut */ | |
836 | ||
837 | I32 | |
838 | Perl_unpack_str(pTHX_ const char *pat, const char *patend, const char *s, | |
839 | const char *strbeg, const char *strend, char **new_s, I32 ocnt, | |
840 | U32 flags) | |
841 | { | |
7918f24d NC |
842 | PERL_ARGS_ASSERT_UNPACK_STR; |
843 | ||
c03e83bf NC |
844 | PERL_UNUSED_ARG(strbeg); |
845 | PERL_UNUSED_ARG(new_s); | |
846 | PERL_UNUSED_ARG(ocnt); | |
847 | ||
848 | return unpackstring(pat, patend, s, strend, flags); | |
849 | } | |
b47163a2 NC |
850 | |
851 | /* | |
852 | =for apidoc pack_cat | |
853 | ||
796b6530 KW |
854 | The engine implementing C<pack()> Perl function. Note: parameters |
855 | C<next_in_list> and C<flags> are not used. This call should not be used; use | |
856 | C<packlist> instead. | |
b47163a2 NC |
857 | |
858 | =cut | |
859 | */ | |
860 | ||
861 | void | |
5aaab254 | 862 | Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags) |
b47163a2 | 863 | { |
7918f24d NC |
864 | PERL_ARGS_ASSERT_PACK_CAT; |
865 | ||
b47163a2 NC |
866 | PERL_UNUSED_ARG(next_in_list); |
867 | PERL_UNUSED_ARG(flags); | |
868 | ||
869 | packlist(cat, pat, patend, beglist, endlist); | |
870 | } | |
4c2df08c NC |
871 | |
872 | HE * | |
873 | Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash) | |
874 | { | |
59af68cc | 875 | return (HE *)hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISSTORE, val, hash); |
4c2df08c NC |
876 | } |
877 | ||
878 | bool | |
879 | Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash) | |
880 | { | |
7918f24d NC |
881 | PERL_ARGS_ASSERT_HV_EXISTS_ENT; |
882 | ||
4c2df08c NC |
883 | return hv_common(hv, keysv, NULL, 0, 0, HV_FETCH_ISEXISTS, 0, hash) |
884 | ? TRUE : FALSE; | |
885 | } | |
886 | ||
887 | HE * | |
888 | Perl_hv_fetch_ent(pTHX_ HV *hv, SV *keysv, I32 lval, U32 hash) | |
889 | { | |
7918f24d NC |
890 | PERL_ARGS_ASSERT_HV_FETCH_ENT; |
891 | ||
59af68cc | 892 | return (HE *)hv_common(hv, keysv, NULL, 0, 0, |
4c2df08c NC |
893 | (lval ? HV_FETCH_LVALUE : 0), NULL, hash); |
894 | } | |
895 | ||
896 | SV * | |
897 | Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash) | |
898 | { | |
7918f24d NC |
899 | PERL_ARGS_ASSERT_HV_DELETE_ENT; |
900 | ||
ad64d0ec NC |
901 | return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL, |
902 | hash)); | |
4c2df08c NC |
903 | } |
904 | ||
a038e571 NC |
905 | SV** |
906 | Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, U32 hash, | |
907 | int flags) | |
908 | { | |
909 | return (SV**) hv_common(hv, NULL, key, klen, flags, | |
910 | (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash); | |
911 | } | |
912 | ||
913 | SV** | |
914 | Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash) | |
915 | { | |
916 | STRLEN klen; | |
917 | int flags; | |
918 | ||
919 | if (klen_i32 < 0) { | |
920 | klen = -klen_i32; | |
921 | flags = HVhek_UTF8; | |
922 | } else { | |
923 | klen = klen_i32; | |
924 | flags = 0; | |
925 | } | |
926 | return (SV **) hv_common(hv, NULL, key, klen, flags, | |
927 | (HV_FETCH_ISSTORE|HV_FETCH_JUST_SV), val, hash); | |
928 | } | |
929 | ||
930 | bool | |
931 | Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen_i32) | |
932 | { | |
933 | STRLEN klen; | |
934 | int flags; | |
935 | ||
7918f24d NC |
936 | PERL_ARGS_ASSERT_HV_EXISTS; |
937 | ||
a038e571 NC |
938 | if (klen_i32 < 0) { |
939 | klen = -klen_i32; | |
940 | flags = HVhek_UTF8; | |
941 | } else { | |
942 | klen = klen_i32; | |
943 | flags = 0; | |
944 | } | |
945 | return hv_common(hv, NULL, key, klen, flags, HV_FETCH_ISEXISTS, 0, 0) | |
946 | ? TRUE : FALSE; | |
947 | } | |
948 | ||
949 | SV** | |
950 | Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval) | |
951 | { | |
952 | STRLEN klen; | |
953 | int flags; | |
954 | ||
7918f24d NC |
955 | PERL_ARGS_ASSERT_HV_FETCH; |
956 | ||
a038e571 NC |
957 | if (klen_i32 < 0) { |
958 | klen = -klen_i32; | |
959 | flags = HVhek_UTF8; | |
960 | } else { | |
961 | klen = klen_i32; | |
962 | flags = 0; | |
963 | } | |
964 | return (SV **) hv_common(hv, NULL, key, klen, flags, | |
965 | lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE) | |
966 | : HV_FETCH_JUST_SV, NULL, 0); | |
967 | } | |
968 | ||
969 | SV * | |
970 | Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags) | |
971 | { | |
972 | STRLEN klen; | |
973 | int k_flags; | |
974 | ||
7918f24d NC |
975 | PERL_ARGS_ASSERT_HV_DELETE; |
976 | ||
a038e571 NC |
977 | if (klen_i32 < 0) { |
978 | klen = -klen_i32; | |
979 | k_flags = HVhek_UTF8; | |
980 | } else { | |
981 | klen = klen_i32; | |
982 | k_flags = 0; | |
983 | } | |
ad64d0ec NC |
984 | return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE, |
985 | NULL, 0)); | |
a038e571 NC |
986 | } |
987 | ||
ac572bf4 NC |
988 | AV * |
989 | Perl_newAV(pTHX) | |
990 | { | |
502c6561 | 991 | return MUTABLE_AV(newSV_type(SVt_PVAV)); |
ac572bf4 NC |
992 | /* sv_upgrade does AvREAL_only(): |
993 | AvALLOC(av) = 0; | |
994 | AvARRAY(av) = NULL; | |
995 | AvMAX(av) = AvFILLp(av) = -1; */ | |
996 | } | |
997 | ||
78ac7dd9 NC |
998 | HV * |
999 | Perl_newHV(pTHX) | |
1000 | { | |
85fbaab2 | 1001 | HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV)); |
78ac7dd9 NC |
1002 | assert(!SvOK(hv)); |
1003 | ||
1004 | return hv; | |
1005 | } | |
1006 | ||
84335ee9 NC |
1007 | void |
1008 | Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len, | |
1009 | const char *const little, const STRLEN littlelen) | |
1010 | { | |
1011 | PERL_ARGS_ASSERT_SV_INSERT; | |
1012 | sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC); | |
1013 | } | |
1014 | ||
2fd8beea NC |
1015 | void |
1016 | Perl_save_freesv(pTHX_ SV *sv) | |
1017 | { | |
2fd8beea NC |
1018 | save_freesv(sv); |
1019 | } | |
1020 | ||
1021 | void | |
1022 | Perl_save_mortalizesv(pTHX_ SV *sv) | |
1023 | { | |
2fd8beea NC |
1024 | PERL_ARGS_ASSERT_SAVE_MORTALIZESV; |
1025 | ||
1026 | save_mortalizesv(sv); | |
1027 | } | |
1028 | ||
1029 | void | |
1030 | Perl_save_freeop(pTHX_ OP *o) | |
1031 | { | |
2fd8beea NC |
1032 | save_freeop(o); |
1033 | } | |
1034 | ||
1035 | void | |
1036 | Perl_save_freepv(pTHX_ char *pv) | |
1037 | { | |
2fd8beea NC |
1038 | save_freepv(pv); |
1039 | } | |
1040 | ||
1041 | void | |
1042 | Perl_save_op(pTHX) | |
1043 | { | |
2fd8beea NC |
1044 | save_op(); |
1045 | } | |
1046 | ||
d5713896 NC |
1047 | #ifdef PERL_DONT_CREATE_GVSV |
1048 | GV * | |
1049 | Perl_gv_SVadd(pTHX_ GV *gv) | |
1050 | { | |
d5713896 NC |
1051 | return gv_SVadd(gv); |
1052 | } | |
1053 | #endif | |
1054 | ||
1055 | GV * | |
1056 | Perl_gv_AVadd(pTHX_ GV *gv) | |
1057 | { | |
d5713896 NC |
1058 | return gv_AVadd(gv); |
1059 | } | |
1060 | ||
1061 | GV * | |
5aaab254 | 1062 | Perl_gv_HVadd(pTHX_ GV *gv) |
d5713896 | 1063 | { |
d5713896 NC |
1064 | return gv_HVadd(gv); |
1065 | } | |
1066 | ||
bb85b28a | 1067 | GV * |
5aaab254 | 1068 | Perl_gv_IOadd(pTHX_ GV *gv) |
bb85b28a NC |
1069 | { |
1070 | return gv_IOadd(gv); | |
1071 | } | |
1072 | ||
85dca89a NC |
1073 | IO * |
1074 | Perl_newIO(pTHX) | |
1075 | { | |
1076 | return MUTABLE_IO(newSV_type(SVt_PVIO)); | |
1077 | } | |
1078 | ||
0d7d409d DM |
1079 | I32 |
1080 | Perl_my_stat(pTHX) | |
1081 | { | |
1082 | return my_stat_flags(SV_GMAGIC); | |
1083 | } | |
1084 | ||
1085 | I32 | |
1086 | Perl_my_lstat(pTHX) | |
1087 | { | |
1088 | return my_lstat_flags(SV_GMAGIC); | |
1089 | } | |
1090 | ||
078504b2 | 1091 | I32 |
5aaab254 | 1092 | Perl_sv_eq(pTHX_ SV *sv1, SV *sv2) |
078504b2 FC |
1093 | { |
1094 | return sv_eq_flags(sv1, sv2, SV_GMAGIC); | |
1095 | } | |
1096 | ||
6129b56c | 1097 | #ifdef USE_LOCALE_COLLATE |
078504b2 FC |
1098 | char * |
1099 | Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp) | |
1100 | { | |
1101 | return sv_collxfrm_flags(sv, nxp, SV_GMAGIC); | |
1102 | } | |
6129b56c | 1103 | #endif |
078504b2 | 1104 | |
06c841cf | 1105 | bool |
5aaab254 | 1106 | Perl_sv_2bool(pTHX_ SV *const sv) |
06c841cf FC |
1107 | { |
1108 | return sv_2bool_flags(sv, SV_GMAGIC); | |
1109 | } | |
1110 | ||
1830b3d9 | 1111 | |
9733086d BM |
1112 | /* |
1113 | =for apidoc custom_op_name | |
796b6530 | 1114 | Return the name for a given custom op. This was once used by the C<OP_NAME> |
9733086d BM |
1115 | macro, but is no longer: it has only been kept for compatibility, and |
1116 | should not be used. | |
1117 | ||
1118 | =for apidoc custom_op_desc | |
72d33970 | 1119 | Return the description of a given custom op. This was once used by the |
796b6530 | 1120 | C<OP_DESC> macro, but is no longer: it has only been kept for |
9733086d BM |
1121 | compatibility, and should not be used. |
1122 | ||
1123 | =cut | |
1124 | */ | |
1125 | ||
1830b3d9 BM |
1126 | const char* |
1127 | Perl_custom_op_name(pTHX_ const OP* o) | |
1128 | { | |
1129 | PERL_ARGS_ASSERT_CUSTOM_OP_NAME; | |
ae103e09 | 1130 | return XopENTRYCUSTOM(o, xop_name); |
1830b3d9 BM |
1131 | } |
1132 | ||
1133 | const char* | |
1134 | Perl_custom_op_desc(pTHX_ const OP* o) | |
1135 | { | |
1136 | PERL_ARGS_ASSERT_CUSTOM_OP_DESC; | |
ae103e09 | 1137 | return XopENTRYCUSTOM(o, xop_desc); |
1830b3d9 | 1138 | } |
7bff8c33 NC |
1139 | |
1140 | CV * | |
1141 | Perl_newSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *block) | |
1142 | { | |
e8f91c91 | 1143 | return newATTRSUB(floor, o, proto, NULL, block); |
7bff8c33 | 1144 | } |
0c9b0438 KW |
1145 | |
1146 | UV | |
1147 | Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp) | |
1148 | { | |
1149 | PERL_ARGS_ASSERT_TO_UTF8_FOLD; | |
1150 | ||
445bf929 | 1151 | return _to_utf8_fold_flags(p, ustrp, lenp, FOLD_FLAGS_FULL); |
0c9b0438 KW |
1152 | } |
1153 | ||
1154 | UV | |
1155 | Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp) | |
1156 | { | |
1157 | PERL_ARGS_ASSERT_TO_UTF8_LOWER; | |
1158 | ||
445bf929 | 1159 | return _to_utf8_lower_flags(p, ustrp, lenp, FALSE); |
0c9b0438 KW |
1160 | } |
1161 | ||
1162 | UV | |
1163 | Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp) | |
1164 | { | |
1165 | PERL_ARGS_ASSERT_TO_UTF8_TITLE; | |
1166 | ||
445bf929 | 1167 | return _to_utf8_title_flags(p, ustrp, lenp, FALSE); |
0c9b0438 KW |
1168 | } |
1169 | ||
1170 | UV | |
1171 | Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp) | |
1172 | { | |
1173 | PERL_ARGS_ASSERT_TO_UTF8_UPPER; | |
1174 | ||
445bf929 | 1175 | return _to_utf8_upper_flags(p, ustrp, lenp, FALSE); |
0c9b0438 KW |
1176 | } |
1177 | ||
108cb980 FC |
1178 | SV * |
1179 | Perl_sv_mortalcopy(pTHX_ SV *const oldstr) | |
1180 | { | |
33971c01 | 1181 | return Perl_sv_mortalcopy_flags(aTHX_ oldstr, SV_GMAGIC); |
108cb980 FC |
1182 | } |
1183 | ||
e4524c4c DD |
1184 | void |
1185 | Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv) | |
1186 | { | |
1187 | PERL_ARGS_ASSERT_SV_COPYPV; | |
1188 | ||
1189 | sv_copypv_flags(dsv, ssv, 0); | |
1190 | } | |
1191 | ||
3d81eea6 KW |
1192 | UV /* Made into a function, so can be deprecated */ |
1193 | NATIVE_TO_NEED(const UV enc, const UV ch) | |
1194 | { | |
1195 | PERL_UNUSED_ARG(enc); | |
1196 | return ch; | |
1197 | } | |
1198 | ||
1199 | UV /* Made into a function, so can be deprecated */ | |
1200 | ASCII_TO_NEED(const UV enc, const UV ch) | |
1201 | { | |
1202 | PERL_UNUSED_ARG(enc); | |
1203 | return ch; | |
1204 | } | |
1205 | ||
f2645549 KW |
1206 | bool /* Made into a function, so can be deprecated */ |
1207 | Perl_isIDFIRST_lazy(pTHX_ const char* p) | |
1208 | { | |
1209 | PERL_ARGS_ASSERT_ISIDFIRST_LAZY; | |
1210 | ||
1211 | return isIDFIRST_lazy_if(p,1); | |
1212 | } | |
1213 | ||
1214 | bool /* Made into a function, so can be deprecated */ | |
1215 | Perl_isALNUM_lazy(pTHX_ const char* p) | |
1216 | { | |
1217 | PERL_ARGS_ASSERT_ISALNUM_LAZY; | |
1218 | ||
1219 | return isALNUM_lazy_if(p,1); | |
1220 | } | |
1221 | ||
dc2e544e KW |
1222 | bool |
1223 | Perl_is_uni_alnum(pTHX_ UV c) | |
1224 | { | |
1225 | return isWORDCHAR_uni(c); | |
1226 | } | |
1227 | ||
1228 | bool | |
1229 | Perl_is_uni_alnumc(pTHX_ UV c) | |
1230 | { | |
1231 | return isALNUM_uni(c); | |
1232 | } | |
1233 | ||
1234 | bool | |
1235 | Perl_is_uni_alpha(pTHX_ UV c) | |
1236 | { | |
1237 | return isALPHA_uni(c); | |
1238 | } | |
1239 | ||
1240 | bool | |
1241 | Perl_is_uni_ascii(pTHX_ UV c) | |
1242 | { | |
81611534 | 1243 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1244 | return isASCII_uni(c); |
1245 | } | |
1246 | ||
1247 | bool | |
1248 | Perl_is_uni_blank(pTHX_ UV c) | |
1249 | { | |
81611534 | 1250 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1251 | return isBLANK_uni(c); |
1252 | } | |
1253 | ||
1254 | bool | |
1255 | Perl_is_uni_space(pTHX_ UV c) | |
1256 | { | |
81611534 | 1257 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1258 | return isSPACE_uni(c); |
1259 | } | |
1260 | ||
1261 | bool | |
1262 | Perl_is_uni_digit(pTHX_ UV c) | |
1263 | { | |
81611534 | 1264 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1265 | return isDIGIT_uni(c); |
1266 | } | |
1267 | ||
1268 | bool | |
1269 | Perl_is_uni_upper(pTHX_ UV c) | |
1270 | { | |
81611534 | 1271 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1272 | return isUPPER_uni(c); |
1273 | } | |
1274 | ||
1275 | bool | |
1276 | Perl_is_uni_lower(pTHX_ UV c) | |
1277 | { | |
81611534 | 1278 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1279 | return isLOWER_uni(c); |
1280 | } | |
1281 | ||
1282 | bool | |
1283 | Perl_is_uni_cntrl(pTHX_ UV c) | |
1284 | { | |
81611534 | 1285 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1286 | return isCNTRL_L1(c); |
1287 | } | |
1288 | ||
1289 | bool | |
1290 | Perl_is_uni_graph(pTHX_ UV c) | |
1291 | { | |
81611534 | 1292 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1293 | return isGRAPH_uni(c); |
1294 | } | |
1295 | ||
1296 | bool | |
1297 | Perl_is_uni_print(pTHX_ UV c) | |
1298 | { | |
81611534 | 1299 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1300 | return isPRINT_uni(c); |
1301 | } | |
1302 | ||
1303 | bool | |
1304 | Perl_is_uni_punct(pTHX_ UV c) | |
1305 | { | |
81611534 | 1306 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1307 | return isPUNCT_uni(c); |
1308 | } | |
1309 | ||
1310 | bool | |
1311 | Perl_is_uni_xdigit(pTHX_ UV c) | |
1312 | { | |
81611534 | 1313 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1314 | return isXDIGIT_uni(c); |
1315 | } | |
1316 | ||
1317 | bool | |
1318 | Perl_is_uni_alnum_lc(pTHX_ UV c) | |
1319 | { | |
81611534 | 1320 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1321 | return isWORDCHAR_LC_uvchr(c); |
1322 | } | |
1323 | ||
1324 | bool | |
1325 | Perl_is_uni_alnumc_lc(pTHX_ UV c) | |
1326 | { | |
81611534 | 1327 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1328 | return isALPHANUMERIC_LC_uvchr(c); |
1329 | } | |
1330 | ||
1331 | bool | |
1332 | Perl_is_uni_idfirst_lc(pTHX_ UV c) | |
1333 | { | |
81611534 | 1334 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1335 | /* XXX Should probably be something that resolves to the old IDFIRST, but |
1336 | * this function is deprecated, so not bothering */ | |
1337 | return isIDFIRST_LC_uvchr(c); | |
1338 | } | |
1339 | ||
1340 | bool | |
1341 | Perl_is_uni_alpha_lc(pTHX_ UV c) | |
1342 | { | |
81611534 | 1343 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1344 | return isALPHA_LC_uvchr(c); |
1345 | } | |
1346 | ||
1347 | bool | |
1348 | Perl_is_uni_ascii_lc(pTHX_ UV c) | |
1349 | { | |
81611534 | 1350 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1351 | return isASCII_LC_uvchr(c); |
1352 | } | |
1353 | ||
1354 | bool | |
1355 | Perl_is_uni_blank_lc(pTHX_ UV c) | |
1356 | { | |
81611534 | 1357 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1358 | return isBLANK_LC_uvchr(c); |
1359 | } | |
1360 | ||
1361 | bool | |
1362 | Perl_is_uni_space_lc(pTHX_ UV c) | |
1363 | { | |
81611534 | 1364 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1365 | return isSPACE_LC_uvchr(c); |
1366 | } | |
1367 | ||
1368 | bool | |
1369 | Perl_is_uni_digit_lc(pTHX_ UV c) | |
1370 | { | |
1371 | return isDIGIT_LC_uvchr(c); | |
1372 | } | |
1373 | ||
1374 | bool | |
f2645549 KW |
1375 | Perl_is_uni_idfirst(pTHX_ UV c) |
1376 | { | |
1377 | U8 tmpbuf[UTF8_MAXBYTES+1]; | |
1378 | uvchr_to_utf8(tmpbuf, c); | |
1379 | return _is_utf8_idstart(tmpbuf); | |
1380 | } | |
1381 | ||
1382 | bool | |
1383 | Perl_is_utf8_idfirst(pTHX_ const U8 *p) /* The naming is historical. */ | |
1384 | { | |
f2645549 KW |
1385 | PERL_ARGS_ASSERT_IS_UTF8_IDFIRST; |
1386 | ||
1387 | return _is_utf8_idstart(p); | |
1388 | } | |
1389 | ||
1390 | bool | |
1391 | Perl_is_utf8_xidfirst(pTHX_ const U8 *p) /* The naming is historical. */ | |
1392 | { | |
f2645549 KW |
1393 | PERL_ARGS_ASSERT_IS_UTF8_XIDFIRST; |
1394 | ||
1395 | return _is_utf8_xidstart(p); | |
1396 | } | |
1397 | ||
1398 | bool | |
1399 | Perl_is_utf8_idcont(pTHX_ const U8 *p) | |
1400 | { | |
f2645549 KW |
1401 | PERL_ARGS_ASSERT_IS_UTF8_IDCONT; |
1402 | ||
1403 | return _is_utf8_idcont(p); | |
1404 | } | |
1405 | ||
1406 | bool | |
1407 | Perl_is_utf8_xidcont(pTHX_ const U8 *p) | |
1408 | { | |
f2645549 KW |
1409 | PERL_ARGS_ASSERT_IS_UTF8_XIDCONT; |
1410 | ||
1411 | return _is_utf8_xidcont(p); | |
1412 | } | |
1413 | ||
1414 | bool | |
dc2e544e KW |
1415 | Perl_is_uni_upper_lc(pTHX_ UV c) |
1416 | { | |
1417 | return isUPPER_LC_uvchr(c); | |
1418 | } | |
1419 | ||
1420 | bool | |
1421 | Perl_is_uni_lower_lc(pTHX_ UV c) | |
1422 | { | |
1423 | return isLOWER_LC_uvchr(c); | |
1424 | } | |
1425 | ||
1426 | bool | |
1427 | Perl_is_uni_cntrl_lc(pTHX_ UV c) | |
1428 | { | |
1429 | return isCNTRL_LC_uvchr(c); | |
1430 | } | |
1431 | ||
1432 | bool | |
1433 | Perl_is_uni_graph_lc(pTHX_ UV c) | |
1434 | { | |
1435 | return isGRAPH_LC_uvchr(c); | |
1436 | } | |
1437 | ||
1438 | bool | |
1439 | Perl_is_uni_print_lc(pTHX_ UV c) | |
1440 | { | |
1441 | return isPRINT_LC_uvchr(c); | |
1442 | } | |
1443 | ||
1444 | bool | |
1445 | Perl_is_uni_punct_lc(pTHX_ UV c) | |
1446 | { | |
1447 | return isPUNCT_LC_uvchr(c); | |
1448 | } | |
1449 | ||
1450 | bool | |
1451 | Perl_is_uni_xdigit_lc(pTHX_ UV c) | |
1452 | { | |
1453 | return isXDIGIT_LC_uvchr(c); | |
1454 | } | |
1455 | ||
1456 | U32 | |
1457 | Perl_to_uni_upper_lc(pTHX_ U32 c) | |
1458 | { | |
1459 | /* XXX returns only the first character -- do not use XXX */ | |
1460 | /* XXX no locale support yet */ | |
1461 | STRLEN len; | |
1462 | U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; | |
1463 | return (U32)to_uni_upper(c, tmpbuf, &len); | |
1464 | } | |
1465 | ||
1466 | U32 | |
1467 | Perl_to_uni_title_lc(pTHX_ U32 c) | |
1468 | { | |
1469 | /* XXX returns only the first character XXX -- do not use XXX */ | |
1470 | /* XXX no locale support yet */ | |
1471 | STRLEN len; | |
1472 | U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; | |
1473 | return (U32)to_uni_title(c, tmpbuf, &len); | |
1474 | } | |
1475 | ||
1476 | U32 | |
1477 | Perl_to_uni_lower_lc(pTHX_ U32 c) | |
1478 | { | |
1479 | /* XXX returns only the first character -- do not use XXX */ | |
1480 | /* XXX no locale support yet */ | |
1481 | STRLEN len; | |
1482 | U8 tmpbuf[UTF8_MAXBYTES_CASE+1]; | |
1483 | return (U32)to_uni_lower(c, tmpbuf, &len); | |
1484 | } | |
1485 | ||
1486 | bool | |
1487 | Perl_is_utf8_alnum(pTHX_ const U8 *p) | |
1488 | { | |
dc2e544e KW |
1489 | PERL_ARGS_ASSERT_IS_UTF8_ALNUM; |
1490 | ||
1491 | /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true | |
1492 | * descendant of isalnum(3), in other words, it doesn't | |
1493 | * contain the '_'. --jhi */ | |
1494 | return isWORDCHAR_utf8(p); | |
1495 | } | |
1496 | ||
1497 | bool | |
1498 | Perl_is_utf8_alnumc(pTHX_ const U8 *p) | |
1499 | { | |
dc2e544e KW |
1500 | PERL_ARGS_ASSERT_IS_UTF8_ALNUMC; |
1501 | ||
1502 | return isALPHANUMERIC_utf8(p); | |
1503 | } | |
1504 | ||
1505 | bool | |
1506 | Perl_is_utf8_alpha(pTHX_ const U8 *p) | |
1507 | { | |
dc2e544e KW |
1508 | PERL_ARGS_ASSERT_IS_UTF8_ALPHA; |
1509 | ||
1510 | return isALPHA_utf8(p); | |
1511 | } | |
1512 | ||
1513 | bool | |
1514 | Perl_is_utf8_ascii(pTHX_ const U8 *p) | |
1515 | { | |
dc2e544e | 1516 | PERL_ARGS_ASSERT_IS_UTF8_ASCII; |
81611534 | 1517 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1518 | |
1519 | return isASCII_utf8(p); | |
1520 | } | |
1521 | ||
1522 | bool | |
1523 | Perl_is_utf8_blank(pTHX_ const U8 *p) | |
1524 | { | |
dc2e544e | 1525 | PERL_ARGS_ASSERT_IS_UTF8_BLANK; |
81611534 | 1526 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1527 | |
1528 | return isBLANK_utf8(p); | |
1529 | } | |
1530 | ||
1531 | bool | |
1532 | Perl_is_utf8_space(pTHX_ const U8 *p) | |
1533 | { | |
dc2e544e | 1534 | PERL_ARGS_ASSERT_IS_UTF8_SPACE; |
81611534 | 1535 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1536 | |
1537 | return isSPACE_utf8(p); | |
1538 | } | |
1539 | ||
1540 | bool | |
1541 | Perl_is_utf8_perl_space(pTHX_ const U8 *p) | |
1542 | { | |
dc2e544e | 1543 | PERL_ARGS_ASSERT_IS_UTF8_PERL_SPACE; |
81611534 | 1544 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1545 | |
1546 | /* Only true if is an ASCII space-like character, and ASCII is invariant | |
1547 | * under utf8, so can just use the macro */ | |
1548 | return isSPACE_A(*p); | |
1549 | } | |
1550 | ||
1551 | bool | |
1552 | Perl_is_utf8_perl_word(pTHX_ const U8 *p) | |
1553 | { | |
dc2e544e | 1554 | PERL_ARGS_ASSERT_IS_UTF8_PERL_WORD; |
81611534 | 1555 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1556 | |
1557 | /* Only true if is an ASCII word character, and ASCII is invariant | |
1558 | * under utf8, so can just use the macro */ | |
1559 | return isWORDCHAR_A(*p); | |
1560 | } | |
1561 | ||
1562 | bool | |
1563 | Perl_is_utf8_digit(pTHX_ const U8 *p) | |
1564 | { | |
dc2e544e KW |
1565 | PERL_ARGS_ASSERT_IS_UTF8_DIGIT; |
1566 | ||
1567 | return isDIGIT_utf8(p); | |
1568 | } | |
1569 | ||
1570 | bool | |
1571 | Perl_is_utf8_posix_digit(pTHX_ const U8 *p) | |
1572 | { | |
dc2e544e | 1573 | PERL_ARGS_ASSERT_IS_UTF8_POSIX_DIGIT; |
81611534 | 1574 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1575 | |
1576 | /* Only true if is an ASCII digit character, and ASCII is invariant | |
1577 | * under utf8, so can just use the macro */ | |
1578 | return isDIGIT_A(*p); | |
1579 | } | |
1580 | ||
1581 | bool | |
1582 | Perl_is_utf8_upper(pTHX_ const U8 *p) | |
1583 | { | |
dc2e544e KW |
1584 | PERL_ARGS_ASSERT_IS_UTF8_UPPER; |
1585 | ||
1586 | return isUPPER_utf8(p); | |
1587 | } | |
1588 | ||
1589 | bool | |
1590 | Perl_is_utf8_lower(pTHX_ const U8 *p) | |
1591 | { | |
dc2e544e KW |
1592 | PERL_ARGS_ASSERT_IS_UTF8_LOWER; |
1593 | ||
1594 | return isLOWER_utf8(p); | |
1595 | } | |
1596 | ||
1597 | bool | |
1598 | Perl_is_utf8_cntrl(pTHX_ const U8 *p) | |
1599 | { | |
dc2e544e | 1600 | PERL_ARGS_ASSERT_IS_UTF8_CNTRL; |
81611534 | 1601 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1602 | |
1603 | return isCNTRL_utf8(p); | |
1604 | } | |
1605 | ||
1606 | bool | |
1607 | Perl_is_utf8_graph(pTHX_ const U8 *p) | |
1608 | { | |
dc2e544e KW |
1609 | PERL_ARGS_ASSERT_IS_UTF8_GRAPH; |
1610 | ||
1611 | return isGRAPH_utf8(p); | |
1612 | } | |
1613 | ||
1614 | bool | |
1615 | Perl_is_utf8_print(pTHX_ const U8 *p) | |
1616 | { | |
dc2e544e KW |
1617 | PERL_ARGS_ASSERT_IS_UTF8_PRINT; |
1618 | ||
1619 | return isPRINT_utf8(p); | |
1620 | } | |
1621 | ||
1622 | bool | |
1623 | Perl_is_utf8_punct(pTHX_ const U8 *p) | |
1624 | { | |
dc2e544e KW |
1625 | PERL_ARGS_ASSERT_IS_UTF8_PUNCT; |
1626 | ||
1627 | return isPUNCT_utf8(p); | |
1628 | } | |
1629 | ||
1630 | bool | |
1631 | Perl_is_utf8_xdigit(pTHX_ const U8 *p) | |
1632 | { | |
dc2e544e | 1633 | PERL_ARGS_ASSERT_IS_UTF8_XDIGIT; |
81611534 | 1634 | PERL_UNUSED_CONTEXT; |
dc2e544e KW |
1635 | |
1636 | return isXDIGIT_utf8(p); | |
1637 | } | |
1638 | ||
1639 | bool | |
1640 | Perl_is_utf8_mark(pTHX_ const U8 *p) | |
1641 | { | |
dc2e544e KW |
1642 | PERL_ARGS_ASSERT_IS_UTF8_MARK; |
1643 | ||
1644 | return _is_utf8_mark(p); | |
1645 | } | |
1646 | ||
f2645549 KW |
1647 | /* |
1648 | =for apidoc is_utf8_char | |
1649 | ||
1650 | Tests if some arbitrary number of bytes begins in a valid UTF-8 | |
1651 | character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines) | |
1652 | character is a valid UTF-8 character. The actual number of bytes in the UTF-8 | |
1653 | character will be returned if it is valid, otherwise 0. | |
1654 | ||
1655 | This function is deprecated due to the possibility that malformed input could | |
1656 | cause reading beyond the end of the input buffer. Use L</isUTF8_CHAR> | |
1657 | instead. | |
1658 | ||
1659 | =cut */ | |
1660 | ||
1661 | STRLEN | |
1662 | Perl_is_utf8_char(const U8 *s) | |
1663 | { | |
1664 | PERL_ARGS_ASSERT_IS_UTF8_CHAR; | |
1665 | ||
1666 | /* Assumes we have enough space, which is why this is deprecated */ | |
1667 | return isUTF8_CHAR(s, s + UTF8SKIP(s)); | |
1668 | } | |
1669 | ||
e4524c4c DD |
1670 | /* |
1671 | =for apidoc is_utf8_char_buf | |
1672 | ||
1673 | This is identical to the macro L</isUTF8_CHAR>. | |
1674 | ||
1675 | =cut */ | |
1676 | ||
1677 | STRLEN | |
1678 | Perl_is_utf8_char_buf(const U8 *buf, const U8* buf_end) | |
1679 | { | |
1680 | ||
1681 | PERL_ARGS_ASSERT_IS_UTF8_CHAR_BUF; | |
1682 | ||
1683 | return isUTF8_CHAR(buf, buf_end); | |
1684 | } | |
1685 | ||
f2645549 KW |
1686 | /* DEPRECATED! |
1687 | * Like L</utf8_to_uvuni_buf>(), but should only be called when it is known that | |
1688 | * there are no malformations in the input UTF-8 string C<s>. Surrogates, | |
1689 | * non-character code points, and non-Unicode code points are allowed */ | |
1690 | ||
1691 | UV | |
1692 | Perl_valid_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen) | |
1693 | { | |
1694 | PERL_ARGS_ASSERT_VALID_UTF8_TO_UVUNI; | |
1695 | ||
1696 | return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen)); | |
1697 | } | |
1698 | ||
1699 | /* | |
1700 | =for apidoc utf8_to_uvchr | |
1701 | ||
1702 | Returns the native code point of the first character in the string C<s> | |
1703 | which is assumed to be in UTF-8 encoding; C<retlen> will be set to the | |
1704 | length, in bytes, of that character. | |
1705 | ||
1706 | Some, but not all, UTF-8 malformations are detected, and in fact, some | |
1707 | malformed input could cause reading beyond the end of the input buffer, which | |
1708 | is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead. | |
1709 | ||
1710 | If C<s> points to one of the detected malformations, and UTF8 warnings are | |
1711 | enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't | |
796b6530 | 1712 | C<NULL>) to -1. If those warnings are off, the computed value if well-defined (or |
f2645549 KW |
1713 | the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen> |
1714 | is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the | |
1715 | next possible position in C<s> that could begin a non-malformed character. | |
1716 | See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned. | |
1717 | ||
1718 | =cut | |
1719 | */ | |
1720 | ||
1721 | UV | |
1722 | Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen) | |
1723 | { | |
1724 | PERL_ARGS_ASSERT_UTF8_TO_UVCHR; | |
1725 | ||
1726 | return utf8_to_uvchr_buf(s, s + UTF8_MAXBYTES, retlen); | |
1727 | } | |
1728 | ||
1729 | /* | |
1730 | =for apidoc utf8_to_uvuni | |
1731 | ||
1732 | Returns the Unicode code point of the first character in the string C<s> | |
1733 | which is assumed to be in UTF-8 encoding; C<retlen> will be set to the | |
1734 | length, in bytes, of that character. | |
1735 | ||
1736 | Some, but not all, UTF-8 malformations are detected, and in fact, some | |
1737 | malformed input could cause reading beyond the end of the input buffer, which | |
1738 | is one reason why this function is deprecated. The other is that only in | |
1739 | extremely limited circumstances should the Unicode versus native code point be | |
1740 | of any interest to you. See L</utf8_to_uvuni_buf> for alternatives. | |
1741 | ||
1742 | If C<s> points to one of the detected malformations, and UTF8 warnings are | |
1743 | enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to | |
1744 | NULL) to -1. If those warnings are off, the computed value if well-defined (or | |
1745 | the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen> | |
1746 | is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the | |
1747 | next possible position in C<s> that could begin a non-malformed character. | |
1748 | See L</utf8n_to_uvchr> for details on when the REPLACEMENT CHARACTER is returned. | |
1749 | ||
1750 | =cut | |
1751 | */ | |
1752 | ||
1753 | UV | |
1754 | Perl_utf8_to_uvuni(pTHX_ const U8 *s, STRLEN *retlen) | |
1755 | { | |
1756 | PERL_ARGS_ASSERT_UTF8_TO_UVUNI; | |
1757 | ||
1758 | return NATIVE_TO_UNI(valid_utf8_to_uvchr(s, retlen)); | |
1759 | } | |
1760 | ||
09d7a3ba FC |
1761 | /* |
1762 | =for apidoc Am|HV *|pad_compname_type|PADOFFSET po | |
1763 | ||
2d7f6611 | 1764 | Looks up the type of the lexical variable at position C<po> in the |
09d7a3ba FC |
1765 | currently-compiling pad. If the variable is typed, the stash of the |
1766 | class to which it is typed is returned. If not, C<NULL> is returned. | |
1767 | ||
1768 | =cut | |
1769 | */ | |
1770 | ||
1771 | HV * | |
1772 | Perl_pad_compname_type(pTHX_ const PADOFFSET po) | |
1773 | { | |
1774 | return PAD_COMPNAME_TYPE(po); | |
1775 | } | |
1776 | ||
534dad48 | 1777 | /* return ptr to little string in big string, NULL if not found */ |
fb245905 | 1778 | /* The original version of this routine was donated by Corey Satten. */ |
534dad48 CB |
1779 | |
1780 | char * | |
1781 | Perl_instr(const char *big, const char *little) | |
1782 | { | |
534dad48 | 1783 | PERL_ARGS_ASSERT_INSTR; |
534dad48 | 1784 | |
fb245905 | 1785 | return instr((char *) big, (char *) little); |
534dad48 | 1786 | } |
0ddd4a5b | 1787 | |
20fac488 GA |
1788 | #endif /* NO_MATHOMS */ |
1789 | ||
d5b2b27b | 1790 | /* |
14d04a33 | 1791 | * ex: set ts=8 sts=4 sw=4 et: |
7ee2227d | 1792 | */ |