develooper Front page | perl.perl5.changes | Postings from September 2021

[Perl/perl5] 7731dc: APItest.xs: remove unneeded SvPV_force_nolen()

iabyn via perl5-changes
September 10, 2021 09:16
[Perl/perl5] 7731dc: APItest.xs: remove unneeded SvPV_force_nolen()
Message ID:
  Branch: refs/heads/blead
  Commit: 7731dc3c70b99105f6680e0e6d3f6f3242fda941
  Author: David Mitchell <>
  Date:   2021-09-10 (Fri, 10 Sep 2021)

  Changed paths:
    M ext/XS-APItest/APItest.xs

  Log Message:
  APItest.xs: remove unneeded SvPV_force_nolen()

The two API test wrappers utf16_to_utf8_reversed() and
utf8_to_utf16(_reversed() included a call to SvPV_force_nolen(), because
the underlying functions in utf8.c which they were wrapping used to
modify the src buffer.

However since v5.35.2-236-g5fd26678bf, these functions no longer modify
the buffer, so the force is superfluous. So this commit removes force.

As a side-effect, this fixes a failure in

    cd t; ./TEST -deparse ../ext/XS-APItest/t/utf16_to_utf8.t

because the test file has this line:

    $utf16_of_U10302 = utf8_to_utf16_reversed(chr 0x10302);

which after a round trip through deparse becomes:

    $utf16_of_U10302 = utf8_to_utf16_reversed("\x{10302}");

and it so happens that at compile time, the chr() form gets constant-
folded into a modifiable PADTMP string constant, which survives a call
to  SvPV_force(), while the latter form is a pure read-only constant SV
which croaks with "Modification of a read-only value attempted" Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About