diff --git a/builtin.c b/builtin.c index a52a22f6fa86..72860b5a60cb 100644 --- a/builtin.c +++ b/builtin.c @@ -285,7 +285,7 @@ XS(XS_builtin_trim) Copy(start, SvPVX(dest), len, U8); SvPVX(dest)[len] = '\0'; - SvPOK_on(dest); + SvPOK_only_UTF8(dest); SvCUR_set(dest, len); if (DO_UTF8(source)) diff --git a/lib/builtin.pm b/lib/builtin.pm index 5d80564e0c32..51010d5b6222 100644 --- a/lib/builtin.pm +++ b/lib/builtin.pm @@ -1,4 +1,4 @@ -package builtin 0.016; +package builtin 0.017; use v5.40; diff --git a/lib/builtin.t b/lib/builtin.t index c4b26ee3640b..8e0d8f152784 100644 --- a/lib/builtin.t +++ b/lib/builtin.t @@ -669,6 +669,14 @@ EOS } } +# github #22784 +{ + use builtin qw( trim ); + sub f { 0+trim($_[0]) } + is(f(4), 4, "populate TARG.iv"); + is(f(123), 123, "check TARG.IOK is reset properly"); +} + # vim: tabstop=4 shiftwidth=4 expandtab autoindent softtabstop=4 done_testing();