From: Nick Ing-Simmons Date: Sun, 10 Jun 2001 12:27:51 +0000 (+0000) Subject: Paper over a crack or two with USE_SFIO X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=92bff44d1afc92cdac64a832f4753e65c2d1454b;p=p5sagit%2Fp5-mst-13.2.git Paper over a crack or two with USE_SFIO p4raw-id: //depot/perlio@10497 --- diff --git a/perlio.c b/perlio.c index b415b5a..005e7f8 100644 --- a/perlio.c +++ b/perlio.c @@ -112,7 +112,11 @@ PerlIO_destruct(pTHX) int PerlIO_binmode(pTHX_ PerlIO *fp, int iotype, int mode, const char *names) { +#ifdef USE_SFIO + return 1; +#else return perlsio_binmode(fp,iotype,mode); +#endif } /* De-mux PerlIO_openn() into fdopen, freopen and fopen type entries */ @@ -206,6 +210,28 @@ PerlIO_init(void) sfset(sfstdout,SF_SHARE,0); } +PerlIO * +PerlIO_importFILE(FILE *stdio, int fl) +{ + int fd = fileno(stdio); + PerlIO *r = PerlIO_fdopen(fd,"r+"); + return r; +} + +FILE * +PerlIO_findFILE(PerlIO *pio) +{ + int fd = PerlIO_fileno(pio); + FILE *f = fdopen(fd,"r+"); + PerlIO_flush(pio); + if (!f && errno == EINVAL) + f = fdopen(fd,"w"); + if (!f && errno == EINVAL) + f = fdopen(fd,"r"); + return f; +} + + #else /* USE_SFIO */ /*======================================================================================*/ /* Implement all the PerlIO interface ourselves. @@ -1938,7 +1964,7 @@ PerlIOUnix_write(PerlIO *f, const void *vbuf, Size_t count) IV PerlIOUnix_seek(PerlIO *f, Off_t offset, int whence) { - dSYS; + dSYS; Off_t new = PerlLIO_lseek(PerlIOSelf(f,PerlIOUnix)->fd,offset,whence); PerlIOBase(f)->flags &= ~PERLIO_F_EOF; return (new == (Off_t) -1) ? -1 : 0; diff --git a/perlsfio.h b/perlsfio.h index 0255876..ed7ab97 100644 --- a/perlsfio.h +++ b/perlsfio.h @@ -1,4 +1,7 @@ /* The next #ifdef should be redundant if Configure behaves ... */ +#ifndef FILE +#define FILE FILE +#endif #ifdef I_SFIO #include #endif @@ -47,9 +50,11 @@ extern int _stdprintf _ARG_((const char*, ...)); #define PerlIO_rewind(f) (void) sfseek((f),0L,0) #define PerlIO_tmpfile() sftmp(0) +#if 0 #define PerlIO_importFILE(f,fl) ((void) Perl_croak(aTHX_ "Import from FILE * unimplemeted"), NULL) -#define PerlIO_exportFILE(f,fl) Perl_croak(aTHX_ "Export to FILE * unimplemeted") #define PerlIO_findFILE(f) NULL +#endif +#define PerlIO_exportFILE(f,fl) Perl_croak(aTHX_ "Export to FILE * unimplemeted") #define PerlIO_releaseFILE(p,f) Perl_croak(aTHX_ "Release of FILE * unimplemeted") #define PerlIO_setlinebuf(f) sfset(f,SF_LINE,1)