diff --git a/CHANGES.current b/CHANGES.current index ab3c00452..cadf4ba36 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,3 +1,6 @@ Version 1.3.39 (in progress) ============================ +2009-02-04: talby + [Perl] Fix SF#2564192 reported by David Kolovratnk. + SWIG_AsCharPtrAndSize() now handles "get" magic. diff --git a/Examples/test-suite/perl5/char_strings_runme.pl b/Examples/test-suite/perl5/char_strings_runme.pl index 51c227bb9..c4573737e 100644 --- a/Examples/test-suite/perl5/char_strings_runme.pl +++ b/Examples/test-suite/perl5/char_strings_runme.pl @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 5; BEGIN { use_ok('char_strings') } require_ok('char_strings'); @@ -10,3 +10,6 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1'); my $val2 = "greetings"; is(char_strings::CharPingPong($val2), "greetings", 'cstr2'); +# SF#2564192 +"this is a test" =~ /(\w+)$/; +is(char_strings::CharPingPong($1), "test", "handles Magical"); diff --git a/Lib/perl5/perlstrings.swg b/Lib/perl5/perlstrings.swg index 2083f0bba..242a9c967 100644 --- a/Lib/perl5/perlstrings.swg +++ b/Lib/perl5/perlstrings.swg @@ -6,6 +6,11 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) { + if (SvMAGICAL(obj)) { + SV *tmp = sv_newmortal(); + SvSetSV(tmp, obj); + obj = tmp; + } if (SvPOK(obj)) { STRLEN len = 0; char *cstr = SvPV(obj, len);