1 #define PERL_IN_XS_APITEST
3 /* We want to be able to test things that aren't API yet. */
6 /* Do *not* define PERL_NO_GET_CONTEXT. This is the one place where we get
7 to test implicit Perl_get_context(). */
12 #include "fakesdio.h" /* Causes us to use PerlIO below */
15 typedef PTR_TBL_t *XS__APItest__PtrTable;
17 #define croak_fail() croak("fail at " __FILE__ " line %d", __LINE__)
18 #define croak_fail_ne(h, w) croak("fail %p!=%p at " __FILE__ " line %d", (h), (w), __LINE__)
23 cat_utf8a2n(SV* sv, const char * const ascii_utf8, STRLEN len)
25 /* Converts variant UTF-8 text pointed to by 'ascii_utf8' of length 'len',
26 * to UTF-EBCDIC, appending that text to the text already in 'sv'.
27 * Currently doesn't work on invariants, as that is unneeded here, and we
28 * could get double translations if we did.
30 * It has the algorithm for strict UTF-8 hard-coded in to find the code
31 * point it represents, then calls uvchr_to_utf8() to convert to
34 * Note that this uses code points, not characters. Thus if the input is
35 * the UTF-8 for the code point 0xFF, the output will be the UTF-EBCDIC for
36 * 0xFF, even though that code point represents different characters on
37 * ASCII vs EBCDIC platforms. */
40 char * p = (char *) ascii_utf8;
41 const char * const e = p + len;
45 U8 native_utf8[UTF8_MAXBYTES + 1];
49 /* Start bytes are the same in both UTF-8 and I8, therefore we can
50 * treat this ASCII UTF-8 byte as an I8 byte. But PL_utf8skip[] is
51 * indexed by NATIVE_UTF8 bytes, so transform to that */
52 STRLEN char_bytes_len = PL_utf8skip[I8_TO_NATIVE_UTF8(start)];
55 croak("fail: Expecting start byte, instead got 0x%X at %s line %d",
56 (U8) *p, __FILE__, __LINE__);
58 code_point = (start & (((char_bytes_len) >= 7)
60 : (0x1F >> ((char_bytes_len)-2))));
62 while (p < e && ((( (U8) *p) & 0xC0) == 0x80)) {
64 code_point = (code_point << 6) | (( (U8) *p) & 0x3F);
68 char_end = uvchr_to_utf8(native_utf8, code_point);
69 sv_catpvn(sv, (char *) native_utf8, char_end - native_utf8);
75 /* for my_cxt tests */
77 #define MY_CXT_KEY "XS::APItest::_guts" XS_VERSION
97 S_myset_set(pTHX_ SV* sv, MAGIC* mg)
99 SV *isv = (SV*)mg->mg_ptr;
106 MGVTBL vtbl_foo, vtbl_bar;
107 MGVTBL vtbl_myset = { 0, S_myset_set, 0, 0, 0, 0, 0, 0 };
110 /* indirect functions to test the [pa]MY_CXT macros */
113 my_cxt_getint_p(pMY_CXT)
119 my_cxt_setint_p(pMY_CXT_ int i)
125 my_cxt_getsv_interp_context(void)
128 dMY_CXT_INTERP(my_perl);
133 my_cxt_getsv_interp(void)
140 my_cxt_setsv_p(SV* sv _pMY_CXT)
146 /* from exception.c */
147 int apitest_exception(int);
149 /* from core_or_not.inc */
150 bool sv_setsv_cow_hashkey_core(void);
151 bool sv_setsv_cow_hashkey_notcore(void);
153 /* A routine to test hv_delayfree_ent
154 (which itself is tested by testing on hv_free_ent */
156 typedef void (freeent_function)(pTHX_ HV *, HE *);
159 test_freeent(freeent_function *f) {
161 HV *test_hash = newHV();
168 victim = (HE*)safemalloc(sizeof(HE));
170 /* Storing then deleting something should ensure that a hash entry is
172 (void) hv_stores(test_hash, "", &PL_sv_yes);
173 (void) hv_deletes(test_hash, "", 0);
175 /* We need to "inline" new_he here as it's static, and the functions we
176 test expect to be able to call del_HE on the HE */
177 if (!PL_body_roots[HE_SVSLOT])
178 croak("PL_he_root is 0");
179 victim = (HE*) PL_body_roots[HE_SVSLOT];
180 PL_body_roots[HE_SVSLOT] = HeNEXT(victim);
183 victim->hent_hek = Perl_share_hek(aTHX_ "", 0, 0);
185 test_scalar = newSV(0);
186 SvREFCNT_inc(test_scalar);
187 HeVAL(victim) = test_scalar;
189 /* Need this little game else we free the temps on the return stack. */
190 results[0] = SvREFCNT(test_scalar);
192 results[1] = SvREFCNT(test_scalar);
193 f(aTHX_ test_hash, victim);
194 results[2] = SvREFCNT(test_scalar);
196 results[3] = SvREFCNT(test_scalar);
201 } while (++i < (int)(sizeof(results)/sizeof(results[0])));
203 /* Goodbye to our extra reference. */
204 SvREFCNT_dec(test_scalar);
207 /* Not that it matters much, but it's handy for the flipped character to just
208 * be the opposite case (at least for ASCII-range and most Latin1 as well). */
209 #define FLIP_BIT ('A' ^ 'a')
212 bitflip_key(pTHX_ IV action, SV *field) {
213 MAGIC *mg = mg_find(field, PERL_MAGIC_uvar);
215 PERL_UNUSED_ARG(action);
216 if (mg && (keysv = mg->mg_obj)) {
218 const char *p = SvPV(keysv, len);
221 /* Allow for the flipped val to be longer than the original. This
222 * is just for testing, so can afford to have some slop */
223 const STRLEN newlen = len * 2;
225 SV *newkey = newSV(newlen);
226 const char * const new_p_orig = SvPVX(newkey);
227 char *new_p = (char *) new_p_orig;
230 const char *const end = p + len;
233 UV chr = utf8_to_uvchr_buf((U8 *)p, (U8 *) end, &curlen);
235 /* Make sure don't exceed bounds */
236 assert(new_p - new_p_orig + curlen < newlen);
238 new_p = (char *)uvchr_to_utf8((U8 *)new_p, chr ^ FLIP_BIT);
244 *new_p++ = *p++ ^ FLIP_BIT;
247 SvCUR_set(newkey, new_p - new_p_orig);
257 rot13_key(pTHX_ IV action, SV *field) {
258 MAGIC *mg = mg_find(field, PERL_MAGIC_uvar);
260 PERL_UNUSED_ARG(action);
261 if (mg && (keysv = mg->mg_obj)) {
263 const char *p = SvPV(keysv, len);
266 SV *newkey = newSV(len);
267 char *new_p = SvPVX(newkey);
269 /* There's a deliberate fencepost error here to loop len + 1 times
270 to copy the trailing \0 */
273 /* Try doing this cleanly and clearly in EBCDIC another way: */
275 case 'A': new_c = 'N'; break;
276 case 'B': new_c = 'O'; break;
277 case 'C': new_c = 'P'; break;
278 case 'D': new_c = 'Q'; break;
279 case 'E': new_c = 'R'; break;
280 case 'F': new_c = 'S'; break;
281 case 'G': new_c = 'T'; break;
282 case 'H': new_c = 'U'; break;
283 case 'I': new_c = 'V'; break;
284 case 'J': new_c = 'W'; break;
285 case 'K': new_c = 'X'; break;
286 case 'L': new_c = 'Y'; break;
287 case 'M': new_c = 'Z'; break;
288 case 'N': new_c = 'A'; break;
289 case 'O': new_c = 'B'; break;
290 case 'P': new_c = 'C'; break;
291 case 'Q': new_c = 'D'; break;
292 case 'R': new_c = 'E'; break;
293 case 'S': new_c = 'F'; break;
294 case 'T': new_c = 'G'; break;
295 case 'U': new_c = 'H'; break;
296 case 'V': new_c = 'I'; break;
297 case 'W': new_c = 'J'; break;
298 case 'X': new_c = 'K'; break;
299 case 'Y': new_c = 'L'; break;
300 case 'Z': new_c = 'M'; break;
301 case 'a': new_c = 'n'; break;
302 case 'b': new_c = 'o'; break;
303 case 'c': new_c = 'p'; break;
304 case 'd': new_c = 'q'; break;
305 case 'e': new_c = 'r'; break;
306 case 'f': new_c = 's'; break;
307 case 'g': new_c = 't'; break;
308 case 'h': new_c = 'u'; break;
309 case 'i': new_c = 'v'; break;
310 case 'j': new_c = 'w'; break;
311 case 'k': new_c = 'x'; break;
312 case 'l': new_c = 'y'; break;
313 case 'm': new_c = 'z'; break;
314 case 'n': new_c = 'a'; break;
315 case 'o': new_c = 'b'; break;
316 case 'p': new_c = 'c'; break;
317 case 'q': new_c = 'd'; break;
318 case 'r': new_c = 'e'; break;
319 case 's': new_c = 'f'; break;
320 case 't': new_c = 'g'; break;
321 case 'u': new_c = 'h'; break;
322 case 'v': new_c = 'i'; break;
323 case 'w': new_c = 'j'; break;
324 case 'x': new_c = 'k'; break;
325 case 'y': new_c = 'l'; break;
326 case 'z': new_c = 'm'; break;
330 SvCUR_set(newkey, SvCUR(keysv));
342 rmagical_a_dummy(pTHX_ IV idx, SV *sv) {
343 PERL_UNUSED_ARG(idx);
348 /* We could do "= { 0 };" but some versions of gcc do warn
349 * (with -Wextra) about missing initializer, this is probably gcc
350 * being a bit too paranoid. But since this is file-static, we can
351 * just have it without initializer, since it should get
352 * zero-initialized. */
353 STATIC MGVTBL rmagical_b;
356 blockhook_csc_start(pTHX_ int full)
359 AV *const cur = GvAV(MY_CXT.cscgv);
361 PERL_UNUSED_ARG(full);
362 SAVEGENERICSV(GvAV(MY_CXT.cscgv));
366 AV *const new_av = newAV();
368 for (i = 0; i <= av_tindex(cur); i++) {
369 av_store(new_av, i, newSVsv(*av_fetch(cur, i, 0)));
372 GvAV(MY_CXT.cscgv) = new_av;
377 blockhook_csc_pre_end(pTHX_ OP **o)
382 /* if we hit the end of a scope we missed the start of, we need to
383 * unconditionally clear @CSC */
384 if (GvAV(MY_CXT.cscgv) == MY_CXT.cscav && MY_CXT.cscav) {
385 av_clear(MY_CXT.cscav);
391 blockhook_test_start(pTHX_ int full)
396 if (MY_CXT.bhk_record) {
398 av_push(av, newSVpvs("start"));
399 av_push(av, newSViv(full));
400 av_push(MY_CXT.bhkav, newRV_noinc(MUTABLE_SV(av)));
405 blockhook_test_pre_end(pTHX_ OP **o)
410 if (MY_CXT.bhk_record)
411 av_push(MY_CXT.bhkav, newSVpvs("pre_end"));
415 blockhook_test_post_end(pTHX_ OP **o)
420 if (MY_CXT.bhk_record)
421 av_push(MY_CXT.bhkav, newSVpvs("post_end"));
425 blockhook_test_eval(pTHX_ OP *const o)
430 if (MY_CXT.bhk_record) {
432 av_push(av, newSVpvs("eval"));
433 av_push(av, newSVpv(OP_NAME(o), 0));
434 av_push(MY_CXT.bhkav, newRV_noinc(MUTABLE_SV(av)));
438 STATIC BHK bhk_csc, bhk_test;
441 my_peep (pTHX_ OP *o)
448 MY_CXT.orig_peep(aTHX_ o);
450 if (!MY_CXT.peep_recording)
453 for (; o; o = o->op_next) {
454 if (o->op_type == OP_CONST && cSVOPx_sv(o) && SvPOK(cSVOPx_sv(o))) {
455 av_push(MY_CXT.peep_recorder, newSVsv(cSVOPx_sv(o)));
461 my_rpeep (pTHX_ OP *o)
468 MY_CXT.orig_rpeep(aTHX_ o);
470 if (!MY_CXT.peep_recording)
473 for (; o; o = o->op_next) {
474 if (o->op_type == OP_CONST && cSVOPx_sv(o) && SvPOK(cSVOPx_sv(o))) {
475 av_push(MY_CXT.rpeep_recorder, newSVsv(cSVOPx_sv(o)));
481 THX_ck_entersub_args_lists(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
483 PERL_UNUSED_ARG(namegv);
484 PERL_UNUSED_ARG(ckobj);
485 return ck_entersub_args_list(entersubop);
489 THX_ck_entersub_args_scalars(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
491 OP *aop = cUNOPx(entersubop)->op_first;
492 PERL_UNUSED_ARG(namegv);
493 PERL_UNUSED_ARG(ckobj);
494 if (!OpHAS_SIBLING(aop))
495 aop = cUNOPx(aop)->op_first;
496 for (aop = OpSIBLING(aop); OpHAS_SIBLING(aop); aop = OpSIBLING(aop)) {
497 op_contextualize(aop, G_SCALAR);
503 THX_ck_entersub_multi_sum(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
506 OP *parent = entersubop;
507 OP *pushop = cUNOPx(entersubop)->op_first;
508 PERL_UNUSED_ARG(namegv);
509 PERL_UNUSED_ARG(ckobj);
510 if (!OpHAS_SIBLING(pushop)) {
512 pushop = cUNOPx(pushop)->op_first;
515 OP *aop = OpSIBLING(pushop);
516 if (!OpHAS_SIBLING(aop))
518 /* cut out first arg */
519 op_sibling_splice(parent, pushop, 1, NULL);
520 op_contextualize(aop, G_SCALAR);
522 sumop = newBINOP(OP_ADD, 0, sumop, aop);
528 sumop = newSVOP(OP_CONST, 0, newSViv(0));
533 STATIC void test_op_list_describe_part(SV *res, OP *o);
535 test_op_list_describe_part(SV *res, OP *o)
537 sv_catpv(res, PL_op_name[o->op_type]);
538 switch (o->op_type) {
540 sv_catpvf(res, "(%d)", (int)SvIV(cSVOPx(o)->op_sv));
543 if (o->op_flags & OPf_KIDS) {
546 for (k = cUNOPx(o)->op_first; k; k = OpSIBLING(k))
547 test_op_list_describe_part(res, k);
555 test_op_list_describe(OP *o)
557 SV *res = sv_2mortal(newSVpvs(""));
559 test_op_list_describe_part(res, o);
563 /* the real new*OP functions have a tendency to call fold_constants, and
564 * other such unhelpful things, so we need our own versions for testing */
566 #define mkUNOP(t, f) THX_mkUNOP(aTHX_ (t), (f))
568 THX_mkUNOP(pTHX_ U32 type, OP *first)
571 NewOp(1103, unop, 1, UNOP);
572 unop->op_type = (OPCODE)type;
573 op_sibling_splice((OP*)unop, NULL, 0, first);
577 #define mkBINOP(t, f, l) THX_mkBINOP(aTHX_ (t), (f), (l))
579 THX_mkBINOP(pTHX_ U32 type, OP *first, OP *last)
582 NewOp(1103, binop, 1, BINOP);
583 binop->op_type = (OPCODE)type;
584 op_sibling_splice((OP*)binop, NULL, 0, last);
585 op_sibling_splice((OP*)binop, NULL, 0, first);
589 #define mkLISTOP(t, f, s, l) THX_mkLISTOP(aTHX_ (t), (f), (s), (l))
591 THX_mkLISTOP(pTHX_ U32 type, OP *first, OP *sib, OP *last)
594 NewOp(1103, listop, 1, LISTOP);
595 listop->op_type = (OPCODE)type;
596 op_sibling_splice((OP*)listop, NULL, 0, last);
597 op_sibling_splice((OP*)listop, NULL, 0, sib);
598 op_sibling_splice((OP*)listop, NULL, 0, first);
603 test_op_linklist_describe(OP *start)
605 SV *rv = sv_2mortal(newSVpvs(""));
607 o = start = LINKLIST(start);
610 sv_catpv(rv, OP_NAME(o));
611 if (o->op_type == OP_CONST)
612 sv_catsv(rv, cSVOPo->op_sv);
614 } while (o && o != start);
618 /** establish_cleanup operator, ripped off from Scope::Cleanup **/
621 THX_run_cleanup(pTHX_ void *cleanup_code_ref)
628 call_sv((SV*)cleanup_code_ref, G_VOID|G_DISCARD);
635 THX_pp_establish_cleanup(pTHX)
638 SV *cleanup_code_ref;
639 cleanup_code_ref = newSVsv(POPs);
640 SAVEFREESV(cleanup_code_ref);
641 SAVEDESTRUCTOR_X(THX_run_cleanup, cleanup_code_ref);
642 if(GIMME_V != G_VOID) PUSHs(&PL_sv_undef);
647 THX_ck_entersub_establish_cleanup(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
649 OP *parent, *pushop, *argop, *estop;
650 ck_entersub_args_proto(entersubop, namegv, ckobj);
652 pushop = cUNOPx(entersubop)->op_first;
653 if(!OpHAS_SIBLING(pushop)) {
655 pushop = cUNOPx(pushop)->op_first;
657 /* extract out first arg, then delete the rest of the tree */
658 argop = OpSIBLING(pushop);
659 op_sibling_splice(parent, pushop, 1, NULL);
662 estop = mkUNOP(OP_RAND, argop);
663 estop->op_ppaddr = THX_pp_establish_cleanup;
664 PL_hints |= HINT_BLOCK_SCOPE;
669 THX_ck_entersub_postinc(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
671 OP *parent, *pushop, *argop;
672 ck_entersub_args_proto(entersubop, namegv, ckobj);
674 pushop = cUNOPx(entersubop)->op_first;
675 if(!OpHAS_SIBLING(pushop)) {
677 pushop = cUNOPx(pushop)->op_first;
679 argop = OpSIBLING(pushop);
680 op_sibling_splice(parent, pushop, 1, NULL);
682 return newUNOP(OP_POSTINC, 0,
683 op_lvalue(op_contextualize(argop, G_SCALAR), OP_POSTINC));
687 THX_ck_entersub_pad_scalar(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
690 PADOFFSET padoff = NOT_IN_PAD;
692 ck_entersub_args_proto(entersubop, namegv, ckobj);
693 pushop = cUNOPx(entersubop)->op_first;
694 if(!OpHAS_SIBLING(pushop))
695 pushop = cUNOPx(pushop)->op_first;
696 argop = OpSIBLING(pushop);
697 if(argop->op_type != OP_CONST || OpSIBLING(argop)->op_type != OP_CONST)
698 croak("bad argument expression type for pad_scalar()");
699 a0 = cSVOPx_sv(argop);
700 a1 = cSVOPx_sv(OpSIBLING(argop));
703 SV *namesv = sv_2mortal(newSVpvs("$"));
704 sv_catsv(namesv, a1);
705 padoff = pad_findmy_sv(namesv, 0);
710 SV *namesv = sv_2mortal(newSVpvs("$"));
711 sv_catsv(namesv, a1);
712 namepv = SvPV(namesv, namelen);
713 padoff = pad_findmy_pvn(namepv, namelen, SvUTF8(namesv));
717 SV *namesv = sv_2mortal(newSVpvs("$"));
718 sv_catsv(namesv, a1);
719 namepv = SvPV_nolen(namesv);
720 padoff = pad_findmy_pv(namepv, SvUTF8(namesv));
723 padoff = pad_findmy_pvs("$foo", 0);
725 default: croak("bad type value for pad_scalar()");
728 if(padoff == NOT_IN_PAD) {
729 return newSVOP(OP_CONST, 0, newSVpvs("NOT_IN_PAD"));
730 } else if(PAD_COMPNAME_FLAGS_isOUR(padoff)) {
731 return newSVOP(OP_CONST, 0, newSVpvs("NOT_MY"));
733 OP *padop = newOP(OP_PADSV, 0);
734 padop->op_targ = padoff;
739 /** RPN keyword parser **/
741 #define sv_is_glob(sv) (SvTYPE(sv) == SVt_PVGV)
742 #define sv_is_regexp(sv) (SvTYPE(sv) == SVt_REGEXP)
743 #define sv_is_string(sv) \
744 (!sv_is_glob(sv) && !sv_is_regexp(sv) && \
745 (SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK|SVp_IOK|SVp_NOK|SVp_POK)))
747 static SV *hintkey_rpn_sv, *hintkey_calcrpn_sv, *hintkey_stufftest_sv;
748 static SV *hintkey_swaptwostmts_sv, *hintkey_looprest_sv;
749 static SV *hintkey_scopelessblock_sv;
750 static SV *hintkey_stmtasexpr_sv, *hintkey_stmtsasexpr_sv;
751 static SV *hintkey_loopblock_sv, *hintkey_blockasexpr_sv;
752 static SV *hintkey_swaplabel_sv, *hintkey_labelconst_sv;
753 static SV *hintkey_arrayfullexpr_sv, *hintkey_arraylistexpr_sv;
754 static SV *hintkey_arraytermexpr_sv, *hintkey_arrayarithexpr_sv;
755 static SV *hintkey_arrayexprflags_sv;
756 static SV *hintkey_DEFSV_sv;
757 static SV *hintkey_with_vars_sv;
758 static SV *hintkey_join_with_space_sv;
759 static int (*next_keyword_plugin)(pTHX_ char *, STRLEN, OP **);
761 /* low-level parser helpers */
763 #define PL_bufptr (PL_parser->bufptr)
764 #define PL_bufend (PL_parser->bufend)
768 #define parse_var() THX_parse_var(aTHX)
769 static OP *THX_parse_var(pTHX)
775 if(*s != '$') croak("RPN syntax error");
778 if(!isALNUM(c)) break;
780 if(s-start < 2) croak("RPN syntax error");
782 varpos = pad_findmy_pvn(start, s-start, 0);
783 if(varpos == NOT_IN_PAD || PAD_COMPNAME_FLAGS_isOUR(varpos))
784 croak("RPN only supports \"my\" variables");
785 padop = newOP(OP_PADSV, 0);
786 padop->op_targ = varpos;
790 #define push_rpn_item(o) \
791 op_sibling_splice(parent, NULL, 0, o);
792 #define pop_rpn_item() ( \
793 (tmpop = op_sibling_splice(parent, NULL, 1, NULL)) \
794 ? tmpop : (croak("RPN stack underflow"), (OP*)NULL))
796 #define parse_rpn_expr() THX_parse_rpn_expr(aTHX)
797 static OP *THX_parse_rpn_expr(pTHX)
800 /* fake parent for splice to mess with */
801 OP *parent = mkBINOP(OP_NULL, NULL, NULL);
806 c = lex_peek_unichar(0);
808 case /*(*/')': case /*{*/'}': {
809 OP *result = pop_rpn_item();
810 if(cLISTOPx(parent)->op_first)
811 croak("RPN expression must return a single value");
815 case '0': case '1': case '2': case '3': case '4':
816 case '5': case '6': case '7': case '8': case '9': {
820 val = 10*val + (c - '0');
821 c = lex_peek_unichar(0);
822 } while(c >= '0' && c <= '9');
823 push_rpn_item(newSVOP(OP_CONST, 0, newSVuv(val)));
826 push_rpn_item(parse_var());
829 OP *b = pop_rpn_item();
830 OP *a = pop_rpn_item();
832 push_rpn_item(newBINOP(OP_I_ADD, 0, a, b));
835 OP *b = pop_rpn_item();
836 OP *a = pop_rpn_item();
838 push_rpn_item(newBINOP(OP_I_SUBTRACT, 0, a, b));
841 OP *b = pop_rpn_item();
842 OP *a = pop_rpn_item();
844 push_rpn_item(newBINOP(OP_I_MULTIPLY, 0, a, b));
847 OP *b = pop_rpn_item();
848 OP *a = pop_rpn_item();
850 push_rpn_item(newBINOP(OP_I_DIVIDE, 0, a, b));
853 OP *b = pop_rpn_item();
854 OP *a = pop_rpn_item();
856 push_rpn_item(newBINOP(OP_I_MODULO, 0, a, b));
859 croak("RPN syntax error");
865 #define parse_keyword_rpn() THX_parse_keyword_rpn(aTHX)
866 static OP *THX_parse_keyword_rpn(pTHX)
870 if(lex_peek_unichar(0) != '('/*)*/)
871 croak("RPN expression must be parenthesised");
873 op = parse_rpn_expr();
874 if(lex_peek_unichar(0) != /*(*/')')
875 croak("RPN expression must be parenthesised");
880 #define parse_keyword_calcrpn() THX_parse_keyword_calcrpn(aTHX)
881 static OP *THX_parse_keyword_calcrpn(pTHX)
887 if(lex_peek_unichar(0) != '{'/*}*/)
888 croak("RPN expression must be braced");
890 exprop = parse_rpn_expr();
891 if(lex_peek_unichar(0) != /*{*/'}')
892 croak("RPN expression must be braced");
894 return newASSIGNOP(OPf_STACKED, varop, 0, exprop);
897 #define parse_keyword_stufftest() THX_parse_keyword_stufftest(aTHX)
898 static OP *THX_parse_keyword_stufftest(pTHX)
903 do_stuff = lex_peek_unichar(0) == '+';
908 c = lex_peek_unichar(0);
911 } else if(c != /*{*/'}') {
912 croak("syntax error");
914 if(do_stuff) lex_stuff_pvs(" ", 0);
915 return newOP(OP_NULL, 0);
918 #define parse_keyword_swaptwostmts() THX_parse_keyword_swaptwostmts(aTHX)
919 static OP *THX_parse_keyword_swaptwostmts(pTHX)
922 a = parse_fullstmt(0);
923 b = parse_fullstmt(0);
925 PL_hints |= HINT_BLOCK_SCOPE;
926 return op_append_list(OP_LINESEQ, b, a);
929 #define parse_keyword_looprest() THX_parse_keyword_looprest(aTHX)
930 static OP *THX_parse_keyword_looprest(pTHX)
932 return newWHILEOP(0, 1, NULL, newSVOP(OP_CONST, 0, &PL_sv_yes),
933 parse_stmtseq(0), NULL, 1);
936 #define parse_keyword_scopelessblock() THX_parse_keyword_scopelessblock(aTHX)
937 static OP *THX_parse_keyword_scopelessblock(pTHX)
942 if(lex_peek_unichar(0) != '{'/*}*/) croak("syntax error");
944 body = parse_stmtseq(0);
945 c = lex_peek_unichar(0);
946 if(c != /*{*/'}' && c != /*[*/']' && c != /*(*/')') croak("syntax error");
951 #define parse_keyword_stmtasexpr() THX_parse_keyword_stmtasexpr(aTHX)
952 static OP *THX_parse_keyword_stmtasexpr(pTHX)
954 OP *o = parse_barestmt(0);
955 if (!o) o = newOP(OP_STUB, 0);
956 if (PL_hints & HINT_BLOCK_SCOPE) o->op_flags |= OPf_PARENS;
960 #define parse_keyword_stmtsasexpr() THX_parse_keyword_stmtsasexpr(aTHX)
961 static OP *THX_parse_keyword_stmtsasexpr(pTHX)
965 if(lex_peek_unichar(0) != '{'/*}*/) croak("syntax error");
967 o = parse_stmtseq(0);
969 if(lex_peek_unichar(0) != /*{*/'}') croak("syntax error");
971 if (!o) o = newOP(OP_STUB, 0);
972 if (PL_hints & HINT_BLOCK_SCOPE) o->op_flags |= OPf_PARENS;
976 #define parse_keyword_loopblock() THX_parse_keyword_loopblock(aTHX)
977 static OP *THX_parse_keyword_loopblock(pTHX)
979 return newWHILEOP(0, 1, NULL, newSVOP(OP_CONST, 0, &PL_sv_yes),
980 parse_block(0), NULL, 1);
983 #define parse_keyword_blockasexpr() THX_parse_keyword_blockasexpr(aTHX)
984 static OP *THX_parse_keyword_blockasexpr(pTHX)
986 OP *o = parse_block(0);
987 if (!o) o = newOP(OP_STUB, 0);
988 if (PL_hints & HINT_BLOCK_SCOPE) o->op_flags |= OPf_PARENS;
992 #define parse_keyword_swaplabel() THX_parse_keyword_swaplabel(aTHX)
993 static OP *THX_parse_keyword_swaplabel(pTHX)
995 OP *sop = parse_barestmt(0);
996 SV *label = parse_label(PARSE_OPTIONAL);
997 if (label) sv_2mortal(label);
998 return newSTATEOP(label ? SvUTF8(label) : 0,
999 label ? savepv(SvPVX(label)) : NULL,
1003 #define parse_keyword_labelconst() THX_parse_keyword_labelconst(aTHX)
1004 static OP *THX_parse_keyword_labelconst(pTHX)
1006 return newSVOP(OP_CONST, 0, parse_label(0));
1009 #define parse_keyword_arrayfullexpr() THX_parse_keyword_arrayfullexpr(aTHX)
1010 static OP *THX_parse_keyword_arrayfullexpr(pTHX)
1012 return newANONLIST(parse_fullexpr(0));
1015 #define parse_keyword_arraylistexpr() THX_parse_keyword_arraylistexpr(aTHX)
1016 static OP *THX_parse_keyword_arraylistexpr(pTHX)
1018 return newANONLIST(parse_listexpr(0));
1021 #define parse_keyword_arraytermexpr() THX_parse_keyword_arraytermexpr(aTHX)
1022 static OP *THX_parse_keyword_arraytermexpr(pTHX)
1024 return newANONLIST(parse_termexpr(0));
1027 #define parse_keyword_arrayarithexpr() THX_parse_keyword_arrayarithexpr(aTHX)
1028 static OP *THX_parse_keyword_arrayarithexpr(pTHX)
1030 return newANONLIST(parse_arithexpr(0));
1033 #define parse_keyword_arrayexprflags() THX_parse_keyword_arrayexprflags(aTHX)
1034 static OP *THX_parse_keyword_arrayexprflags(pTHX)
1040 c = lex_peek_unichar(0);
1041 if (c != '!' && c != '?') croak("syntax error");
1042 lex_read_unichar(0);
1043 if (c == '?') flags |= PARSE_OPTIONAL;
1044 o = parse_listexpr(flags);
1045 return o ? newANONLIST(o) : newANONHASH(newOP(OP_STUB, 0));
1048 #define parse_keyword_DEFSV() THX_parse_keyword_DEFSV(aTHX)
1049 static OP *THX_parse_keyword_DEFSV(pTHX)
1051 return newDEFSVOP();
1054 #define sv_cat_c(a,b) THX_sv_cat_c(aTHX_ a, b)
1055 static void THX_sv_cat_c(pTHX_ SV *sv, U32 c) {
1056 char ds[UTF8_MAXBYTES + 1], *d;
1057 d = (char *)uvchr_to_utf8((U8 *)ds, c);
1059 sv_utf8_upgrade(sv);
1061 sv_catpvn(sv, ds, d - ds);
1064 #define parse_keyword_with_vars() THX_parse_keyword_with_vars(aTHX)
1065 static OP *THX_parse_keyword_with_vars(pTHX)
1070 OP *vardeclseq, *body;
1072 save_ix = block_start(TRUE);
1078 c = lex_peek_unichar(0);
1084 croak("unexpected EOF; expecting '{'");
1087 if (!isIDFIRST_uni(c)) {
1088 croak("unexpected '%c'; expecting an identifier", (int)c);
1091 varname = newSVpvs("$");
1092 if (lex_bufutf8()) {
1096 sv_cat_c(varname, c);
1097 lex_read_unichar(0);
1099 while (c = lex_peek_unichar(0), c != -1 && isIDCONT_uni(c)) {
1100 sv_cat_c(varname, c);
1101 lex_read_unichar(0);
1104 padoff = pad_add_name_sv(varname, padadd_NO_DUP_CHECK, NULL, NULL);
1107 OP *my_var = newOP(OP_PADSV, OPf_MOD | (OPpLVAL_INTRO << 8));
1108 my_var->op_targ = padoff;
1110 vardeclseq = op_append_list(
1128 c = lex_peek_unichar(0);
1133 body = parse_block(0);
1135 return block_end(save_ix, op_append_list(OP_LINESEQ, vardeclseq, body));
1138 #define parse_join_with_space() THX_parse_join_with_space(aTHX)
1139 static OP *THX_parse_join_with_space(pTHX)
1143 args = parse_listexpr(0);
1144 delim = newSVOP(OP_CONST, 0, newSVpvs(" "));
1145 return op_convert_list(OP_JOIN, 0, op_prepend_elem(OP_LIST, delim, args));
1150 #define keyword_active(hintkey_sv) THX_keyword_active(aTHX_ hintkey_sv)
1151 static int THX_keyword_active(pTHX_ SV *hintkey_sv)
1154 if(!GvHV(PL_hintgv)) return 0;
1155 he = hv_fetch_ent(GvHV(PL_hintgv), hintkey_sv, 0,
1156 SvSHARED_HASH(hintkey_sv));
1157 return he && SvTRUE(HeVAL(he));
1160 static int my_keyword_plugin(pTHX_
1161 char *keyword_ptr, STRLEN keyword_len, OP **op_ptr)
1163 if(keyword_len == 3 && strEQs(keyword_ptr, "rpn") &&
1164 keyword_active(hintkey_rpn_sv)) {
1165 *op_ptr = parse_keyword_rpn();
1166 return KEYWORD_PLUGIN_EXPR;
1167 } else if(keyword_len == 7 && strEQs(keyword_ptr, "calcrpn") &&
1168 keyword_active(hintkey_calcrpn_sv)) {
1169 *op_ptr = parse_keyword_calcrpn();
1170 return KEYWORD_PLUGIN_STMT;
1171 } else if(keyword_len == 9 && strEQs(keyword_ptr, "stufftest") &&
1172 keyword_active(hintkey_stufftest_sv)) {
1173 *op_ptr = parse_keyword_stufftest();
1174 return KEYWORD_PLUGIN_STMT;
1175 } else if(keyword_len == 12 &&
1176 strEQs(keyword_ptr, "swaptwostmts") &&
1177 keyword_active(hintkey_swaptwostmts_sv)) {
1178 *op_ptr = parse_keyword_swaptwostmts();
1179 return KEYWORD_PLUGIN_STMT;
1180 } else if(keyword_len == 8 && strEQs(keyword_ptr, "looprest") &&
1181 keyword_active(hintkey_looprest_sv)) {
1182 *op_ptr = parse_keyword_looprest();
1183 return KEYWORD_PLUGIN_STMT;
1184 } else if(keyword_len == 14 && strEQs(keyword_ptr, "scopelessblock") &&
1185 keyword_active(hintkey_scopelessblock_sv)) {
1186 *op_ptr = parse_keyword_scopelessblock();
1187 return KEYWORD_PLUGIN_STMT;
1188 } else if(keyword_len == 10 && strEQs(keyword_ptr, "stmtasexpr") &&
1189 keyword_active(hintkey_stmtasexpr_sv)) {
1190 *op_ptr = parse_keyword_stmtasexpr();
1191 return KEYWORD_PLUGIN_EXPR;
1192 } else if(keyword_len == 11 && strEQs(keyword_ptr, "stmtsasexpr") &&
1193 keyword_active(hintkey_stmtsasexpr_sv)) {
1194 *op_ptr = parse_keyword_stmtsasexpr();
1195 return KEYWORD_PLUGIN_EXPR;
1196 } else if(keyword_len == 9 && strEQs(keyword_ptr, "loopblock") &&
1197 keyword_active(hintkey_loopblock_sv)) {
1198 *op_ptr = parse_keyword_loopblock();
1199 return KEYWORD_PLUGIN_STMT;
1200 } else if(keyword_len == 11 && strEQs(keyword_ptr, "blockasexpr") &&
1201 keyword_active(hintkey_blockasexpr_sv)) {
1202 *op_ptr = parse_keyword_blockasexpr();
1203 return KEYWORD_PLUGIN_EXPR;
1204 } else if(keyword_len == 9 && strEQs(keyword_ptr, "swaplabel") &&
1205 keyword_active(hintkey_swaplabel_sv)) {
1206 *op_ptr = parse_keyword_swaplabel();
1207 return KEYWORD_PLUGIN_STMT;
1208 } else if(keyword_len == 10 && strEQs(keyword_ptr, "labelconst") &&
1209 keyword_active(hintkey_labelconst_sv)) {
1210 *op_ptr = parse_keyword_labelconst();
1211 return KEYWORD_PLUGIN_EXPR;
1212 } else if(keyword_len == 13 && strEQs(keyword_ptr, "arrayfullexpr") &&
1213 keyword_active(hintkey_arrayfullexpr_sv)) {
1214 *op_ptr = parse_keyword_arrayfullexpr();
1215 return KEYWORD_PLUGIN_EXPR;
1216 } else if(keyword_len == 13 && strEQs(keyword_ptr, "arraylistexpr") &&
1217 keyword_active(hintkey_arraylistexpr_sv)) {
1218 *op_ptr = parse_keyword_arraylistexpr();
1219 return KEYWORD_PLUGIN_EXPR;
1220 } else if(keyword_len == 13 && strEQs(keyword_ptr, "arraytermexpr") &&
1221 keyword_active(hintkey_arraytermexpr_sv)) {
1222 *op_ptr = parse_keyword_arraytermexpr();
1223 return KEYWORD_PLUGIN_EXPR;
1224 } else if(keyword_len == 14 && strEQs(keyword_ptr, "arrayarithexpr") &&
1225 keyword_active(hintkey_arrayarithexpr_sv)) {
1226 *op_ptr = parse_keyword_arrayarithexpr();
1227 return KEYWORD_PLUGIN_EXPR;
1228 } else if(keyword_len == 14 && strEQs(keyword_ptr, "arrayexprflags") &&
1229 keyword_active(hintkey_arrayexprflags_sv)) {
1230 *op_ptr = parse_keyword_arrayexprflags();
1231 return KEYWORD_PLUGIN_EXPR;
1232 } else if(keyword_len == 5 && strEQs(keyword_ptr, "DEFSV") &&
1233 keyword_active(hintkey_DEFSV_sv)) {
1234 *op_ptr = parse_keyword_DEFSV();
1235 return KEYWORD_PLUGIN_EXPR;
1236 } else if(keyword_len == 9 && strEQs(keyword_ptr, "with_vars") &&
1237 keyword_active(hintkey_with_vars_sv)) {
1238 *op_ptr = parse_keyword_with_vars();
1239 return KEYWORD_PLUGIN_STMT;
1240 } else if(keyword_len == 15 && strEQs(keyword_ptr, "join_with_space") &&
1241 keyword_active(hintkey_join_with_space_sv)) {
1242 *op_ptr = parse_join_with_space();
1243 return KEYWORD_PLUGIN_EXPR;
1245 return next_keyword_plugin(aTHX_ keyword_ptr, keyword_len, op_ptr);
1254 return PL_op->op_next;
1258 peep_xop(pTHX_ OP *o, OP *oldop)
1261 av_push(MY_CXT.xop_record, newSVpvf("peep:%" UVxf, PTR2UV(o)));
1262 av_push(MY_CXT.xop_record, newSVpvf("oldop:%" UVxf, PTR2UV(oldop)));
1266 filter_call(pTHX_ int idx, SV *buf_sv, int maxlen)
1270 int n = FILTER_READ(idx + 1, buf_sv, maxlen);
1274 p = SvPV_force_nolen(buf_sv);
1275 end = p + SvCUR(buf_sv);
1277 if (*p == 'o') *p = 'e';
1280 return SvCUR(buf_sv);
1284 myget_linear_isa(pTHX_ HV *stash, U32 level) {
1285 GV **gvp = (GV **)hv_fetchs(stash, "ISA", 0);
1286 PERL_UNUSED_ARG(level);
1287 return gvp && *gvp && GvAV(*gvp)
1289 : (AV *)sv_2mortal((SV *)newAV());
1293 XS_EXTERNAL(XS_XS__APItest__XSUB_XS_VERSION_undef);
1294 XS_EXTERNAL(XS_XS__APItest__XSUB_XS_VERSION_empty);
1295 XS_EXTERNAL(XS_XS__APItest__XSUB_XS_APIVERSION_invalid);
1297 static struct mro_alg mymro;
1299 static Perl_check_t addissub_nxck_add;
1302 addissub_myck_add(pTHX_ OP *op)
1304 SV **flag_svp = hv_fetchs(GvHV(PL_hintgv), "XS::APItest/addissub", 0);
1307 if (!(flag_svp && SvTRUE(*flag_svp) && (op->op_flags & OPf_KIDS) &&
1308 (aop = cBINOPx(op)->op_first) && (bop = OpSIBLING(aop)) &&
1309 !OpHAS_SIBLING(bop)))
1310 return addissub_nxck_add(aTHX_ op);
1311 flags = op->op_flags;
1312 op_sibling_splice(op, NULL, 1, NULL); /* excise aop */
1313 op_sibling_splice(op, NULL, 1, NULL); /* excise bop */
1314 op_free(op); /* free the empty husk */
1316 return newBINOP(OP_SUBTRACT, flags, aop, bop);
1319 static Perl_check_t old_ck_rv2cv;
1322 my_ck_rv2cv(pTHX_ OP *o)
1325 SV **flag_svp = hv_fetchs(GvHV(PL_hintgv), "XS::APItest/addunder", 0);
1328 if (flag_svp && SvTRUE(*flag_svp) && (o->op_flags & OPf_KIDS)
1329 && (aop = cUNOPx(o)->op_first) && aop->op_type == OP_CONST
1330 && aop->op_private & (OPpCONST_ENTERED|OPpCONST_BARE)
1331 && (ref = cSVOPx(aop)->op_sv) && SvPOK(ref) && SvCUR(ref)
1332 && *(SvEND(ref)-1) == 'o')
1334 SvGROW(ref, SvCUR(ref)+2);
1339 return old_ck_rv2cv(aTHX_ o);
1342 #include "const-c.inc"
1344 MODULE = XS::APItest PACKAGE = XS::APItest
1346 INCLUDE: const-xs.inc
1353 /* this only needs to compile and checks that assert() can be
1354 used this way syntactically */
1355 (void)(assert(x), 1);
1358 MODULE = XS::APItest::utf8 PACKAGE = XS::APItest::utf8
1361 bytes_cmp_utf8(bytes, utf8)
1370 b = (const U8 *)SvPVbyte(bytes, blen);
1371 u = (const U8 *)SvPVbyte(utf8, ulen);
1372 RETVAL = bytes_cmp_utf8(b, blen, u, ulen);
1377 test_utf8n_to_uvchr_error(s, len, flags)
1389 /* Now that utf8n_to_uvchr() is a trivial wrapper for
1390 * utf8n_to_uvchr_error(), call the latter with the inputs. It always
1391 * asks for the actual length to be returned and errors to be returned
1393 * Length to assume <s> is; not checked, so could have buffer overflow
1396 sv_2mortal((SV*)RETVAL);
1398 ret = utf8n_to_uvchr_error((U8*) SvPV(s, slen),
1404 /* Returns the return value in [0]; <retlen> in [1], <errors> in [2] */
1405 av_push(RETVAL, newSVuv(ret));
1406 if (retlen == (STRLEN) -1) {
1407 av_push(RETVAL, newSViv(-1));
1410 av_push(RETVAL, newSVuv(retlen));
1412 av_push(RETVAL, newSVuv(errors));
1418 test_valid_utf8_to_uvchr(s)
1427 /* Call utf8n_to_uvchr() with the inputs. It always asks for the
1428 * actual length to be returned
1430 * Length to assume <s> is; not checked, so could have buffer overflow
1433 sv_2mortal((SV*)RETVAL);
1436 = valid_utf8_to_uvchr((U8*) SvPV(s, slen), &retlen);
1438 /* Returns the return value in [0]; <retlen> in [1] */
1439 av_push(RETVAL, newSVuv(ret));
1440 av_push(RETVAL, newSVuv(retlen));
1446 test_uvchr_to_utf8_flags(uv, flags)
1451 U8 dest[UTF8_MAXBYTES];
1455 /* Call uvchr_to_utf8_flags() with the inputs. */
1456 ret = uvchr_to_utf8_flags(dest, SvUV(uv), SvUV(flags));
1460 RETVAL = newSVpvn((char *) dest, ret - dest);
1465 MODULE = XS::APItest:Overload PACKAGE = XS::APItest::Overload
1468 amagic_deref_call(sv, what)
1472 /* The reference is owned by something else. */
1473 PUSHs(amagic_deref_call(sv, what));
1475 # I'd certainly like to discourage the use of this macro, given that we now
1476 # have amagic_deref_call
1479 tryAMAGICunDEREF_var(sv, what)
1487 tryAMAGICunDEREF(to_av);
1490 tryAMAGICunDEREF(to_cv);
1493 tryAMAGICunDEREF(to_gv);
1496 tryAMAGICunDEREF(to_hv);
1499 tryAMAGICunDEREF(to_sv);
1502 croak("Invalid value %d passed to tryAMAGICunDEREF_var", what);
1505 /* The reference is owned by something else. */
1508 MODULE = XS::APItest PACKAGE = XS::APItest::XSUB
1511 newXS("XS::APItest::XSUB::XS_VERSION_undef", XS_XS__APItest__XSUB_XS_VERSION_undef, __FILE__);
1512 newXS("XS::APItest::XSUB::XS_VERSION_empty", XS_XS__APItest__XSUB_XS_VERSION_empty, __FILE__);
1513 newXS("XS::APItest::XSUB::XS_APIVERSION_invalid", XS_XS__APItest__XSUB_XS_APIVERSION_invalid, __FILE__);
1516 XS_VERSION_defined(...)
1518 XS_VERSION_BOOTCHECK;
1522 XS_APIVERSION_valid(...)
1524 XS_APIVERSION_BOOTCHECK;
1532 for ( ; i < len; i++ ) {
1533 ST(i) = sv_2mortal( newSViv(i) );
1540 XSRETURN_IV(I32_MIN + 1);
1545 XSRETURN_UV( (U32)((1U<<31) + 1) );
1555 XSRETURN_PV("returned");
1560 XSRETURN_PVN("returned too much",8);
1582 MODULE = XS::APItest:Hash PACKAGE = XS::APItest::Hash
1590 uf.uf_val = rot13_key;
1594 sv_magic((SV*)hash, NULL, PERL_MAGIC_uvar, (char*)&uf, sizeof(uf));
1603 uf.uf_val = bitflip_key;
1607 sv_magic((SV*)hash, NULL, PERL_MAGIC_uvar, (char*)&uf, sizeof(uf));
1610 #define UTF8KLEN(sv, len) (SvUTF8(sv) ? -(I32)len : (I32)len)
1613 exists(hash, key_sv)
1621 key = SvPV(key_sv, len);
1622 RETVAL = hv_exists(hash, key, UTF8KLEN(key_sv, len));
1627 exists_ent(hash, key_sv)
1633 RETVAL = hv_exists_ent(hash, key_sv, 0);
1638 delete(hash, key_sv, flags = 0)
1647 key = SvPV(key_sv, len);
1648 /* It's already mortal, so need to increase reference count. */
1650 = SvREFCNT_inc(hv_delete(hash, key, UTF8KLEN(key_sv, len), flags));
1655 delete_ent(hash, key_sv, flags = 0)
1661 /* It's already mortal, so need to increase reference count. */
1662 RETVAL = SvREFCNT_inc(hv_delete_ent(hash, key_sv, flags, 0));
1667 store_ent(hash, key, value)
1677 result = hv_store_ent(hash, key, copy, 0);
1678 SvSetMagicSV(copy, value);
1683 /* It's about to become mortal, so need to increase reference count.
1685 RETVAL = SvREFCNT_inc(HeVAL(result));
1690 store(hash, key_sv, value)
1701 key = SvPV(key_sv, len);
1703 result = hv_store(hash, key, UTF8KLEN(key_sv, len), copy, 0);
1704 SvSetMagicSV(copy, value);
1709 /* It's about to become mortal, so need to increase reference count.
1711 RETVAL = SvREFCNT_inc(*result);
1716 fetch_ent(hash, key_sv)
1723 result = hv_fetch_ent(hash, key_sv, 0, 0);
1728 RETVAL = newSVsv(HeVAL(result));
1742 key = SvPV(key_sv, len);
1743 result = hv_fetch(hash, key, UTF8KLEN(key_sv, len), 0);
1748 RETVAL = newSVsv(*result);
1752 #if defined (hv_common)
1762 const char *key = NULL;
1770 if ((svp = hv_fetchs(params, "hv", 0))) {
1771 SV *const rv = *svp;
1773 croak("common passed a non-reference for parameter hv");
1774 hv = (HV *)SvRV(rv);
1776 if ((svp = hv_fetchs(params, "keysv", 0)))
1778 if ((svp = hv_fetchs(params, "keypv", 0))) {
1779 key = SvPV_const(*svp, klen);
1783 if ((svp = hv_fetchs(params, "action", 0)))
1784 action = SvIV(*svp);
1785 if ((svp = hv_fetchs(params, "val", 0)))
1786 val = newSVsv(*svp);
1787 if ((svp = hv_fetchs(params, "hash", 0)))
1790 if (hv_fetchs(params, "hash_pv", 0)) {
1792 PERL_HASH(hash, key, klen);
1794 if (hv_fetchs(params, "hash_sv", 0)) {
1798 const char *const p = SvPV(keysv, len);
1799 PERL_HASH(hash, p, len);
1803 result = (HE *)hv_common(hv, keysv, key, klen, flags, action, val, hash);
1808 RETVAL = newSVsv(HeVAL(result));
1817 test_freeent(&Perl_hv_free_ent);
1821 test_hv_delayfree_ent()
1823 test_freeent(&Perl_hv_delayfree_ent);
1827 test_share_unshare_pvn(input)
1836 pvx = SvPV(input, len);
1837 PERL_HASH(hash, pvx, len);
1838 p = sharepvn(pvx, len, hash);
1839 RETVAL = newSVpvn(p, len);
1840 unsharepvn(p, len, hash);
1844 #if PERL_VERSION >= 9
1847 refcounted_he_exists(key, level=0)
1852 croak("level must be zero, not %" IVdf, level);
1854 RETVAL = (cop_hints_fetch_sv(PL_curcop, key, 0, 0) != &PL_sv_placeholder);
1859 refcounted_he_fetch(key, level=0)
1864 croak("level must be zero, not %" IVdf, level);
1866 RETVAL = cop_hints_fetch_sv(PL_curcop, key, 0, 0);
1867 SvREFCNT_inc(RETVAL);
1874 test_force_keys(HV *hv)
1880 he = hv_iternext(hv);
1882 SV *sv = HeSVKEY_force(he);
1885 PUSHs(sv_mortalcopy(sv));
1886 he = hv_iternext(hv);
1891 sub TIEHASH { bless {}, $_[0] }
1892 sub STORE { $_[0]->{$_[1]} = $_[2] }
1893 sub FETCH { $_[0]->{$_[1]} }
1894 sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} }
1895 sub NEXTKEY { each %{$_[0]} }
1896 sub EXISTS { exists $_[0]->{$_[1]} }
1897 sub DELETE { delete $_[0]->{$_[1]} }
1898 sub CLEAR { %{$_[0]} = () }
1902 MODULE = XS::APItest:TempLv PACKAGE = XS::APItest::TempLv
1908 SV * const lv = newSV_type(SVt_PVLV);
1913 sv_magic(lv, NULL, PERL_MAGIC_substr, NULL, 0);
1915 LvTARG(lv) = SvREFCNT_inc_simple(sv);
1916 LvTARGOFF(lv) = len == 0 ? 0 : 1;
1917 LvTARGLEN(lv) = len < 2 ? 0 : len-2;
1920 ST(0) = sv_2mortal(lv);
1924 MODULE = XS::APItest::PtrTable PACKAGE = XS::APItest::PtrTable PREFIX = ptr_table_
1927 ptr_table_new(classname)
1928 const char * classname
1930 PUSHs(sv_setref_pv(sv_newmortal(), classname, (void*)ptr_table_new()));
1934 XS::APItest::PtrTable table
1936 ptr_table_free(table);
1939 ptr_table_store(table, from, to)
1940 XS::APItest::PtrTable table
1944 ptr_table_store(table, from, to);
1947 ptr_table_fetch(table, from)
1948 XS::APItest::PtrTable table
1951 RETVAL = PTR2UV(ptr_table_fetch(table, from));
1956 ptr_table_split(table)
1957 XS::APItest::PtrTable table
1960 ptr_table_clear(table)
1961 XS::APItest::PtrTable table
1963 MODULE = XS::APItest::AutoLoader PACKAGE = XS::APItest::AutoLoader
1968 RETVAL = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SvUTF8(cv));
1976 PERL_UNUSED_ARG(items);
1977 RETVAL = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SvUTF8(cv));
1982 MODULE = XS::APItest PACKAGE = XS::APItest
1987 mymro.resolve = myget_linear_isa;
1988 mymro.name = "justisa";
1992 Perl_mro_register(aTHX_ &mymro);
1997 RETVAL = PL_custom_ops;
2002 xop_custom_op_names ()
2004 PL_custom_op_names = newHV();
2005 RETVAL = PL_custom_op_names;
2010 xop_custom_op_descs ()
2012 PL_custom_op_descs = newHV();
2013 RETVAL = PL_custom_op_descs;
2020 XopENTRY_set(&my_xop, xop_name, "my_xop");
2021 XopENTRY_set(&my_xop, xop_desc, "XOP for testing");
2022 XopENTRY_set(&my_xop, xop_class, OA_UNOP);
2023 XopENTRY_set(&my_xop, xop_peep, peep_xop);
2024 Perl_custom_op_register(aTHX_ pp_xop, &my_xop);
2029 XopDISABLE(&my_xop, xop_name);
2030 XopDISABLE(&my_xop, xop_desc);
2031 XopDISABLE(&my_xop, xop_class);
2032 XopDISABLE(&my_xop, xop_peep);
2037 RETVAL = PTR2IV(&my_xop);
2044 RETVAL = PTR2IV(pp_xop);
2062 MY_CXT.xop_record = newAV();
2064 kid = newSVOP(OP_CONST, 0, newSViv(42));
2066 unop = (UNOP*)mkUNOP(OP_CUSTOM, kid);
2067 unop->op_ppaddr = pp_xop;
2068 unop->op_private = 0;
2069 unop->op_next = NULL;
2070 kid->op_next = (OP*)unop;
2072 av_push(MY_CXT.xop_record, newSVpvf("unop:%" UVxf, PTR2UV(unop)));
2073 av_push(MY_CXT.xop_record, newSVpvf("kid:%" UVxf, PTR2UV(kid)));
2075 av_push(MY_CXT.xop_record, newSVpvf("NAME:%s", OP_NAME((OP*)unop)));
2076 av_push(MY_CXT.xop_record, newSVpvf("DESC:%s", OP_DESC((OP*)unop)));
2077 av_push(MY_CXT.xop_record, newSVpvf("CLASS:%d", (int)OP_CLASS((OP*)unop)));
2079 PL_rpeepp(aTHX_ kid);
2084 RETVAL = MY_CXT.xop_record;
2085 MY_CXT.xop_record = NULL;
2090 xop_from_custom_op ()
2092 /* author note: this test doesn't imply Perl_custom_op_xop is or isn't public
2093 API or that Perl_custom_op_xop is known to be used outside the core */
2097 unop = (UNOP*)mkUNOP(OP_CUSTOM, NULL);
2098 unop->op_ppaddr = pp_xop;
2099 unop->op_private = 0;
2100 unop->op_next = NULL;
2102 xop = Perl_custom_op_xop(aTHX_ (OP *)unop);
2104 RETVAL = PTR2IV(xop);
2113 MY_CXT.sv = newSVpv("initial",0);
2115 MY_CXT.bhkav = get_av("XS::APItest::bhkav", GV_ADDMULTI);
2116 MY_CXT.bhk_record = 0;
2118 BhkENTRY_set(&bhk_test, bhk_start, blockhook_test_start);
2119 BhkENTRY_set(&bhk_test, bhk_pre_end, blockhook_test_pre_end);
2120 BhkENTRY_set(&bhk_test, bhk_post_end, blockhook_test_post_end);
2121 BhkENTRY_set(&bhk_test, bhk_eval, blockhook_test_eval);
2122 Perl_blockhook_register(aTHX_ &bhk_test);
2124 MY_CXT.cscgv = gv_fetchpvs("XS::APItest::COMPILE_SCOPE_CONTAINER",
2125 GV_ADDMULTI, SVt_PVAV);
2126 MY_CXT.cscav = GvAV(MY_CXT.cscgv);
2128 BhkENTRY_set(&bhk_csc, bhk_start, blockhook_csc_start);
2129 BhkENTRY_set(&bhk_csc, bhk_pre_end, blockhook_csc_pre_end);
2130 Perl_blockhook_register(aTHX_ &bhk_csc);
2132 MY_CXT.peep_recorder = newAV();
2133 MY_CXT.rpeep_recorder = newAV();
2135 MY_CXT.orig_peep = PL_peepp;
2136 MY_CXT.orig_rpeep = PL_rpeepp;
2138 PL_rpeepp = my_rpeep;
2145 PERL_UNUSED_VAR(items);
2146 MY_CXT.sv = newSVpv("initial_clone",0);
2147 MY_CXT.cscgv = gv_fetchpvs("XS::APItest::COMPILE_SCOPE_CONTAINER",
2148 GV_ADDMULTI, SVt_PVAV);
2149 MY_CXT.cscav = NULL;
2150 MY_CXT.bhkav = get_av("XS::APItest::bhkav", GV_ADDMULTI);
2151 MY_CXT.bhk_record = 0;
2152 MY_CXT.peep_recorder = newAV();
2153 MY_CXT.rpeep_recorder = newAV();
2159 printf("%5.3f\n",val);
2164 #ifdef HAS_LONG_DOUBLE
2175 #ifdef HAS_LONG_DOUBLE
2176 # if defined(PERL_PRIfldbl) && (LONG_DOUBLESIZE > DOUBLESIZE)
2177 long double val = 7.0;
2178 printf("%5.3" PERL_PRIfldbl "\n",val);
2181 printf("%5.3f\n",val);
2195 printf("%ld\n",val);
2201 printf("%5.3f\n",val);
2249 mXPUSHp("three", 5);
2277 # test_EXTEND(): excerise the EXTEND() macro.
2278 # After calling EXTEND(), it also does *(p+n) = NULL and
2279 # *PL_stack_max = NULL to allow valgrind etc to spot if the stack hasn't
2280 # actually been extended properly.
2282 # max_offset specifies the SP to use. It is treated as a signed offset
2283 # from PL_stack_max.
2284 # nsv is the SV holding the value of n indicating how many slots
2285 # to extend the stack by.
2286 # use_ss is a boolean indicating that n should be cast to a SSize_t
2289 test_EXTEND(max_offset, nsv, use_ss)
2294 SV **sp = PL_stack_max + max_offset;
2297 SSize_t n = (SSize_t)SvIV(nsv);
2306 *PL_stack_max = NULL;
2317 SV * miscsv = sv_newmortal();
2318 HV * hv = (HV*)sv_2mortal((SV*)newHV());
2320 i_sub = get_cv("i", 0);
2322 /* PUTBACK not needed since this sub was called with 0 args, and is calling
2323 0 args, so global SP doesn't need to be moved before a call_* */
2324 retcnt = call_sv((SV*)i_sub, 0); /* try a CV* */
2326 SP -= retcnt; /* dont care about return count, wipe everything off */
2327 sv_setpvs(miscsv, "i");
2329 retcnt = call_sv(miscsv, 0); /* try a PV */
2332 /* no add and SVt_NULL are intentional, sub i should be defined already */
2333 i_gv = gv_fetchpvn_flags("i", sizeof("i")-1, 0, SVt_NULL);
2335 retcnt = call_sv((SV*)i_gv, 0); /* try a GV* */
2338 /* the tests below are not declaring this being public API behavior,
2339 only current internal behavior, these tests can be changed in the
2340 future if necessery */
2342 retcnt = call_sv(&PL_sv_yes, 0); /* does nothing */
2346 retcnt = call_sv(&PL_sv_no, G_EVAL);
2350 errstr = SvPV_nolen(errsv);
2351 if(strnEQ(errstr, "Undefined subroutine &main:: called at",
2352 sizeof("Undefined subroutine &main:: called at") - 1)) {
2354 retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
2359 retcnt = call_sv(&PL_sv_undef, G_EVAL);
2363 errstr = SvPV_nolen(errsv);
2364 if(strnEQ(errstr, "Can't use an undefined value as a subroutine reference at",
2365 sizeof("Can't use an undefined value as a subroutine reference at") - 1)) {
2367 retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
2372 retcnt = call_sv((SV*)hv, G_EVAL);
2376 errstr = SvPV_nolen(errsv);
2377 if(strnEQ(errstr, "Not a CODE reference at",
2378 sizeof("Not a CODE reference at") - 1)) {
2380 retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
2386 call_sv(sv, flags, ...)
2392 for (i=0; i<items-2; i++)
2393 ST(i) = ST(i+2); /* pop first two args */
2397 i = call_sv(sv, flags);
2400 PUSHs(sv_2mortal(newSViv(i)));
2403 call_pv(subname, flags, ...)
2409 for (i=0; i<items-2; i++)
2410 ST(i) = ST(i+2); /* pop first two args */
2414 i = call_pv(subname, flags);
2417 PUSHs(sv_2mortal(newSViv(i)));
2420 call_argv(subname, flags, ...)
2427 for (i=0; i<items-2; i++)
2428 tmpary[i] = SvPV_nolen(ST(i+2)); /* ignore first two args */
2431 i = call_argv(subname, flags, tmpary);
2434 PUSHs(sv_2mortal(newSViv(i)));
2437 call_method(methname, flags, ...)
2443 for (i=0; i<items-2; i++)
2444 ST(i) = ST(i+2); /* pop first two args */
2448 i = call_method(methname, flags);
2451 PUSHs(sv_2mortal(newSViv(i)));
2454 newCONSTSUB(stash, name, flags, sv)
2460 newCONSTSUB_flags = 1
2464 const char *pv = SvPV(name, len);
2468 mycv = newCONSTSUB(stash, pv, SvOK(sv) ? SvREFCNT_inc(sv) : NULL);
2471 mycv = newCONSTSUB_flags(
2472 stash, pv, len, flags | SvUTF8(name), SvOK(sv) ? SvREFCNT_inc(sv) : NULL
2478 PUSHs( CvCONST(mycv) ? &PL_sv_yes : &PL_sv_no );
2479 PUSHs((SV*)CvGV(mycv));
2482 gv_init_type(namesv, multi, flags, type)
2489 const char * const name = SvPV_const(namesv, len);
2490 GV *gv = *(GV**)hv_fetch(PL_defstash, name, len, TRUE);
2492 if (SvTYPE(gv) == SVt_PVGV)
2493 Perl_croak(aTHX_ "GV is already a PVGV");
2494 if (multi) flags |= GV_ADDMULTI;
2497 gv_init(gv, PL_defstash, name, len, multi);
2500 gv_init_sv(gv, PL_defstash, namesv, flags);
2503 gv_init_pv(gv, PL_defstash, name, flags | SvUTF8(namesv));
2506 gv_init_pvn(gv, PL_defstash, name, len, flags | SvUTF8(namesv));
2509 XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
2512 gv_fetchmeth_type(stash, methname, type, level, flags)
2520 const char * const name = SvPV_const(methname, len);
2525 gv = gv_fetchmeth(stash, name, len, level);
2528 gv = gv_fetchmeth_sv(stash, methname, level, flags);
2531 gv = gv_fetchmeth_pv(stash, name, level, flags | SvUTF8(methname));
2534 gv = gv_fetchmeth_pvn(stash, name, len, level, flags | SvUTF8(methname));
2537 XPUSHs( gv ? MUTABLE_SV(gv) : &PL_sv_undef );
2540 gv_fetchmeth_autoload_type(stash, methname, type, level, flags)
2548 const char * const name = SvPV_const(methname, len);
2553 gv = gv_fetchmeth_autoload(stash, name, len, level);
2556 gv = gv_fetchmeth_sv_autoload(stash, methname, level, flags);
2559 gv = gv_fetchmeth_pv_autoload(stash, name, level, flags | SvUTF8(methname));
2562 gv = gv_fetchmeth_pvn_autoload(stash, name, len, level, flags | SvUTF8(methname));
2565 XPUSHs( gv ? MUTABLE_SV(gv) : &PL_sv_undef );
2568 gv_fetchmethod_flags_type(stash, methname, type, flags)
2578 gv = gv_fetchmethod_flags(stash, SvPVX_const(methname), flags);
2581 gv = gv_fetchmethod_sv_flags(stash, methname, flags);
2584 gv = gv_fetchmethod_pv_flags(stash, SvPV_nolen(methname), flags | SvUTF8(methname));
2588 const char * const name = SvPV_const(methname, len);
2589 gv = gv_fetchmethod_pvn_flags(stash, name, len, flags | SvUTF8(methname));
2593 gv = gv_fetchmethod_pvn_flags(stash, SvPV_nolen(methname),
2594 flags, SvUTF8(methname));
2596 XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
2599 gv_autoload_type(stash, methname, type, method)
2606 const char * const name = SvPV_const(methname, len);
2608 I32 flags = method ? GV_AUTOLOAD_ISMETHOD : 0;
2612 gv = gv_autoload4(stash, name, len, method);
2615 gv = gv_autoload_sv(stash, methname, flags);
2618 gv = gv_autoload_pv(stash, name, flags | SvUTF8(methname));
2621 gv = gv_autoload_pvn(stash, name, len, flags | SvUTF8(methname));
2624 XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
2627 gv_const_sv(SV *name)
2632 HV *stash = gv_stashpv("main",0);
2633 HE *he = hv_fetch_ent(stash, name, 0, 0);
2634 gv = (GV *)HeVAL(he);
2639 RETVAL = gv_const_sv(gv);
2642 RETVAL = newSVsv(RETVAL);
2647 whichsig_type(namesv, type)
2652 const char * const name = SvPV_const(namesv, len);
2660 i = whichsig_sv(namesv);
2663 i = whichsig_pv(name);
2666 i = whichsig_pvn(name, len);
2669 XPUSHs(sv_2mortal(newSViv(i)));
2679 i = eval_sv(sv, flags);
2682 PUSHs(sv_2mortal(newSViv(i)));
2685 eval_pv(p, croak_on_error)
2691 PUSHs(eval_pv(p, croak_on_error));
2701 apitest_exception(throw_e)
2711 Perl_croak(aTHX_ "%s", SvPV_nolen(sv));
2714 Perl_croak(aTHX_ NULL);
2720 RETVAL = newRV_inc((SV*)PL_strtab);
2728 RETVAL = my_cxt_getint_p(aMY_CXT);
2737 my_cxt_setint_p(aMY_CXT_ i);
2744 ST(0) = how ? my_cxt_getsv_interp_context() : my_cxt_getsv_interp();
2752 SvREFCNT_dec(MY_CXT.sv);
2753 my_cxt_setsv_p(sv _aMY_CXT);
2757 sv_setsv_cow_hashkey_core()
2760 sv_setsv_cow_hashkey_notcore()
2763 sv_set_deref(SV *sv, SV *sv2, int which)
2767 const char *pv = SvPV(sv2,len);
2768 if (!SvROK(sv)) croak("Not a ref");
2771 case 0: sv_setsv(sv,sv2); break;
2772 case 1: sv_setpv(sv,pv); break;
2773 case 2: sv_setpvn(sv,pv,len); break;
2778 rmagical_cast(sv, type)
2784 if (!SvOK(sv) || !SvROK(sv) || !SvOK(type)) { XSRETURN_UNDEF; }
2786 if (SvTYPE(sv) != SVt_PVHV) { XSRETURN_UNDEF; }
2787 uf.uf_val = rmagical_a_dummy;
2790 if (SvTRUE(type)) { /* b */
2791 sv_magicext(sv, NULL, PERL_MAGIC_ext, &rmagical_b, NULL, 0);
2793 sv_magic(sv, NULL, PERL_MAGIC_uvar, (char *) &uf, sizeof(uf));
2801 if (!SvOK(sv) || !SvROK(sv)) { XSRETURN_UNDEF; }
2804 mXPUSHu(SvFLAGS(sv) & SVs_GMG);
2805 mXPUSHu(SvFLAGS(sv) & SVs_SMG);
2806 mXPUSHu(SvFLAGS(sv) & SVs_RMG);
2813 const PERL_CONTEXT *cx, *dbcx;
2818 cx = caller_cx(level, &dbcx);
2821 pv = CopSTASHPV(cx->blk_oldcop);
2822 ST(0) = pv ? sv_2mortal(newSVpv(pv, 0)) : &PL_sv_undef;
2823 gv = CvGV(cx->blk_sub.cv);
2824 ST(1) = isGV(gv) ? sv_2mortal(newSVpv(GvNAME(gv), 0)) : &PL_sv_undef;
2826 pv = CopSTASHPV(dbcx->blk_oldcop);
2827 ST(2) = pv ? sv_2mortal(newSVpv(pv, 0)) : &PL_sv_undef;
2828 gv = CvGV(dbcx->blk_sub.cv);
2829 ST(3) = isGV(gv) ? sv_2mortal(newSVpv(GvNAME(gv), 0)) : &PL_sv_undef;
2831 ST(4) = cop_hints_fetch_pvs(cx->blk_oldcop, "foo", 0);
2832 ST(5) = cop_hints_fetch_pvn(cx->blk_oldcop, "foo", 3, 0, 0);
2833 ST(6) = cop_hints_fetch_sv(cx->blk_oldcop,
2834 sv_2mortal(newSVpvs("foo")), 0, 0);
2836 hv = cop_hints_2hv(cx->blk_oldcop, 0);
2837 ST(7) = hv ? sv_2mortal(newRV_noinc((SV *)hv)) : &PL_sv_undef;
2846 ST (0) = newSVpv (Perl_sv_peek (aTHX_ sv), 0);
2852 sv_inc(get_sv("XS::APItest::BEGIN_called", GV_ADD|GV_ADDMULTI));
2857 sv_inc(get_sv("XS::APItest::CHECK_called", GV_ADD|GV_ADDMULTI));
2862 sv_inc(get_sv("XS::APItest::UNITCHECK_called", GV_ADD|GV_ADDMULTI));
2867 sv_inc(get_sv("XS::APItest::INIT_called", GV_ADD|GV_ADDMULTI));
2872 sv_inc(get_sv("XS::APItest::END_called", GV_ADD|GV_ADDMULTI));
2875 utf16_to_utf8 (sv, ...)
2878 utf16_to_utf8_reversed = 1
2883 I32 got; /* Gah, badly thought out APIs */
2885 if (ix) (void)SvPV_force_nolen(sv);
2886 source = (U8 *)SvPVbyte(sv, len);
2887 /* Optionally only convert part of the buffer. */
2891 /* Mortalise this right now, as we'll be testing croak()s */
2892 dest = sv_2mortal(newSV(len * 3 / 2 + 1));
2894 utf16_to_utf8_reversed(source, (U8 *)SvPVX(dest), len, &got);
2896 utf16_to_utf8(source, (U8 *)SvPVX(dest), len, &got);
2898 SvCUR_set(dest, got);
2899 SvPVX(dest)[got] = '\0';
2905 my_exit(int exitcode)
2915 s = SvPVbyte(sv, len);
2923 RETVAL = PL_sv_count;
2931 MY_CXT.bhk_record = on;
2933 av_clear(MY_CXT.bhkav);
2939 MAGIC *callmg, *uvarmg;
2941 sv = sv_2mortal(newSV(0));
2942 if (SvTYPE(sv) >= SVt_PVMG) croak_fail();
2943 if (SvMAGICAL(sv)) croak_fail();
2944 sv_magic(sv, &PL_sv_yes, PERL_MAGIC_checkcall, (char*)&callmg, 0);
2945 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2946 if (!SvMAGICAL(sv)) croak_fail();
2947 if (mg_find(sv, PERL_MAGIC_uvar)) croak_fail();
2948 callmg = mg_find(sv, PERL_MAGIC_checkcall);
2949 if (!callmg) croak_fail();
2950 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2952 sv_magic(sv, &PL_sv_no, PERL_MAGIC_uvar, (char*)&uvarmg, 0);
2953 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2954 if (!SvMAGICAL(sv)) croak_fail();
2955 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2956 uvarmg = mg_find(sv, PERL_MAGIC_uvar);
2957 if (!uvarmg) croak_fail();
2958 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2960 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2962 mg_free_type(sv, PERL_MAGIC_vec);
2963 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2964 if (!SvMAGICAL(sv)) croak_fail();
2965 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2966 if (mg_find(sv, PERL_MAGIC_uvar) != uvarmg) croak_fail();
2967 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2969 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2971 mg_free_type(sv, PERL_MAGIC_uvar);
2972 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2973 if (!SvMAGICAL(sv)) croak_fail();
2974 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2975 if (mg_find(sv, PERL_MAGIC_uvar)) croak_fail();
2976 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2978 sv_magic(sv, &PL_sv_no, PERL_MAGIC_uvar, (char*)&uvarmg, 0);
2979 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2980 if (!SvMAGICAL(sv)) croak_fail();
2981 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2982 uvarmg = mg_find(sv, PERL_MAGIC_uvar);
2983 if (!uvarmg) croak_fail();
2984 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2986 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2988 mg_free_type(sv, PERL_MAGIC_checkcall);
2989 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2990 if (!SvMAGICAL(sv)) croak_fail();
2991 if (mg_find(sv, PERL_MAGIC_uvar) != uvarmg) croak_fail();
2992 if (mg_find(sv, PERL_MAGIC_checkcall)) croak_fail();
2993 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2995 mg_free_type(sv, PERL_MAGIC_uvar);
2996 if (SvMAGICAL(sv)) croak_fail();
2997 if (mg_find(sv, PERL_MAGIC_checkcall)) croak_fail();
2998 if (mg_find(sv, PERL_MAGIC_uvar)) croak_fail();
3001 test_op_contextualize()
3005 o = newSVOP(OP_CONST, 0, newSViv(0));
3006 o->op_flags &= ~OPf_WANT;
3007 o = op_contextualize(o, G_SCALAR);
3008 if (o->op_type != OP_CONST ||
3009 (o->op_flags & OPf_WANT) != OPf_WANT_SCALAR)
3012 o = newSVOP(OP_CONST, 0, newSViv(0));
3013 o->op_flags &= ~OPf_WANT;
3014 o = op_contextualize(o, G_ARRAY);
3015 if (o->op_type != OP_CONST ||
3016 (o->op_flags & OPf_WANT) != OPf_WANT_LIST)
3019 o = newSVOP(OP_CONST, 0, newSViv(0));
3020 o->op_flags &= ~OPf_WANT;
3021 o = op_contextualize(o, G_VOID);
3022 if (o->op_type != OP_NULL) croak_fail();
3033 troc_gv = gv_fetchpv("XS::APItest::test_rv2cv_op_cv", 0, SVt_PVGV);
3034 troc_cv = get_cv("XS::APItest::test_rv2cv_op_cv", 0);
3035 o = newCVREF(0, newGVOP(OP_GV, 0, troc_gv));
3036 if (rv2cv_op_cv(o, 0) != troc_cv) croak_fail();
3037 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV) != (CV*)troc_gv)
3039 o->op_private |= OPpENTERSUB_AMPER;
3040 if (rv2cv_op_cv(o, 0)) croak_fail();
3041 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3042 o->op_private &= ~OPpENTERSUB_AMPER;
3043 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3044 if (rv2cv_op_cv(o, RV2CVOPCV_MARK_EARLY) != troc_cv) croak_fail();
3045 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3047 o = newSVOP(OP_CONST, 0, newSVpv("XS::APItest::test_rv2cv_op_cv", 0));
3048 o->op_private = OPpCONST_BARE;
3050 if (rv2cv_op_cv(o, 0) != troc_cv) croak_fail();
3051 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV) != (CV*)troc_gv)
3053 o->op_private |= OPpENTERSUB_AMPER;
3054 if (rv2cv_op_cv(o, 0)) croak_fail();
3055 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3057 o = newCVREF(0, newSVOP(OP_CONST, 0, newRV_inc((SV*)troc_cv)));
3058 if (rv2cv_op_cv(o, 0) != troc_cv) croak_fail();
3059 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV) != (CV*)troc_gv)
3061 o->op_private |= OPpENTERSUB_AMPER;
3062 if (rv2cv_op_cv(o, 0)) croak_fail();
3063 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3064 o->op_private &= ~OPpENTERSUB_AMPER;
3065 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3066 if (rv2cv_op_cv(o, RV2CVOPCV_MARK_EARLY) != troc_cv) croak_fail();
3067 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3069 o = newCVREF(0, newUNOP(OP_RAND, 0, newSVOP(OP_CONST, 0, newSViv(0))));
3070 if (rv2cv_op_cv(o, 0)) croak_fail();
3071 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3072 o->op_private |= OPpENTERSUB_AMPER;
3073 if (rv2cv_op_cv(o, 0)) croak_fail();
3074 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3075 o->op_private &= ~OPpENTERSUB_AMPER;
3076 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3077 if (rv2cv_op_cv(o, RV2CVOPCV_MARK_EARLY)) croak_fail();
3078 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3080 o = newUNOP(OP_RAND, 0, newSVOP(OP_CONST, 0, newSViv(0)));
3081 if (rv2cv_op_cv(o, 0)) croak_fail();
3082 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3086 test_cv_getset_call_checker()
3088 CV *troc_cv, *tsh_cv;
3089 Perl_call_checker ckfun;
3092 #define check_cc(cv, xckfun, xckobj) \
3094 cv_get_call_checker((cv), &ckfun, &ckobj); \
3095 if (ckfun != (xckfun)) croak_fail_ne(FPTR2DPTR(void *, ckfun), xckfun); \
3096 if (ckobj != (xckobj)) croak_fail_ne(FPTR2DPTR(void *, ckobj), xckobj); \
3098 troc_cv = get_cv("XS::APItest::test_rv2cv_op_cv", 0);
3099 tsh_cv = get_cv("XS::APItest::test_savehints", 0);
3100 check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
3101 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
3102 cv_set_call_checker(tsh_cv, Perl_ck_entersub_args_proto_or_list,
3104 check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
3105 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes);
3106 cv_set_call_checker(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
3107 check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
3108 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes);
3109 cv_set_call_checker(tsh_cv, Perl_ck_entersub_args_proto_or_list,
3111 check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
3112 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
3113 cv_set_call_checker(troc_cv, Perl_ck_entersub_args_proto_or_list,
3115 check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
3116 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
3117 if (SvMAGICAL((SV*)troc_cv) || SvMAGIC((SV*)troc_cv)) croak_fail();
3118 if (SvMAGICAL((SV*)tsh_cv) || SvMAGIC((SV*)tsh_cv)) croak_fail();
3122 cv_set_call_checker_lists(CV *cv)
3124 cv_set_call_checker(cv, THX_ck_entersub_args_lists, &PL_sv_undef);
3127 cv_set_call_checker_scalars(CV *cv)
3129 cv_set_call_checker(cv, THX_ck_entersub_args_scalars, &PL_sv_undef);
3132 cv_set_call_checker_proto(CV *cv, SV *proto)
3135 proto = SvRV(proto);
3136 cv_set_call_checker(cv, Perl_ck_entersub_args_proto, proto);
3139 cv_set_call_checker_proto_or_list(CV *cv, SV *proto)
3142 proto = SvRV(proto);
3143 cv_set_call_checker(cv, Perl_ck_entersub_args_proto_or_list, proto);
3146 cv_set_call_checker_multi_sum(CV *cv)
3148 cv_set_call_checker(cv, THX_ck_entersub_multi_sum, &PL_sv_undef);
3160 #define check_ph(EXPR) \
3161 do { if((EXPR) != &PL_sv_placeholder) croak("fail"); } while(0)
3162 #define check_iv(EXPR, EXPECT) \
3163 do { if(SvIV(EXPR) != (EXPECT)) croak("fail"); } while(0)
3164 #define msvpvs(STR) sv_2mortal(newSVpvs(STR))
3165 #define msviv(VALUE) sv_2mortal(newSViv(VALUE))
3166 a = cophh_new_empty();
3167 check_ph(cophh_fetch_pvn(a, "foo_1", 5, 0, 0));
3168 check_ph(cophh_fetch_pvs(a, "foo_1", 0));
3169 check_ph(cophh_fetch_pv(a, "foo_1", 0, 0));
3170 check_ph(cophh_fetch_sv(a, msvpvs("foo_1"), 0, 0));
3171 a = cophh_store_pvn(a, "foo_1abc", 5, 0, msviv(111), 0);
3172 a = cophh_store_pvs(a, "foo_2", msviv(222), 0);
3173 a = cophh_store_pv(a, "foo_3", 0, msviv(333), 0);
3174 a = cophh_store_sv(a, msvpvs("foo_4"), 0, msviv(444), 0);
3175 check_iv(cophh_fetch_pvn(a, "foo_1xyz", 5, 0, 0), 111);
3176 check_iv(cophh_fetch_pvs(a, "foo_1", 0), 111);
3177 check_iv(cophh_fetch_pv(a, "foo_1", 0, 0), 111);
3178 check_iv(cophh_fetch_sv(a, msvpvs("foo_1"), 0, 0), 111);
3179 check_iv(cophh_fetch_pvs(a, "foo_2", 0), 222);
3180 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3181 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3182 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3184 b = cophh_store_pvs(b, "foo_1", msviv(1111), 0);
3185 check_iv(cophh_fetch_pvs(a, "foo_1", 0), 111);
3186 check_iv(cophh_fetch_pvs(a, "foo_2", 0), 222);
3187 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3188 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3189 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3190 check_iv(cophh_fetch_pvs(b, "foo_1", 0), 1111);
3191 check_iv(cophh_fetch_pvs(b, "foo_2", 0), 222);
3192 check_iv(cophh_fetch_pvs(b, "foo_3", 0), 333);
3193 check_iv(cophh_fetch_pvs(b, "foo_4", 0), 444);
3194 check_ph(cophh_fetch_pvs(b, "foo_5", 0));
3195 a = cophh_delete_pvn(a, "foo_1abc", 5, 0, 0);
3196 a = cophh_delete_pvs(a, "foo_2", 0);
3197 b = cophh_delete_pv(b, "foo_3", 0, 0);
3198 b = cophh_delete_sv(b, msvpvs("foo_4"), 0, 0);
3199 check_ph(cophh_fetch_pvs(a, "foo_1", 0));
3200 check_ph(cophh_fetch_pvs(a, "foo_2", 0));
3201 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3202 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3203 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3204 check_iv(cophh_fetch_pvs(b, "foo_1", 0), 1111);
3205 check_iv(cophh_fetch_pvs(b, "foo_2", 0), 222);
3206 check_ph(cophh_fetch_pvs(b, "foo_3", 0));
3207 check_ph(cophh_fetch_pvs(b, "foo_4", 0));
3208 check_ph(cophh_fetch_pvs(b, "foo_5", 0));
3209 b = cophh_delete_pvs(b, "foo_3", 0);
3210 b = cophh_delete_pvs(b, "foo_5", 0);
3211 check_iv(cophh_fetch_pvs(b, "foo_1", 0), 1111);
3212 check_iv(cophh_fetch_pvs(b, "foo_2", 0), 222);
3213 check_ph(cophh_fetch_pvs(b, "foo_3", 0));
3214 check_ph(cophh_fetch_pvs(b, "foo_4", 0));
3215 check_ph(cophh_fetch_pvs(b, "foo_5", 0));
3217 check_ph(cophh_fetch_pvs(a, "foo_1", 0));
3218 check_ph(cophh_fetch_pvs(a, "foo_2", 0));
3219 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3220 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3221 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3222 a = cophh_store_pvs(a, "foo_1", msviv(11111), COPHH_KEY_UTF8);
3223 a = cophh_store_pvs(a, "foo_\xaa", msviv(123), 0);
3225 a = cophh_store_pvs(a, "foo_\xc2\xbb", msviv(456), COPHH_KEY_UTF8);
3227 /* On EBCDIC, we need to translate the UTF-8 in the ASCII test to the
3228 * equivalent UTF-EBCDIC for the code page. This is done at runtime
3229 * (with the helper function in this file). Therefore we can't use
3230 * cophhh_store_pvs(), as we don't have literal string */
3231 key_sv = sv_2mortal(newSVpvs("foo_"));
3232 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xbb"));
3233 key_name = SvPV(key_sv, key_len);
3234 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(456), COPHH_KEY_UTF8);
3237 a = cophh_store_pvs(a, "foo_\xc3\x8c", msviv(789), COPHH_KEY_UTF8);
3239 sv_setpvs(key_sv, "foo_");
3240 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc3\x8c"));
3241 key_name = SvPV(key_sv, key_len);
3242 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(789), COPHH_KEY_UTF8);
3245 a = cophh_store_pvs(a, "foo_\xd9\xa6", msviv(666), COPHH_KEY_UTF8);
3247 sv_setpvs(key_sv, "foo_");
3248 cat_utf8a2n(key_sv, STR_WITH_LEN("\xd9\xa6"));
3249 key_name = SvPV(key_sv, key_len);
3250 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(666), COPHH_KEY_UTF8);
3252 check_iv(cophh_fetch_pvs(a, "foo_1", 0), 11111);
3253 check_iv(cophh_fetch_pvs(a, "foo_1", COPHH_KEY_UTF8), 11111);
3254 check_iv(cophh_fetch_pvs(a, "foo_\xaa", 0), 123);
3256 check_iv(cophh_fetch_pvs(a, "foo_\xc2\xaa", COPHH_KEY_UTF8), 123);
3257 check_ph(cophh_fetch_pvs(a, "foo_\xc2\xaa", 0));
3259 sv_setpvs(key_sv, "foo_");
3260 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xaa"));
3261 key_name = SvPV(key_sv, key_len);
3262 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 123);
3263 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3265 check_iv(cophh_fetch_pvs(a, "foo_\xbb", 0), 456);
3267 check_iv(cophh_fetch_pvs(a, "foo_\xc2\xbb", COPHH_KEY_UTF8), 456);
3268 check_ph(cophh_fetch_pvs(a, "foo_\xc2\xbb", 0));
3270 sv_setpvs(key_sv, "foo_");
3271 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xbb"));
3272 key_name = SvPV(key_sv, key_len);
3273 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 456);
3274 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3276 check_iv(cophh_fetch_pvs(a, "foo_\xcc", 0), 789);
3278 check_iv(cophh_fetch_pvs(a, "foo_\xc3\x8c", COPHH_KEY_UTF8), 789);
3279 check_ph(cophh_fetch_pvs(a, "foo_\xc2\x8c", 0));
3281 sv_setpvs(key_sv, "foo_");
3282 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc3\x8c"));
3283 key_name = SvPV(key_sv, key_len);
3284 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 789);
3285 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3288 check_iv(cophh_fetch_pvs(a, "foo_\xd9\xa6", COPHH_KEY_UTF8), 666);
3289 check_ph(cophh_fetch_pvs(a, "foo_\xd9\xa6", 0));
3291 sv_setpvs(key_sv, "foo_");
3292 cat_utf8a2n(key_sv, STR_WITH_LEN("\xd9\xa6"));
3293 key_name = SvPV(key_sv, key_len);
3294 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 666);
3295 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3313 cop = &PL_compiling;
3314 Perl_cop_store_label(aTHX_ cop, "foo", 3, 0);
3315 label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
3316 if (strcmp(label,"foo")) croak("fail # cop_fetch_label label");
3317 if (len != 3) croak("fail # cop_fetch_label len");
3318 if (utf8) croak("fail # cop_fetch_label utf8");
3319 /* SMALL GERMAN UMLAUT A */
3320 Perl_cop_store_label(aTHX_ cop, "fo\xc3\xa4", 4, SVf_UTF8);
3321 label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
3322 if (strcmp(label,"fo\xc3\xa4")) croak("fail # cop_fetch_label label");
3323 if (len != 4) croak("fail # cop_fetch_label len");
3324 if (!utf8) croak("fail # cop_fetch_label utf8");
3337 #define msviv(VALUE) sv_2mortal(newSViv(VALUE))
3338 a = cophh_new_empty();
3339 a = cophh_store_pvs(a, "foo_0", msviv(999), 0);
3340 a = cophh_store_pvs(a, "foo_1", msviv(111), 0);
3341 a = cophh_store_pvs(a, "foo_\xaa", msviv(123), 0);
3343 a = cophh_store_pvs(a, "foo_\xc2\xbb", msviv(456), COPHH_KEY_UTF8);
3345 key_sv = sv_2mortal(newSVpvs("foo_"));
3346 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xbb"));
3347 key_name = SvPV(key_sv, key_len);
3348 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(456), COPHH_KEY_UTF8);
3351 a = cophh_store_pvs(a, "foo_\xc3\x8c", msviv(789), COPHH_KEY_UTF8);
3353 sv_setpvs(key_sv, "foo_");
3354 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc3\x8c"));
3355 key_name = SvPV(key_sv, key_len);
3356 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(789), COPHH_KEY_UTF8);
3359 a = cophh_store_pvs(a, "foo_\xd9\xa6", msviv(666), COPHH_KEY_UTF8);
3361 sv_setpvs(key_sv, "foo_");
3362 cat_utf8a2n(key_sv, STR_WITH_LEN("\xd9\xa6"));
3363 key_name = SvPV(key_sv, key_len);
3364 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(666), COPHH_KEY_UTF8);
3366 a = cophh_delete_pvs(a, "foo_0", 0);
3367 a = cophh_delete_pvs(a, "foo_2", 0);
3368 RETVAL = cophh_2hv(a, 0);
3379 #define store_hint(KEY, VALUE) \
3380 sv_setiv_mg(*hv_fetchs(GvHV(PL_hintgv), KEY, 1), (VALUE))
3381 #define hint_ok(KEY, EXPECT) \
3382 ((svp = hv_fetchs(GvHV(PL_hintgv), KEY, 0)) && \
3383 (sv = *svp) && SvIV(sv) == (EXPECT) && \
3384 (sv = cop_hints_fetch_pvs(&PL_compiling, KEY, 0)) && \
3385 SvIV(sv) == (EXPECT))
3386 #define check_hint(KEY, EXPECT) \
3387 do { if (!hint_ok(KEY, EXPECT)) croak_fail(); } while(0)
3388 PL_hints |= HINT_LOCALIZE_HH;
3391 PL_hints &= HINT_INTEGER;
3392 store_hint("t0", 123);
3393 store_hint("t1", 456);
3394 if (PL_hints & HINT_INTEGER) croak_fail();
3395 check_hint("t0", 123); check_hint("t1", 456);
3398 if (PL_hints & HINT_INTEGER) croak_fail();
3399 check_hint("t0", 123); check_hint("t1", 456);
3400 PL_hints |= HINT_INTEGER;
3401 store_hint("t0", 321);
3402 if (!(PL_hints & HINT_INTEGER)) croak_fail();
3403 check_hint("t0", 321); check_hint("t1", 456);
3405 if (PL_hints & HINT_INTEGER) croak_fail();
3406 check_hint("t0", 123); check_hint("t1", 456);
3409 if (PL_hints & HINT_INTEGER) croak_fail();
3410 check_hint("t0", 123); check_hint("t1", 456);
3411 store_hint("t1", 654);
3412 if (PL_hints & HINT_INTEGER) croak_fail();
3413 check_hint("t0", 123); check_hint("t1", 654);
3415 if (PL_hints & HINT_INTEGER) croak_fail();
3416 check_hint("t0", 123); check_hint("t1", 456);
3427 PL_hints |= HINT_LOCALIZE_HH;
3430 sv_setiv_mg(*hv_fetchs(GvHV(PL_hintgv), "t0", 1), 123);
3431 if (SvIV(cop_hints_fetch_pvs(&PL_compiling, "t0", 0)) != 123)
3433 a = newHVhv(GvHV(PL_hintgv));
3435 sv_setiv_mg(*hv_fetchs(a, "t0", 1), 456);
3436 if (SvIV(cop_hints_fetch_pvs(&PL_compiling, "t0", 0)) != 123)
3438 b = hv_copy_hints_hv(a);
3440 sv_setiv_mg(*hv_fetchs(b, "t0", 1), 789);
3441 if (SvIV(cop_hints_fetch_pvs(&PL_compiling, "t0", 0)) != 789)
3450 #define iv_op(iv) newSVOP(OP_CONST, 0, newSViv(iv))
3451 #define check_op(o, expect) \
3453 if (strcmp(test_op_list_describe(o), (expect))) \
3454 croak("fail %s %s", test_op_list_describe(o), (expect)); \
3456 a = op_append_elem(OP_LIST, NULL, NULL);
3458 a = op_append_elem(OP_LIST, iv_op(1), a);
3459 check_op(a, "const(1).");
3460 a = op_append_elem(OP_LIST, NULL, a);
3461 check_op(a, "const(1).");
3462 a = op_append_elem(OP_LIST, a, iv_op(2));
3463 check_op(a, "list[pushmark.const(1).const(2).]");
3464 a = op_append_elem(OP_LIST, a, iv_op(3));
3465 check_op(a, "list[pushmark.const(1).const(2).const(3).]");
3466 a = op_append_elem(OP_LIST, a, NULL);
3467 check_op(a, "list[pushmark.const(1).const(2).const(3).]");
3468 a = op_append_elem(OP_LIST, NULL, a);
3469 check_op(a, "list[pushmark.const(1).const(2).const(3).]");
3470 a = op_append_elem(OP_LIST, iv_op(4), a);
3471 check_op(a, "list[pushmark.const(4)."
3472 "list[pushmark.const(1).const(2).const(3).]]");
3473 a = op_append_elem(OP_LIST, a, iv_op(5));
3474 check_op(a, "list[pushmark.const(4)."
3475 "list[pushmark.const(1).const(2).const(3).]const(5).]");
3476 a = op_append_elem(OP_LIST, a,
3477 op_append_elem(OP_LIST, iv_op(7), iv_op(6)));
3478 check_op(a, "list[pushmark.const(4)."
3479 "list[pushmark.const(1).const(2).const(3).]const(5)."
3480 "list[pushmark.const(7).const(6).]]");
3482 a = op_append_elem(OP_LINESEQ, iv_op(1), iv_op(2));
3483 check_op(a, "lineseq[const(1).const(2).]");
3484 a = op_append_elem(OP_LINESEQ, a, iv_op(3));
3485 check_op(a, "lineseq[const(1).const(2).const(3).]");
3487 a = op_append_elem(OP_LINESEQ,
3488 op_append_elem(OP_LIST, iv_op(1), iv_op(2)),
3490 check_op(a, "lineseq[list[pushmark.const(1).const(2).]const(3).]");
3492 a = op_prepend_elem(OP_LIST, NULL, NULL);
3494 a = op_prepend_elem(OP_LIST, a, iv_op(1));
3495 check_op(a, "const(1).");
3496 a = op_prepend_elem(OP_LIST, a, NULL);
3497 check_op(a, "const(1).");
3498 a = op_prepend_elem(OP_LIST, iv_op(2), a);
3499 check_op(a, "list[pushmark.const(2).const(1).]");
3500 a = op_prepend_elem(OP_LIST, iv_op(3), a);
3501 check_op(a, "list[pushmark.const(3).const(2).const(1).]");
3502 a = op_prepend_elem(OP_LIST, NULL, a);
3503 check_op(a, "list[pushmark.const(3).const(2).const(1).]");
3504 a = op_prepend_elem(OP_LIST, a, NULL);
3505 check_op(a, "list[pushmark.const(3).const(2).const(1).]");
3506 a = op_prepend_elem(OP_LIST, a, iv_op(4));
3507 check_op(a, "list[pushmark."
3508 "list[pushmark.const(3).const(2).const(1).]const(4).]");
3509 a = op_prepend_elem(OP_LIST, iv_op(5), a);
3510 check_op(a, "list[pushmark.const(5)."
3511 "list[pushmark.const(3).const(2).const(1).]const(4).]");
3512 a = op_prepend_elem(OP_LIST,
3513 op_prepend_elem(OP_LIST, iv_op(6), iv_op(7)), a);
3514 check_op(a, "list[pushmark.list[pushmark.const(6).const(7).]const(5)."
3515 "list[pushmark.const(3).const(2).const(1).]const(4).]");
3517 a = op_prepend_elem(OP_LINESEQ, iv_op(2), iv_op(1));
3518 check_op(a, "lineseq[const(2).const(1).]");
3519 a = op_prepend_elem(OP_LINESEQ, iv_op(3), a);
3520 check_op(a, "lineseq[const(3).const(2).const(1).]");
3522 a = op_prepend_elem(OP_LINESEQ, iv_op(3),
3523 op_prepend_elem(OP_LIST, iv_op(2), iv_op(1)));
3524 check_op(a, "lineseq[const(3).list[pushmark.const(2).const(1).]]");
3526 a = op_append_list(OP_LINESEQ, NULL, NULL);
3528 a = op_append_list(OP_LINESEQ, iv_op(1), a);
3529 check_op(a, "const(1).");
3530 a = op_append_list(OP_LINESEQ, NULL, a);
3531 check_op(a, "const(1).");
3532 a = op_append_list(OP_LINESEQ, a, iv_op(2));
3533 check_op(a, "lineseq[const(1).const(2).]");
3534 a = op_append_list(OP_LINESEQ, a, iv_op(3));
3535 check_op(a, "lineseq[const(1).const(2).const(3).]");
3536 a = op_append_list(OP_LINESEQ, iv_op(4), a);
3537 check_op(a, "lineseq[const(4).const(1).const(2).const(3).]");
3538 a = op_append_list(OP_LINESEQ, a, NULL);
3539 check_op(a, "lineseq[const(4).const(1).const(2).const(3).]");
3540 a = op_append_list(OP_LINESEQ, NULL, a);
3541 check_op(a, "lineseq[const(4).const(1).const(2).const(3).]");
3542 a = op_append_list(OP_LINESEQ, a,
3543 op_append_list(OP_LINESEQ, iv_op(5), iv_op(6)));
3544 check_op(a, "lineseq[const(4).const(1).const(2).const(3)."
3545 "const(5).const(6).]");
3547 a = op_append_list(OP_LINESEQ,
3548 op_append_list(OP_LINESEQ, iv_op(1), iv_op(2)),
3549 op_append_list(OP_LIST, iv_op(3), iv_op(4)));
3550 check_op(a, "lineseq[const(1).const(2)."
3551 "list[pushmark.const(3).const(4).]]");
3553 a = op_append_list(OP_LINESEQ,
3554 op_append_list(OP_LIST, iv_op(1), iv_op(2)),
3555 op_append_list(OP_LINESEQ, iv_op(3), iv_op(4)));
3556 check_op(a, "lineseq[list[pushmark.const(1).const(2).]"
3557 "const(3).const(4).]");
3566 #define check_ll(o, expect) \
3568 if (strNE(test_op_linklist_describe(o), (expect))) \
3569 croak("fail %s %s", test_op_linklist_describe(o), (expect)); \
3572 check_ll(o, ".const1");
3575 o = mkUNOP(OP_NOT, iv_op(1));
3576 check_ll(o, ".const1.not");
3579 o = mkUNOP(OP_NOT, mkUNOP(OP_NEGATE, iv_op(1)));
3580 check_ll(o, ".const1.negate.not");
3583 o = mkBINOP(OP_ADD, iv_op(1), iv_op(2));
3584 check_ll(o, ".const1.const2.add");
3587 o = mkBINOP(OP_ADD, mkUNOP(OP_NOT, iv_op(1)), iv_op(2));
3588 check_ll(o, ".const1.not.const2.add");
3591 o = mkUNOP(OP_NOT, mkBINOP(OP_ADD, iv_op(1), iv_op(2)));
3592 check_ll(o, ".const1.const2.add.not");
3595 o = mkLISTOP(OP_LINESEQ, iv_op(1), iv_op(2), iv_op(3));
3596 check_ll(o, ".const1.const2.const3.lineseq");
3599 o = mkLISTOP(OP_LINESEQ,
3600 mkBINOP(OP_ADD, iv_op(1), iv_op(2)),
3601 mkUNOP(OP_NOT, iv_op(3)),
3602 mkLISTOP(OP_SUBSTR, iv_op(4), iv_op(5), iv_op(6)));
3603 check_ll(o, ".const1.const2.add.const3.not"
3604 ".const4.const5.const6.substr.lineseq");
3607 o = mkBINOP(OP_ADD, iv_op(1), iv_op(2));
3609 o = mkBINOP(OP_SUBTRACT, o, iv_op(3));
3610 check_ll(o, ".const1.const2.add.const3.subtract");
3620 av_clear(MY_CXT.peep_recorder);
3621 av_clear(MY_CXT.rpeep_recorder);
3622 MY_CXT.peep_recording = 1;
3629 MY_CXT.peep_recording = 0;
3636 RETVAL = newRV_inc((SV *)MY_CXT.peep_recorder);
3645 RETVAL = newRV_inc((SV *)MY_CXT.rpeep_recorder);
3651 multicall_each: call a sub for each item in the list. Used to test MULTICALL
3656 multicall_each(block,...)
3665 I32 gimme = G_SCALAR;
3666 SV **args = &PL_stack_base[ax];
3672 cv = sv_2cv(block, &stash, &gv, 0);
3674 croak("multicall_each: not a subroutine reference");
3677 SAVESPTR(GvSV(PL_defgv));
3679 for(index = 1 ; index < items ; index++) {
3680 GvSV(PL_defgv) = args[index];
3689 multicall_return(): call the passed sub once in the specificed context
3690 and return whatever it returns
3695 multicall_return(block, context)
3705 I32 gimme = context;
3711 cv = sv_2cv(block, &stash, &gv, 0);
3713 croak("multicall_return not a subroutine reference");
3719 /* copy returned values into an array so they're not freed during
3730 av_push(av, SvREFCNT_inc(TOPs));
3734 for (p = PL_stack_base + 1; p <= SP; p++)
3735 av_push(av, SvREFCNT_inc(*p));
3741 size = AvFILLp(av) + 1;
3743 for (i = 0; i < size; i++)
3744 ST(i) = *av_fetch(av, i, FALSE);
3745 sv_2mortal((SV*)av);
3756 PerlInterpreter *interp = aTHX; /* The original interpreter */
3757 PerlInterpreter *interp_dup; /* The duplicate interpreter */
3758 int oldscope = 1; /* We are responsible for all scopes */
3760 interp_dup = perl_clone(interp, CLONEf_COPY_STACKS | CLONEf_CLONE_HOST );
3762 /* destroy old perl */
3763 PERL_SET_CONTEXT(interp);
3765 POPSTACK_TO(PL_mainstack);
3766 if (cxstack_ix >= 0) {
3768 cx_popblock(cxstack);
3771 PL_scopestack_ix = oldscope;
3774 perl_destruct(interp);
3777 /* switch to new perl */
3778 PERL_SET_CONTEXT(interp_dup);
3780 /* continue after 'clone_with_stack' */
3781 if (interp_dup->Iop)
3782 interp_dup->Iop = interp_dup->Iop->op_next;
3784 /* run with new perl */
3785 Perl_runops_standard(interp_dup);
3787 /* We may have additional unclosed scopes if fork() was called
3788 * from within a BEGIN block. See perlfork.pod for more details.
3789 * We cannot clean up these other scopes because they belong to a
3790 * different interpreter, but we also cannot leave PL_scopestack_ix
3791 * dangling because that can trigger an assertion in perl_destruct().
3793 if (PL_scopestack_ix > oldscope) {
3794 PL_scopestack[oldscope-1] = PL_scopestack[PL_scopestack_ix-1];
3795 PL_scopestack_ix = oldscope;
3798 perl_destruct(interp_dup);
3799 perl_free(interp_dup);
3801 /* call the real 'exit' not PerlProc_exit */
3806 #endif /* USE_ITHREDS */
3809 take_svref(SVREF sv)
3811 RETVAL = newRV_inc(sv);
3818 RETVAL = newRV_inc((SV*)av);
3825 RETVAL = newRV_inc((SV*)hv);
3833 RETVAL = newRV_inc((SV*)cv);
3843 stash = gv_stashpv("XS::APItest::TempLv", 0);
3845 meth = hv_fetchs(stash, "make_temp_mg_lv", 0);
3847 croak("lost method 'make_temp_mg_lv'");
3854 hintkey_rpn_sv = newSVpvs_share("XS::APItest/rpn");
3855 hintkey_calcrpn_sv = newSVpvs_share("XS::APItest/calcrpn");
3856 hintkey_stufftest_sv = newSVpvs_share("XS::APItest/stufftest");
3857 hintkey_swaptwostmts_sv = newSVpvs_share("XS::APItest/swaptwostmts");
3858 hintkey_looprest_sv = newSVpvs_share("XS::APItest/looprest");
3859 hintkey_scopelessblock_sv = newSVpvs_share("XS::APItest/scopelessblock");
3860 hintkey_stmtasexpr_sv = newSVpvs_share("XS::APItest/stmtasexpr");
3861 hintkey_stmtsasexpr_sv = newSVpvs_share("XS::APItest/stmtsasexpr");
3862 hintkey_loopblock_sv = newSVpvs_share("XS::APItest/loopblock");
3863 hintkey_blockasexpr_sv = newSVpvs_share("XS::APItest/blockasexpr");
3864 hintkey_swaplabel_sv = newSVpvs_share("XS::APItest/swaplabel");
3865 hintkey_labelconst_sv = newSVpvs_share("XS::APItest/labelconst");
3866 hintkey_arrayfullexpr_sv = newSVpvs_share("XS::APItest/arrayfullexpr");
3867 hintkey_arraylistexpr_sv = newSVpvs_share("XS::APItest/arraylistexpr");
3868 hintkey_arraytermexpr_sv = newSVpvs_share("XS::APItest/arraytermexpr");
3869 hintkey_arrayarithexpr_sv = newSVpvs_share("XS::APItest/arrayarithexpr");
3870 hintkey_arrayexprflags_sv = newSVpvs_share("XS::APItest/arrayexprflags");
3871 hintkey_DEFSV_sv = newSVpvs_share("XS::APItest/DEFSV");
3872 hintkey_with_vars_sv = newSVpvs_share("XS::APItest/with_vars");
3873 hintkey_join_with_space_sv = newSVpvs_share("XS::APItest/join_with_space");
3874 next_keyword_plugin = PL_keyword_plugin;
3875 PL_keyword_plugin = my_keyword_plugin;
3879 establish_cleanup(...)
3882 PERL_UNUSED_VAR(items);
3883 croak("establish_cleanup called as a function");
3887 CV *estcv = get_cv("XS::APItest::establish_cleanup", 0);
3888 cv_set_call_checker(estcv, THX_ck_entersub_establish_cleanup, (SV*)estcv);
3895 PERL_UNUSED_VAR(items);
3896 croak("postinc called as a function");
3901 filter_add(filter_call, NULL);
3905 CV *asscv = get_cv("XS::APItest::postinc", 0);
3906 cv_set_call_checker(asscv, THX_ck_entersub_postinc, (SV*)asscv);
3914 newRV_noinc(newSV(0)),
3915 gv_stashpvs("XS::APItest::TempObj",GV_ADD)
3916 ); /* Package defined in test script */
3921 fill_hash_with_nulls(HV *hv)
3925 for(; i < 1000; ++i) {
3926 HE *entry = hv_fetch_ent(hv, sv_2mortal(newSVuv(i)), 1, 0);
3927 SvREFCNT_dec(HeVAL(entry));
3928 HeVAL(entry) = NULL;
3934 RETVAL = newHVhv(hv);
3941 RETVAL = SvIsCOW(sv);
3949 PERL_UNUSED_VAR(items);
3950 croak("pad_scalar called as a function");
3954 CV *pscv = get_cv("XS::APItest::pad_scalar", 0);
3955 cv_set_call_checker(pscv, THX_ck_entersub_pad_scalar, (SV*)pscv);
3959 fetch_pad_names( cv )
3963 PADNAMELIST *pad_namelist;
3964 AV *retav = newAV();
3966 pad_namelist = PadlistNAMES(CvPADLIST(cv));
3968 for ( i = PadnamelistMAX(pad_namelist); i >= 0; i-- ) {
3969 PADNAME* name = PadnamelistARRAY(pad_namelist)[i];
3971 if (PadnameLEN(name)) {
3972 av_push(retav, newSVpadname(name));
3975 RETVAL = newRV_noinc((SV*)retav);
3987 u = find_rundefsv();
3988 pv = (U8*)SvPV(u, bytelen);
3989 RETVAL = SvUTF8(u) ? utf8_length(pv, pv+bytelen) : bytelen;
3996 (void)SvPV_nolen(sv);
4001 RETVAL = hv && HvENAME(hv)
4003 HvENAME(hv),HvENAMELEN(hv),
4004 (HvENAMEUTF8(hv) ? SVf_UTF8 : 0)
4011 xs_cmp(int a, int b)
4013 /* Odd sorting (odd numbers first), to make sure we are actually
4015 RETVAL = a % 2 != b % 2
4017 : a < b ? -1 : a == b ? 0 : 1;
4022 xs_cmp_undef(SV *a, SV *b)
4026 RETVAL = &PL_sv_undef;
4033 RETVAL = SvPVbyte_nolen(sv);
4040 RETVAL = SvPVutf8_nolen(sv);
4047 wrap_op_checker(OP_ADD, addissub_myck_add, &addissub_nxck_add);
4050 setup_rv2cv_addunderbar()
4052 wrap_op_checker(OP_RV2CV, my_ck_rv2cv, &old_ck_rv2cv);
4057 test_alloccopstash()
4059 RETVAL = PL_stashpad[alloccopstash(PL_defstash)] == PL_defstash;
4066 test_newFOROP_without_slab()
4069 const I32 floor = start_subparse(0,0);
4071 /* The slab allocator does not like CvROOT being set. */
4072 CvROOT(PL_compcv) = (OP *)1;
4073 o = newFOROP(0, 0, newOP(OP_PUSHMARK, 0), 0, 0);
4074 #ifdef PERL_OP_PARENT
4075 if (cLOOPx(cUNOPo->op_first)->op_last->op_sibparent
4076 != cUNOPo->op_first)
4078 Perl_warn(aTHX_ "Op parent pointer is stale");
4083 /* If we do not crash before returning, the test passes. */
4086 CvROOT(PL_compcv) = NULL;
4087 SvREFCNT_dec(PL_compcv);
4093 # provide access to CALLREGEXEC, except replace pointers within the
4094 # string with offsets from the start of the string
4097 callregexec(SV *prog, STRLEN stringarg, STRLEN strend, I32 minend, SV *sv, U32 nosave)
4104 strbeg = SvPV_force(sv, len);
4105 RETVAL = CALLREGEXEC((REGEXP *)prog,
4118 lexical_import(SV *name, CV *cv)
4125 "lexical_import can only be called at compile time");
4126 pl = CvPADLIST(PL_compcv);
4128 SAVESPTR(PL_comppad_name); PL_comppad_name = PadlistNAMES(pl);
4129 SAVESPTR(PL_comppad); PL_comppad = PadlistARRAY(pl)[1];
4130 SAVESPTR(PL_curpad); PL_curpad = PadARRAY(PL_comppad);
4131 off = pad_add_name_sv(sv_2mortal(newSVpvf("&%" SVf,name)),
4132 padadd_STATE, 0, 0);
4133 SvREFCNT_dec(PL_curpad[off]);
4134 PL_curpad[off] = SvREFCNT_inc(cv);
4140 sv_mortalcopy(SV *sv)
4142 RETVAL = SvREFCNT_inc(sv_mortalcopy(sv));
4150 alias_av(AV *av, IV ix, SV *sv)
4152 av_store(av, ix, SvREFCNT_inc(sv));
4155 cv_name(SVREF ref, ...)
4157 RETVAL = SvREFCNT_inc(cv_name((CV *)ref,
4158 items>1 && ST(1) != &PL_sv_undef
4161 items>2 ? SvUV(ST(2)) : 0));
4166 sv_catpvn(SV *sv, SV *sv2)
4170 const char *s = SvPV(sv2,len);
4171 sv_catpvn_flags(sv,s,len, SvUTF8(sv2) ? SV_CATUTF8 : SV_CATBYTES);
4178 OP *o = newLISTOP(OP_CUSTOM, 0, NULL, NULL);
4180 o = newOP(OP_CUSTOM, 0);
4182 o = newUNOP(OP_CUSTOM, 0, NULL);
4184 o = newUNOP_AUX(OP_CUSTOM, 0, NULL, NULL);
4186 o = newMETHOP(OP_CUSTOM, 0, newOP(OP_NULL,0));
4188 o = newMETHOP_named(OP_CUSTOM, 0, newSV(0));
4190 o = newBINOP(OP_CUSTOM, 0, NULL, NULL);
4192 o = newPMOP(OP_CUSTOM, 0);
4194 o = newSVOP(OP_CUSTOM, 0, newSV(0));
4198 lex_start(NULL, NULL, 0);
4200 I32 ix = start_subparse(FALSE,0);
4201 o = newPADOP(OP_CUSTOM, 0, newSV(0));
4207 o = newPVOP(OP_CUSTOM, 0, NULL);
4209 o = newLOGOP(OP_CUSTOM, 0, newOP(OP_NULL,0), newOP(OP_NULL,0));
4211 o = newLOOPEX(OP_CUSTOM, newOP(OP_NULL,0));
4219 test_sv_catpvf(SV *fmtsv)
4224 fmt = SvPV_nolen(fmtsv);
4225 sv = sv_2mortal(newSVpvn("", 0));
4226 sv_catpvf(sv, fmt, 5, 6, 7, 8);
4229 load_module(flags, name, ...)
4234 Perl_load_module(aTHX_ flags, SvREFCNT_inc(name), NULL);
4235 } else if (items == 3) {
4236 Perl_load_module(aTHX_ flags, SvREFCNT_inc(name), SvREFCNT_inc(ST(2)));
4238 Perl_croak(aTHX_ "load_module can't yet support %" IVdf " items",
4242 string_without_null(SV *sv)
4246 const char *s = SvPV(sv, len);
4247 RETVAL = newSVpvn_flags(s, len, SvUTF8(sv));
4248 *SvEND(RETVAL) = 0xff;
4253 MODULE = XS::APItest PACKAGE = XS::APItest::AUTOLOADtest
4259 SV* class_and_method;
4261 PERL_UNUSED_ARG(items);
4262 class_and_method = GvSV(CvGV(cv));
4263 comms = get_sv("main::the_method", 1);
4264 if (class_and_method == NULL) {
4266 } else if (!SvOK(class_and_method)) {
4268 } else if (!SvPOK(class_and_method)) {
4271 sv_setsv(comms, class_and_method);
4277 MODULE = XS::APItest PACKAGE = XS::APItest::Magic
4282 sv_magic_foo(SV *sv, SV *thingy)
4286 sv_magicext(SvRV(sv), NULL, PERL_MAGIC_ext, ix ? &vtbl_bar : &vtbl_foo, (const char *)thingy, 0);
4293 MAGIC *mg = mg_findext(SvRV(sv), PERL_MAGIC_ext, ix ? &vtbl_bar : &vtbl_foo);
4294 RETVAL = mg ? SvREFCNT_inc((SV *)mg->mg_ptr) : &PL_sv_undef;
4299 sv_unmagic_foo(SV *sv)
4303 sv_unmagicext(SvRV(sv), PERL_MAGIC_ext, ix ? &vtbl_bar : &vtbl_foo);
4306 sv_magic(SV *sv, SV *thingy)
4308 sv_magic(SvRV(sv), NULL, PERL_MAGIC_ext, (const char *)thingy, 0);
4316 #define test_get_this_vtable(name) \
4317 want = (MGVTBL*)CAT2(&PL_vtbl_, name); \
4318 have = get_vtbl(CAT2(want_vtbl_, name)); \
4320 croak("fail %p!=%p for get_vtbl(want_vtbl_" STRINGIFY(name) ") at " __FILE__ " line %d", have, want, __LINE__)
4322 test_get_this_vtable(sv);
4323 test_get_this_vtable(env);
4324 test_get_this_vtable(envelem);
4325 test_get_this_vtable(sigelem);
4326 test_get_this_vtable(pack);
4327 test_get_this_vtable(packelem);
4328 test_get_this_vtable(dbline);
4329 test_get_this_vtable(isa);
4330 test_get_this_vtable(isaelem);
4331 test_get_this_vtable(arylen);
4332 test_get_this_vtable(mglob);
4333 test_get_this_vtable(nkeys);
4334 test_get_this_vtable(taint);
4335 test_get_this_vtable(substr);
4336 test_get_this_vtable(vec);
4337 test_get_this_vtable(pos);
4338 test_get_this_vtable(bm);
4339 test_get_this_vtable(fm);
4340 test_get_this_vtable(uvar);
4341 test_get_this_vtable(defelem);
4342 test_get_this_vtable(regexp);
4343 test_get_this_vtable(regdata);
4344 test_get_this_vtable(regdatum);
4345 #ifdef USE_LOCALE_COLLATE
4346 test_get_this_vtable(collxfrm);
4348 test_get_this_vtable(backref);
4349 test_get_this_vtable(utf8);
4351 RETVAL = PTR2UV(get_vtbl(-1));
4356 # attach ext magic to the SV pointed to by rsv that only has set magic,
4357 # where that magic's job is to increment thingy
4360 sv_magic_myset(SV *rsv, SV *thingy)
4362 sv_magicext(SvRV(rsv), NULL, PERL_MAGIC_ext, &vtbl_myset,
4363 (const char *)thingy, 0);
4368 test_isBLANK_uni(UV ord)
4370 RETVAL = isBLANK_uni(ord);
4375 test_isBLANK_uvchr(UV ord)
4377 RETVAL = isBLANK_uvchr(ord);
4382 test_isBLANK_LC_uvchr(UV ord)
4384 RETVAL = isBLANK_LC_uvchr(ord);
4389 test_isBLANK(UV ord)
4391 RETVAL = isBLANK(ord);
4396 test_isBLANK_A(UV ord)
4398 RETVAL = isBLANK_A(ord);
4403 test_isBLANK_L1(UV ord)
4405 RETVAL = isBLANK_L1(ord);
4410 test_isBLANK_LC(UV ord)
4412 RETVAL = isBLANK_LC(ord);
4417 test_isBLANK_utf8(unsigned char * p, int type)
4419 const unsigned char * e;
4422 /* In this function and those that follow, the boolean 'type'
4423 * indicates if to pass a malformed UTF-8 string to the tested macro
4424 * (malformed by making it too short) */
4426 e = p + UTF8SKIP(p) - type;
4427 RETVAL = isBLANK_utf8_safe(p, e);
4430 RETVAL = isBLANK_utf8(p);
4436 test_isBLANK_LC_utf8(unsigned char * p, int type)
4438 const unsigned char * e;
4441 e = p + UTF8SKIP(p) - type;
4442 RETVAL = isBLANK_LC_utf8_safe(p, e);
4445 RETVAL = isBLANK_LC_utf8(p);
4451 test_isVERTWS_uni(UV ord)
4453 RETVAL = isVERTWS_uni(ord);
4458 test_isVERTWS_uvchr(UV ord)
4460 RETVAL = isVERTWS_uvchr(ord);
4465 test_isVERTWS_utf8(unsigned char * p, int type)
4467 const unsigned char * e;
4470 e = p + UTF8SKIP(p) - type;
4471 RETVAL = isVERTWS_utf8_safe(p, e);
4474 RETVAL = isVERTWS_utf8(p);
4480 test_isUPPER_uni(UV ord)
4482 RETVAL = isUPPER_uni(ord);
4487 test_isUPPER_uvchr(UV ord)
4489 RETVAL = isUPPER_uvchr(ord);
4494 test_isUPPER_LC_uvchr(UV ord)
4496 RETVAL = isUPPER_LC_uvchr(ord);
4501 test_isUPPER(UV ord)
4503 RETVAL = isUPPER(ord);
4508 test_isUPPER_A(UV ord)
4510 RETVAL = isUPPER_A(ord);
4515 test_isUPPER_L1(UV ord)
4517 RETVAL = isUPPER_L1(ord);
4522 test_isUPPER_LC(UV ord)
4524 RETVAL = isUPPER_LC(ord);
4529 test_isUPPER_utf8(unsigned char * p, int type)
4531 const unsigned char * e;
4534 e = p + UTF8SKIP(p) - type;
4535 RETVAL = isUPPER_utf8_safe(p, e);
4538 RETVAL = isUPPER_utf8(p);
4544 test_isUPPER_LC_utf8(unsigned char * p, int type)
4546 const unsigned char * e;
4549 e = p + UTF8SKIP(p) - type;
4550 RETVAL = isUPPER_LC_utf8_safe(p, e);
4553 RETVAL = isUPPER_LC_utf8(p);
4559 test_isLOWER_uni(UV ord)
4561 RETVAL = isLOWER_uni(ord);
4566 test_isLOWER_uvchr(UV ord)
4568 RETVAL = isLOWER_uvchr(ord);
4573 test_isLOWER_LC_uvchr(UV ord)
4575 RETVAL = isLOWER_LC_uvchr(ord);
4580 test_isLOWER(UV ord)
4582 RETVAL = isLOWER(ord);
4587 test_isLOWER_A(UV ord)
4589 RETVAL = isLOWER_A(ord);
4594 test_isLOWER_L1(UV ord)
4596 RETVAL = isLOWER_L1(ord);
4601 test_isLOWER_LC(UV ord)
4603 RETVAL = isLOWER_LC(ord);
4608 test_isLOWER_utf8(unsigned char * p, int type)
4610 const unsigned char * e;
4613 e = p + UTF8SKIP(p) - type;
4614 RETVAL = isLOWER_utf8_safe(p, e);
4617 RETVAL = isLOWER_utf8(p);
4623 test_isLOWER_LC_utf8(unsigned char * p, int type)
4625 const unsigned char * e;
4628 e = p + UTF8SKIP(p) - type;
4629 RETVAL = isLOWER_LC_utf8_safe(p, e);
4632 RETVAL = isLOWER_LC_utf8(p);
4638 test_isALPHA_uni(UV ord)
4640 RETVAL = isALPHA_uni(ord);
4645 test_isALPHA_uvchr(UV ord)
4647 RETVAL = isALPHA_uvchr(ord);
4652 test_isALPHA_LC_uvchr(UV ord)
4654 RETVAL = isALPHA_LC_uvchr(ord);
4659 test_isALPHA(UV ord)
4661 RETVAL = isALPHA(ord);
4666 test_isALPHA_A(UV ord)
4668 RETVAL = isALPHA_A(ord);
4673 test_isALPHA_L1(UV ord)
4675 RETVAL = isALPHA_L1(ord);
4680 test_isALPHA_LC(UV ord)
4682 RETVAL = isALPHA_LC(ord);
4687 test_isALPHA_utf8(unsigned char * p, int type)
4689 const unsigned char * e;
4692 e = p + UTF8SKIP(p) - type;
4693 RETVAL = isALPHA_utf8_safe(p, e);
4696 RETVAL = isALPHA_utf8(p);
4702 test_isALPHA_LC_utf8(unsigned char * p, int type)
4704 const unsigned char * e;
4707 e = p + UTF8SKIP(p) - type;
4708 RETVAL = isALPHA_LC_utf8_safe(p, e);
4711 RETVAL = isALPHA_LC_utf8(p);
4717 test_isWORDCHAR_uni(UV ord)
4719 RETVAL = isWORDCHAR_uni(ord);
4724 test_isWORDCHAR_uvchr(UV ord)
4726 RETVAL = isWORDCHAR_uvchr(ord);
4731 test_isWORDCHAR_LC_uvchr(UV ord)
4733 RETVAL = isWORDCHAR_LC_uvchr(ord);
4738 test_isWORDCHAR(UV ord)
4740 RETVAL = isWORDCHAR(ord);
4745 test_isWORDCHAR_A(UV ord)
4747 RETVAL = isWORDCHAR_A(ord);
4752 test_isWORDCHAR_L1(UV ord)
4754 RETVAL = isWORDCHAR_L1(ord);
4759 test_isWORDCHAR_LC(UV ord)
4761 RETVAL = isWORDCHAR_LC(ord);
4766 test_isWORDCHAR_utf8(unsigned char * p, int type)
4768 const unsigned char * e;
4771 e = p + UTF8SKIP(p) - type;
4772 RETVAL = isWORDCHAR_utf8_safe(p, e);
4775 RETVAL = isWORDCHAR_utf8(p);
4781 test_isWORDCHAR_LC_utf8(unsigned char * p, int type)
4783 const unsigned char * e;
4786 e = p + UTF8SKIP(p) - type;
4787 RETVAL = isWORDCHAR_LC_utf8_safe(p, e);
4790 RETVAL = isWORDCHAR_LC_utf8(p);
4796 test_isALPHANUMERIC_uni(UV ord)
4798 RETVAL = isALPHANUMERIC_uni(ord);
4803 test_isALPHANUMERIC_uvchr(UV ord)
4805 RETVAL = isALPHANUMERIC_uvchr(ord);
4810 test_isALPHANUMERIC_LC_uvchr(UV ord)
4812 RETVAL = isALPHANUMERIC_LC_uvchr(ord);
4817 test_isALPHANUMERIC(UV ord)
4819 RETVAL = isALPHANUMERIC(ord);
4824 test_isALPHANUMERIC_A(UV ord)
4826 RETVAL = isALPHANUMERIC_A(ord);
4831 test_isALPHANUMERIC_L1(UV ord)
4833 RETVAL = isALPHANUMERIC_L1(ord);
4838 test_isALPHANUMERIC_LC(UV ord)
4840 RETVAL = isALPHANUMERIC_LC(ord);
4845 test_isALPHANUMERIC_utf8(unsigned char * p, int type)
4847 const unsigned char * e;
4850 e = p + UTF8SKIP(p) - type;
4851 RETVAL = isALPHANUMERIC_utf8_safe(p, e);
4854 RETVAL = isALPHANUMERIC_utf8(p);
4860 test_isALPHANUMERIC_LC_utf8(unsigned char * p, int type)
4862 const unsigned char * e;
4865 e = p + UTF8SKIP(p) - type;
4866 RETVAL = isALPHANUMERIC_LC_utf8_safe(p, e);
4869 RETVAL = isALPHANUMERIC_LC_utf8(p);
4875 test_isALNUM(UV ord)
4877 RETVAL = isALNUM(ord);
4882 test_isALNUM_uni(UV ord)
4884 RETVAL = isALNUM_uni(ord);
4889 test_isALNUM_LC_uvchr(UV ord)
4891 RETVAL = isALNUM_LC_uvchr(ord);
4896 test_isALNUM_LC(UV ord)
4898 RETVAL = isALNUM_LC(ord);
4903 test_isALNUM_utf8(unsigned char * p, int type)
4905 const unsigned char * e;
4908 e = p + UTF8SKIP(p) - type;
4909 RETVAL = isWORDCHAR_utf8_safe(p, e);
4912 RETVAL = isWORDCHAR_utf8(p);
4918 test_isALNUM_LC_utf8(unsigned char * p, int type)
4920 const unsigned char * e;
4923 e = p + UTF8SKIP(p) - type;
4924 RETVAL = isWORDCHAR_LC_utf8_safe(p, e);
4927 RETVAL = isWORDCHAR_LC_utf8(p);
4933 test_isDIGIT_uni(UV ord)
4935 RETVAL = isDIGIT_uni(ord);
4940 test_isDIGIT_uvchr(UV ord)
4942 RETVAL = isDIGIT_uvchr(ord);
4947 test_isDIGIT_LC_uvchr(UV ord)
4949 RETVAL = isDIGIT_LC_uvchr(ord);
4954 test_isDIGIT_utf8(unsigned char * p, int type)
4956 const unsigned char * e;
4959 e = p + UTF8SKIP(p) - type;
4960 RETVAL = isDIGIT_utf8_safe(p, e);
4963 RETVAL = isDIGIT_utf8(p);
4969 test_isDIGIT_LC_utf8(unsigned char * p, int type)
4971 const unsigned char * e;
4974 e = p + UTF8SKIP(p) - type;
4975 RETVAL = isDIGIT_LC_utf8_safe(p, e);
4978 RETVAL = isDIGIT_LC_utf8(p);
4984 test_isDIGIT(UV ord)
4986 RETVAL = isDIGIT(ord);
4991 test_isDIGIT_A(UV ord)
4993 RETVAL = isDIGIT_A(ord);
4998 test_isDIGIT_L1(UV ord)
5000 RETVAL = isDIGIT_L1(ord);
5005 test_isDIGIT_LC(UV ord)
5007 RETVAL = isDIGIT_LC(ord);
5012 test_isOCTAL(UV ord)
5014 RETVAL = isOCTAL(ord);
5019 test_isOCTAL_A(UV ord)
5021 RETVAL = isOCTAL_A(ord);
5026 test_isOCTAL_L1(UV ord)
5028 RETVAL = isOCTAL_L1(ord);
5033 test_isIDFIRST_uni(UV ord)
5035 RETVAL = isIDFIRST_uni(ord);
5040 test_isIDFIRST_uvchr(UV ord)
5042 RETVAL = isIDFIRST_uvchr(ord);
5047 test_isIDFIRST_LC_uvchr(UV ord)
5049 RETVAL = isIDFIRST_LC_uvchr(ord);
5054 test_isIDFIRST(UV ord)
5056 RETVAL = isIDFIRST(ord);
5061 test_isIDFIRST_A(UV ord)
5063 RETVAL = isIDFIRST_A(ord);
5068 test_isIDFIRST_L1(UV ord)
5070 RETVAL = isIDFIRST_L1(ord);
5075 test_isIDFIRST_LC(UV ord)
5077 RETVAL = isIDFIRST_LC(ord);
5082 test_isIDFIRST_utf8(unsigned char * p, int type)
5084 const unsigned char * e;
5087 e = p + UTF8SKIP(p) - type;
5088 RETVAL = isIDFIRST_utf8_safe(p, e);
5091 RETVAL = isIDFIRST_utf8(p);
5097 test_isIDFIRST_LC_utf8(unsigned char * p, int type)
5099 const unsigned char * e;
5102 e = p + UTF8SKIP(p) - type;
5103 RETVAL = isIDFIRST_LC_utf8_safe(p, e);
5106 RETVAL = isIDFIRST_LC_utf8(p);
5112 test_isIDCONT_uni(UV ord)
5114 RETVAL = isIDCONT_uni(ord);
5119 test_isIDCONT_uvchr(UV ord)
5121 RETVAL = isIDCONT_uvchr(ord);
5126 test_isIDCONT_LC_uvchr(UV ord)
5128 RETVAL = isIDCONT_LC_uvchr(ord);
5133 test_isIDCONT(UV ord)
5135 RETVAL = isIDCONT(ord);
5140 test_isIDCONT_A(UV ord)
5142 RETVAL = isIDCONT_A(ord);
5147 test_isIDCONT_L1(UV ord)
5149 RETVAL = isIDCONT_L1(ord);
5154 test_isIDCONT_LC(UV ord)
5156 RETVAL = isIDCONT_LC(ord);
5161 test_isIDCONT_utf8(unsigned char * p, int type)
5163 const unsigned char * e;
5166 e = p + UTF8SKIP(p) - type;
5167 RETVAL = isIDCONT_utf8_safe(p, e);
5170 RETVAL = isIDCONT_utf8(p);
5176 test_isIDCONT_LC_utf8(unsigned char * p, int type)
5178 const unsigned char * e;
5181 e = p + UTF8SKIP(p) - type;
5182 RETVAL = isIDCONT_LC_utf8_safe(p, e);
5185 RETVAL = isIDCONT_LC_utf8(p);
5191 test_isSPACE_uni(UV ord)
5193 RETVAL = isSPACE_uni(ord);
5198 test_isSPACE_uvchr(UV ord)
5200 RETVAL = isSPACE_uvchr(ord);
5205 test_isSPACE_LC_uvchr(UV ord)
5207 RETVAL = isSPACE_LC_uvchr(ord);
5212 test_isSPACE(UV ord)
5214 RETVAL = isSPACE(ord);
5219 test_isSPACE_A(UV ord)
5221 RETVAL = isSPACE_A(ord);
5226 test_isSPACE_L1(UV ord)
5228 RETVAL = isSPACE_L1(ord);
5233 test_isSPACE_LC(UV ord)
5235 RETVAL = isSPACE_LC(ord);
5240 test_isSPACE_utf8(unsigned char * p, int type)
5242 const unsigned char * e;
5245 e = p + UTF8SKIP(p) - type;
5246 RETVAL = isSPACE_utf8_safe(p, e);
5249 RETVAL = isSPACE_utf8(p);
5255 test_isSPACE_LC_utf8(unsigned char * p, int type)
5257 const unsigned char * e;
5260 e = p + UTF8SKIP(p) - type;
5261 RETVAL = isSPACE_LC_utf8_safe(p, e);
5264 RETVAL = isSPACE_LC_utf8(p);
5270 test_isASCII_uni(UV ord)
5272 RETVAL = isASCII_uni(ord);
5277 test_isASCII_uvchr(UV ord)
5279 RETVAL = isASCII_uvchr(ord);
5284 test_isASCII_LC_uvchr(UV ord)
5286 RETVAL = isASCII_LC_uvchr(ord);
5291 test_isASCII(UV ord)
5293 RETVAL = isASCII(ord);
5298 test_isASCII_A(UV ord)
5300 RETVAL = isASCII_A(ord);
5305 test_isASCII_L1(UV ord)
5307 RETVAL = isASCII_L1(ord);
5312 test_isASCII_LC(UV ord)
5314 RETVAL = isASCII_LC(ord);
5319 test_isASCII_utf8(unsigned char * p, int type)
5321 const unsigned char * e;
5327 e = p + UTF8SKIP(p) - type;
5328 RETVAL = isASCII_utf8_safe(p, e);
5331 RETVAL = isASCII_utf8(p);
5337 test_isASCII_LC_utf8(unsigned char * p, int type)
5339 const unsigned char * e;
5345 e = p + UTF8SKIP(p) - type;
5346 RETVAL = isASCII_LC_utf8_safe(p, e);
5349 RETVAL = isASCII_LC_utf8(p);
5355 test_isCNTRL_uni(UV ord)
5357 RETVAL = isCNTRL_uni(ord);
5362 test_isCNTRL_uvchr(UV ord)
5364 RETVAL = isCNTRL_uvchr(ord);
5369 test_isCNTRL_LC_uvchr(UV ord)
5371 RETVAL = isCNTRL_LC_uvchr(ord);
5376 test_isCNTRL(UV ord)
5378 RETVAL = isCNTRL(ord);
5383 test_isCNTRL_A(UV ord)
5385 RETVAL = isCNTRL_A(ord);
5390 test_isCNTRL_L1(UV ord)
5392 RETVAL = isCNTRL_L1(ord);
5397 test_isCNTRL_LC(UV ord)
5399 RETVAL = isCNTRL_LC(ord);
5404 test_isCNTRL_utf8(unsigned char * p, int type)
5406 const unsigned char * e;
5409 e = p + UTF8SKIP(p) - type;
5410 RETVAL = isCNTRL_utf8_safe(p, e);
5413 RETVAL = isCNTRL_utf8(p);
5419 test_isCNTRL_LC_utf8(unsigned char * p, int type)
5421 const unsigned char * e;
5424 e = p + UTF8SKIP(p) - type;
5425 RETVAL = isCNTRL_LC_utf8_safe(p, e);
5428 RETVAL = isCNTRL_LC_utf8(p);
5434 test_isPRINT_uni(UV ord)
5436 RETVAL = isPRINT_uni(ord);
5441 test_isPRINT_uvchr(UV ord)
5443 RETVAL = isPRINT_uvchr(ord);
5448 test_isPRINT_LC_uvchr(UV ord)
5450 RETVAL = isPRINT_LC_uvchr(ord);
5455 test_isPRINT(UV ord)
5457 RETVAL = isPRINT(ord);
5462 test_isPRINT_A(UV ord)
5464 RETVAL = isPRINT_A(ord);
5469 test_isPRINT_L1(UV ord)
5471 RETVAL = isPRINT_L1(ord);
5476 test_isPRINT_LC(UV ord)
5478 RETVAL = isPRINT_LC(ord);
5483 test_isPRINT_utf8(unsigned char * p, int type)
5485 const unsigned char * e;
5488 e = p + UTF8SKIP(p) - type;
5489 RETVAL = isPRINT_utf8_safe(p, e);
5492 RETVAL = isPRINT_utf8(p);
5498 test_isPRINT_LC_utf8(unsigned char * p, int type)
5500 const unsigned char * e;
5503 e = p + UTF8SKIP(p) - type;
5504 RETVAL = isPRINT_LC_utf8_safe(p, e);
5507 RETVAL = isPRINT_LC_utf8(p);
5513 test_isGRAPH_uni(UV ord)
5515 RETVAL = isGRAPH_uni(ord);
5520 test_isGRAPH_uvchr(UV ord)
5522 RETVAL = isGRAPH_uvchr(ord);
5527 test_isGRAPH_LC_uvchr(UV ord)
5529 RETVAL = isGRAPH_LC_uvchr(ord);
5534 test_isGRAPH(UV ord)
5536 RETVAL = isGRAPH(ord);
5541 test_isGRAPH_A(UV ord)
5543 RETVAL = isGRAPH_A(ord);
5548 test_isGRAPH_L1(UV ord)
5550 RETVAL = isGRAPH_L1(ord);
5555 test_isGRAPH_LC(UV ord)
5557 RETVAL = isGRAPH_LC(ord);
5562 test_isGRAPH_utf8(unsigned char * p, int type)
5564 const unsigned char * e;
5567 e = p + UTF8SKIP(p) - type;
5568 RETVAL = isGRAPH_utf8_safe(p, e);
5571 RETVAL = isGRAPH_utf8(p);
5577 test_isGRAPH_LC_utf8(unsigned char * p, int type)
5579 const unsigned char * e;
5582 e = p + UTF8SKIP(p) - type;
5583 RETVAL = isGRAPH_LC_utf8_safe(p, e);
5586 RETVAL = isGRAPH_LC_utf8(p);
5592 test_isPUNCT_uni(UV ord)
5594 RETVAL = isPUNCT_uni(ord);
5599 test_isPUNCT_uvchr(UV ord)
5601 RETVAL = isPUNCT_uvchr(ord);
5606 test_isPUNCT_LC_uvchr(UV ord)
5608 RETVAL = isPUNCT_LC_uvchr(ord);
5613 test_isPUNCT(UV ord)
5615 RETVAL = isPUNCT(ord);
5620 test_isPUNCT_A(UV ord)
5622 RETVAL = isPUNCT_A(ord);
5627 test_isPUNCT_L1(UV ord)
5629 RETVAL = isPUNCT_L1(ord);
5634 test_isPUNCT_LC(UV ord)
5636 RETVAL = isPUNCT_LC(ord);
5641 test_isPUNCT_utf8(unsigned char * p, int type)
5643 const unsigned char * e;
5646 e = p + UTF8SKIP(p) - type;
5647 RETVAL = isPUNCT_utf8_safe(p, e);
5650 RETVAL = isPUNCT_utf8(p);
5656 test_isPUNCT_LC_utf8(unsigned char * p, int type)
5658 const unsigned char * e;
5661 e = p + UTF8SKIP(p) - type;
5662 RETVAL = isPUNCT_LC_utf8_safe(p, e);
5665 RETVAL = isPUNCT_LC_utf8(p);
5671 test_isXDIGIT_uni(UV ord)
5673 RETVAL = isXDIGIT_uni(ord);
5678 test_isXDIGIT_uvchr(UV ord)
5680 RETVAL = isXDIGIT_uvchr(ord);
5685 test_isXDIGIT_LC_uvchr(UV ord)
5687 RETVAL = isXDIGIT_LC_uvchr(ord);
5692 test_isXDIGIT(UV ord)
5694 RETVAL = isXDIGIT(ord);
5699 test_isXDIGIT_A(UV ord)
5701 RETVAL = isXDIGIT_A(ord);
5706 test_isXDIGIT_L1(UV ord)
5708 RETVAL = isXDIGIT_L1(ord);
5713 test_isXDIGIT_LC(UV ord)
5715 RETVAL = isXDIGIT_LC(ord);
5720 test_isXDIGIT_utf8(unsigned char * p, int type)
5722 const unsigned char * e;
5725 e = p + UTF8SKIP(p) - type;
5726 RETVAL = isXDIGIT_utf8_safe(p, e);
5729 RETVAL = isXDIGIT_utf8(p);
5735 test_isXDIGIT_LC_utf8(unsigned char * p, int type)
5737 const unsigned char * e;
5740 e = p + UTF8SKIP(p) - type;
5741 RETVAL = isXDIGIT_LC_utf8_safe(p, e);
5744 RETVAL = isXDIGIT_LC_utf8(p);
5750 test_isPSXSPC_uni(UV ord)
5752 RETVAL = isPSXSPC_uni(ord);
5757 test_isPSXSPC_uvchr(UV ord)
5759 RETVAL = isPSXSPC_uvchr(ord);
5764 test_isPSXSPC_LC_uvchr(UV ord)
5766 RETVAL = isPSXSPC_LC_uvchr(ord);
5771 test_isPSXSPC(UV ord)
5773 RETVAL = isPSXSPC(ord);
5778 test_isPSXSPC_A(UV ord)
5780 RETVAL = isPSXSPC_A(ord);
5785 test_isPSXSPC_L1(UV ord)
5787 RETVAL = isPSXSPC_L1(ord);
5792 test_isPSXSPC_LC(UV ord)
5794 RETVAL = isPSXSPC_LC(ord);
5799 test_isPSXSPC_utf8(unsigned char * p, int type)
5801 const unsigned char * e;
5804 e = p + UTF8SKIP(p) - type;
5805 RETVAL = isPSXSPC_utf8_safe(p, e);
5808 RETVAL = isPSXSPC_utf8(p);
5814 test_isPSXSPC_LC_utf8(unsigned char * p, int type)
5816 const unsigned char * e;
5819 e = p + UTF8SKIP(p) - type;
5820 RETVAL = isPSXSPC_LC_utf8_safe(p, e);
5823 RETVAL = isPSXSPC_LC_utf8(p);
5829 test_isQUOTEMETA(UV ord)
5831 RETVAL = _isQUOTEMETA(ord);
5836 test_OFFUNISKIP(UV ord)
5838 RETVAL = OFFUNISKIP(ord);
5843 test_OFFUNI_IS_INVARIANT(UV ord)
5845 RETVAL = OFFUNI_IS_INVARIANT(ord);
5850 test_UVCHR_IS_INVARIANT(UV ord)
5852 RETVAL = UVCHR_IS_INVARIANT(ord);
5857 test_UTF8_IS_INVARIANT(char ch)
5859 RETVAL = UTF8_IS_INVARIANT(ch);
5864 test_UVCHR_SKIP(UV ord)
5866 RETVAL = UVCHR_SKIP(ord);
5871 test_UTF8_SKIP(char * ch)
5873 RETVAL = UTF8_SKIP(ch);
5878 test_UTF8_IS_START(char ch)
5880 RETVAL = UTF8_IS_START(ch);
5885 test_UTF8_IS_CONTINUATION(char ch)
5887 RETVAL = UTF8_IS_CONTINUATION(ch);
5892 test_UTF8_IS_CONTINUED(char ch)
5894 RETVAL = UTF8_IS_CONTINUED(ch);
5899 test_UTF8_IS_DOWNGRADEABLE_START(char ch)
5901 RETVAL = UTF8_IS_DOWNGRADEABLE_START(ch);
5906 test_UTF8_IS_ABOVE_LATIN1(char ch)
5908 RETVAL = UTF8_IS_ABOVE_LATIN1(ch);
5913 test_isUTF8_POSSIBLY_PROBLEMATIC(char ch)
5915 RETVAL = isUTF8_POSSIBLY_PROBLEMATIC(ch);
5920 test_isUTF8_CHAR(char *s, STRLEN len)
5922 RETVAL = isUTF8_CHAR((U8 *) s, (U8 *) s + len);
5927 test_isUTF8_CHAR_flags(char *s, STRLEN len, U32 flags)
5929 RETVAL = isUTF8_CHAR_flags((U8 *) s, (U8 *) s + len, flags);
5934 test_isSTRICT_UTF8_CHAR(char *s, STRLEN len)
5936 RETVAL = isSTRICT_UTF8_CHAR((U8 *) s, (U8 *) s + len);
5941 test_isC9_STRICT_UTF8_CHAR(char *s, STRLEN len)
5943 RETVAL = isC9_STRICT_UTF8_CHAR((U8 *) s, (U8 *) s + len);
5948 test_is_utf8_valid_partial_char_flags(char *s, STRLEN len, U32 flags)
5950 /* RETVAL should be bool (here and in tests below), but making it IV
5951 * allows us to test it returning 0 or 1 */
5952 RETVAL = is_utf8_valid_partial_char_flags((U8 *) s, (U8 *) s + len, flags);
5957 test_is_utf8_string(char *s, STRLEN len)
5959 RETVAL = is_utf8_string((U8 *) s, len);
5964 test_is_utf8_string_loc(char *s, STRLEN len)
5970 av_push(av, newSViv(is_utf8_string_loc((U8 *) s, len, &ep)));
5971 av_push(av, newSViv(ep - (U8 *) s));
5977 test_is_utf8_string_loclen(char *s, STRLEN len)
5984 av_push(av, newSViv(is_utf8_string_loclen((U8 *) s, len, &ep, &ret_len)));
5985 av_push(av, newSViv(ep - (U8 *) s));
5986 av_push(av, newSVuv(ret_len));
5992 test_is_utf8_string_flags(char *s, STRLEN len, U32 flags)
5994 RETVAL = is_utf8_string_flags((U8 *) s, len, flags);
5999 test_is_utf8_string_loc_flags(char *s, STRLEN len, U32 flags)
6005 av_push(av, newSViv(is_utf8_string_loc_flags((U8 *) s, len, &ep, flags)));
6006 av_push(av, newSViv(ep - (U8 *) s));
6012 test_is_utf8_string_loclen_flags(char *s, STRLEN len, U32 flags)
6019 av_push(av, newSViv(is_utf8_string_loclen_flags((U8 *) s, len, &ep, &ret_len, flags)));
6020 av_push(av, newSViv(ep - (U8 *) s));
6021 av_push(av, newSVuv(ret_len));
6027 test_is_strict_utf8_string(char *s, STRLEN len)
6029 RETVAL = is_strict_utf8_string((U8 *) s, len);
6034 test_is_strict_utf8_string_loc(char *s, STRLEN len)
6040 av_push(av, newSViv(is_strict_utf8_string_loc((U8 *) s, len, &ep)));
6041 av_push(av, newSViv(ep - (U8 *) s));
6047 test_is_strict_utf8_string_loclen(char *s, STRLEN len)
6054 av_push(av, newSViv(is_strict_utf8_string_loclen((U8 *) s, len, &ep, &ret_len)));
6055 av_push(av, newSViv(ep - (U8 *) s));
6056 av_push(av, newSVuv(ret_len));
6062 test_is_c9strict_utf8_string(char *s, STRLEN len)
6064 RETVAL = is_c9strict_utf8_string((U8 *) s, len);
6069 test_is_c9strict_utf8_string_loc(char *s, STRLEN len)
6075 av_push(av, newSViv(is_c9strict_utf8_string_loc((U8 *) s, len, &ep)));
6076 av_push(av, newSViv(ep - (U8 *) s));
6082 test_is_c9strict_utf8_string_loclen(char *s, STRLEN len)
6089 av_push(av, newSViv(is_c9strict_utf8_string_loclen((U8 *) s, len, &ep, &ret_len)));
6090 av_push(av, newSViv(ep - (U8 *) s));
6091 av_push(av, newSVuv(ret_len));
6097 test_is_utf8_fixed_width_buf_flags(char *s, STRLEN len, U32 flags)
6099 RETVAL = is_utf8_fixed_width_buf_flags((U8 *) s, len, flags);
6104 test_is_utf8_fixed_width_buf_loc_flags(char *s, STRLEN len, U32 flags)
6110 av_push(av, newSViv(is_utf8_fixed_width_buf_loc_flags((U8 *) s, len, &ep, flags)));
6111 av_push(av, newSViv(ep - (U8 *) s));
6117 test_is_utf8_fixed_width_buf_loclen_flags(char *s, STRLEN len, U32 flags)
6124 av_push(av, newSViv(is_utf8_fixed_width_buf_loclen_flags((U8 *) s, len, &ep, &ret_len, flags)));
6125 av_push(av, newSViv(ep - (U8 *) s));
6126 av_push(av, newSVuv(ret_len));
6132 test_utf8_hop_safe(SV *s_sv, STRLEN s_off, IV off)
6138 p = (U8 *)SvPV(s_sv, len);
6139 r = utf8_hop_safe(p + s_off, off, p, p + len);
6145 test_toLOWER(UV ord)
6147 RETVAL = toLOWER(ord);
6152 test_toLOWER_L1(UV ord)
6154 RETVAL = toLOWER_L1(ord);
6159 test_toLOWER_LC(UV ord)
6161 RETVAL = toLOWER_LC(ord);
6166 test_toLOWER_uni(UV ord)
6168 U8 s[UTF8_MAXBYTES_CASE + 1];
6174 av_push(av, newSVuv(toLOWER_uni(ord, s, &len)));
6176 utf8 = newSVpvn((char *) s, len);
6180 av_push(av, newSVuv(len));
6186 test_toLOWER_uvchr(UV ord)
6188 U8 s[UTF8_MAXBYTES_CASE + 1];
6194 av_push(av, newSVuv(toLOWER_uvchr(ord, s, &len)));
6196 utf8 = newSVpvn((char *) s, len);
6200 av_push(av, newSVuv(len));
6206 test_toLOWER_utf8(SV * p, int type)
6209 U8 s[UTF8_MAXBYTES_CASE + 1];
6213 const unsigned char * e;
6214 UV resultant_cp = UV_MAX; /* Initialized because of dumb compilers */
6216 input = (U8 *) SvPV(p, len);
6219 e = input + UTF8SKIP(input) - type;
6220 resultant_cp = toLOWER_utf8_safe(input, e, s, &len);
6222 else if (type == -1) {
6223 resultant_cp = toLOWER_utf8(input, s, &len);
6227 resultant_cp = Perl_to_utf8_lower(aTHX_ input, s, &len);
6230 av_push(av, newSVuv(resultant_cp));
6232 utf8 = newSVpvn((char *) s, len);
6236 av_push(av, newSVuv(len));
6244 RETVAL = toFOLD(ord);
6249 test_toFOLD_LC(UV ord)
6251 RETVAL = toFOLD_LC(ord);
6256 test_toFOLD_uni(UV ord)
6258 U8 s[UTF8_MAXBYTES_CASE + 1];
6264 av_push(av, newSVuv(toFOLD_uni(ord, s, &len)));
6266 utf8 = newSVpvn((char *) s, len);
6270 av_push(av, newSVuv(len));
6276 test_toFOLD_uvchr(UV ord)
6278 U8 s[UTF8_MAXBYTES_CASE + 1];
6284 av_push(av, newSVuv(toFOLD_uvchr(ord, s, &len)));
6286 utf8 = newSVpvn((char *) s, len);
6290 av_push(av, newSVuv(len));
6296 test_toFOLD_utf8(SV * p, int type)
6299 U8 s[UTF8_MAXBYTES_CASE + 1];
6303 const unsigned char * e;
6304 UV resultant_cp = UV_MAX;
6306 input = (U8 *) SvPV(p, len);
6309 e = input + UTF8SKIP(input) - type;
6310 resultant_cp = toFOLD_utf8_safe(input, e, s, &len);
6312 else if (type == -1) {
6313 resultant_cp = toFOLD_utf8(input, s, &len);
6317 resultant_cp = Perl_to_utf8_fold(aTHX_ input, s, &len);
6320 av_push(av, newSVuv(resultant_cp));
6322 utf8 = newSVpvn((char *) s, len);
6326 av_push(av, newSVuv(len));
6332 test_toUPPER(UV ord)
6334 RETVAL = toUPPER(ord);
6339 test_toUPPER_LC(UV ord)
6341 RETVAL = toUPPER_LC(ord);
6346 test_toUPPER_uni(UV ord)
6348 U8 s[UTF8_MAXBYTES_CASE + 1];
6354 av_push(av, newSVuv(toUPPER_uni(ord, s, &len)));
6356 utf8 = newSVpvn((char *) s, len);
6360 av_push(av, newSVuv(len));
6366 test_toUPPER_uvchr(UV ord)
6368 U8 s[UTF8_MAXBYTES_CASE + 1];
6374 av_push(av, newSVuv(toUPPER_uvchr(ord, s, &len)));
6376 utf8 = newSVpvn((char *) s, len);
6380 av_push(av, newSVuv(len));
6386 test_toUPPER_utf8(SV * p, int type)
6389 U8 s[UTF8_MAXBYTES_CASE + 1];
6393 const unsigned char * e;
6394 UV resultant_cp = UV_MAX;
6396 input = (U8 *) SvPV(p, len);
6399 e = input + UTF8SKIP(input) - type;
6400 resultant_cp = toUPPER_utf8_safe(input, e, s, &len);
6402 else if (type == -1) {
6403 resultant_cp = toUPPER_utf8(input, s, &len);
6407 resultant_cp = Perl_to_utf8_upper(aTHX_ input, s, &len);
6410 av_push(av, newSVuv(resultant_cp));
6412 utf8 = newSVpvn((char *) s, len);
6416 av_push(av, newSVuv(len));
6422 test_toTITLE(UV ord)
6424 RETVAL = toTITLE(ord);
6429 test_toTITLE_uni(UV ord)
6431 U8 s[UTF8_MAXBYTES_CASE + 1];
6437 av_push(av, newSVuv(toTITLE_uni(ord, s, &len)));
6439 utf8 = newSVpvn((char *) s, len);
6443 av_push(av, newSVuv(len));
6449 test_toTITLE_uvchr(UV ord)
6451 U8 s[UTF8_MAXBYTES_CASE + 1];
6457 av_push(av, newSVuv(toTITLE_uvchr(ord, s, &len)));
6459 utf8 = newSVpvn((char *) s, len);
6463 av_push(av, newSVuv(len));
6469 test_toTITLE_utf8(SV * p, int type)
6472 U8 s[UTF8_MAXBYTES_CASE + 1];
6476 const unsigned char * e;
6477 UV resultant_cp = UV_MAX;
6479 input = (U8 *) SvPV(p, len);
6482 e = input + UTF8SKIP(input) - type;
6483 resultant_cp = toTITLE_utf8_safe(input, e, s, &len);
6485 else if (type == -1) {
6486 resultant_cp = toTITLE_utf8(input, s, &len);
6490 resultant_cp = Perl_to_utf8_title(aTHX_ input, s, &len);
6493 av_push(av, newSVuv(resultant_cp));
6495 utf8 = newSVpvn((char *) s, len);
6499 av_push(av, newSVuv(len));
6505 test_Gconvert(SV * number, SV * num_digits)
6510 len = (int) SvIV(num_digits);
6511 if (len > 99) croak("Too long a number for test_Gconvert");
6512 if (len < 0) croak("Too short a number for test_Gconvert");
6513 PERL_UNUSED_RESULT(Gconvert(SvNV(number), len,
6514 0, /* No trailing zeroes */
6516 RETVAL = newSVpv(buffer, 0);
6520 MODULE = XS::APItest PACKAGE = XS::APItest::Backrefs
6523 apitest_weaken(SV *sv)
6529 has_backrefs(SV *sv)
6531 if (SvROK(sv) && sv_get_backrefs(SvRV(sv)))
6532 RETVAL = &PL_sv_yes;
6539 #ifdef PERL_IMPLICIT_SYS
6542 PerlDir_mapA(const char *path)
6545 PerlDir_mapW(const WCHAR *wpath)
6553 VS_FIXEDFILEINFO *info;
6559 dll = GetModuleHandle("comctl32.dll"); /* must already be in proc */
6561 croak("Comctl32Version: comctl32.dll not in process???");
6562 hrsc = FindResource(dll, MAKEINTRESOURCE(VS_VERSION_INFO),
6563 MAKEINTRESOURCE(VS_FILE_INFO));
6565 croak("Comctl32Version: comctl32.dll no version???");
6566 ver = LoadResource(dll, hrsc);
6567 len = SizeofResource(dll, hrsc);
6568 vercopy = _alloca(len);
6569 memcpy(vercopy, ver, len);
6570 if (VerQueryValue(vercopy, "\\", (void**)&info, &len)) {
6571 int dwValueMS1 = (info->dwFileVersionMS>>16);
6572 int dwValueMS2 = (info->dwFileVersionMS&0xffff);
6573 int dwValueLS1 = (info->dwFileVersionLS>>16);
6574 int dwValueLS2 = (info->dwFileVersionLS&0xffff);