/* We want to be able to test things that aren't API yet. */
#define PERL_EXT
+/* Do *not* define PERL_NO_GET_CONTEXT. This is the one place where we get
+ to test implicit Perl_get_context(). */
+
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+
+typedef FILE NativeFile;
+
#include "fakesdio.h" /* Causes us to use PerlIO below */
typedef SV *SVREF;
typedef PTR_TBL_t *XS__APItest__PtrTable;
+typedef PerlIO * InputStream;
+typedef PerlIO * OutputStream;
#define croak_fail() croak("fail at " __FILE__ " line %d", __LINE__)
-#define croak_fail_ne(h, w) croak("fail %p!=%p at " __FILE__ " line %d", (h), (w), __LINE__)
+#define croak_fail_nep(h, w) croak("fail %p!=%p at " __FILE__ " line %d", (h), (w), __LINE__)
+#define croak_fail_nei(h, w) croak("fail %d!=%d at " __FILE__ " line %d", (int)(h), (int)(w), __LINE__)
+
+#if IVSIZE == 8
+# define TEST_64BIT 1
+#else
+# define TEST_64BIT 0
+#endif
#ifdef EBCDIC
START_MY_CXT
+int
+S_myset_set(pTHX_ SV* sv, MAGIC* mg)
+{
+ SV *isv = (SV*)mg->mg_ptr;
+
+ PERL_UNUSED_ARG(sv);
+ SvIVX(isv)++;
+ return 0;
+}
+
MGVTBL vtbl_foo, vtbl_bar;
+MGVTBL vtbl_myset = { 0, S_myset_set, 0, 0, 0, 0, 0, 0 };
+
/* indirect functions to test the [pa]MY_CXT macros */
#else
/* Storing then deleting something should ensure that a hash entry is
available. */
- (void) hv_store(test_hash, "", 0, &PL_sv_yes, 0);
- (void) hv_delete(test_hash, "", 0, 0);
+ (void) hv_stores(test_hash, "", &PL_sv_yes);
+ (void) hv_deletes(test_hash, "", 0);
/* We need to "inline" new_he here as it's static, and the functions we
test expect to be able to call del_HE on the HE */
i = 0;
do {
- mPUSHu(results[i]);
+ mXPUSHu(results[i]);
} while (++i < (int)(sizeof(results)/sizeof(results[0])));
/* Goodbye to our extra reference. */
SAVEGENERICSV(GvAV(MY_CXT.cscgv));
if (cur) {
- I32 i;
+ Size_t i;
AV *const new_av = newAV();
- for (i = 0; i <= av_tindex(cur); i++) {
+ for (i = 0; i < av_count(cur); i++) {
av_store(new_av, i, newSVsv(*av_fetch(cur, i, 0)));
}
}
STATIC void
-my_rpeep (pTHX_ OP *o)
+my_rpeep (pTHX_ OP *first)
{
dMY_CXT;
+ OP *o, *t;
- if (!o)
+ if (!first)
return;
- MY_CXT.orig_rpeep(aTHX_ o);
+ MY_CXT.orig_rpeep(aTHX_ first);
if (!MY_CXT.peep_recording)
return;
- for (; o; o = o->op_next) {
+ for (o = first, t = first; o; o = o->op_next, t = t->op_next) {
+ if (o->op_type == OP_CONST && cSVOPx_sv(o) && SvPOK(cSVOPx_sv(o))) {
+ av_push(MY_CXT.rpeep_recorder, newSVsv(cSVOPx_sv(o)));
+ }
+ o = o->op_next;
+ if (!o || o == t) break;
if (o->op_type == OP_CONST && cSVOPx_sv(o) && SvPOK(cSVOPx_sv(o))) {
av_push(MY_CXT.rpeep_recorder, newSVsv(cSVOPx_sv(o)));
}
static SV *hintkey_arrayfullexpr_sv, *hintkey_arraylistexpr_sv;
static SV *hintkey_arraytermexpr_sv, *hintkey_arrayarithexpr_sv;
static SV *hintkey_arrayexprflags_sv;
+static SV *hintkey_subsignature_sv;
static SV *hintkey_DEFSV_sv;
static SV *hintkey_with_vars_sv;
static SV *hintkey_join_with_space_sv;
return o ? newANONLIST(o) : newANONHASH(newOP(OP_STUB, 0));
}
+#define parse_keyword_subsignature() THX_parse_keyword_subsignature(aTHX)
+static OP *THX_parse_keyword_subsignature(pTHX)
+{
+ OP *retop = NULL, *listop, *sigop = parse_subsignature(0);
+ OP *kid;
+ int seen_nextstate = 0;
+
+ /* We can't yield the optree as is to the caller because it won't be
+ * executable outside of a called sub. We'll have to convert it into
+ * something safe for them to invoke.
+ * sigop should be an OP_NULL above a OP_LINESEQ containing
+ * OP_NEXTSTATE-separated OP_ARGCHECK and OP_ARGELEMs
+ */
+ if(sigop->op_type != OP_NULL)
+ croak("Expected parse_subsignature() to yield an OP_NULL");
+
+ if(!(sigop->op_flags & OPf_KIDS))
+ croak("Expected parse_subsignature() to yield an OP_NULL with kids");
+ listop = cUNOPx(sigop)->op_first;
+
+ if(listop->op_type != OP_LINESEQ)
+ croak("Expected parse_subsignature() to yield an OP_LINESEQ");
+
+ for(kid = cLISTOPx(listop)->op_first; kid; kid = OpSIBLING(kid)) {
+ switch(kid->op_type) {
+ case OP_NEXTSTATE:
+ /* Only emit the first one otherwise they get boring */
+ if(seen_nextstate)
+ break;
+ seen_nextstate++;
+ retop = op_append_list(OP_LIST, retop, newSVOP(OP_CONST, 0,
+ /* newSVpvf("nextstate:%s:%d", CopFILE(cCOPx(kid)), cCOPx(kid)->cop_line))); */
+ newSVpvf("nextstate:%u", (unsigned int)cCOPx(kid)->cop_line)));
+ break;
+ case OP_ARGCHECK: {
+ struct op_argcheck_aux *p =
+ (struct op_argcheck_aux*)(cUNOP_AUXx(kid)->op_aux);
+ retop = op_append_list(OP_LIST, retop, newSVOP(OP_CONST, 0,
+ newSVpvf("argcheck:%" UVuf ":%" UVuf ":%c",
+ p->params, p->opt_params,
+ p->slurpy ? p->slurpy : '-')));
+ break;
+ }
+ case OP_ARGELEM: {
+ PADOFFSET padix = kid->op_targ;
+ PADNAMELIST *names = PadlistNAMES(CvPADLIST(find_runcv(0)));
+ char *namepv = PadnamePV(padnamelist_fetch(names, padix));
+ retop = op_append_list(OP_LIST, retop, newSVOP(OP_CONST, 0,
+ newSVpvf(kid->op_flags & OPf_KIDS ? "argelem:%s:d" : "argelem:%s", namepv)));
+ break;
+ }
+ default:
+ fprintf(stderr, "TODO: examine kid %p (optype=%s)\n", kid, PL_op_name[kid->op_type]);
+ break;
+ }
+ }
+
+ op_free(sigop);
+ return newANONLIST(retop);
+}
+
#define parse_keyword_DEFSV() THX_parse_keyword_DEFSV(aTHX)
static OP *THX_parse_keyword_DEFSV(pTHX)
{
static int my_keyword_plugin(pTHX_
char *keyword_ptr, STRLEN keyword_len, OP **op_ptr)
{
- if(keyword_len == 3 && strnEQ(keyword_ptr, "rpn", 3) &&
+ if (memEQs(keyword_ptr, keyword_len, "rpn") &&
keyword_active(hintkey_rpn_sv)) {
*op_ptr = parse_keyword_rpn();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 7 && strnEQ(keyword_ptr, "calcrpn", 7) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "calcrpn") &&
keyword_active(hintkey_calcrpn_sv)) {
*op_ptr = parse_keyword_calcrpn();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 9 && strnEQ(keyword_ptr, "stufftest", 9) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "stufftest") &&
keyword_active(hintkey_stufftest_sv)) {
*op_ptr = parse_keyword_stufftest();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 12 &&
- strnEQ(keyword_ptr, "swaptwostmts", 12) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "swaptwostmts") &&
keyword_active(hintkey_swaptwostmts_sv)) {
*op_ptr = parse_keyword_swaptwostmts();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 8 && strnEQ(keyword_ptr, "looprest", 8) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "looprest") &&
keyword_active(hintkey_looprest_sv)) {
*op_ptr = parse_keyword_looprest();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 14 && strnEQ(keyword_ptr, "scopelessblock", 14) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "scopelessblock") &&
keyword_active(hintkey_scopelessblock_sv)) {
*op_ptr = parse_keyword_scopelessblock();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 10 && strnEQ(keyword_ptr, "stmtasexpr", 10) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "stmtasexpr") &&
keyword_active(hintkey_stmtasexpr_sv)) {
*op_ptr = parse_keyword_stmtasexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 11 && strnEQ(keyword_ptr, "stmtsasexpr", 11) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "stmtsasexpr") &&
keyword_active(hintkey_stmtsasexpr_sv)) {
*op_ptr = parse_keyword_stmtsasexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 9 && strnEQ(keyword_ptr, "loopblock", 9) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "loopblock") &&
keyword_active(hintkey_loopblock_sv)) {
*op_ptr = parse_keyword_loopblock();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 11 && strnEQ(keyword_ptr, "blockasexpr", 11) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "blockasexpr") &&
keyword_active(hintkey_blockasexpr_sv)) {
*op_ptr = parse_keyword_blockasexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 9 && strnEQ(keyword_ptr, "swaplabel", 9) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "swaplabel") &&
keyword_active(hintkey_swaplabel_sv)) {
*op_ptr = parse_keyword_swaplabel();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 10 && strnEQ(keyword_ptr, "labelconst", 10) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "labelconst") &&
keyword_active(hintkey_labelconst_sv)) {
*op_ptr = parse_keyword_labelconst();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 13 && strnEQ(keyword_ptr, "arrayfullexpr", 13) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "arrayfullexpr") &&
keyword_active(hintkey_arrayfullexpr_sv)) {
*op_ptr = parse_keyword_arrayfullexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 13 && strnEQ(keyword_ptr, "arraylistexpr", 13) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "arraylistexpr") &&
keyword_active(hintkey_arraylistexpr_sv)) {
*op_ptr = parse_keyword_arraylistexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 13 && strnEQ(keyword_ptr, "arraytermexpr", 13) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "arraytermexpr") &&
keyword_active(hintkey_arraytermexpr_sv)) {
*op_ptr = parse_keyword_arraytermexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 14 && strnEQ(keyword_ptr, "arrayarithexpr", 14) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "arrayarithexpr") &&
keyword_active(hintkey_arrayarithexpr_sv)) {
*op_ptr = parse_keyword_arrayarithexpr();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 14 && strnEQ(keyword_ptr, "arrayexprflags", 14) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "arrayexprflags") &&
keyword_active(hintkey_arrayexprflags_sv)) {
*op_ptr = parse_keyword_arrayexprflags();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 5 && strnEQ(keyword_ptr, "DEFSV", 5) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "DEFSV") &&
keyword_active(hintkey_DEFSV_sv)) {
*op_ptr = parse_keyword_DEFSV();
return KEYWORD_PLUGIN_EXPR;
- } else if(keyword_len == 9 && strnEQ(keyword_ptr, "with_vars", 9) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "with_vars") &&
keyword_active(hintkey_with_vars_sv)) {
*op_ptr = parse_keyword_with_vars();
return KEYWORD_PLUGIN_STMT;
- } else if(keyword_len == 15 && strnEQ(keyword_ptr, "join_with_space", 15) &&
+ } else if (memEQs(keyword_ptr, keyword_len, "join_with_space") &&
keyword_active(hintkey_join_with_space_sv)) {
*op_ptr = parse_join_with_space();
return KEYWORD_PLUGIN_EXPR;
+ } else if (memEQs(keyword_ptr, keyword_len, "subsignature") &&
+ keyword_active(hintkey_subsignature_sv)) {
+ *op_ptr = parse_keyword_subsignature();
+ return KEYWORD_PLUGIN_EXPR;
} else {
+ assert(next_keyword_plugin != my_keyword_plugin);
return next_keyword_plugin(aTHX_ keyword_ptr, keyword_len, op_ptr);
}
}
peep_xop(pTHX_ OP *o, OP *oldop)
{
dMY_CXT;
- av_push(MY_CXT.xop_record, newSVpvf("peep:%"UVxf, PTR2UV(o)));
- av_push(MY_CXT.xop_record, newSVpvf("oldop:%"UVxf, PTR2UV(oldop)));
+ av_push(MY_CXT.xop_record, newSVpvf("peep:%" UVxf, PTR2UV(o)));
+ av_push(MY_CXT.xop_record, newSVpvf("oldop:%" UVxf, PTR2UV(oldop)));
}
static I32
{
SvGROW(ref, SvCUR(ref)+2);
*SvEND(ref) = '_';
- SvCUR(ref)++;
+ SvCUR(ref)++; /* Not _set, so we don't accidentally break non-PERL_CORE */
*SvEND(ref) = '\0';
}
return old_ck_rv2cv(aTHX_ o);
RETVAL
AV *
-test_utf8n_to_uvchr(s, len, flags)
+test_utf8_to_bytes(bytes, len)
+ U8 * bytes
+ STRLEN len
+ PREINIT:
+ char * ret;
+ CODE:
+ RETVAL = newAV();
+ sv_2mortal((SV*)RETVAL);
- SV *s
- SV *len
- SV *flags
+ ret = (char *) utf8_to_bytes(bytes, &len);
+ av_push(RETVAL, newSVpv(ret, 0));
+
+ /* utf8_to_bytes uses (STRLEN)-1 to signal errors, and we want to
+ * return that as -1 to perl, so cast to SSize_t in case
+ * sizeof(IV) > sizeof(STRLEN) */
+ av_push(RETVAL, newSViv((SSize_t)len));
+ av_push(RETVAL, newSVpv((const char *) bytes, 0));
+
+ OUTPUT:
+ RETVAL
+
+AV *
+test_utf8n_to_uvchr_msgs(s, len, flags)
+ char *s
+ STRLEN len
+ U32 flags
PREINIT:
STRLEN retlen;
UV ret;
- STRLEN slen;
+ U32 errors;
+ AV *msgs = NULL;
CODE:
- /* Call utf8n_to_uvchr() with the inputs. It always asks for the
- * actual length to be returned
+ RETVAL = newAV();
+ sv_2mortal((SV*)RETVAL);
+
+ ret = utf8n_to_uvchr_msgs((U8*) s,
+ len,
+ &retlen,
+ flags,
+ &errors,
+ &msgs);
+
+ /* Returns the return value in [0]; <retlen> in [1], <errors> in [2] */
+ av_push(RETVAL, newSVuv(ret));
+ if (retlen == (STRLEN) -1) {
+ av_push(RETVAL, newSViv(-1));
+ }
+ else {
+ av_push(RETVAL, newSVuv(retlen));
+ }
+ av_push(RETVAL, newSVuv(errors));
+
+ /* And any messages in [3] */
+ if (msgs) {
+ av_push(RETVAL, newRV_noinc((SV*)msgs));
+ }
+
+ OUTPUT:
+ RETVAL
+
+AV *
+test_utf8n_to_uvchr_error(s, len, flags)
+
+ char *s
+ STRLEN len
+ U32 flags
+ PREINIT:
+ STRLEN retlen;
+ UV ret;
+ U32 errors;
+
+ CODE:
+ /* Now that utf8n_to_uvchr() is a trivial wrapper for
+ * utf8n_to_uvchr_error(), call the latter with the inputs. It always
+ * asks for the actual length to be returned and errors to be returned
*
* Length to assume <s> is; not checked, so could have buffer overflow
*/
RETVAL = newAV();
sv_2mortal((SV*)RETVAL);
- ret
- = utf8n_to_uvchr((U8*) SvPV(s, slen), SvUV(len), &retlen, SvUV(flags));
+ ret = utf8n_to_uvchr_error((U8*) s,
+ len,
+ &retlen,
+ flags,
+ &errors);
- /* Returns the return value in [0]; <retlen> in [1] */
+ /* Returns the return value in [0]; <retlen> in [1], <errors> in [2] */
av_push(RETVAL, newSVuv(ret));
if (retlen == (STRLEN) -1) {
av_push(RETVAL, newSViv(-1));
else {
av_push(RETVAL, newSVuv(retlen));
}
+ av_push(RETVAL, newSVuv(errors));
OUTPUT:
RETVAL
PREINIT:
STRLEN retlen;
UV ret;
- STRLEN slen;
CODE:
/* Call utf8n_to_uvchr() with the inputs. It always asks for the
RETVAL = newAV();
sv_2mortal((SV*)RETVAL);
- ret
- = valid_utf8_to_uvchr((U8*) SvPV(s, slen), &retlen);
+ ret = valid_utf8_to_uvchr((U8*) SvPV_nolen(s), &retlen);
/* Returns the return value in [0]; <retlen> in [1] */
av_push(RETVAL, newSVuv(ret));
SV *uv
SV *flags
PREINIT:
- U8 dest[UTF8_MAXBYTES];
+ U8 dest[UTF8_MAXBYTES + 1];
U8 *ret;
CODE:
OUTPUT:
RETVAL
+AV *
+test_uvchr_to_utf8_flags_msgs(uv, flags)
+
+ SV *uv
+ SV *flags
+ PREINIT:
+ U8 dest[UTF8_MAXBYTES + 1];
+ U8 *ret;
+
+ CODE:
+ HV *msgs = NULL;
+ RETVAL = newAV();
+ sv_2mortal((SV*)RETVAL);
+
+ ret = uvchr_to_utf8_flags_msgs(dest, SvUV(uv), SvUV(flags), &msgs);
+
+ if (ret) {
+ av_push(RETVAL, newSVpvn((char *) dest, ret - dest));
+ }
+ else {
+ av_push(RETVAL, &PL_sv_undef);
+ }
+
+ if (msgs) {
+ av_push(RETVAL, newRV_noinc((SV*)msgs));
+ }
+
+ OUTPUT:
+ RETVAL
+
MODULE = XS::APItest:Overload PACKAGE = XS::APItest::Overload
void
OUTPUT:
RETVAL
-#if PERL_VERSION >= 9
+#if PERL_VERSION_GE(5,9,0)
bool
refcounted_he_exists(key, level=0)
IV level
CODE:
if (level) {
- croak("level must be zero, not %"IVdf, level);
+ croak("level must be zero, not %" IVdf, level);
}
RETVAL = (cop_hints_fetch_sv(PL_curcop, key, 0, 0) != &PL_sv_placeholder);
OUTPUT:
IV level
CODE:
if (level) {
- croak("level must be zero, not %"IVdf, level);
+ croak("level must be zero, not %" IVdf, level);
}
RETVAL = cop_hints_fetch_sv(PL_curcop, key, 0, 0);
SvREFCNT_inc(RETVAL);
unop->op_next = NULL;
kid->op_next = (OP*)unop;
- av_push(MY_CXT.xop_record, newSVpvf("unop:%"UVxf, PTR2UV(unop)));
- av_push(MY_CXT.xop_record, newSVpvf("kid:%"UVxf, PTR2UV(kid)));
+ av_push(MY_CXT.xop_record, newSVpvf("unop:%" UVxf, PTR2UV(unop)));
+ av_push(MY_CXT.xop_record, newSVpvf("kid:%" UVxf, PTR2UV(kid)));
av_push(MY_CXT.xop_record, newSVpvf("NAME:%s", OP_NAME((OP*)unop)));
av_push(MY_CXT.xop_record, newSVpvf("DESC:%s", OP_DESC((OP*)unop)));
I32 retcnt;
SV * errsv;
char * errstr;
+ STRLEN errlen;
SV * miscsv = sv_newmortal();
HV * hv = (HV*)sv_2mortal((SV*)newHV());
CODE:
only current internal behavior, these tests can be changed in the
future if necessery */
PUSHMARK(SP);
- retcnt = call_sv(&PL_sv_yes, 0); /* does nothing */
+ retcnt = call_sv(&PL_sv_yes, G_EVAL);
SPAGAIN;
SP -= retcnt;
+ errsv = ERRSV;
+ errstr = SvPV(errsv, errlen);
+ if(memBEGINs(errstr, errlen, "Undefined subroutine &main::1 called at")) {
+ PUSHMARK(SP);
+ retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
+ SPAGAIN;
+ SP -= retcnt;
+ }
PUSHMARK(SP);
retcnt = call_sv(&PL_sv_no, G_EVAL);
SPAGAIN;
SP -= retcnt;
errsv = ERRSV;
- errstr = SvPV_nolen(errsv);
- if(strnEQ(errstr, "Undefined subroutine &main:: called at",
- sizeof("Undefined subroutine &main:: called at") - 1)) {
+ errstr = SvPV(errsv, errlen);
+ if(memBEGINs(errstr, errlen, "Undefined subroutine &main:: called at")) {
PUSHMARK(SP);
retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
SPAGAIN;
SPAGAIN;
SP -= retcnt;
errsv = ERRSV;
- errstr = SvPV_nolen(errsv);
- if(strnEQ(errstr, "Can't use an undefined value as a subroutine reference at",
- sizeof("Can't use an undefined value as a subroutine reference at") - 1)) {
+ errstr = SvPV(errsv, errlen);
+ if(memBEGINs(errstr, errlen, "Can't use an undefined value as a subroutine reference at")) {
PUSHMARK(SP);
retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
SPAGAIN;
SPAGAIN;
SP -= retcnt;
errsv = ERRSV;
- errstr = SvPV_nolen(errsv);
- if(strnEQ(errstr, "Not a CODE reference at",
- sizeof("Not a CODE reference at") - 1)) {
+ errstr = SvPV(errsv, errlen);
+ if(memBEGINs(errstr, errlen, "Not a CODE reference at")) {
PUSHMARK(SP);
retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
SPAGAIN;
PUSHs(sv_2mortal(newSViv(i)));
void
+call_argv(subname, flags, ...)
+ char* subname
+ I32 flags
+ PREINIT:
+ I32 i;
+ char *tmpary[4];
+ PPCODE:
+ for (i=0; i<items-2; i++)
+ tmpary[i] = SvPV_nolen(ST(i+2)); /* ignore first two args */
+ tmpary[i] = NULL;
+ PUTBACK;
+ i = call_argv(subname, flags, tmpary);
+ SPAGAIN;
+ EXTEND(SP, 1);
+ PUSHs(sv_2mortal(newSViv(i)));
+
+void
call_method(methname, flags, ...)
char* methname
I32 flags
gv = gv_fetchmethod_pvn_flags(stash, name, len, flags | SvUTF8(methname));
break;
}
+ case 4:
+ gv = gv_fetchmethod_pvn_flags(stash, SvPV_nolen(methname),
+ flags, SvUTF8(methname));
}
XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
STRLEN len;
U8 *source;
SV *dest;
- I32 got; /* Gah, badly thought out APIs */
+ Size_t got;
CODE:
if (ix) (void)SvPV_force_nolen(sv);
source = (U8 *)SvPVbyte(sv, len);
len = SvUV(ST(1));
}
/* Mortalise this right now, as we'll be testing croak()s */
- dest = sv_2mortal(newSV(len * 3 / 2 + 1));
+ dest = sv_2mortal(newSV(len * 2 + 1));
if (ix) {
utf16_to_utf8_reversed(source, (U8 *)SvPVX(dest), len, &got);
} else {
CV *troc_cv, *tsh_cv;
Perl_call_checker ckfun;
SV *ckobj;
+ U32 ckflags;
CODE:
-#define check_cc(cv, xckfun, xckobj) \
+#define check_cc(cv, xckfun, xckobj, xckflags) \
do { \
cv_get_call_checker((cv), &ckfun, &ckobj); \
- if (ckfun != (xckfun)) croak_fail_ne(FPTR2DPTR(void *, ckfun), xckfun); \
- if (ckobj != (xckobj)) croak_fail_ne(FPTR2DPTR(void *, ckobj), xckobj); \
+ if (ckfun != (xckfun)) croak_fail_nep(FPTR2DPTR(void *, ckfun), xckfun); \
+ if (ckobj != (xckobj)) croak_fail_nep(FPTR2DPTR(void *, ckobj), xckobj); \
+ cv_get_call_checker_flags((cv), CALL_CHECKER_REQUIRE_GV, &ckfun, &ckobj, &ckflags); \
+ if (ckfun != (xckfun)) croak_fail_nep(FPTR2DPTR(void *, ckfun), xckfun); \
+ if (ckobj != (xckobj)) croak_fail_nep(FPTR2DPTR(void *, ckobj), xckobj); \
+ if (ckflags != CALL_CHECKER_REQUIRE_GV) croak_fail_nei(ckflags, CALL_CHECKER_REQUIRE_GV); \
+ cv_get_call_checker_flags((cv), 0, &ckfun, &ckobj, &ckflags); \
+ if (ckfun != (xckfun)) croak_fail_nep(FPTR2DPTR(void *, ckfun), xckfun); \
+ if (ckobj != (xckobj)) croak_fail_nep(FPTR2DPTR(void *, ckobj), xckobj); \
+ if (ckflags != (xckflags)) croak_fail_nei(ckflags, (xckflags)); \
} while(0)
troc_cv = get_cv("XS::APItest::test_rv2cv_op_cv", 0);
tsh_cv = get_cv("XS::APItest::test_savehints", 0);
- check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
- check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
+ check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv, 0);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv, 0);
cv_set_call_checker(tsh_cv, Perl_ck_entersub_args_proto_or_list,
&PL_sv_yes);
- check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
- check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes);
+ check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv, 0);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes, CALL_CHECKER_REQUIRE_GV);
cv_set_call_checker(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
- check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
- check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes);
+ check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no, CALL_CHECKER_REQUIRE_GV);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes, CALL_CHECKER_REQUIRE_GV);
cv_set_call_checker(tsh_cv, Perl_ck_entersub_args_proto_or_list,
(SV*)tsh_cv);
- check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
- check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
+ check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no, CALL_CHECKER_REQUIRE_GV);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv, 0);
cv_set_call_checker(troc_cv, Perl_ck_entersub_args_proto_or_list,
(SV*)troc_cv);
- check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
- check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
+ check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv, 0);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv, 0);
if (SvMAGICAL((SV*)troc_cv) || SvMAGIC((SV*)troc_cv)) croak_fail();
if (SvMAGICAL((SV*)tsh_cv) || SvMAGIC((SV*)tsh_cv)) croak_fail();
+ cv_set_call_checker_flags(tsh_cv, Perl_ck_entersub_args_proto_or_list,
+ &PL_sv_yes, 0);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes, 0);
+ cv_set_call_checker_flags(tsh_cv, Perl_ck_entersub_args_proto_or_list,
+ &PL_sv_yes, CALL_CHECKER_REQUIRE_GV);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes, CALL_CHECKER_REQUIRE_GV);
+ cv_set_call_checker_flags(tsh_cv, Perl_ck_entersub_args_proto_or_list,
+ (SV*)tsh_cv, 0);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv, 0);
+ if (SvMAGICAL((SV*)tsh_cv) || SvMAGIC((SV*)tsh_cv)) croak_fail();
+ cv_set_call_checker_flags(tsh_cv, Perl_ck_entersub_args_proto_or_list,
+ &PL_sv_yes, CALL_CHECKER_REQUIRE_GV);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes, CALL_CHECKER_REQUIRE_GV);
+ cv_set_call_checker_flags(tsh_cv, Perl_ck_entersub_args_proto_or_list,
+ (SV*)tsh_cv, CALL_CHECKER_REQUIRE_GV);
+ check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv, 0);
+ if (SvMAGICAL((SV*)tsh_cv) || SvMAGIC((SV*)tsh_cv)) croak_fail();
#undef check_cc
void
cop = &PL_compiling;
Perl_cop_store_label(aTHX_ cop, "foo", 3, 0);
label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
- if (strcmp(label,"foo")) croak("fail # cop_fetch_label label");
+ if (strNE(label,"foo")) croak("fail # cop_fetch_label label");
if (len != 3) croak("fail # cop_fetch_label len");
if (utf8) croak("fail # cop_fetch_label utf8");
/* SMALL GERMAN UMLAUT A */
Perl_cop_store_label(aTHX_ cop, "fo\xc3\xa4", 4, SVf_UTF8);
label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
- if (strcmp(label,"fo\xc3\xa4")) croak("fail # cop_fetch_label label");
+ if (strNE(label,"fo\xc3\xa4")) croak("fail # cop_fetch_label label");
if (len != 4) croak("fail # cop_fetch_label len");
if (!utf8) croak("fail # cop_fetch_label utf8");
#define iv_op(iv) newSVOP(OP_CONST, 0, newSViv(iv))
#define check_op(o, expect) \
do { \
- if (strcmp(test_op_list_describe(o), (expect))) \
+ if (strNE(test_op_list_describe(o), (expect))) \
croak("fail %s %s", test_op_list_describe(o), (expect)); \
} while(0)
a = op_append_elem(OP_LIST, NULL, NULL);
hintkey_arraytermexpr_sv = newSVpvs_share("XS::APItest/arraytermexpr");
hintkey_arrayarithexpr_sv = newSVpvs_share("XS::APItest/arrayarithexpr");
hintkey_arrayexprflags_sv = newSVpvs_share("XS::APItest/arrayexprflags");
+ hintkey_subsignature_sv = newSVpvs_share("XS::APItest/subsignature");
hintkey_DEFSV_sv = newSVpvs_share("XS::APItest/DEFSV");
hintkey_with_vars_sv = newSVpvs_share("XS::APItest/with_vars");
hintkey_join_with_space_sv = newSVpvs_share("XS::APItest/join_with_space");
- next_keyword_plugin = PL_keyword_plugin;
- PL_keyword_plugin = my_keyword_plugin;
+ wrap_keyword_plugin(my_keyword_plugin, &next_keyword_plugin);
}
void
RETVAL
char *
+SvPVbyte_nomg(SV *sv)
+CODE:
+ RETVAL = SvPVbyte_nomg(sv, PL_na);
+OUTPUT:
+ RETVAL
+
+char *
SvPVutf8(SV *sv)
CODE:
RETVAL = SvPVutf8_nolen(sv);
OUTPUT:
RETVAL
+char *
+SvPVutf8_nomg(SV *sv)
+CODE:
+ RETVAL = SvPVutf8_nomg(sv, PL_na);
+OUTPUT:
+ RETVAL
+
void
setup_addissub()
CODE:
/* The slab allocator does not like CvROOT being set. */
CvROOT(PL_compcv) = (OP *)1;
o = newFOROP(0, 0, newOP(OP_PUSHMARK, 0), 0, 0);
-#ifdef PERL_OP_PARENT
if (cLOOPx(cUNOPo->op_first)->op_last->op_sibparent
!= cUNOPo->op_first)
{
RETVAL = FALSE;
}
else
-#endif
/* If we do not crash before returning, the test passes. */
RETVAL = TRUE;
op_free(o);
SAVESPTR(PL_comppad_name); PL_comppad_name = PadlistNAMES(pl);
SAVESPTR(PL_comppad); PL_comppad = PadlistARRAY(pl)[1];
SAVESPTR(PL_curpad); PL_curpad = PadARRAY(PL_comppad);
- off = pad_add_name_sv(sv_2mortal(newSVpvf("&%"SVf,name)),
+ off = pad_add_name_sv(sv_2mortal(newSVpvf("&%" SVf,name)),
padadd_STATE, 0, 0);
SvREFCNT_dec(PL_curpad[off]);
PL_curpad[off] = SvREFCNT_inc(cv);
} else if (items == 3) {
Perl_load_module(aTHX_ flags, SvREFCNT_inc(name), SvREFCNT_inc(ST(2)));
} else
- Perl_croak(aTHX_ "load_module can't yet support %"IVdf" items", (IV)items);
+ Perl_croak(aTHX_ "load_module can't yet support %" IVdf " items",
+ (IV)items);
+
+SV *
+string_without_null(SV *sv)
+ CODE:
+ {
+ STRLEN len;
+ const char *s = SvPV(sv, len);
+ RETVAL = newSVpvn_flags(s, len, SvUTF8(sv));
+ *SvEND(RETVAL) = 0xff;
+ }
+ OUTPUT:
+ RETVAL
+
+CV *
+get_cv(SV *sv)
+ CODE:
+ {
+ STRLEN len;
+ const char *s = SvPV(sv, len);
+ RETVAL = get_cvn_flags(s, len, 0);
+ }
+ OUTPUT:
+ RETVAL
+
+CV *
+get_cv_flags(SV *sv, UV flags)
+ CODE:
+ {
+ STRLEN len;
+ const char *s = SvPV(sv, len);
+ RETVAL = get_cvn_flags(s, len, flags);
+ }
+ OUTPUT:
+ RETVAL
+
+void
+unshift_and_set_defav(SV *sv,...)
+ CODE:
+ av_unshift(GvAVn(PL_defgv), 1);
+ av_store(GvAV(PL_defgv), 0, newSVuv(42));
+ sv_setuv(sv, 43);
+
+PerlIO *
+PerlIO_stderr()
+
+OutputStream
+PerlIO_stdout()
+
+InputStream
+PerlIO_stdin()
+
+#undef FILE
+#define FILE NativeFile
+
+FILE *
+PerlIO_exportFILE(PerlIO *f, const char *mode)
+
+SV *
+test_MAX_types()
+ CODE:
+ /* tests that IV_MAX and UV_MAX have types suitable
+ for the IVdf and UVdf formats.
+ If this warns then don't add casts here.
+ */
+ RETVAL = newSVpvf("iv %" IVdf " uv %" UVuf, IV_MAX, UV_MAX);
+ OUTPUT:
+ RETVAL
MODULE = XS::APItest PACKAGE = XS::APItest::AUTOLOADtest
OUTPUT:
RETVAL
+
+ # attach ext magic to the SV pointed to by rsv that only has set magic,
+ # where that magic's job is to increment thingy
+
+void
+sv_magic_myset(SV *rsv, SV *thingy)
+CODE:
+ sv_magicext(SvRV(rsv), NULL, PERL_MAGIC_ext, &vtbl_myset,
+ (const char *)thingy, 0);
+
+
+
bool
test_isBLANK_uni(UV ord)
CODE:
RETVAL
bool
+test_isBLANK_uvchr(UV ord)
+ CODE:
+ RETVAL = isBLANK_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isBLANK_LC_uvchr(UV ord)
CODE:
RETVAL = isBLANK_LC_uvchr(ord);
RETVAL
bool
+test_isBLANK(UV ord)
+ CODE:
+ RETVAL = isBLANK(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isBLANK_A(UV ord)
CODE:
RETVAL = isBLANK_A(ord);
RETVAL
bool
-test_isBLANK_utf8(unsigned char * p)
+test_isBLANK_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isBLANK_utf8(p);
+
+ /* In this function and those that follow, the boolean 'type'
+ * indicates if to pass a malformed UTF-8 string to the tested macro
+ * (malformed by making it too short) */
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isBLANK_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isBLANK_LC_utf8(unsigned char * p)
+test_isBLANK_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isBLANK_LC_utf8(p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isBLANK_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
-test_isVERTWS_utf8(unsigned char * p)
+test_isVERTWS_uvchr(UV ord)
+ CODE:
+ RETVAL = isVERTWS_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isVERTWS_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isVERTWS_utf8(p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isVERTWS_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isUPPER_uvchr(UV ord)
+ CODE:
+ RETVAL = isUPPER_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isUPPER_LC_uvchr(UV ord)
CODE:
RETVAL = isUPPER_LC_uvchr(ord);
RETVAL
bool
+test_isUPPER(UV ord)
+ CODE:
+ RETVAL = isUPPER(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isUPPER_A(UV ord)
CODE:
RETVAL = isUPPER_A(ord);
RETVAL
bool
-test_isUPPER_utf8(unsigned char * p)
+test_isUPPER_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isUPPER_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isUPPER_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isUPPER_LC_utf8(unsigned char * p)
+test_isUPPER_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isUPPER_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isUPPER_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isLOWER_uvchr(UV ord)
+ CODE:
+ RETVAL = isLOWER_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isLOWER_LC_uvchr(UV ord)
CODE:
RETVAL = isLOWER_LC_uvchr(ord);
RETVAL
bool
+test_isLOWER(UV ord)
+ CODE:
+ RETVAL = isLOWER(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isLOWER_A(UV ord)
CODE:
RETVAL = isLOWER_A(ord);
RETVAL
bool
-test_isLOWER_utf8(unsigned char * p)
+test_isLOWER_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isLOWER_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isLOWER_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isLOWER_LC_utf8(unsigned char * p)
+test_isLOWER_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isLOWER_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isLOWER_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isALPHA_uvchr(UV ord)
+ CODE:
+ RETVAL = isALPHA_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isALPHA_LC_uvchr(UV ord)
CODE:
RETVAL = isALPHA_LC_uvchr(ord);
RETVAL
bool
+test_isALPHA(UV ord)
+ CODE:
+ RETVAL = isALPHA(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isALPHA_A(UV ord)
CODE:
RETVAL = isALPHA_A(ord);
RETVAL
bool
-test_isALPHA_utf8(unsigned char * p)
+test_isALPHA_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isALPHA_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isALPHA_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isALPHA_LC_utf8(unsigned char * p)
+test_isALPHA_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isALPHA_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isALPHA_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
-test_isWORDCHAR_LC_uvchr(UV ord)
+test_isWORDCHAR_uvchr(UV ord)
CODE:
- RETVAL = isWORDCHAR_LC_uvchr(ord);
+ RETVAL = isWORDCHAR_uvchr(ord);
OUTPUT:
RETVAL
bool
-test_isWORDCHAR_A(UV ord)
+test_isWORDCHAR_LC_uvchr(UV ord)
CODE:
- RETVAL = isWORDCHAR_A(ord);
+ RETVAL = isWORDCHAR_LC_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isWORDCHAR(UV ord)
+ CODE:
+ RETVAL = isWORDCHAR(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isWORDCHAR_A(UV ord)
+ CODE:
+ RETVAL = isWORDCHAR_A(ord);
OUTPUT:
RETVAL
RETVAL
bool
-test_isWORDCHAR_utf8(unsigned char * p)
+test_isWORDCHAR_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isWORDCHAR_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isWORDCHAR_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isWORDCHAR_LC_utf8(unsigned char * p)
+test_isWORDCHAR_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isWORDCHAR_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isWORDCHAR_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isALPHANUMERIC_uvchr(UV ord)
+ CODE:
+ RETVAL = isALPHANUMERIC_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isALPHANUMERIC_LC_uvchr(UV ord)
CODE:
RETVAL = isALPHANUMERIC_LC_uvchr(ord);
RETVAL
bool
+test_isALPHANUMERIC(UV ord)
+ CODE:
+ RETVAL = isALPHANUMERIC(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isALPHANUMERIC_A(UV ord)
CODE:
RETVAL = isALPHANUMERIC_A(ord);
RETVAL
bool
-test_isALPHANUMERIC_utf8(unsigned char * p)
+test_isALPHANUMERIC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
+ CODE:
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isALPHANUMERIC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
+bool
+test_isALPHANUMERIC_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isALPHANUMERIC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isALPHANUMERIC_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isALPHANUMERIC_LC_utf8(unsigned char * p)
+test_isALNUM(UV ord)
CODE:
- RETVAL = isALPHANUMERIC_LC_utf8( p);
+ RETVAL = isALNUM(ord);
OUTPUT:
RETVAL
RETVAL
bool
-test_isALNUM_utf8(unsigned char * p)
+test_isALNUM_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isALNUM_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isWORDCHAR_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isALNUM_LC_utf8(unsigned char * p)
+test_isALNUM_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isALNUM_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isWORDCHAR_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isDIGIT_uvchr(UV ord)
+ CODE:
+ RETVAL = isDIGIT_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isDIGIT_LC_uvchr(UV ord)
CODE:
RETVAL = isDIGIT_LC_uvchr(ord);
RETVAL
bool
-test_isDIGIT_utf8(unsigned char * p)
+test_isDIGIT_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
+ CODE:
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isDIGIT_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
+bool
+test_isDIGIT_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isDIGIT_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isDIGIT_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isDIGIT_LC_utf8(unsigned char * p)
+test_isDIGIT(UV ord)
CODE:
- RETVAL = isDIGIT_LC_utf8( p);
+ RETVAL = isDIGIT(ord);
OUTPUT:
RETVAL
RETVAL
bool
+test_isOCTAL(UV ord)
+ CODE:
+ RETVAL = isOCTAL(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isOCTAL_A(UV ord)
+ CODE:
+ RETVAL = isOCTAL_A(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isOCTAL_L1(UV ord)
+ CODE:
+ RETVAL = isOCTAL_L1(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isIDFIRST_uni(UV ord)
CODE:
RETVAL = isIDFIRST_uni(ord);
RETVAL
bool
+test_isIDFIRST_uvchr(UV ord)
+ CODE:
+ RETVAL = isIDFIRST_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isIDFIRST_LC_uvchr(UV ord)
CODE:
RETVAL = isIDFIRST_LC_uvchr(ord);
RETVAL
bool
+test_isIDFIRST(UV ord)
+ CODE:
+ RETVAL = isIDFIRST(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isIDFIRST_A(UV ord)
CODE:
RETVAL = isIDFIRST_A(ord);
RETVAL
bool
-test_isIDFIRST_utf8(unsigned char * p)
+test_isIDFIRST_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isIDFIRST_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isIDFIRST_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isIDFIRST_LC_utf8(unsigned char * p)
+test_isIDFIRST_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isIDFIRST_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isIDFIRST_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isIDCONT_uvchr(UV ord)
+ CODE:
+ RETVAL = isIDCONT_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isIDCONT_LC_uvchr(UV ord)
CODE:
RETVAL = isIDCONT_LC_uvchr(ord);
RETVAL
bool
+test_isIDCONT(UV ord)
+ CODE:
+ RETVAL = isIDCONT(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isIDCONT_A(UV ord)
CODE:
RETVAL = isIDCONT_A(ord);
RETVAL
bool
-test_isIDCONT_utf8(unsigned char * p)
+test_isIDCONT_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isIDCONT_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isIDCONT_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isIDCONT_LC_utf8(unsigned char * p)
+test_isIDCONT_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isIDCONT_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isIDCONT_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isSPACE_uvchr(UV ord)
+ CODE:
+ RETVAL = isSPACE_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isSPACE_LC_uvchr(UV ord)
CODE:
RETVAL = isSPACE_LC_uvchr(ord);
RETVAL
bool
+test_isSPACE(UV ord)
+ CODE:
+ RETVAL = isSPACE(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isSPACE_A(UV ord)
CODE:
RETVAL = isSPACE_A(ord);
RETVAL
bool
-test_isSPACE_utf8(unsigned char * p)
+test_isSPACE_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isSPACE_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isSPACE_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isSPACE_LC_utf8(unsigned char * p)
+test_isSPACE_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isSPACE_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isSPACE_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isASCII_uvchr(UV ord)
+ CODE:
+ RETVAL = isASCII_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isASCII_LC_uvchr(UV ord)
CODE:
RETVAL = isASCII_LC_uvchr(ord);
RETVAL
bool
+test_isASCII(UV ord)
+ CODE:
+ RETVAL = isASCII(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isASCII_A(UV ord)
CODE:
RETVAL = isASCII_A(ord);
RETVAL
bool
-test_isASCII_utf8(unsigned char * p)
+test_isASCII_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isASCII_utf8( p);
+#ifndef DEBUGGING
+ PERL_UNUSED_VAR(e);
+#endif
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isASCII_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isASCII_LC_utf8(unsigned char * p)
+test_isASCII_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isASCII_LC_utf8( p);
+#ifndef DEBUGGING
+ PERL_UNUSED_VAR(e);
+#endif
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isASCII_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isCNTRL_uvchr(UV ord)
+ CODE:
+ RETVAL = isCNTRL_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isCNTRL_LC_uvchr(UV ord)
CODE:
RETVAL = isCNTRL_LC_uvchr(ord);
RETVAL
bool
+test_isCNTRL(UV ord)
+ CODE:
+ RETVAL = isCNTRL(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isCNTRL_A(UV ord)
CODE:
RETVAL = isCNTRL_A(ord);
RETVAL
bool
-test_isCNTRL_utf8(unsigned char * p)
+test_isCNTRL_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isCNTRL_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isCNTRL_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isCNTRL_LC_utf8(unsigned char * p)
+test_isCNTRL_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isCNTRL_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isCNTRL_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isPRINT_uvchr(UV ord)
+ CODE:
+ RETVAL = isPRINT_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isPRINT_LC_uvchr(UV ord)
CODE:
RETVAL = isPRINT_LC_uvchr(ord);
RETVAL
bool
+test_isPRINT(UV ord)
+ CODE:
+ RETVAL = isPRINT(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isPRINT_A(UV ord)
CODE:
RETVAL = isPRINT_A(ord);
RETVAL
bool
-test_isPRINT_utf8(unsigned char * p)
+test_isPRINT_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isPRINT_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isPRINT_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isPRINT_LC_utf8(unsigned char * p)
+test_isPRINT_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isPRINT_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isPRINT_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isGRAPH_uvchr(UV ord)
+ CODE:
+ RETVAL = isGRAPH_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isGRAPH_LC_uvchr(UV ord)
CODE:
RETVAL = isGRAPH_LC_uvchr(ord);
RETVAL
bool
+test_isGRAPH(UV ord)
+ CODE:
+ RETVAL = isGRAPH(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isGRAPH_A(UV ord)
CODE:
RETVAL = isGRAPH_A(ord);
RETVAL
bool
-test_isGRAPH_utf8(unsigned char * p)
+test_isGRAPH_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isGRAPH_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isGRAPH_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isGRAPH_LC_utf8(unsigned char * p)
+test_isGRAPH_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isGRAPH_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isGRAPH_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isPUNCT_uvchr(UV ord)
+ CODE:
+ RETVAL = isPUNCT_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isPUNCT_LC_uvchr(UV ord)
CODE:
RETVAL = isPUNCT_LC_uvchr(ord);
RETVAL
bool
+test_isPUNCT(UV ord)
+ CODE:
+ RETVAL = isPUNCT(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isPUNCT_A(UV ord)
CODE:
RETVAL = isPUNCT_A(ord);
RETVAL
bool
-test_isPUNCT_utf8(unsigned char * p)
+test_isPUNCT_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isPUNCT_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isPUNCT_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isPUNCT_LC_utf8(unsigned char * p)
+test_isPUNCT_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isPUNCT_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isPUNCT_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
+test_isXDIGIT_uvchr(UV ord)
+ CODE:
+ RETVAL = isXDIGIT_uvchr(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isXDIGIT_LC_uvchr(UV ord)
CODE:
RETVAL = isXDIGIT_LC_uvchr(ord);
RETVAL
bool
+test_isXDIGIT(UV ord)
+ CODE:
+ RETVAL = isXDIGIT(ord);
+ OUTPUT:
+ RETVAL
+
+bool
test_isXDIGIT_A(UV ord)
CODE:
RETVAL = isXDIGIT_A(ord);
RETVAL
bool
-test_isXDIGIT_utf8(unsigned char * p)
+test_isXDIGIT_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isXDIGIT_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isXDIGIT_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isXDIGIT_LC_utf8(unsigned char * p)
+test_isXDIGIT_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isXDIGIT_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isXDIGIT_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
RETVAL
bool
-test_isPSXSPC_LC_uvchr(UV ord)
+test_isPSXSPC_uvchr(UV ord)
CODE:
- RETVAL = isPSXSPC_LC_uvchr(ord);
+ RETVAL = isPSXSPC_uvchr(ord);
OUTPUT:
RETVAL
bool
-test_isPSXSPC_A(UV ord)
+test_isPSXSPC_LC_uvchr(UV ord)
CODE:
- RETVAL = isPSXSPC_A(ord);
+ RETVAL = isPSXSPC_LC_uvchr(ord);
OUTPUT:
RETVAL
bool
-test_isPSXSPC_L1(UV ord)
+test_isPSXSPC(UV ord)
CODE:
- RETVAL = isPSXSPC_L1(ord);
+ RETVAL = isPSXSPC(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isPSXSPC_A(UV ord)
+ CODE:
+ RETVAL = isPSXSPC_A(ord);
+ OUTPUT:
+ RETVAL
+
+bool
+test_isPSXSPC_L1(UV ord)
+ CODE:
+ RETVAL = isPSXSPC_L1(ord);
OUTPUT:
RETVAL
RETVAL
bool
-test_isPSXSPC_utf8(unsigned char * p)
+test_isPSXSPC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isPSXSPC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isPSXSPC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
bool
-test_isPSXSPC_LC_utf8(unsigned char * p)
+test_isPSXSPC_LC_utf8(U8 * p, int type)
+ PREINIT:
+ const U8 * e;
CODE:
- RETVAL = isPSXSPC_LC_utf8( p);
+ if (type >= 0) {
+ e = p + UTF8SKIP(p) - type;
+ RETVAL = isPSXSPC_LC_utf8_safe(p, e);
+ }
+ else {
+ RETVAL = 0;
+ }
OUTPUT:
RETVAL
OUTPUT:
RETVAL
+STRLEN
+test_isUTF8_CHAR(char *s, STRLEN len)
+ CODE:
+ RETVAL = isUTF8_CHAR((U8 *) s, (U8 *) s + len);
+ OUTPUT:
+ RETVAL
+
+STRLEN
+test_isUTF8_CHAR_flags(char *s, STRLEN len, U32 flags)
+ CODE:
+ RETVAL = isUTF8_CHAR_flags((U8 *) s, (U8 *) s + len, flags);
+ OUTPUT:
+ RETVAL
+
+STRLEN
+test_isSTRICT_UTF8_CHAR(char *s, STRLEN len)
+ CODE:
+ RETVAL = isSTRICT_UTF8_CHAR((U8 *) s, (U8 *) s + len);
+ OUTPUT:
+ RETVAL
+
+STRLEN
+test_isC9_STRICT_UTF8_CHAR(char *s, STRLEN len)
+ CODE:
+ RETVAL = isC9_STRICT_UTF8_CHAR((U8 *) s, (U8 *) s + len);
+ OUTPUT:
+ RETVAL
+
+IV
+test_is_utf8_valid_partial_char_flags(char *s, STRLEN len, U32 flags)
+ CODE:
+ /* RETVAL should be bool (here and in tests below), but making it IV
+ * allows us to test it returning 0 or 1 */
+ RETVAL = is_utf8_valid_partial_char_flags((U8 *) s, (U8 *) s + len, flags);
+ OUTPUT:
+ RETVAL
+
+IV
+test_is_utf8_string(char *s, STRLEN len)
+ CODE:
+ RETVAL = is_utf8_string((U8 *) s, len);
+ OUTPUT:
+ RETVAL
+
+#define WORDSIZE sizeof(PERL_UINTMAX_T)
+
+AV *
+test_is_utf8_invariant_string_loc(U8 *s, STRLEN offset, STRLEN len)
+ PREINIT:
+ AV *av;
+ const U8 * ep = NULL;
+ PERL_UINTMAX_T* copy;
+ CODE:
+ /* 'offset' is number of bytes past a word boundary the testing of 's'
+ * is to start at. Allocate space that does start at the word
+ * boundary, and copy 's' to the correct offset past it. Then call the
+ * tested function with that position */
+ Newx(copy, 1 + ((len + WORDSIZE - 1) / WORDSIZE), PERL_UINTMAX_T);
+ Copy(s, (U8 *) copy + offset, len, U8);
+ av = newAV();
+ av_push(av, newSViv(is_utf8_invariant_string_loc((U8 *) copy + offset, len, &ep)));
+ av_push(av, newSViv(ep - ((U8 *) copy + offset)));
+ RETVAL = av;
+ Safefree(copy);
+ OUTPUT:
+ RETVAL
+
+STRLEN
+test_variant_under_utf8_count(U8 *s, STRLEN offset, STRLEN len)
+ PREINIT:
+ PERL_UINTMAX_T * copy;
+ CODE:
+ Newx(copy, 1 + ((len + WORDSIZE - 1) / WORDSIZE), PERL_UINTMAX_T);
+ Copy(s, (U8 *) copy + offset, len, U8);
+ RETVAL = variant_under_utf8_count((U8 *) copy + offset, (U8 *) copy + offset + len);
+ Safefree(copy);
+ OUTPUT:
+ RETVAL
+
+STRLEN
+test_utf8_length(U8 *s, STRLEN offset, STRLEN len)
+CODE:
+ RETVAL = utf8_length(s + offset, s + len);
+OUTPUT:
+ RETVAL
+
+AV *
+test_is_utf8_string_loc(char *s, STRLEN len)
+ PREINIT:
+ AV *av;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_utf8_string_loc((U8 *) s, len, &ep)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_utf8_string_loclen(char *s, STRLEN len)
+ PREINIT:
+ AV *av;
+ STRLEN ret_len;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_utf8_string_loclen((U8 *) s, len, &ep, &ret_len)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ av_push(av, newSVuv(ret_len));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+IV
+test_is_utf8_string_flags(char *s, STRLEN len, U32 flags)
+ CODE:
+ RETVAL = is_utf8_string_flags((U8 *) s, len, flags);
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_utf8_string_loc_flags(char *s, STRLEN len, U32 flags)
+ PREINIT:
+ AV *av;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_utf8_string_loc_flags((U8 *) s, len, &ep, flags)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_utf8_string_loclen_flags(char *s, STRLEN len, U32 flags)
+ PREINIT:
+ AV *av;
+ STRLEN ret_len;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_utf8_string_loclen_flags((U8 *) s, len, &ep, &ret_len, flags)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ av_push(av, newSVuv(ret_len));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+IV
+test_is_strict_utf8_string(char *s, STRLEN len)
+ CODE:
+ RETVAL = is_strict_utf8_string((U8 *) s, len);
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_strict_utf8_string_loc(char *s, STRLEN len)
+ PREINIT:
+ AV *av;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_strict_utf8_string_loc((U8 *) s, len, &ep)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_strict_utf8_string_loclen(char *s, STRLEN len)
+ PREINIT:
+ AV *av;
+ STRLEN ret_len;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_strict_utf8_string_loclen((U8 *) s, len, &ep, &ret_len)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ av_push(av, newSVuv(ret_len));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+IV
+test_is_c9strict_utf8_string(char *s, STRLEN len)
+ CODE:
+ RETVAL = is_c9strict_utf8_string((U8 *) s, len);
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_c9strict_utf8_string_loc(char *s, STRLEN len)
+ PREINIT:
+ AV *av;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_c9strict_utf8_string_loc((U8 *) s, len, &ep)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_c9strict_utf8_string_loclen(char *s, STRLEN len)
+ PREINIT:
+ AV *av;
+ STRLEN ret_len;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_c9strict_utf8_string_loclen((U8 *) s, len, &ep, &ret_len)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ av_push(av, newSVuv(ret_len));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+IV
+test_is_utf8_fixed_width_buf_flags(char *s, STRLEN len, U32 flags)
+ CODE:
+ RETVAL = is_utf8_fixed_width_buf_flags((U8 *) s, len, flags);
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_utf8_fixed_width_buf_loc_flags(char *s, STRLEN len, U32 flags)
+ PREINIT:
+ AV *av;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_utf8_fixed_width_buf_loc_flags((U8 *) s, len, &ep, flags)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+AV *
+test_is_utf8_fixed_width_buf_loclen_flags(char *s, STRLEN len, U32 flags)
+ PREINIT:
+ AV *av;
+ STRLEN ret_len;
+ const U8 * ep;
+ CODE:
+ av = newAV();
+ av_push(av, newSViv(is_utf8_fixed_width_buf_loclen_flags((U8 *) s, len, &ep, &ret_len, flags)));
+ av_push(av, newSViv(ep - (U8 *) s));
+ av_push(av, newSVuv(ret_len));
+ RETVAL = av;
+ OUTPUT:
+ RETVAL
+
+IV
+test_utf8_hop_safe(SV *s_sv, STRLEN s_off, IV off)
+ PREINIT:
+ STRLEN len;
+ U8 *p;
+ U8 *r;
+ CODE:
+ p = (U8 *)SvPV(s_sv, len);
+ r = utf8_hop_safe(p + s_off, off, p, p + len);
+ RETVAL = r - p;
+ OUTPUT:
+ RETVAL
+
UV
test_toLOWER(UV ord)
CODE:
RETVAL
AV *
-test_toLOWER_utf8(SV * p)
+test_toLOWER_uvchr(UV ord)
PREINIT:
- U8 *input;
U8 s[UTF8_MAXBYTES_CASE + 1];
STRLEN len;
AV *av;
SV *utf8;
CODE:
- input = (U8 *) SvPV(p, len);
av = newAV();
- av_push(av, newSVuv(toLOWER_utf8(input, s, &len)));
+ av_push(av, newSVuv(toLOWER_uvchr(ord, s, &len)));
utf8 = newSVpvn((char *) s, len);
SvUTF8_on(utf8);
OUTPUT:
RETVAL
+AV *
+test_toLOWER_utf8(SV * p, int type)
+ PREINIT:
+ U8 *input;
+ U8 s[UTF8_MAXBYTES_CASE + 1];
+ STRLEN len;
+ AV *av;
+ SV *utf8;
+ const U8 * e;
+ UV resultant_cp = UV_MAX; /* Initialized because of dumb compilers */
+ CODE:
+ input = (U8 *) SvPV(p, len);
+ av = newAV();
+ if (type >= 0) {
+ e = input + UTF8SKIP(input) - type;
+ resultant_cp = toLOWER_utf8_safe(input, e, s, &len);
+ av_push(av, newSVuv(resultant_cp));
+
+ utf8 = newSVpvn((char *) s, len);
+ SvUTF8_on(utf8);
+ av_push(av, utf8);
+
+ av_push(av, newSVuv(len));
+ RETVAL = av;
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
UV
test_toFOLD(UV ord)
CODE:
RETVAL
AV *
-test_toFOLD_utf8(SV * p)
+test_toFOLD_uvchr(UV ord)
PREINIT:
- U8 *input;
U8 s[UTF8_MAXBYTES_CASE + 1];
STRLEN len;
AV *av;
SV *utf8;
CODE:
- input = (U8 *) SvPV(p, len);
av = newAV();
- av_push(av, newSVuv(toFOLD_utf8(input, s, &len)));
+ av_push(av, newSVuv(toFOLD_uvchr(ord, s, &len)));
utf8 = newSVpvn((char *) s, len);
SvUTF8_on(utf8);
OUTPUT:
RETVAL
+AV *
+test_toFOLD_utf8(SV * p, int type)
+ PREINIT:
+ U8 *input;
+ U8 s[UTF8_MAXBYTES_CASE + 1];
+ STRLEN len;
+ AV *av;
+ SV *utf8;
+ const U8 * e;
+ UV resultant_cp = UV_MAX;
+ CODE:
+ input = (U8 *) SvPV(p, len);
+ av = newAV();
+ if (type >= 0) {
+ e = input + UTF8SKIP(input) - type;
+ resultant_cp = toFOLD_utf8_safe(input, e, s, &len);
+ av_push(av, newSVuv(resultant_cp));
+
+ utf8 = newSVpvn((char *) s, len);
+ SvUTF8_on(utf8);
+ av_push(av, utf8);
+
+ av_push(av, newSVuv(len));
+ RETVAL = av;
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
UV
test_toUPPER(UV ord)
CODE:
RETVAL
AV *
-test_toUPPER_utf8(SV * p)
+test_toUPPER_uvchr(UV ord)
PREINIT:
- U8 *input;
U8 s[UTF8_MAXBYTES_CASE + 1];
STRLEN len;
AV *av;
SV *utf8;
CODE:
- input = (U8 *) SvPV(p, len);
av = newAV();
- av_push(av, newSVuv(toUPPER_utf8(input, s, &len)));
+ av_push(av, newSVuv(toUPPER_uvchr(ord, s, &len)));
utf8 = newSVpvn((char *) s, len);
SvUTF8_on(utf8);
OUTPUT:
RETVAL
+AV *
+test_toUPPER_utf8(SV * p, int type)
+ PREINIT:
+ U8 *input;
+ U8 s[UTF8_MAXBYTES_CASE + 1];
+ STRLEN len;
+ AV *av;
+ SV *utf8;
+ const U8 * e;
+ UV resultant_cp = UV_MAX;
+ CODE:
+ input = (U8 *) SvPV(p, len);
+ av = newAV();
+ if (type >= 0) {
+ e = input + UTF8SKIP(input) - type;
+ resultant_cp = toUPPER_utf8_safe(input, e, s, &len);
+ av_push(av, newSVuv(resultant_cp));
+
+ utf8 = newSVpvn((char *) s, len);
+ SvUTF8_on(utf8);
+ av_push(av, utf8);
+
+ av_push(av, newSVuv(len));
+ RETVAL = av;
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
UV
test_toTITLE(UV ord)
CODE:
RETVAL
AV *
-test_toTITLE_utf8(SV * p)
+test_toTITLE_uvchr(UV ord)
PREINIT:
- U8 *input;
U8 s[UTF8_MAXBYTES_CASE + 1];
STRLEN len;
AV *av;
SV *utf8;
CODE:
- input = (U8 *) SvPV(p, len);
av = newAV();
- av_push(av, newSVuv(toTITLE_utf8(input, s, &len)));
+ av_push(av, newSVuv(toTITLE_uvchr(ord, s, &len)));
utf8 = newSVpvn((char *) s, len);
SvUTF8_on(utf8);
OUTPUT:
RETVAL
+AV *
+test_toTITLE_utf8(SV * p, int type)
+ PREINIT:
+ U8 *input;
+ U8 s[UTF8_MAXBYTES_CASE + 1];
+ STRLEN len;
+ AV *av;
+ SV *utf8;
+ const U8 * e;
+ UV resultant_cp = UV_MAX;
+ CODE:
+ input = (U8 *) SvPV(p, len);
+ av = newAV();
+ if (type >= 0) {
+ e = input + UTF8SKIP(input) - type;
+ resultant_cp = toTITLE_utf8_safe(input, e, s, &len);
+ av_push(av, newSVuv(resultant_cp));
+
+ utf8 = newSVpvn((char *) s, len);
+ SvUTF8_on(utf8);
+ av_push(av, utf8);
+
+ av_push(av, newSVuv(len));
+ RETVAL = av;
+ }
+ else {
+ RETVAL = 0;
+ }
+ OUTPUT:
+ RETVAL
+
SV *
test_Gconvert(SV * number, SV * num_digits)
PREINIT:
OUTPUT:
RETVAL
+SV *
+test_Perl_langinfo(SV * item)
+ CODE:
+ RETVAL = newSVpv(Perl_langinfo(SvIV(item)), 0);
+ OUTPUT:
+ RETVAL
+
MODULE = XS::APItest PACKAGE = XS::APItest::Backrefs
void
if(!dll)
croak("Comctl32Version: comctl32.dll not in process???");
hrsc = FindResource(dll, MAKEINTRESOURCE(VS_VERSION_INFO),
- MAKEINTRESOURCE(VS_FILE_INFO));
+ MAKEINTRESOURCE((Size_t)VS_FILE_INFO));
if(!hrsc)
croak("Comctl32Version: comctl32.dll no version???");
ver = LoadResource(dll, hrsc);
len = SizeofResource(dll, hrsc);
- vercopy = _alloca(len);
+ vercopy = (void *)sv_grow(sv_newmortal(),len);
memcpy(vercopy, ver, len);
if (VerQueryValue(vercopy, "\\", (void**)&info, &len)) {
int dwValueMS1 = (info->dwFileVersionMS>>16);
#endif
+MODULE = XS::APItest PACKAGE = XS::APItest::HvMacro
+
+
+UV
+u8_to_u16_le(SV *sv, STRLEN ofs)
+ ALIAS:
+ u8_to_u32_le = 1
+ u8_to_u64_le = 2
+ CODE:
+ {
+ STRLEN len;
+ char *pv= SvPV(sv,len);
+ STRLEN minlen= 2<<ix;
+ U16 u16;
+ U32 u32;
+ U64 u64;
+ RETVAL= 0; /* silence warnings about uninitialized RETVAL */
+ switch (ix) {
+ case 0:
+ if (ofs+minlen>len) croak("cowardly refusing to read past end of string in u8_to_u16_le");
+ u16= U8TO16_LE(pv+ofs);
+ RETVAL= (UV)u16;
+ break;
+ case 1:
+ if (ofs+minlen>len) croak("cowardly refusing to read past end of string in u8_to_u32_le");
+ u32= U8TO32_LE(pv+ofs);
+ RETVAL= (UV)u32;
+ break;
+ case 2:
+#if TEST_64BIT
+ if (ofs+minlen>len) croak("cowardly refusing to read past end of string in u8_to_u64_le");
+ u64= U8TO64_LE(pv+ofs);
+ RETVAL= (UV)u64;
+#else
+ PERL_UNUSED_VAR(u64);
+ croak("not a 64 bit perl IVSIZE=%d",IVSIZE);
+#endif
+ break;
+ }
+ }
+ OUTPUT:
+ RETVAL
+
+U32
+rotl32(U32 n, U8 r)
+ CODE:
+ {
+ RETVAL= ROTL32(n,r);
+ }
+ OUTPUT:
+ RETVAL
+
+U32
+rotr32(U32 n, U8 r)
+ CODE:
+ {
+ RETVAL= ROTR32(n,r);
+ }
+ OUTPUT:
+ RETVAL
+
+#if TEST_64BIT
+
+UV
+rotl64(UV n, U8 r)
+ CODE:
+ {
+ RETVAL= ROTL64(n,r);
+ }
+ OUTPUT:
+ RETVAL
+
+UV
+rotr64(UV n, U8 r)
+ CODE:
+ {
+ RETVAL= ROTR64(n,r);
+ }
+ OUTPUT:
+ RETVAL
+
+SV *
+siphash_seed_state(SV *seed_sv)
+ CODE:
+ {
+ U8 state_buf[sizeof(U64)*4];
+ STRLEN seed_len;
+ U8 *seed_pv= (U8*)SvPV(seed_sv,seed_len);
+ if (seed_len<16) croak("seed should be 16 bytes long");
+ else if (seed_len>16) warn("only using the first 16 bytes of seed");
+ RETVAL= newSV(sizeof(U64)*4+3);
+ S_perl_siphash_seed_state(seed_pv,state_buf);
+ sv_setpvn(RETVAL,(char*)state_buf,sizeof(U64)*4);
+ }
+ OUTPUT:
+ RETVAL
+
+
+UV
+siphash24(SV *state_sv, SV *str_sv)
+ ALIAS:
+ siphash13 = 1
+ CODE:
+ {
+ STRLEN state_len;
+ STRLEN str_len;
+ U8 *str_pv= (U8*)SvPV(str_sv,str_len);
+ /* (U8*)SvPV(state_sv, state_len) return differs between little-endian *
+ * and big-endian. It's the same values, but in a different order. *
+ * On big-endian architecture, we transpose the values into the same *
+ * order as for little-endian, so that we can test against the same *
+ * test vectors. *
+ * We could alternatively alter the code that produced state_sv to *
+ * output identical arrangements for big-endian and little-endian. */
+#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
+ U8 *state_pv= (U8*)SvPV(state_sv,state_len);
+ if (state_len!=32) croak("siphash state should be exactly 32 bytes");
+#else
+ U8 *temp_pv = (U8*)SvPV(state_sv, state_len);
+ U8 state_pv[32];
+ int i;
+ if (state_len!=32) croak("siphash state should be exactly 32 bytes");
+ for( i = 0; i < 32; i++ ) {
+ if (i < 8) state_pv[ 7 - i] = temp_pv[i];
+ else if(i < 16) state_pv[23 - i] = temp_pv[i];
+ else if(i < 24) state_pv[39 - i] = temp_pv[i];
+ else state_pv[55 - i] = temp_pv[i];
+ }
+#endif
+ if (ix) {
+ RETVAL= S_perl_hash_siphash_1_3_with_state_64(state_pv,str_pv,str_len);
+ } else {
+ RETVAL= S_perl_hash_siphash_2_4_with_state_64(state_pv,str_pv,str_len);
+ }
+ }
+ OUTPUT:
+ RETVAL
+
+
+UV
+test_siphash24()
+ CODE:
+ {
+ U8 vectors[64][8] = {
+ { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
+ { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
+ { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
+ { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
+ { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
+ { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
+ { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
+ { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
+ { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
+ { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
+ { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
+ { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
+ { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
+ { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
+ { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
+ { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
+ { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
+ { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
+ { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
+ { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
+ { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
+ { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
+ { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
+ { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
+ { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
+ { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
+ { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
+ { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
+ { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
+ { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
+ { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
+ { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
+ { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
+ { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
+ { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
+ { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
+ { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
+ { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
+ { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
+ { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
+ { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
+ { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
+ { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
+ { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
+ { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
+ { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
+ { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
+ { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
+ { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
+ { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
+ { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
+ { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
+ { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
+ { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
+ { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
+ { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
+ { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
+ { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
+ { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
+ { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
+ { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
+ { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
+ { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
+ { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
+ };
+ U32 vectors_32[64] = {
+ 0xaf61d576,
+ 0xe7245e38,
+ 0xd4c5cf53,
+ 0x529c18bb,
+ 0xe8561357,
+ 0xd5eff3e9,
+ 0x9337a5a0,
+ 0x2003d1c2,
+ 0x0966d11b,
+ 0x95a9666f,
+ 0xee800236,
+ 0xd6d882e1,
+ 0xf3106a47,
+ 0xd46e6bb7,
+ 0x7959387e,
+ 0xe8978f84,
+ 0x68e857a4,
+ 0x4524ae61,
+ 0xdd4c606c,
+ 0x1c14a8a0,
+ 0xa474b26a,
+ 0xfec9ac77,
+ 0x70f0591d,
+ 0x6550cd44,
+ 0x4ee4ff52,
+ 0x36642a34,
+ 0x4c63204b,
+ 0x2845aece,
+ 0x79506309,
+ 0x21373517,
+ 0xf1ce4c7b,
+ 0xea9951b8,
+ 0x03d52de1,
+ 0x5eaa5ba5,
+ 0xa9e5a222,
+ 0x1a41a37a,
+ 0x39585c0a,
+ 0x2b1ba971,
+ 0x5428d8a8,
+ 0xf08cab2a,
+ 0x5d3a0ebb,
+ 0x51541b44,
+ 0x83b11361,
+ 0x27df2129,
+ 0x1dc758ef,
+ 0xb026d883,
+ 0x2ef668cf,
+ 0x8c65ed26,
+ 0x78d90a9a,
+ 0x3bcb49ba,
+ 0x7936bd28,
+ 0x13d7c32c,
+ 0x844cf30d,
+ 0xa1077c52,
+ 0xdc1acee1,
+ 0x18f31558,
+ 0x8d003c12,
+ 0xd830cf6e,
+ 0xc39f4c30,
+ 0x202efc77,
+ 0x30fb7d50,
+ 0xc3f44852,
+ 0x6be96737,
+ 0x7e8c773e
+ };
+
+ const U8 MAXLEN= 64;
+ U8 in[64], seed_pv[16], state_pv[32];
+ union {
+ U64 hash;
+ U32 h32[2];
+ U8 bytes[8];
+ } out;
+ int i,j;
+ int failed = 0;
+ U32 hash32;
+ /* S_perl_siphash_seed_state(seed_pv, state_pv) sets state_pv *
+ * differently between little-endian and big-endian. It's the same *
+ * values, but in a different order. *
+ * On big-endian architecture, we transpose the values into the same *
+ * order as for little-endian, so that we can test against the same *
+ * test vectors. *
+ * We could alternatively alter the code that produces state_pv to *
+ * output identical arrangements for big-endian and little-endian. */
+#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
+ for( i = 0; i < 16; ++i ) seed_pv[i] = i;
+ S_perl_siphash_seed_state(seed_pv, state_pv);
+#else
+ U8 temp_pv[32];
+ for( i = 0; i < 16; ++i ) seed_pv[i] = i;
+ S_perl_siphash_seed_state(seed_pv, temp_pv);
+ for( i = 0; i < 32; ++i ) {
+ if (i < 8) state_pv[ 7 - i] = temp_pv[i];
+ else if(i < 16) state_pv[23 - i] = temp_pv[i];
+ else if(i < 24) state_pv[39 - i] = temp_pv[i];
+ else state_pv[55 - i] = temp_pv[i];
+ }
+#endif
+ for( i = 0; i < MAXLEN; ++i )
+ {
+ in[i] = i;
+
+ out.hash= S_perl_hash_siphash_2_4_with_state_64( state_pv, in, i );
+
+ hash32= S_perl_hash_siphash_2_4_with_state( state_pv, in, i);
+ /* The test vectors need to reversed here for big-endian architecture *
+ * Alternatively we could rewrite S_perl_hash_siphash_2_4_with_state_64 *
+ * to produce reversed vectors when run on big-endian architecture */
+#if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321 /* reverse order of vectors[i] */
+ temp_pv [0] = vectors[i][0]; /* temp_pv is temporary holder of vectors[i][0] */
+ vectors[i][0] = vectors[i][7];
+ vectors[i][7] = temp_pv[0];
+
+ temp_pv [0] = vectors[i][1]; /* temp_pv is temporary holder of vectors[i][1] */
+ vectors[i][1] = vectors[i][6];
+ vectors[i][6] = temp_pv[0];
+
+ temp_pv [0] = vectors[i][2]; /* temp_pv is temporary holder of vectors[i][2] */
+ vectors[i][2] = vectors[i][5];
+ vectors[i][5] = temp_pv[0];
+
+ temp_pv [0] = vectors[i][3]; /* temp_pv is temporary holder of vectors[i][3] */
+ vectors[i][3] = vectors[i][4];
+ vectors[i][4] = temp_pv[0];
+#endif
+ if ( memcmp( out.bytes, vectors[i], 8 ) )
+ {
+ failed++;
+ printf( "Error in 64 bit result on test vector of length %d for siphash24\n have: {", i );
+ for (j=0;j<7;j++)
+ printf( "0x%02x, ", out.bytes[j]);
+ printf( "0x%02x },\n", out.bytes[7]);
+ printf( " want: {" );
+ for (j=0;j<7;j++)
+ printf( "0x%02x, ", vectors[i][j]);
+ printf( "0x%02x },\n", vectors[i][7]);
+ }
+ if (hash32 != vectors_32[i]) {
+ failed++;
+ printf( "Error in 32 bit result on test vector of length %d for siphash24\n"
+ " have: 0x%08x\n"
+ " want: 0x%08x\n",
+ i, hash32, vectors_32[i]);
+ }
+ }
+ RETVAL= failed;
+ }
+ OUTPUT:
+ RETVAL
+
+UV
+test_siphash13()
+ CODE:
+ {
+ U8 vectors[64][8] = {
+ {0xdc, 0xc4, 0x0f, 0x05, 0x58, 0x01, 0xac, 0xab },
+ {0x93, 0xca, 0x57, 0x7d, 0xf3, 0x9b, 0xf4, 0xc9 },
+ {0x4d, 0xd4, 0xc7, 0x4d, 0x02, 0x9b, 0xcb, 0x82 },
+ {0xfb, 0xf7, 0xdd, 0xe7, 0xb8, 0x0a, 0xf8, 0x8b },
+ {0x28, 0x83, 0xd3, 0x88, 0x60, 0x57, 0x75, 0xcf },
+ {0x67, 0x3b, 0x53, 0x49, 0x2f, 0xd5, 0xf9, 0xde },
+ {0xa7, 0x22, 0x9f, 0xc5, 0x50, 0x2b, 0x0d, 0xc5 },
+ {0x40, 0x11, 0xb1, 0x9b, 0x98, 0x7d, 0x92, 0xd3 },
+ {0x8e, 0x9a, 0x29, 0x8d, 0x11, 0x95, 0x90, 0x36 },
+ {0xe4, 0x3d, 0x06, 0x6c, 0xb3, 0x8e, 0xa4, 0x25 },
+ {0x7f, 0x09, 0xff, 0x92, 0xee, 0x85, 0xde, 0x79 },
+ {0x52, 0xc3, 0x4d, 0xf9, 0xc1, 0x18, 0xc1, 0x70 },
+ {0xa2, 0xd9, 0xb4, 0x57, 0xb1, 0x84, 0xa3, 0x78 },
+ {0xa7, 0xff, 0x29, 0x12, 0x0c, 0x76, 0x6f, 0x30 },
+ {0x34, 0x5d, 0xf9, 0xc0, 0x11, 0xa1, 0x5a, 0x60 },
+ {0x56, 0x99, 0x51, 0x2a, 0x6d, 0xd8, 0x20, 0xd3 },
+ {0x66, 0x8b, 0x90, 0x7d, 0x1a, 0xdd, 0x4f, 0xcc },
+ {0x0c, 0xd8, 0xdb, 0x63, 0x90, 0x68, 0xf2, 0x9c },
+ {0x3e, 0xe6, 0x73, 0xb4, 0x9c, 0x38, 0xfc, 0x8f },
+ {0x1c, 0x7d, 0x29, 0x8d, 0xe5, 0x9d, 0x1f, 0xf2 },
+ {0x40, 0xe0, 0xcc, 0xa6, 0x46, 0x2f, 0xdc, 0xc0 },
+ {0x44, 0xf8, 0x45, 0x2b, 0xfe, 0xab, 0x92, 0xb9 },
+ {0x2e, 0x87, 0x20, 0xa3, 0x9b, 0x7b, 0xfe, 0x7f },
+ {0x23, 0xc1, 0xe6, 0xda, 0x7f, 0x0e, 0x5a, 0x52 },
+ {0x8c, 0x9c, 0x34, 0x67, 0xb2, 0xae, 0x64, 0xf4 },
+ {0x79, 0x09, 0x5b, 0x70, 0x28, 0x59, 0xcd, 0x45 },
+ {0xa5, 0x13, 0x99, 0xca, 0xe3, 0x35, 0x3e, 0x3a },
+ {0x35, 0x3b, 0xde, 0x4a, 0x4e, 0xc7, 0x1d, 0xa9 },
+ {0x0d, 0xd0, 0x6c, 0xef, 0x02, 0xed, 0x0b, 0xfb },
+ {0xf4, 0xe1, 0xb1, 0x4a, 0xb4, 0x3c, 0xd9, 0x88 },
+ {0x63, 0xe6, 0xc5, 0x43, 0xd6, 0x11, 0x0f, 0x54 },
+ {0xbc, 0xd1, 0x21, 0x8c, 0x1f, 0xdd, 0x70, 0x23 },
+ {0x0d, 0xb6, 0xa7, 0x16, 0x6c, 0x7b, 0x15, 0x81 },
+ {0xbf, 0xf9, 0x8f, 0x7a, 0xe5, 0xb9, 0x54, 0x4d },
+ {0x3e, 0x75, 0x2a, 0x1f, 0x78, 0x12, 0x9f, 0x75 },
+ {0x91, 0x6b, 0x18, 0xbf, 0xbe, 0xa3, 0xa1, 0xce },
+ {0x06, 0x62, 0xa2, 0xad, 0xd3, 0x08, 0xf5, 0x2c },
+ {0x57, 0x30, 0xc3, 0xa3, 0x2d, 0x1c, 0x10, 0xb6 },
+ {0xa1, 0x36, 0x3a, 0xae, 0x96, 0x74, 0xf4, 0xb3 },
+ {0x92, 0x83, 0x10, 0x7b, 0x54, 0x57, 0x6b, 0x62 },
+ {0x31, 0x15, 0xe4, 0x99, 0x32, 0x36, 0xd2, 0xc1 },
+ {0x44, 0xd9, 0x1a, 0x3f, 0x92, 0xc1, 0x7c, 0x66 },
+ {0x25, 0x88, 0x13, 0xc8, 0xfe, 0x4f, 0x70, 0x65 },
+ {0xa6, 0x49, 0x89, 0xc2, 0xd1, 0x80, 0xf2, 0x24 },
+ {0x6b, 0x87, 0xf8, 0xfa, 0xed, 0x1c, 0xca, 0xc2 },
+ {0x96, 0x21, 0x04, 0x9f, 0xfc, 0x4b, 0x16, 0xc2 },
+ {0x23, 0xd6, 0xb1, 0x68, 0x93, 0x9c, 0x6e, 0xa1 },
+ {0xfd, 0x14, 0x51, 0x8b, 0x9c, 0x16, 0xfb, 0x49 },
+ {0x46, 0x4c, 0x07, 0xdf, 0xf8, 0x43, 0x31, 0x9f },
+ {0xb3, 0x86, 0xcc, 0x12, 0x24, 0xaf, 0xfd, 0xc6 },
+ {0x8f, 0x09, 0x52, 0x0a, 0xd1, 0x49, 0xaf, 0x7e },
+ {0x9a, 0x2f, 0x29, 0x9d, 0x55, 0x13, 0xf3, 0x1c },
+ {0x12, 0x1f, 0xf4, 0xa2, 0xdd, 0x30, 0x4a, 0xc4 },
+ {0xd0, 0x1e, 0xa7, 0x43, 0x89, 0xe9, 0xfa, 0x36 },
+ {0xe6, 0xbc, 0xf0, 0x73, 0x4c, 0xb3, 0x8f, 0x31 },
+ {0x80, 0xe9, 0xa7, 0x70, 0x36, 0xbf, 0x7a, 0xa2 },
+ {0x75, 0x6d, 0x3c, 0x24, 0xdb, 0xc0, 0xbc, 0xb4 },
+ {0x13, 0x15, 0xb7, 0xfd, 0x52, 0xd8, 0xf8, 0x23 },
+ {0x08, 0x8a, 0x7d, 0xa6, 0x4d, 0x5f, 0x03, 0x8f },
+ {0x48, 0xf1, 0xe8, 0xb7, 0xe5, 0xd0, 0x9c, 0xd8 },
+ {0xee, 0x44, 0xa6, 0xf7, 0xbc, 0xe6, 0xf4, 0xf6 },
+ {0xf2, 0x37, 0x18, 0x0f, 0xd8, 0x9a, 0xc5, 0xae },
+ {0xe0, 0x94, 0x66, 0x4b, 0x15, 0xf6, 0xb2, 0xc3 },
+ {0xa8, 0xb3, 0xbb, 0xb7, 0x62, 0x90, 0x19, 0x9d }
+ };
+ U32 vectors_32[64] = {
+ 0xaea3c584,
+ 0xb4a35160,
+ 0xcf0c4f4f,
+ 0x6c25fd43,
+ 0x47a6d448,
+ 0x97aaee48,
+ 0x009209f7,
+ 0x48236cd8,
+ 0xbbb90f9f,
+ 0x49a2b357,
+ 0xeb218c91,
+ 0x898cdb93,
+ 0x2f175d13,
+ 0x224689ab,
+ 0xa0a3fc25,
+ 0xf971413b,
+ 0xb1df567c,
+ 0xff29b09c,
+ 0x3b8fdea2,
+ 0x7f36e0f9,
+ 0x6610cf06,
+ 0x92d753ba,
+ 0xdcdefcb5,
+ 0x88bccf5c,
+ 0x9350323e,
+ 0x35965051,
+ 0xf0a72646,
+ 0xe3c3fc7b,
+ 0x14673d0f,
+ 0xc268dd40,
+ 0x17caf7b5,
+ 0xaf510ca3,
+ 0x97b2cd61,
+ 0x37db405a,
+ 0x6ab56746,
+ 0x71b9c82f,
+ 0x81576ad5,
+ 0x15d32c7a,
+ 0x1dce4237,
+ 0x197bd4c6,
+ 0x58362303,
+ 0x596618d6,
+ 0xad63c7db,
+ 0xe67bc977,
+ 0x38329b86,
+ 0x5d126a6a,
+ 0xc9df4ab0,
+ 0xc2aa0261,
+ 0x40360fbe,
+ 0xd4312997,
+ 0x74fd405e,
+ 0x81da3ccf,
+ 0x66be2fcf,
+ 0x755df759,
+ 0x427f0faa,
+ 0xd2dd56b6,
+ 0x9080adae,
+ 0xde4fcd41,
+ 0x297ed545,
+ 0x6f7421ad,
+ 0x0152a252,
+ 0xa1ddad2a,
+ 0x88d462f5,
+ 0x2aa223ca,
+ };
+
+ const U8 MAXLEN= 64;
+ U8 in[64], seed_pv[16], state_pv[32];
+ union {
+ U64 hash;
+ U32 h32[2];
+ U8 bytes[8];
+ } out;
+ int i,j;
+ int failed = 0;
+ U32 hash32;
+ /* S_perl_siphash_seed_state(seed_pv, state_pv) sets state_pv *
+ * differently between little-endian and big-endian. It's the same *
+ * values, but in a different order. *
+ * On big-endian architecture, we transpose the values into the same *
+ * order as for little-endian, so that we can test against the same *
+ * test vectors. *
+ * We could alternatively alter the code that produces state_pv to *
+ * output identical arrangements for big-endian and little-endian. */
+#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
+ for( i = 0; i < 16; ++i ) seed_pv[i] = i;
+ S_perl_siphash_seed_state(seed_pv, state_pv);
+#else
+ U8 temp_pv[32];
+ for( i = 0; i < 16; ++i ) seed_pv[i] = i;
+ S_perl_siphash_seed_state(seed_pv, temp_pv);
+ for( i = 0; i < 32; ++i ) {
+ if (i < 8) state_pv[ 7 - i] = temp_pv[i];
+ else if(i < 16) state_pv[23 - i] = temp_pv[i];
+ else if(i < 24) state_pv[39 - i] = temp_pv[i];
+ else state_pv[55 - i] = temp_pv[i];
+ }
+#endif
+ for( i = 0; i < MAXLEN; ++i )
+ {
+ in[i] = i;
+
+ out.hash= S_perl_hash_siphash_1_3_with_state_64( state_pv, in, i );
+
+ hash32= S_perl_hash_siphash_1_3_with_state( state_pv, in, i);
+ /* The test vectors need to reversed here for big-endian architecture *
+ * Alternatively we could rewrite S_perl_hash_siphash_1_3_with_state_64 *
+ * to produce reversed vectors when run on big-endian architecture */
+#if BYTEORDER == 0x4321 || BYTEORDER == 0x87654321
+ temp_pv [0] = vectors[i][0]; /* temp_pv is temporary holder of vectors[i][0] */
+ vectors[i][0] = vectors[i][7];
+ vectors[i][7] = temp_pv[0];
+
+ temp_pv [0] = vectors[i][1]; /* temp_pv is temporary holder of vectors[i][1] */
+ vectors[i][1] = vectors[i][6];
+ vectors[i][6] = temp_pv[0];
+
+ temp_pv [0] = vectors[i][2]; /* temp_pv is temporary holder of vectors[i][2] */
+ vectors[i][2] = vectors[i][5];
+ vectors[i][5] = temp_pv[0];
+
+ temp_pv [0] = vectors[i][3]; /* temp_pv is temporary holder of vectors[i][3] */
+ vectors[i][3] = vectors[i][4];
+ vectors[i][4] = temp_pv[0];
+#endif
+ if ( memcmp( out.bytes, vectors[i], 8 ) )
+ {
+ failed++;
+ printf( "Error in 64 bit result on test vector of length %d for siphash13\n have: {", i );
+ for (j=0;j<7;j++)
+ printf( "0x%02x, ", out.bytes[j]);
+ printf( "0x%02x },\n", out.bytes[7]);
+ printf( " want: {" );
+ for (j=0;j<7;j++)
+ printf( "0x%02x, ", vectors[i][j]);
+ printf( "0x%02x },\n", vectors[i][7]);
+ }
+ if (hash32 != vectors_32[i]) {
+ failed++;
+ printf( "Error in 32 bit result on test vector of length %d for siphash13\n"
+ " have: 0x%08x\n"
+ " want: 0x%08x\n",
+ i, hash32, vectors_32[i]);
+ }
+ }
+ RETVAL= failed;
+ }
+ OUTPUT:
+ RETVAL
+
+#endif