I'm trying to read from a text file using 'sv_gets()', but all I can get 'sv_gets()' to produce is a segmentation fault. Here's the code:
---------------------------------------- use warnings; use Inline C => <<'EOC';
void readfile (char * filename, int append) { PerlIO * f; SV * line;
if((f = PerlIO_open(filename, "r")) != NULL) { printf("File opened\n"); sv_gets(line, f, append); printf("%s\n", SvPV_nolen(line)); PerlIO_close(f); } else printf("Failure to open file\n"); }
EOC
$file = 'test'; $append = 0; readfile($file, $append); ----------------------------------------------
I've tried other values for $append (including '1', '100', and '1000') as I'm not sure what it's supposed to be. The docs would suggest to me that it's a boolean - true to append and false to not append, I guess. Is that correct ?
Anyway, whatever value I bestow upon $append makes no difference - 'sv_gets()' always produces a segmentation fault. I would like to have the SV* 'line' contain at least some portion of the file 'test'.
What have I failed to realise ?
(Both perl 5.6.1 and perl 5.8.0 with Inline-0.44 on Win2k.)
Cheers, Rob
--
Any emails containing attachments will be deleted from my ISP's mail server before I even get to see them. If you wish to email me an attachment, please provide advance warning so that I can make the necessary arrangements.