1 ################################################################################
3 ## Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
4 ## Version 2.x, Copyright (C) 2001, Paul Marquess.
5 ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
7 ## This program is free software; you can redistribute it and/or
8 ## modify it under the same terms as Perl itself.
10 ################################################################################
27 PERL_USE_GCC_BRACE_GROUPS
39 __UNDEFINED__ cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
40 __UNDEFINED__ OpHAS_SIBLING(o) (cBOOL((o)->op_sibling))
41 __UNDEFINED__ OpSIBLING(o) (0 + (o)->op_sibling)
42 __UNDEFINED__ OpMORESIB_set(o, sib) ((o)->op_sibling = (sib))
43 __UNDEFINED__ OpLASTSIB_set(o, parent) ((o)->op_sibling = NULL)
44 __UNDEFINED__ OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib))
45 __UNDEFINED__ HEf_SVKEY -2
47 #if defined(DEBUGGING) && !defined(__COVERITY__)
48 __UNDEFINED__ __ASSERT_(statement) assert(statement),
50 __UNDEFINED__ __ASSERT_(statement)
53 /* These could become provided when they become part of the public API */
54 __UNDEF_NOT_PROVIDED__ withinCOUNT(c, l, n) \
55 (((WIDEST_UTYPE) (((c)) - ((l) | 0))) <= (((WIDEST_UTYPE) ((n) | 0))))
56 __UNDEF_NOT_PROVIDED__ inRANGE(c, l, u) \
57 ( (sizeof(c) == sizeof(U8)) ? withinCOUNT(((U8) (c)), (l), ((u) - (l))) \
58 : (sizeof(c) == sizeof(U16)) ? withinCOUNT(((U16) (c)), (l), ((u) - (l))) \
59 : (sizeof(c) == sizeof(U32)) ? withinCOUNT(((U32) (c)), (l), ((u) - (l))) \
60 : (withinCOUNT(((WIDEST_UTYPE) (c)), (l), ((u) - (l)))))
62 /* Create the macro for "is'macro'_utf8_safe(s, e)". For code points below
63 * 256, it calls the equivalent _L1 macro by converting the UTF-8 to code
64 * point. That is so that it can automatically get the bug fixes done in this
66 #define D_PPP_IS_GENERIC_UTF8_SAFE(s, e, macro) \
69 : UTF8_IS_INVARIANT((s)[0]) \
70 ? is ## macro ## _L1((s)[0]) \
71 : (((e) - (s)) < UTF8SKIP(s)) \
73 : UTF8_IS_DOWNGRADEABLE_START((s)[0]) \
74 /* The cast in the line below is only to silence warnings */ \
75 ? is ## macro ## _L1((WIDEST_UTYPE) LATIN1_TO_NATIVE( \
76 UTF8_ACCUMULATE(NATIVE_UTF8_TO_I8((s)[0]) \
77 & UTF_START_MASK(2), \
79 : is ## macro ## _utf8(s))
81 __UNDEFINED__ SvRX(rv) (SvROK((rv)) ? (SvMAGICAL(SvRV((rv))) ? (mg_find(SvRV((rv)), PERL_MAGIC_qr) ? mg_find(SvRV((rv)), PERL_MAGIC_qr)->mg_obj : NULL) : NULL) : NULL)
82 __UNDEFINED__ SvRXOK(sv) (!!SvRX(sv))
84 #ifndef PERL_UNUSED_DECL
86 # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
87 # define PERL_UNUSED_DECL
89 # define PERL_UNUSED_DECL __attribute__((unused))
92 # define PERL_UNUSED_DECL
96 #ifndef PERL_UNUSED_ARG
97 # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
99 # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
101 # define PERL_UNUSED_ARG(x) ((void)x)
105 #ifndef PERL_UNUSED_VAR
106 # define PERL_UNUSED_VAR(x) ((void)x)
109 #ifndef PERL_UNUSED_CONTEXT
111 # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl)
113 # define PERL_UNUSED_CONTEXT
117 #ifndef PERL_UNUSED_RESULT
118 # if defined(__GNUC__) && defined(HASATTRIBUTE_WARN_UNUSED_RESULT)
119 # define PERL_UNUSED_RESULT(v) STMT_START { __typeof__(v) z = (v); (void)sizeof(z); } STMT_END
121 # define PERL_UNUSED_RESULT(v) ((void)(v))
125 __UNDEFINED__ NOOP /*EMPTY*/(void)0
126 __UNDEFINED__ dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL
129 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
130 # define NVTYPE long double
132 # define NVTYPE double
138 # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
140 # define INT2PTR(any,d) (any)(d)
142 # if PTRSIZE == LONGSIZE
143 # define PTRV unsigned long
145 # define PTRV unsigned
147 # define INT2PTR(any,d) (any)(PTRV)(d)
152 # if PTRSIZE == LONGSIZE
153 # define PTR2ul(p) (unsigned long)(p)
155 # define PTR2ul(p) INT2PTR(unsigned long,p)
159 __UNDEFINED__ PTR2nat(p) (PTRV)(p)
160 __UNDEFINED__ NUM2PTR(any,d) (any)PTR2nat(d)
161 __UNDEFINED__ PTR2IV(p) INT2PTR(IV,p)
162 __UNDEFINED__ PTR2UV(p) INT2PTR(UV,p)
163 __UNDEFINED__ PTR2NV(p) NUM2PTR(NV,p)
165 #undef START_EXTERN_C
169 # define START_EXTERN_C extern "C" {
170 # define END_EXTERN_C }
171 # define EXTERN_C extern "C"
173 # define START_EXTERN_C
174 # define END_EXTERN_C
175 # define EXTERN_C extern
178 #if { VERSION < 5.004 } || defined(PERL_GCC_PEDANTIC)
179 # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
180 __UNDEF_NOT_PROVIDED__ PERL_GCC_BRACE_GROUPS_FORBIDDEN
184 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
185 # ifndef PERL_USE_GCC_BRACE_GROUPS
186 # define PERL_USE_GCC_BRACE_GROUPS
192 #ifdef PERL_USE_GCC_BRACE_GROUPS
193 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
196 # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
197 # define STMT_START if (1)
198 # define STMT_END else (void)0
200 # define STMT_START do
201 # define STMT_END while (0)
205 __UNDEFINED__ boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
207 /* DEFSV appears first in 5.004_56 */
208 __UNDEFINED__ DEFSV GvSV(PL_defgv)
209 __UNDEFINED__ SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
210 __UNDEFINED__ DEFSV_set(sv) (DEFSV = (sv))
212 /* Older perls (<=5.003) lack AvFILLp */
213 __UNDEFINED__ AvFILLp AvFILL
215 __UNDEFINED__ av_tindex AvFILL
216 __UNDEFINED__ av_top_index AvFILL
218 __UNDEFINED__ ERRSV get_sv("@",FALSE)
221 * This function's backport doesn't support the length parameter, but
222 * rather ignores it. Portability can only be ensured if the length
223 * parameter is used for speed reasons, but the length can always be
224 * correctly computed from the string argument.
227 __UNDEFINED__ gv_stashpvn(str,len,create) gv_stashpv(str,create)
230 __UNDEFINED__ get_cv perl_get_cv
231 __UNDEFINED__ get_sv perl_get_sv
232 __UNDEFINED__ get_av perl_get_av
233 __UNDEFINED__ get_hv perl_get_hv
236 __UNDEFINED__ dUNDERBAR dNOOP
237 __UNDEFINED__ UNDERBAR DEFSV
239 __UNDEFINED__ dAX I32 ax = MARK - PL_stack_base + 1
240 __UNDEFINED__ dITEMS I32 items = SP - MARK
242 __UNDEFINED__ dXSTARG SV * targ = sv_newmortal()
244 __UNDEFINED__ dAXMARK I32 ax = POPMARK; \
245 register SV ** const mark = PL_stack_base + ax++
248 __UNDEFINED__ XSprePUSH (sp = PL_stack_base + ax - 1)
250 #if { VERSION < 5.005 }
252 # define XSRETURN(off) \
254 PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
259 __UNDEFINED__ XSPROTO(name) void name(pTHX_ CV* cv)
260 __UNDEFINED__ SVfARG(p) ((void*)(p))
262 __UNDEFINED__ PERL_ABS(x) ((x) < 0 ? -(x) : (x))
264 __UNDEFINED__ dVAR dNOOP
266 __UNDEFINED__ SVf "_"
268 __UNDEFINED__ CPERLscope(x) x
270 __UNDEFINED__ PERL_HASH(hash,str,len) \
272 const char *s_PeRlHaSh = str; \
273 I32 i_PeRlHaSh = len; \
274 U32 hash_PeRlHaSh = 0; \
275 while (i_PeRlHaSh--) \
276 hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
277 (hash) = hash_PeRlHaSh; \
280 #ifndef PERLIO_FUNCS_DECL
281 # ifdef PERLIO_FUNCS_CONST
282 # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs
283 # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs)
285 # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs
286 # define PERLIO_FUNCS_CAST(funcs) (funcs)
290 /* provide these typedefs for older perls */
291 #if { VERSION < 5.9.3 }
294 typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto);
296 typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX);
299 typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*);
306 # define WIDEST_UTYPE U64TYPE
308 # define WIDEST_UTYPE Quad_t
311 # define WIDEST_UTYPE U32
315 /* On versions without NATIVE_TO_ASCII, only ASCII is supported */
316 #if defined(EBCDIC) && defined(NATIVE_TO_ASCI)
317 __UNDEFINED__ NATIVE_TO_LATIN1(c) NATIVE_TO_ASCII(c)
318 __UNDEFINED__ LATIN1_TO_NATIVE(c) ASCII_TO_NATIVE(c)
319 __UNDEFINED__ NATIVE_TO_UNI(c) ((c) > 255 ? (c) : NATIVE_TO_LATIN1(c))
320 __UNDEFINED__ UNI_TO_NATIVE(c) ((c) > 255 ? (c) : LATIN1_TO_NATIVE(c))
322 __UNDEFINED__ NATIVE_TO_LATIN1(c) (c)
323 __UNDEFINED__ LATIN1_TO_NATIVE(c) (c)
324 __UNDEFINED__ NATIVE_TO_UNI(c) (c)
325 __UNDEFINED__ UNI_TO_NATIVE(c) (c)
328 /* Warning: LATIN1_TO_NATIVE, NATIVE_TO_LATIN1 NATIVE_TO_UNI UNI_TO_NATIVE
329 EBCDIC is not supported on versions earlier than 5.7.1
334 /* This is the first version where these macros are fully correct on EBCDIC
335 * platforms. Relying on * the C library functions, as earlier releases did,
336 * causes problems with * locales */
337 # if { VERSION < 5.22.0 }
347 # undef isALPHANUMERIC
348 # undef isALPHANUMERIC_A
349 # undef isALPHANUMERIC_L1
394 # undef isWORDCHAR_L1
400 __UNDEFINED__ isASCII(c) (isCNTRL(c) || isPRINT(c))
402 /* The below is accurate for all EBCDIC code pages supported by
403 * all the versions of Perl overridden by this */
404 __UNDEFINED__ isCNTRL(c) ( (c) == '\0' || (c) == '\a' || (c) == '\b' \
405 || (c) == '\f' || (c) == '\n' || (c) == '\r' \
406 || (c) == '\t' || (c) == '\v' \
407 || ((c) <= 3 && (c) >= 1) /* SOH, STX, ETX */ \
408 || (c) == 7 /* U+7F DEL */ \
409 || ((c) <= 0x13 && (c) >= 0x0E) /* SO, SI */ \
411 || (c) == 0x18 /* U+18 CAN */ \
412 || (c) == 0x19 /* U+19 EOM */ \
413 || ((c) <= 0x1F && (c) >= 0x1C) /* [FGRU]S */ \
414 || (c) == 0x26 /* U+17 ETB */ \
415 || (c) == 0x27 /* U+1B ESC */ \
416 || (c) == 0x2D /* U+05 ENQ */ \
417 || (c) == 0x2E /* U+06 ACK */ \
418 || (c) == 0x32 /* U+16 SYN */ \
419 || (c) == 0x37 /* U+04 EOT */ \
420 || (c) == 0x3C /* U+14 DC4 */ \
421 || (c) == 0x3D /* U+15 NAK */ \
422 || (c) == 0x3F /* U+1A SUB */ \
425 #if '^' == 106 /* EBCDIC POSIX-BC */
426 # define D_PPP_OUTLIER_CONTROL 0x5F
427 #else /* EBCDIC 1047 037 */
428 # define D_PPP_OUTLIER_CONTROL 0xFF
431 /* The controls are everything below blank, plus one outlier */
432 __UNDEFINED__ isCNTRL_L1(c) ((WIDEST_UTYPE) (c) < ' ' \
433 || (WIDEST_UTYPE) (c) == D_PPP_OUTLIER_CONTROL)
434 /* The ordering of the tests in this and isUPPER are to exclude most characters
436 __UNDEFINED__ isLOWER(c) ( (c) >= 'a' && (c) <= 'z' \
438 || ((c) >= 'j' && (c) <= 'r') \
440 __UNDEFINED__ isUPPER(c) ( (c) >= 'A' && (c) <= 'Z' \
442 || ((c) >= 'J' && (c) <= 'R') \
445 #else /* Above is EBCDIC; below is ASCII */
447 # if { VERSION < 5.4.0 }
448 /* The implementation of these in older perl versions can give wrong results if
449 * the C program locale is set to other than the C locale */
464 # if { VERSION < 5.8.0 } /* earlier perls omitted DEL */
468 # if { VERSION < 5.10.0 }
469 /* earlier perls included all of the isSPACE() characters, which is wrong. The
470 * version provided by Devel::PPPort always overrides an existing buggy
476 # if { VERSION < 5.14.0 }
477 /* earlier perls always returned true if the parameter was a signed char */
482 # if { VERSION < 5.17.8 } /* earlier perls didn't include PILCROW, SECTION SIGN */
486 # if { VERSION < 5.13.7 } /* khw didn't investigate why this failed */
490 # if { VERSION < 5.20.0 } /* earlier perls didn't include \v */
497 __UNDEFINED__ isASCII(c) ((WIDEST_UTYPE) (c) <= 127)
498 __UNDEFINED__ isCNTRL(c) ((WIDEST_UTYPE) (c) < ' ' || (c) == 127)
499 __UNDEFINED__ isCNTRL_L1(c) (isCNTRL(c) || ( (WIDEST_UTYPE) (c) <= 0x9F \
500 && (WIDEST_UTYPE) (c) >= 0x80))
501 __UNDEFINED__ isLOWER(c) ((c) >= 'a' && (c) <= 'z')
502 __UNDEFINED__ isUPPER(c) ((c) <= 'Z' && (c) >= 'A')
504 #endif /* Below are definitions common to EBCDIC and ASCII */
506 __UNDEFINED__ isASCII_L1(c) isASCII(c)
507 __UNDEFINED__ isALNUM(c) isWORDCHAR(c)
508 __UNDEFINED__ isALNUMC(c) isALPHANUMERIC(c)
509 __UNDEFINED__ isALNUMC_L1(c) isALPHANUMERIC_L1(c)
510 __UNDEFINED__ isALPHA(c) (isUPPER(c) || isLOWER(c))
511 __UNDEFINED__ isALPHA_L1(c) (isUPPER_L1(c) || isLOWER_L1(c))
512 __UNDEFINED__ isALPHANUMERIC(c) (isALPHA(c) || isDIGIT(c))
513 __UNDEFINED__ isALPHANUMERIC_L1(c) (isALPHA_L1(c) || isDIGIT(c))
514 __UNDEFINED__ isBLANK(c) ((c) == ' ' || (c) == '\t')
515 __UNDEFINED__ isBLANK_L1(c) ( isBLANK(c) \
516 || ( (WIDEST_UTYPE) (c) < 256 \
517 && NATIVE_TO_LATIN1((U8) c) == 0xA0))
518 __UNDEFINED__ isDIGIT(c) ((c) <= '9' && (c) >= '0')
519 __UNDEFINED__ isDIGIT_L1(c) isDIGIT(c)
520 __UNDEFINED__ isGRAPH(c) (isWORDCHAR(c) || isPUNCT(c))
521 __UNDEFINED__ isGRAPH_L1(c) ( isPRINT_L1(c) \
523 && NATIVE_TO_LATIN1((U8) c) != 0xA0)
524 __UNDEFINED__ isIDCONT(c) isWORDCHAR(c)
525 __UNDEFINED__ isIDCONT_L1(c) isWORDCHAR_L1(c)
526 __UNDEFINED__ isIDFIRST(c) (isALPHA(c) || (c) == '_')
527 __UNDEFINED__ isIDFIRST_L1(c) (isALPHA_L1(c) || NATIVE_TO_LATIN1(c) == '_')
528 __UNDEFINED__ isLOWER_L1(c) ( isLOWER(c) \
529 || ( (WIDEST_UTYPE) (c) < 256 \
530 && ( ( NATIVE_TO_LATIN1((U8) c) >= 0xDF \
531 && NATIVE_TO_LATIN1((U8) c) != 0xF7) \
532 || NATIVE_TO_LATIN1((U8) c) == 0xAA \
533 || NATIVE_TO_LATIN1((U8) c) == 0xBA \
534 || NATIVE_TO_LATIN1((U8) c) == 0xB5)))
535 __UNDEFINED__ isOCTAL(c) (((WIDEST_UTYPE)((c)) & ~7) == '0')
536 __UNDEFINED__ isOCTAL_L1(c) isOCTAL(c)
537 __UNDEFINED__ isPRINT(c) (isGRAPH(c) || (c) == ' ')
538 __UNDEFINED__ isPRINT_L1(c) ((WIDEST_UTYPE) (c) < 256 && ! isCNTRL_L1(c))
539 __UNDEFINED__ isPSXSPC(c) isSPACE(c)
540 __UNDEFINED__ isPSXSPC_L1(c) isSPACE_L1(c)
541 __UNDEFINED__ isPUNCT(c) ( (c) == '-' || (c) == '!' || (c) == '"' \
542 || (c) == '#' || (c) == '$' || (c) == '%' \
543 || (c) == '&' || (c) == '\'' || (c) == '(' \
544 || (c) == ')' || (c) == '*' || (c) == '+' \
545 || (c) == ',' || (c) == '.' || (c) == '/' \
546 || (c) == ':' || (c) == ';' || (c) == '<' \
547 || (c) == '=' || (c) == '>' || (c) == '?' \
548 || (c) == '@' || (c) == '[' || (c) == '\\' \
549 || (c) == ']' || (c) == '^' || (c) == '_' \
550 || (c) == '`' || (c) == '{' || (c) == '|' \
551 || (c) == '}' || (c) == '~')
552 __UNDEFINED__ isPUNCT_L1(c) ( isPUNCT(c) \
553 || ( (WIDEST_UTYPE) (c) < 256 \
554 && ( NATIVE_TO_LATIN1((U8) c) == 0xA1 \
555 || NATIVE_TO_LATIN1((U8) c) == 0xA7 \
556 || NATIVE_TO_LATIN1((U8) c) == 0xAB \
557 || NATIVE_TO_LATIN1((U8) c) == 0xB6 \
558 || NATIVE_TO_LATIN1((U8) c) == 0xB7 \
559 || NATIVE_TO_LATIN1((U8) c) == 0xBB \
560 || NATIVE_TO_LATIN1((U8) c) == 0xBF)))
561 __UNDEFINED__ isSPACE(c) ( isBLANK(c) || (c) == '\n' || (c) == '\r' \
562 || (c) == '\v' || (c) == '\f')
563 __UNDEFINED__ isSPACE_L1(c) ( isSPACE(c) \
564 || ( (WIDEST_UTYPE) (c) < 256 \
565 && ( NATIVE_TO_LATIN1((U8) c) == 0x85 \
566 || NATIVE_TO_LATIN1((U8) c) == 0xA0)))
567 __UNDEFINED__ isUPPER_L1(c) ( isUPPER(c) \
568 || ( (WIDEST_UTYPE) (c) < 256 \
569 && ( NATIVE_TO_LATIN1((U8) c) >= 0xC0 \
570 && NATIVE_TO_LATIN1((U8) c) <= 0xDE \
571 && NATIVE_TO_LATIN1((U8) c) != 0xD7)))
572 __UNDEFINED__ isWORDCHAR(c) (isALPHANUMERIC(c) || (c) == '_')
573 __UNDEFINED__ isWORDCHAR_L1(c) (isIDFIRST_L1(c) || isDIGIT(c))
574 __UNDEFINED__ isXDIGIT(c) ( isDIGIT(c) \
575 || ((c) >= 'a' && (c) <= 'f') \
576 || ((c) >= 'A' && (c) <= 'F'))
577 __UNDEFINED__ isXDIGIT_L1(c) isXDIGIT(c)
579 __UNDEFINED__ isALNUM_A(c) isALNUM(c)
580 __UNDEFINED__ isALNUMC_A(c) isALNUMC(c)
581 __UNDEFINED__ isALPHA_A(c) isALPHA(c)
582 __UNDEFINED__ isALPHANUMERIC_A(c) isALPHANUMERIC(c)
583 __UNDEFINED__ isASCII_A(c) isASCII(c)
584 __UNDEFINED__ isBLANK_A(c) isBLANK(c)
585 __UNDEFINED__ isCNTRL_A(c) isCNTRL(c)
586 __UNDEFINED__ isDIGIT_A(c) isDIGIT(c)
587 __UNDEFINED__ isGRAPH_A(c) isGRAPH(c)
588 __UNDEFINED__ isIDCONT_A(c) isIDCONT(c)
589 __UNDEFINED__ isIDFIRST_A(c) isIDFIRST(c)
590 __UNDEFINED__ isLOWER_A(c) isLOWER(c)
591 __UNDEFINED__ isOCTAL_A(c) isOCTAL(c)
592 __UNDEFINED__ isPRINT_A(c) isPRINT(c)
593 __UNDEFINED__ isPSXSPC_A(c) isPSXSPC(c)
594 __UNDEFINED__ isPUNCT_A(c) isPUNCT(c)
595 __UNDEFINED__ isSPACE_A(c) isSPACE(c)
596 __UNDEFINED__ isUPPER_A(c) isUPPER(c)
597 __UNDEFINED__ isWORDCHAR_A(c) isWORDCHAR(c)
598 __UNDEFINED__ isXDIGIT_A(c) isXDIGIT(c)
600 __UNDEFINED__ isASCII_utf8_safe(s,e) isASCII(*(s))
602 #if { VERSION >= 5.006 }
604 __UNDEFINED__ isALPHA_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, ALPHA)
605 # ifdef isALPHANUMERIC_utf8
606 __UNDEFINED__ isALPHANUMERIC_utf8_safe(s,e) \
607 D_PPP_IS_GENERIC_UTF8_SAFE(s, e, ALPHANUMERIC)
609 __UNDEFINED__ isALPHANUMERIC_utf8_safe(s,e) \
610 (isALPHA_utf8_safe(s,e) || isDIGIT_utf8_safe(s,e))
613 /* This was broken before 5.18, and just use this instead of worrying about
614 * which releases the official works on */
616 __UNDEFINED__ isBLANK_utf8_safe(s,e) \
617 ( ( LIKELY((e) > (s)) ) ? /* Machine generated */ \
618 ( ( 0x09 == ((const U8*)s)[0] || 0x20 == ((const U8*)s)[0] ) ? 1 \
619 : ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) ? \
620 ( ( 0xC2 == ((const U8*)s)[0] ) ? \
621 ( ( 0xA0 == ((const U8*)s)[1] ) ? 2 : 0 ) \
622 : ( 0xE1 == ((const U8*)s)[0] ) ? \
623 ( ( ( 0x9A == ((const U8*)s)[1] ) && ( 0x80 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
624 : ( 0xE2 == ((const U8*)s)[0] ) ? \
625 ( ( 0x80 == ((const U8*)s)[1] ) ? \
626 ( ( inRANGE(((const U8*)s)[2], 0x80, 0x8A ) || 0xAF == ((const U8*)s)[2] ) ? 3 : 0 )\
627 : ( ( 0x81 == ((const U8*)s)[1] ) && ( 0x9F == ((const U8*)s)[2] ) ) ? 3 : 0 )\
628 : ( ( ( 0xE3 == ((const U8*)s)[0] ) && ( 0x80 == ((const U8*)s)[1] ) ) && ( 0x80 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
632 # elif 'A' == 193 && '^' == 95 /* EBCDIC 1047 */
634 __UNDEFINED__ isBLANK_utf8_safe(s,e) \
635 ( ( LIKELY((e) > (s)) ) ? \
636 ( ( 0x05 == ((const U8*)s)[0] || 0x40 == ((const U8*)s)[0] ) ? 1 \
637 : ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) ? \
638 ( ( 0x80 == ((const U8*)s)[0] ) ? \
639 ( ( 0x41 == ((const U8*)s)[1] ) ? 2 : 0 ) \
640 : ( 0xBC == ((const U8*)s)[0] ) ? \
641 ( ( ( 0x63 == ((const U8*)s)[1] ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
642 : ( 0xCA == ((const U8*)s)[0] ) ? \
643 ( ( 0x41 == ((const U8*)s)[1] ) ? \
644 ( ( inRANGE(((const U8*)s)[2], 0x41, 0x4A ) || 0x51 == ((const U8*)s)[2] ) ? 3 : 0 )\
645 : ( 0x42 == ((const U8*)s)[1] ) ? \
646 ( ( 0x56 == ((const U8*)s)[2] ) ? 3 : 0 ) \
647 : ( ( 0x43 == ((const U8*)s)[1] ) && ( 0x73 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
648 : ( ( ( 0xCE == ((const U8*)s)[0] ) && ( 0x41 == ((const U8*)s)[1] ) ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
652 # elif 'A' == 193 && '^' == 176 /* EBCDIC 037 */
654 __UNDEFINED__ isBLANK_utf8_safe(s,e) \
655 ( ( LIKELY((e) > (s)) ) ? \
656 ( ( 0x05 == ((const U8*)s)[0] || 0x40 == ((const U8*)s)[0] ) ? 1 \
657 : ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) ? \
658 ( ( 0x78 == ((const U8*)s)[0] ) ? \
659 ( ( 0x41 == ((const U8*)s)[1] ) ? 2 : 0 ) \
660 : ( 0xBD == ((const U8*)s)[0] ) ? \
661 ( ( ( 0x62 == ((const U8*)s)[1] ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
662 : ( 0xCA == ((const U8*)s)[0] ) ? \
663 ( ( 0x41 == ((const U8*)s)[1] ) ? \
664 ( ( inRANGE(((const U8*)s)[2], 0x41, 0x4A ) || 0x51 == ((const U8*)s)[2] ) ? 3 : 0 )\
665 : ( 0x42 == ((const U8*)s)[1] ) ? \
666 ( ( 0x56 == ((const U8*)s)[2] ) ? 3 : 0 ) \
667 : ( ( 0x43 == ((const U8*)s)[1] ) && ( 0x72 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
668 : ( ( ( 0xCE == ((const U8*)s)[0] ) && ( 0x41 == ((const U8*)s)[1] ) ) && ( 0x41 == ((const U8*)s)[2] ) ) ? 3 : 0 )\
673 # error Unknown character set
676 __UNDEFINED__ isCNTRL_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, CNTRL)
677 __UNDEFINED__ isDIGIT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, DIGIT)
678 __UNDEFINED__ isGRAPH_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, GRAPH)
679 # ifdef isIDCONT_utf8
680 __UNDEFINED__ isIDCONT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, IDCONT)
682 __UNDEFINED__ isIDCONT_utf8_safe(s,e) isWORDCHAR_utf8_safe(s,e)
685 __UNDEFINED__ isIDFIRST_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, IDFIRST)
686 __UNDEFINED__ isLOWER_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, LOWER)
687 __UNDEFINED__ isPRINT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, PRINT)
689 #undef isPSXSPC_utf8_safe /* Use the modern definition */
690 __UNDEFINED__ isPSXSPC_utf8_safe(s,e) isSPACE_utf8_safe(s,e)
692 __UNDEFINED__ isPUNCT_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, PUNCT)
693 __UNDEFINED__ isSPACE_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, SPACE)
694 __UNDEFINED__ isUPPER_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, UPPER)
696 # ifdef isWORDCHAR_utf8
697 __UNDEFINED__ isWORDCHAR_utf8_safe(s,e) D_PPP_IS_GENERIC_UTF8_SAFE(s, e, WORDCHAR)
699 __UNDEFINED__ isWORDCHAR_utf8_safe(s,e) \
700 (isALPHANUMERIC_utf8_safe(s,e) || (*(s)) == '_')
703 /* This was broken before 5.12, and just use this instead of worrying about
704 * which releases the official works on */
706 __UNDEFINED__ isXDIGIT_utf8_safe(s,e) \
707 ( ( LIKELY((e) > (s)) ) ? \
708 ( ( inRANGE(((const U8*)s)[0], 0x30, 0x39 ) || inRANGE(((const U8*)s)[0], 0x41, 0x46 ) || inRANGE(((const U8*)s)[0], 0x61, 0x66 ) ) ? 1\
709 : ( ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) && ( 0xEF == ((const U8*)s)[0] ) ) ? ( ( 0xBC == ((const U8*)s)[1] ) ?\
710 ( ( inRANGE(((const U8*)s)[2], 0x90, 0x99 ) || inRANGE(((const U8*)s)[2], 0xA1, 0xA6 ) ) ? 3 : 0 )\
711 : ( ( 0xBD == ((const U8*)s)[1] ) && ( inRANGE(((const U8*)s)[2], 0x81, 0x86 ) ) ) ? 3 : 0 ) : 0 )\
714 # elif 'A' == 193 && '^' == 95 /* EBCDIC 1047 */
716 __UNDEFINED__ isXDIGIT_utf8_safe(s,e) \
717 ( ( LIKELY((e) > (s)) ) ? \
718 ( ( inRANGE(((const U8*)s)[0], 0x81, 0x86 ) || inRANGE(((const U8*)s)[0], 0xC1, 0xC6 ) || inRANGE(((const U8*)s)[0], 0xF0, 0xF9 ) ) ? 1\
719 : ( ( ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) && ( 0xDD == ((const U8*)s)[0] ) ) && ( 0x73 == ((const U8*)s)[1] ) ) ? ( ( 0x67 == ((const U8*)s)[2] ) ?\
720 ( ( inRANGE(((const U8*)s)[3], 0x57, 0x59 ) || inRANGE(((const U8*)s)[3], 0x62, 0x68 ) ) ? 4 : 0 )\
721 : ( ( inRANGE(((const U8*)s)[2], 0x68, 0x69 ) ) && ( inRANGE(((const U8*)s)[3], 0x42, 0x47 ) ) ) ? 4 : 0 ) : 0 )\
724 # elif 'A' == 193 && '^' == 176 /* EBCDIC 037 */
726 __UNDEFINED__ isXDIGIT_utf8_safe(s,e) \
727 ( ( LIKELY((e) > (s)) ) ? \
728 ( ( inRANGE(((const U8*)s)[0], 0x81, 0x86 ) || inRANGE(((const U8*)s)[0], 0xC1, 0xC6 ) || inRANGE(((const U8*)s)[0], 0xF0, 0xF9 ) ) ? 1\
729 : ( ( ( LIKELY(((e) - (s)) >= UTF8SKIP(s)) ) && ( 0xDD == ((const U8*)s)[0] ) ) && ( 0x72 == ((const U8*)s)[1] ) ) ? ( ( 0x66 == ((const U8*)s)[2] ) ?\
730 ( ( inRANGE(((const U8*)s)[3], 0x57, 0x59 ) || 0x5F == ((const U8*)s)[3] || inRANGE(((const U8*)s)[3], 0x62, 0x67 ) ) ? 4 : 0 )\
731 : ( ( inRANGE(((const U8*)s)[2], 0x67, 0x68 ) ) && ( inRANGE(((const U8*)s)[3], 0x42, 0x47 ) ) ) ? 4 : 0 ) : 0 )\
735 # error Unknown character set
740 /* Until we figure out how to support this in older perls... */
741 #if { VERSION >= 5.8.0 }
743 __UNDEFINED__ HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
744 SvUTF8(HeKEY_sv(he)) : \
749 __UNDEFINED__ C_ARRAY_LENGTH(a) (sizeof(a)/sizeof((a)[0]))
750 __UNDEFINED__ C_ARRAY_END(a) ((a) + C_ARRAY_LENGTH(a))
752 __UNDEFINED__ LIKELY(x) (x)
753 __UNDEFINED__ UNLIKELY(x) (x)
756 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
757 # define MUTABLE_PTR(p) ({ void *_p = (p); _p; })
759 # define MUTABLE_PTR(p) ((void *) (p))
763 __UNDEFINED__ MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p))
767 typedef XSPROTO(XSPROTO_test_t);
768 typedef XSPROTO_test_t *XSPROTO_test_t_ptr;
770 XS(XS_Devel__PPPort_dXSTARG); /* prototype */
771 XS(XS_Devel__PPPort_dXSTARG)
779 iv = SvIV(ST(0)) + 1;
784 XS(XS_Devel__PPPort_dAXMARK); /* prototype */
785 XS(XS_Devel__PPPort_dAXMARK)
794 iv = SvIV(ST(0)) - 1;
802 XSPROTO_test_t_ptr p = &XS_Devel__PPPort_dXSTARG;
803 newXS("Devel::PPPort::dXSTARG", *p, file);
805 newXS("Devel::PPPort::dAXMARK", XS_Devel__PPPort_dAXMARK, file);
820 x = newOP(OP_PUSHMARK, 0);
822 /* No siblings yet! */
823 if (OpHAS_SIBLING(x) || OpSIBLING(x)) {
824 failures++; warn("Op should not have had a sib");
831 for (i = 0; i < 2; i++) {
832 OP *newsib = newOP(OP_PUSHMARK, 0);
833 OpMORESIB_set(kid, newsib);
835 kid = OpSIBLING(kid);
838 middlekid = OpSIBLING(x);
840 /* Should now have a sibling */
841 if (! OpHAS_SIBLING(x) || ! OpSIBLING(x) ) {
842 failures++; warn("Op should have had a sib after moresib_set");
845 /* Count the siblings */
846 for (kid = OpSIBLING(x); kid; kid = OpSIBLING(kid)) {
851 failures++; warn("Kid had %d sibs, expected 2", count);
854 if (OpHAS_SIBLING(lastkid) || OpSIBLING(lastkid)) {
855 failures++; warn("Last kid should not have a sib");
858 /* Really sets the parent, and says 'no more siblings' */
859 OpLASTSIB_set(x, lastkid);
861 if (OpHAS_SIBLING(x) || OpSIBLING(x)) {
862 failures++; warn("OpLASTSIB_set failed?");
865 /* Restore the kid */
866 OpMORESIB_set(x, lastkid);
868 /* Try to remove it again */
869 OpLASTSIB_set(x, NULL);
871 if (OpHAS_SIBLING(x) || OpSIBLING(x)) {
872 failures++; warn("OpLASTSIB_set with NULL failed?");
875 /* Try to restore with maybesib_set */
876 OpMAYBESIB_set(x, lastkid, NULL);
878 if (! OpHAS_SIBLING(x) || ! OpSIBLING(x) ) {
879 failures++; warn("Op should have had a sib after maybesibset");
904 RETVAL += PTR2nat(p) != 0 ? 1 : 0;
905 RETVAL += PTR2ul(p) != 0UL ? 2 : 0;
906 RETVAL += PTR2UV(p) != (UV) 0 ? 4 : 0;
907 RETVAL += PTR2IV(p) != (IV) 0 ? 8 : 0;
908 RETVAL += PTR2NV(p) != (NV) 0 ? 16 : 0;
909 RETVAL += p > NUM2PTR(int *, 0) ? 32 : 0;
915 gv_stashpvn(name, create)
919 RETVAL = gv_stashpvn(name, strlen(name), create) != NULL;
928 RETVAL = get_sv(name, create) != NULL;
937 RETVAL = get_av(name, create) != NULL;
946 RETVAL = get_hv(name, create) != NULL;
955 RETVAL = get_cv(name, create) != NULL;
975 RETVAL = newSVsv(boolSV(value));
982 RETVAL = newSVsv(DEFSV);
989 XPUSHs(sv_mortalcopy(DEFSV));
992 DEFSV_set(newSVpvs("DEFSV"));
993 XPUSHs(sv_mortalcopy(DEFSV));
994 /* Yes, this leaks the above scalar; 5.005 with threads for some reason */
995 /* frees it upon LEAVE, thus mortalizing it causes "attempt to free..." */
996 /* sv_2mortal(DEFSV); */
998 XPUSHs(sv_mortalcopy(DEFSV));
1004 RETVAL = SvTRUEx(ERRSV);
1013 RETVAL = newSVsv(UNDERBAR);
1036 #if { VERSION >= 5.004 }
1037 x = sv_2mortal(newSVpvf("[%" SVf "]", SVfARG(x)));
1043 Perl_ppaddr_t(string)
1046 Perl_ppaddr_t lower;
1048 lower = PL_ppaddr[OP_LC];
1049 mXPUSHs(newSVpv(string, 0));
1052 (void)*(lower)(aTHXR);
1057 #if { VERSION >= 5.8.0 }
1060 check_HeUTF8(utf8_key)
1070 key = SvPV(utf8_key, klen);
1071 if (SvUTF8(utf8_key)) klen *= -1;
1072 hv_store(hash, key, klen, newSVpvs("string"), 0);
1074 ent = hv_iternext(hash);
1076 mXPUSHp((HeUTF8(ent) == 0 ? "norm" : "utf8"), 4);
1085 int x[] = { 10, 11, 12, 13 };
1087 mXPUSHi(C_ARRAY_LENGTH(x)); /* 4 */
1088 mXPUSHi(*(C_ARRAY_END(x)-1)); /* 13 */
1094 RETVAL = isBLANK(ord);
1102 RETVAL = isBLANK_A(ord);
1110 RETVAL = isBLANK_L1(ord);
1118 RETVAL = isUPPER(ord);
1126 RETVAL = isUPPER_A(ord);
1134 RETVAL = isUPPER_L1(ord);
1142 RETVAL = isLOWER(ord);
1150 RETVAL = isLOWER_A(ord);
1158 RETVAL = isLOWER_L1(ord);
1166 RETVAL = isALPHA(ord);
1174 RETVAL = isALPHA_A(ord);
1182 RETVAL = isALPHA_L1(ord);
1190 RETVAL = isWORDCHAR(ord);
1198 RETVAL = isWORDCHAR_A(ord);
1206 RETVAL = isWORDCHAR_L1(ord);
1214 RETVAL = isALPHANUMERIC(ord);
1219 isALPHANUMERIC_A(ord)
1222 RETVAL = isALPHANUMERIC_A(ord);
1230 RETVAL = isALNUM(ord);
1238 RETVAL = isALNUM_A(ord);
1246 RETVAL = isDIGIT(ord);
1254 RETVAL = isDIGIT_A(ord);
1262 RETVAL = isOCTAL(ord);
1270 RETVAL = isOCTAL_A(ord);
1278 RETVAL = isIDFIRST(ord);
1286 RETVAL = isIDFIRST_A(ord);
1294 RETVAL = isIDCONT(ord);
1302 RETVAL = isIDCONT_A(ord);
1310 RETVAL = isSPACE(ord);
1318 RETVAL = isSPACE_A(ord);
1326 RETVAL = isASCII(ord);
1334 RETVAL = isASCII_A(ord);
1342 RETVAL = isCNTRL(ord);
1350 RETVAL = isCNTRL_A(ord);
1358 RETVAL = isPRINT(ord);
1366 RETVAL = isPRINT_A(ord);
1374 RETVAL = isGRAPH(ord);
1382 RETVAL = isGRAPH_A(ord);
1390 RETVAL = isPUNCT(ord);
1398 RETVAL = isPUNCT_A(ord);
1406 RETVAL = isXDIGIT(ord);
1414 RETVAL = isXDIGIT_A(ord);
1422 RETVAL = isPSXSPC(ord);
1430 RETVAL = isPSXSPC_A(ord);
1435 isALPHANUMERIC_L1(ord)
1438 RETVAL = isALPHANUMERIC_L1(ord);
1446 RETVAL = isALNUMC_L1(ord);
1454 RETVAL = isDIGIT_L1(ord);
1462 RETVAL = isOCTAL_L1(ord);
1470 RETVAL = isIDFIRST_L1(ord);
1478 RETVAL = isIDCONT_L1(ord);
1486 RETVAL = isSPACE_L1(ord);
1494 RETVAL = isASCII_L1(ord);
1502 RETVAL = isCNTRL_L1(ord);
1510 RETVAL = isPRINT_L1(ord);
1518 RETVAL = isGRAPH_L1(ord);
1526 RETVAL = isPUNCT_L1(ord);
1534 RETVAL = isXDIGIT_L1(ord);
1542 RETVAL = isPSXSPC_L1(ord);
1546 #if { VERSION >= 5.006 }
1549 isALPHA_utf8_safe(s, offset)
1553 RETVAL = isALPHA_utf8_safe(s, s + UTF8SKIP(s) + offset);
1558 isALPHANUMERIC_utf8_safe(s, offset)
1562 RETVAL = isALPHANUMERIC_utf8_safe(s, s + UTF8SKIP(s) + offset);
1567 isASCII_utf8_safe(s, offset)
1571 RETVAL = isASCII_utf8_safe(s, s + UTF8SKIP(s) + offset);
1576 isBLANK_utf8_safe(s, offset)
1580 RETVAL = isBLANK_utf8_safe(s, s + UTF8SKIP(s) + offset);
1585 isCNTRL_utf8_safe(s, offset)
1589 RETVAL = isCNTRL_utf8_safe(s, s + UTF8SKIP(s) + offset);
1594 isDIGIT_utf8_safe(s, offset)
1598 RETVAL = isDIGIT_utf8_safe(s, s + UTF8SKIP(s) + offset);
1603 isGRAPH_utf8_safe(s, offset)
1607 RETVAL = isGRAPH_utf8_safe(s, s + UTF8SKIP(s) + offset);
1612 isIDCONT_utf8_safe(s, offset)
1616 RETVAL = isIDCONT_utf8_safe(s, s + UTF8SKIP(s) + offset);
1621 isIDFIRST_utf8_safe(s, offset)
1625 RETVAL = isIDFIRST_utf8_safe(s, s + UTF8SKIP(s) + offset);
1630 isLOWER_utf8_safe(s, offset)
1634 RETVAL = isLOWER_utf8_safe(s, s + UTF8SKIP(s) + offset);
1639 isPRINT_utf8_safe(s, offset)
1643 RETVAL = isPRINT_utf8_safe(s, s + UTF8SKIP(s) + offset);
1648 isPSXSPC_utf8_safe(s, offset)
1652 RETVAL = isPSXSPC_utf8_safe(s, s + UTF8SKIP(s) + offset);
1657 isPUNCT_utf8_safe(s, offset)
1661 RETVAL = isPUNCT_utf8_safe(s, s + UTF8SKIP(s) + offset);
1666 isSPACE_utf8_safe(s, offset)
1670 RETVAL = isSPACE_utf8_safe(s, s + UTF8SKIP(s) + offset);
1675 isUPPER_utf8_safe(s, offset)
1679 RETVAL = isUPPER_utf8_safe(s, s + UTF8SKIP(s) + offset);
1684 isWORDCHAR_utf8_safe(s, offset)
1688 RETVAL = isWORDCHAR_utf8_safe(s, s + UTF8SKIP(s) + offset);
1693 isXDIGIT_utf8_safe(s, offset)
1697 RETVAL = isXDIGIT_utf8_safe(s, s + UTF8SKIP(s) + offset);
1704 LATIN1_TO_NATIVE(cp)
1707 if (cp > 255) RETVAL= cp;
1708 else RETVAL= LATIN1_TO_NATIVE(cp);
1713 NATIVE_TO_LATIN1(cp)
1716 RETVAL= NATIVE_TO_LATIN1(cp);
1724 RETVAL = av_tindex((AV*)SvRV(av));
1732 RETVAL = av_top_index((AV*)SvRV(av));
1736 =tests plan => 17678
1738 use vars qw($my_sv @my_av %my_hv);
1740 ok(&Devel::PPPort::boolSV(1));
1741 ok(!&Devel::PPPort::boolSV(0));
1744 ok(&Devel::PPPort::DEFSV(), "Fred");
1745 ok(&Devel::PPPort::UNDERBAR(), "Fred");
1747 if ("$]" >= 5.009002 && "$]" < 5.023 && "$]" < 5.023004) {
1749 no warnings "deprecated";
1750 no if $^V > v5.17.9, warnings => "experimental::lexical_topic";
1752 ok(&Devel::PPPort::DEFSV(), "Fred");
1753 ok(&Devel::PPPort::UNDERBAR(), "Tony");
1761 my @r = &Devel::PPPort::DEFSV_modify();
1768 ok(&Devel::PPPort::DEFSV(), "Fred");
1771 ok(!&Devel::PPPort::ERRSV());
1772 eval { cannot_call_this_one() };
1773 ok(&Devel::PPPort::ERRSV());
1775 ok(&Devel::PPPort::gv_stashpvn('Devel::PPPort', 0));
1776 ok(!&Devel::PPPort::gv_stashpvn('does::not::exist', 0));
1777 ok(&Devel::PPPort::gv_stashpvn('does::not::exist', 1));
1780 ok(&Devel::PPPort::get_sv('my_sv', 0));
1781 ok(!&Devel::PPPort::get_sv('not_my_sv', 0));
1782 ok(&Devel::PPPort::get_sv('not_my_sv', 1));
1785 ok(&Devel::PPPort::get_av('my_av', 0));
1786 ok(!&Devel::PPPort::get_av('not_my_av', 0));
1787 ok(&Devel::PPPort::get_av('not_my_av', 1));
1790 ok(&Devel::PPPort::get_hv('my_hv', 0));
1791 ok(!&Devel::PPPort::get_hv('not_my_hv', 0));
1792 ok(&Devel::PPPort::get_hv('not_my_hv', 1));
1795 ok(&Devel::PPPort::get_cv('my_cv', 0));
1796 ok(!&Devel::PPPort::get_cv('not_my_cv', 0));
1797 ok(&Devel::PPPort::get_cv('not_my_cv', 1));
1799 ok(Devel::PPPort::dXSTARG(42), 43);
1800 ok(Devel::PPPort::dAXMARK(4711), 4710);
1802 ok(Devel::PPPort::prepush(), 42);
1804 ok(join(':', Devel::PPPort::xsreturn(0)), 'test1');
1805 ok(join(':', Devel::PPPort::xsreturn(1)), 'test1:test2');
1807 ok(Devel::PPPort::PERL_ABS(42), 42);
1808 ok(Devel::PPPort::PERL_ABS(-13), 13);
1810 ok(Devel::PPPort::SVf(42), "$]" >= 5.004 ? '[42]' : '42');
1811 ok(Devel::PPPort::SVf('abc'), "$]" >= 5.004 ? '[abc]' : 'abc');
1813 ok(&Devel::PPPort::Perl_ppaddr_t("FOO"), "foo");
1815 ok(&Devel::PPPort::ptrtests(), 63);
1817 ok(&Devel::PPPort::OpSIBLING_tests(), 0);
1819 if ("$]" >= 5.009000) {
1821 ok(&Devel::PPPort::check_HeUTF8("hello"), "norm");
1822 ok(&Devel::PPPort::check_HeUTF8("\N{U+263a}"), "utf8");
1829 @r = &Devel::PPPort::check_c_array();
1833 ok(!Devel::PPPort::SvRXOK(""));
1834 ok(!Devel::PPPort::SvRXOK(bless [], "Regexp"));
1837 skip 'no qr// objects in this perl', 0;
1838 skip 'no qr// objects in this perl', 0;
1840 my $qr = eval 'qr/./';
1841 ok(Devel::PPPort::SvRXOK($qr));
1842 ok(Devel::PPPort::SvRXOK(bless $qr, "Surprise"));
1845 ok( Devel::PPPort::NATIVE_TO_LATIN1(0xB6) == 0xB6);
1846 ok( Devel::PPPort::NATIVE_TO_LATIN1(0x1) == 0x1);
1847 ok( Devel::PPPort::NATIVE_TO_LATIN1(ord("A")) == 0x41);
1848 ok( Devel::PPPort::NATIVE_TO_LATIN1(ord("0")) == 0x30);
1850 ok( Devel::PPPort::LATIN1_TO_NATIVE(0xB6) == 0xB6);
1851 if (ord("A") == 65) {
1852 ok( Devel::PPPort::LATIN1_TO_NATIVE(0x41) == 0x41);
1853 ok( Devel::PPPort::LATIN1_TO_NATIVE(0x30) == 0x30);
1856 ok( Devel::PPPort::LATIN1_TO_NATIVE(0x41) == 0xC1);
1857 ok( Devel::PPPort::LATIN1_TO_NATIVE(0x30) == 0xF0);
1860 ok( Devel::PPPort::isALNUMC_L1(ord("5")));
1861 ok( Devel::PPPort::isALNUMC_L1(0xFC));
1862 ok(! Devel::PPPort::isALNUMC_L1(0xB6));
1864 ok( Devel::PPPort::isOCTAL(ord("7")));
1865 ok(! Devel::PPPort::isOCTAL(ord("8")));
1867 ok( Devel::PPPort::isOCTAL_A(ord("0")));
1868 ok(! Devel::PPPort::isOCTAL_A(ord("9")));
1870 ok( Devel::PPPort::isOCTAL_L1(ord("2")));
1871 ok(! Devel::PPPort::isOCTAL_L1(ord("8")));
1873 # For the other properties, we test every code point from 0.255, and a
1874 # smattering of higher ones. First populate a hash with keys like '65:ALPHA'
1875 # to indicate that the code point there is alphabetic
1878 for $i (0x41..0x5A, 0x61..0x7A, 0xAA, 0xB5, 0xBA, 0xC0..0xD6, 0xD8..0xF6,
1881 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1882 $types{"$native:ALPHA"} = 1;
1883 $types{"$native:ALPHANUMERIC"} = 1;
1884 $types{"$native:IDFIRST"} = 1;
1885 $types{"$native:IDCONT"} = 1;
1886 $types{"$native:PRINT"} = 1;
1887 $types{"$native:WORDCHAR"} = 1;
1889 for $i (0x30..0x39, 0x660, 0xFF19) {
1890 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1891 $types{"$native:ALPHANUMERIC"} = 1;
1892 $types{"$native:DIGIT"} = 1;
1893 $types{"$native:IDCONT"} = 1;
1894 $types{"$native:WORDCHAR"} = 1;
1895 $types{"$native:GRAPH"} = 1;
1896 $types{"$native:PRINT"} = 1;
1897 $types{"$native:XDIGIT"} = 1 if $i < 255 || ($i >= 0xFF10 && $i <= 0xFF19);
1901 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1902 $types{"$native:ASCII"} = 1;
1904 for $i (0..0x1f, 0x7F..0x9F) {
1905 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1906 $types{"$native:CNTRL"} = 1;
1908 for $i (0x21..0x7E, 0xA1..0x101, 0x660) {
1909 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1910 $types{"$native:GRAPH"} = 1;
1911 $types{"$native:PRINT"} = 1;
1913 for $i (0x09, 0x20, 0xA0) {
1914 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1915 $types{"$native:BLANK"} = 1;
1916 $types{"$native:SPACE"} = 1;
1917 $types{"$native:PSXSPC"} = 1;
1918 $types{"$native:PRINT"} = 1 if $i > 0x09;
1920 for $i (0x09..0x0D, 0x85, 0x2029) {
1921 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1922 $types{"$native:SPACE"} = 1;
1923 $types{"$native:PSXSPC"} = 1;
1925 for $i (0x41..0x5A, 0xC0..0xD6, 0xD8..0xDE, 0x100) {
1926 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1927 $types{"$native:UPPER"} = 1;
1928 $types{"$native:XDIGIT"} = 1 if $i < 0x47;
1930 for $i (0x61..0x7A, 0xAA, 0xB5, 0xBA, 0xDF..0xF6, 0xF8..0xFF, 0x101) {
1931 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1932 $types{"$native:LOWER"} = 1;
1933 $types{"$native:XDIGIT"} = 1 if $i < 0x67;
1935 for $i (0x21..0x2F, 0x3A..0x40, 0x5B..0x60, 0x7B..0x7E, 0xB6, 0xA1, 0xA7, 0xAB,
1936 0xB7, 0xBB, 0xBF, 0x5BE)
1938 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1939 $types{"$native:PUNCT"} = 1;
1940 $types{"$native:GRAPH"} = 1;
1941 $types{"$native:PRINT"} = 1;
1945 $types{"$i:WORDCHAR"} = 1;
1946 $types{"$i:IDFIRST"} = 1;
1947 $types{"$i:IDCONT"} = 1;
1949 # Now find all the unique code points included above.
1950 my %code_points_to_test;
1952 for $key (keys %types) {
1954 $code_points_to_test{$key} = 1;
1958 for $i (sort { $a <=> $b } keys %code_points_to_test) {
1959 my $native = Devel::PPPort::LATIN1_TO_NATIVE($i);
1960 my $hex = sprintf("0x%02X", $native);
1962 # And for each code point test each of the classes
1964 for $class (qw(ALPHA ALPHANUMERIC ASCII BLANK CNTRL DIGIT GRAPH IDCONT
1965 IDFIRST LOWER PRINT PSXSPC PUNCT SPACE UPPER WORDCHAR
1968 if ($i < 256) { # For the ones that can fit in a byte, test each of
1971 for $suffix ("", "_A", "_L1") {
1972 my $should_be = ($i > 0x7F && $suffix ne "_L1")
1973 ? 0 # Fail on non-ASCII unless L1
1974 : ($types{"$native:$class"} || 0);
1975 my $eval_string = "Devel::PPPort::is${class}$suffix($hex)";
1976 my $is = eval $eval_string || 0;
1977 die "eval 'For $i: $eval_string' gave $@" if $@;
1978 ok($is, $should_be, "'$eval_string'");
1982 # For all code points, test the '_utf8' macros
1984 skip("No UTF-8 on this perl", 0);
1986 skip("No UTF-8 on this perl", 0);
1990 my $utf8 = quotemeta Devel::PPPort::uvoffuni_to_utf8($i);
1991 if ("$]" < 5.007 && $native > 255) {
1992 skip("Perls earlier than 5.7 give wrong answers for above Latin1 code points", 0);
1994 elsif ("$]" <= 5.011003 && $native == 0x2029 && ($class eq 'PRINT' || $class eq 'GRAPH')) {
1995 skip("Perls earlier than 5.11.3 considered high space characters as isPRINT and isGRAPH", 0);
1999 my $should_be = $types{"$native:$class"} || 0;
2000 my $eval_string = "Devel::PPPort::is${class}_utf8_safe(\"$utf8\", 0)";
2001 my $is = eval $eval_string || 0;
2002 die "eval 'For $i, $eval_string' gave $@" if $@;
2003 ok($is, $should_be, sprintf("For U+%04X '%s'", $native, $eval_string));
2006 # And for the high code points, test that a too short malformation (the
2007 # -1) causes it to fail
2009 if ("$]" >= 5.025009) {
2010 skip("Prints an annoying error message that khw doesn't know how to easily suppress", 0);
2013 my $eval_string = "Devel::PPPort::is${class}_utf8_safe(\"$utf8\", -1)";
2014 my $is = eval "no warnings; $eval_string" || 0;
2015 die "eval '$eval_string' gave $@" if $@;
2016 ok($is, 0, sprintf("For U+%04X '%s'", $native, $eval_string));
2023 ok(&Devel::PPPort::av_top_index([1,2,3]), 2);
2024 ok(&Devel::PPPort::av_tindex([1,2,3,4]), 3);