summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-04-19 13:11:40 -0600
committerKarl Williamson <khw@cpan.org>2019-04-20 00:37:35 -0600
commite28192fdcb19f10a7d2e4a2957906771b0e63f54 (patch)
treeda338032fb72363fb0741411e09f29b9a3e40671 /dist
parentf2e3e4cea216e41aacb94169005f2224fa7ad288 (diff)
downloadperl-e28192fdcb19f10a7d2e4a2957906771b0e63f54.tar.gz
Provide my_strnlen()
This is needed for a future feature
Diffstat (limited to 'dist')
-rw-r--r--dist/Devel-PPPort/Changes1
-rw-r--r--dist/Devel-PPPort/parts/inc/uv34
-rw-r--r--dist/Devel-PPPort/t/uv.t5
3 files changed, 37 insertions, 3 deletions
diff --git a/dist/Devel-PPPort/Changes b/dist/Devel-PPPort/Changes
index b04a12b6b6..733354538c 100644
--- a/dist/Devel-PPPort/Changes
+++ b/dist/Devel-PPPort/Changes
@@ -21,6 +21,7 @@
* Provide av_tindex/av_top_index
* Provide __ASSERT_ for assertions inside macros
* Provide UTF8_SAFE_SKIP
+ * Provide my_strnlen()
3.45 - 2019-03-19
diff --git a/dist/Devel-PPPort/parts/inc/uv b/dist/Devel-PPPort/parts/inc/uv
index fa2583d543..c94f03c6fc 100644
--- a/dist/Devel-PPPort/parts/inc/uv
+++ b/dist/Devel-PPPort/parts/inc/uv
@@ -12,6 +12,7 @@
=provides
__UNDEFINED__
+my_strnlen
SvUOK
=implementation
@@ -57,6 +58,27 @@ __UNDEFINED__ UTF8_SAFE_SKIP(s, e) (__ASSERT_((e) >= (s))
: UTF8SKIP(s))
#endif
+#if !defined(my_strnlen)
+#if { NEED my_strnlen }
+
+STRLEN
+my_strnlen(const char *str, Size_t maxlen)
+{
+ const char *p = str;
+
+ while(maxlen-- && *p)
+ p++;
+
+ return p - str;
+}
+
+#endif
+#endif
+
+=xsinit
+
+#define NEED_my_strnlen
+
=xsubs
SV *
@@ -127,7 +149,16 @@ UTF8_SAFE_SKIP(s, adjustment)
OUTPUT:
RETVAL
-=tests plan => 12
+STRLEN
+my_strnlen(s, max)
+ char * s
+ STRLEN max
+ CODE:
+ RETVAL= my_strnlen(s, max);
+ OUTPUT:
+ RETVAL
+
+=tests plan => 13
ok(&Devel::PPPort::sv_setuv(42), 42);
ok(&Devel::PPPort::newSVuv(123), 123);
@@ -141,3 +172,4 @@ ok(&Devel::PPPort::PUSHu(), 42);
ok(&Devel::PPPort::XPUSHu(), 43);
ok(&Devel::PPPort::UTF8_SAFE_SKIP("A", 0), 1);
ok(&Devel::PPPort::UTF8_SAFE_SKIP("A", -1), 0);
+ok(&Devel::PPPort::my_strnlen("abc\0def", 7), 3);
diff --git a/dist/Devel-PPPort/t/uv.t b/dist/Devel-PPPort/t/uv.t
index 4661b3eabf..7f8a20dbda 100644
--- a/dist/Devel-PPPort/t/uv.t
+++ b/dist/Devel-PPPort/t/uv.t
@@ -30,9 +30,9 @@ BEGIN {
require 'testutil.pl' if $@;
}
- if (12) {
+ if (13) {
load();
- plan(tests => 12);
+ plan(tests => 13);
}
}
@@ -60,4 +60,5 @@ ok(&Devel::PPPort::PUSHu(), 42);
ok(&Devel::PPPort::XPUSHu(), 43);
ok(&Devel::PPPort::UTF8_SAFE_SKIP("A", 0), 1);
ok(&Devel::PPPort::UTF8_SAFE_SKIP("A", -1), 0);
+ok(&Devel::PPPort::my_strnlen("abc\0def", 7), 3);