summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/XS-APItest/APItest.xs13
-rw-r--r--handy.h7
2 files changed, 14 insertions, 6 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 5dc1b27635..99a3957e6c 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -2312,6 +2312,7 @@ PREINIT:
I32 retcnt;
SV * errsv;
char * errstr;
+ STRLEN errlen;
SV * miscsv = sv_newmortal();
HV * hv = (HV*)sv_2mortal((SV*)newHV());
CODE:
@@ -2345,8 +2346,8 @@ CODE:
SPAGAIN;
SP -= retcnt;
errsv = ERRSV;
- errstr = SvPV_nolen(errsv);
- if(strBEGINs(errstr, "Undefined subroutine &main:: called at")) {
+ 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;
@@ -2357,8 +2358,8 @@ CODE:
SPAGAIN;
SP -= retcnt;
errsv = ERRSV;
- errstr = SvPV_nolen(errsv);
- if(strBEGINs(errstr, "Can't use an undefined value as a subroutine reference at")) {
+ 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;
@@ -2369,8 +2370,8 @@ CODE:
SPAGAIN;
SP -= retcnt;
errsv = ERRSV;
- errstr = SvPV_nolen(errsv);
- if(strBEGINs(errstr, "Not a CODE reference at")) {
+ 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;
diff --git a/handy.h b/handy.h
index d4a8aaaf3b..06db1e25a6 100644
--- a/handy.h
+++ b/handy.h
@@ -492,6 +492,13 @@ Returns zero if non-equal, or non-zero if equal.
(memEQ((s1), ("" s2 ""), (sizeof(s2)-1)))
#define _memNEs(s1, s2) (memNE((s1),("" s2 ""),(sizeof(s2)-1)))
+#define memBEGINs(s1, l, s2) \
+ ( (l) >= sizeof(s2) - 1 \
+ && memEQ(s1, "" s2 "", sizeof(s2)-1))
+#define memENDs(s1, l, s2) \
+ ( (l) >= sizeof(s2) - 1 \
+ && memEQ(s1 + (l) - (sizeof(s2) - 1), "" s2 "", sizeof(s2)-1))
+
#define memLT(s1,s2,l) (memcmp(s1,s2,l) < 0)
#define memLE(s1,s2,l) (memcmp(s1,s2,l) <= 0)
#define memGT(s1,s2,l) (memcmp(s1,s2,l) > 0)