Greets,

I've just gotten an RT ticket for my CPAN distribution Sort::External, a mostly-perl module with a couple functions in XS. The XS fails to compile "for perl v5.8.2 built for i386-freebsd." Looking at the errors thrown by make, I'm at a bit of a loss.

bash-2.05b# make
cc -c -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN" - DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/ local/include -O -pipe -march=pentiumpro -DVERSION=\"0.12\" - DXS_VERSION=\"0.12\" -DPIC -fPIC "-I/usr/local/lib/perl5/5.8.2/mach/ CORE" External.c
External.xs: In function `XS_Sort__External__print_to_sortfile':
External.xs:58: syntax error before `char'
External.xs:61: `encoded_len' undeclared (first use in this function)
External.xs:61: (Each undeclared identifier is reported only once
External.xs:61: for each function it appears in.)
External.xs: In function `XS_Sort__External__Buffer__refill_buffer':
External.xs:91: syntax error before `char'
External.xs:104: `amount_read' undeclared (first use in this function)
External.xs:108: `item_length' undeclared (first use in this function)
External.xs:110: `check' undeclared (first use in this function)
External.xs:110: `read_buf' undeclared (first use in this function)
External.xs:142: `num_items' undeclared (first use in this function)
*** Error code 1

Stop in /usr/local/src/Search-Kinosearch-0.021/Sort-External-0.12.

The line in question is a declaration, preceded by an SvPV macro.

        aUV        = string_len;
        string     = SvPV(thing_sv, string_len);

        char* encoded_len = end_of_buf;     /* <-- line 58 */

(The full function is below, for reference.) Now, what could be causing a syntax error in the .xs file there?

The second "syntax error" is another declaration, this time following a New macro, and baffles me for the same reasons. Is this a ppport.h problem? or ??

Thanks,

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/

#------------------------------------------------------

SV*
_print_to_sortfile (...)
PPCODE:
{
    /* get the filehandle we'll print to */
    SV* fh_sv_ref = ST(0);
    PerlIO* fh    = IoOFP( sv_2io(fh_sv_ref) );

    int i, check;
    SV* thing_sv;
    char* string;
    STRLEN string_len;
    UV aUV;
    char  buf[(sizeof(UV)*8)/7 + 1];
    char* end_of_buf = buf + sizeof(buf);


    /* encode len as a BER integer, print len . string */
    for (i = 1; i < items; i++) {
        thing_sv   = ST(i);
        string_len = SvCUR(thing_sv);
        aUV        = string_len;
        string     = SvPV(thing_sv, string_len);

        char* encoded_len = end_of_buf;

        do {
            *--encoded_len = (char)((aUV & 0x7f) | 0x80);
            aUV >>= 7;
        } while (aUV);
        *(end_of_buf - 1) &= 0x7f;

check = PerlIO_write(fh, encoded_len, (end_of_buf - encoded_len));
        check_io_error(check);
        check = PerlIO_write(fh, string, string_len);
        check_io_error(check);
    }
}




Reply via email to