From 6574067b725d7acc74cd98a7f15a78680f066211 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Thu, 5 Feb 2009 15:47:42 +0000 Subject: [PATCH] Fix SF#2564192 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11110 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/perl5/char_strings_runme.pl | 5 ++++- Lib/perl5/perlstrings.swg | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) 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);