Sat Apr 20 02:53:07 2013: Request 11748 was acted upon.
Transaction: Correspondence added by iang
       Queue: Inline
     Subject: Inline::CPP config gets lost because of Inline::C bug
   Broken in: (no value)
    Severity: Important
       Owner: Nobody
  Requestors: nick_...@pisem.net
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=11748 >


On Mon Jun 29 19:24:59 2009, SISYPHUS wrote:
> On Fri Mar 04 06:12:48 2005, guest wrote:
> > It had seemed that Inline::CPP ignores INC Config option, but the bug
> >    has been discovered in Inline::C: $o->{ILSM}{MAKEFILE}{INC} gets
> >    erased each time validate() sub is called (sometimes it occurs
> >    several times per script execution).
> 
> A simple script demonstrating the precise problem would be handy, just 
> to make sure that we (I) understand correctly. I'm not sure that the 
> suggested patch is really necessary ... though there's probably no 
> compelling reason to reject it.
> 
> Cheers,
> Rob

I think the fault is in Inline::CPP, not Inline::C. If Inline::CPP generates 
typemap data (if $typemap has non-zero length in Inline::CPP::write_typemap) 
then Inline::CPP::validate is called with the generated TYPEMAP data passed, 
but this calls Inline::C::validate, which sets $o->{ILSM}{MAKEFILE}{INC}, 
unless $o->UNTAINT is set.

A simple script which elicits the problem is as follows. The extra include 
directory is useless, but it is also lost. Sorry, but the real case I was 
working on is a lengthy mess at the moment and I don't know a simple case where 
the extra include is actually needed.

Part of the issue is that when validating TYPEMAP, all the other options are 
not passed to Inlince::C::validate. The initialization there sets INC and the 
previously passed value is not appended because it is not passed, only the 
TYPEMAP is passed.


#!C:/strawberry/perl/bin/perl.exe
#
use strict;
use warnings;
use Inline ('CPP' => 'DATA',
            'INC'   => '-IC:/',
            );

print "9 + 16 = ", add(9, 16), "\n";

__END__
__CPP__

// change 7
int add(int x, int y) {
    return x + y;
}

// Adding the following class causes Inline:CPP to generate
// typemap data which is validated. The validation of the
// typemap data causes the configuration of INC to be lost
// In this case, Inline::C::validate, which is called from
// Inline::CPP::validate, sets $o->{ILSM}{MAKEFILE}{INC}
// unless $o->UNTAINT is set.
class CRectangle {
    int x, y;
    public:
        void set_values(int, int);
        int area() { return(x*y); }
};

void CRectangle::set_values(int a, int b) {
    x = a;
    y = b;
}




Reply via email to