#183 [perl] fixed perlstrings.swg to use sv_setpvn()

closed-accepted
nobody
None
5
2007-09-17
2007-06-28
matsubaray
No

cdata() fails to retrieve the data containing \x00 (null character) when used in perl5.

I attached a test case and a patch for this problem.
It works for me and passed check-perl5-test-suite as well as the original sources.

This patch contains:
- correction of Lib/perl5/perlstrings.swg
- a test case
- Examples/test-suite/li_cdata_carrays.i
- Examples/test-suite/perl5/li_cdata_carrays_runme.pl
- modification of Examples/test-suite/perl5/Makefile.in

Originally suggested in
https://sourceforge.net/tracker/index.php?func=detail&aid=1737640&group_id=1645&atid=301645
> binary data cannot be used in perlstrings.swg
> SWIG_FromCharPtrAndSize().
> I believe the block
>
> if (carray[size - 1] == 0) {
> sv_setpv(obj, carray);
> } else {
> char *tmp = %new_array(size + 1, char);
> memcpy(tmp, carray, size);
> tmp[size] = 0;
> sv_setpv(obj, tmp);
> %delete_array(tmp);
> }
>
> should be substituted by
>
> sv_setpvn(obj, carray, size);

Discussion

  • matsubaray

    matsubaray - 2007-06-28

    patch to svn revision 9859

     
  • Olly Betts

    Olly Betts - 2007-09-17

    Logged In: YES
    user_id=14972
    Originator: NO

    Thanks for the fix and testcases - I've applied these to SVN HEAD.

     
  • Olly Betts

    Olly Betts - 2007-09-17
    • status: open --> closed-accepted
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks