From 3108bccef9188eaf3311b0a5751a3b5750f874f0 Mon Sep 17 00:00:00 2001 From: Sergei Zhmylev Date: Mon, 1 Sep 2025 16:14:32 +0300 Subject: [PATCH] ParseXS: fix space translation for $ntype Variable $ntype is used in T_PACKED and T_PACKEDARRAY AS-IS making impossible to use these typemaps with any types containing spaces, like 'struct Foo'. This commit replaces spaces with underscores. Signed-off-by: Sergei Zhmylev --- dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm | 5 +++-- dist/ExtUtils-ParseXS/lib/perlxstypemap.pod | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm index b1436f2f668b..f7a6126dfa4b 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm @@ -1382,9 +1382,10 @@ sub lookup_input_typemap { my $typemaps = $pxs->{typemaps_object}; - # Normalised type ('Foo *' becomes 'FooPtr): one of the valid vars - # which can appear within a typemap template. + # Normalised type ('struct Foo *' becomes 'struct_FooPtr): one of + # the valid vars which can appear within a typemap template. (my $ntype = $type) =~ s/\s*\*/Ptr/g; + $ntype =~ s/\s/_/g; # $subtype is really just for the T_ARRAY / DO_ARRAY_ELEM code below, # where it's the type of each array element. But it's also passed to diff --git a/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod b/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod index 7d1f73c52558..8ae95d708f6c 100644 --- a/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod +++ b/dist/ExtUtils-ParseXS/lib/perlxstypemap.pod @@ -230,8 +230,9 @@ e.g. for a type of C, I<$type> is C =item * -I<$ntype> - the supplied type with C<*> replaced with C. -e.g. for a type of C, I<$ntype> is C +I<$ntype> - the supplied type with C<*> replaced with C and +C<\s> replaced with C<_>. +e.g. for a type of C, I<$ntype> is C =item *