X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perlio.c;h=969b8d1c6d24062beaf2c00e72cab59972d9c283;hb=a6c71b5b9462db13c7bb2cd263cee5995315784c;hp=a2e979ab6fe464e7e2bfc92f8cb717634aa6ef6e;hpb=961e40eebbdecbc4e587e5c0fd92623798217256;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perlio.c b/perlio.c index a2e979a..969b8d1 100644 --- a/perlio.c +++ b/perlio.c @@ -1,16 +1,19 @@ /* perlio.c * - * Copyright (c) 1996-1999, Nick Ing-Simmons + * Copyright (c) 1996-2000, Nick Ing-Simmons * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. * */ -#if !defined(PERL_IMPLICIT_SYS) #define VOIDUSED 1 -#include "config.h" +#ifdef PERL_MICRO +# include "uconfig.h" +#else +# include "config.h" +#endif #define PERLIO_NOT_STDIO 0 #if !defined(PERLIO_IS_STDIO) && !defined(USE_SFIO) @@ -26,6 +29,8 @@ #define PERL_IN_PERLIO_C #include "perl.h" +#if !defined(PERL_IMPLICIT_SYS) + #ifdef PERLIO_IS_STDIO void @@ -157,8 +162,8 @@ PerlIO_set_cnt(PerlIO *f, int cnt) void PerlIO_set_ptrcnt(PerlIO *f, STDCHAR *ptr, int cnt) { -#ifdef FILE_bufsiz dTHX; +#ifdef FILE_bufsiz STDCHAR *e = FILE_base(f) + FILE_bufsiz(f); int ec = e - ptr; if (ptr > e + 1 && ckWARN_d(WARN_INTERNAL)) @@ -167,16 +172,18 @@ PerlIO_set_ptrcnt(PerlIO *f, STDCHAR *ptr, int cnt) Perl_warner(aTHX_ WARN_INTERNAL, "Setting cnt to %d, ptr implies %d\n",cnt,ec); #endif #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) - FILE_ptr(f) = ptr; + FILE_ptr(f) = ptr; #else - dTHX; - Perl_croak(aTHX_ "Cannot set 'ptr' of FILE * on this system"); + Perl_croak(aTHX_ "Cannot set 'ptr' of FILE * on this system"); #endif -#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE) - FILE_cnt(f) = cnt; +#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE) && defined (STDIO_PTR_LVAL_NOCHANGE_CNT) + FILE_cnt(f) = cnt; #else - dTHX; - Perl_croak(aTHX_ "Cannot set 'cnt' of FILE * on this system"); +#if defined(STDIO_PTR_LVAL_SETS_CNT) + assert (FILE_cnt(f) == cnt); +#else + Perl_croak(aTHX_ "Cannot set 'cnt' of FILE * on this system when setting 'ptr'"); +#endif #endif } @@ -387,7 +394,7 @@ PerlIO_vprintf(PerlIO *f, const char *fmt, va_list ap) Off_t PerlIO_tell(PerlIO *f) { -#ifdef HAS_FTELLO +#if defined(USE_64_BIT_STDIO) && defined(HAS_FTELLO) && !defined(USE_FTELL64) return ftello(f); #else return ftell(f); @@ -398,7 +405,7 @@ PerlIO_tell(PerlIO *f) int PerlIO_seek(PerlIO *f, Off_t offset, int whence) { -#ifdef HAS_FSEEKO +#if defined(USE_64_BIT_STDIO) && defined(HAS_FSEEKO) && !defined(USE_FSEEK64) return fseeko(f,offset,whence); #else return fseek(f,offset,whence); @@ -496,7 +503,11 @@ PerlIO_setpos(PerlIO *f, const Fpos_t *pos) int PerlIO_setpos(PerlIO *f, const Fpos_t *pos) { +#if defined(USE_64_BIT_STDIO) && defined(USE_FSETPOS64) + return fsetpos64(f, pos); +#else return fsetpos(f, pos); +#endif } #endif #endif @@ -515,7 +526,11 @@ PerlIO_getpos(PerlIO *f, Fpos_t *pos) int PerlIO_getpos(PerlIO *f, Fpos_t *pos) { +#if defined(USE_64_BIT_STDIO) && defined(USE_FSETPOS64) + return fgetpos64(f, pos); +#else return fgetpos(f, pos); +#endif } #endif #endif @@ -547,11 +562,9 @@ PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap) { if (strlen(s) >= (STRLEN)n) { - PerlIO_puts(PerlIO_stderr(),"panic: sprintf overflow - memory corrupted!\n"); - { - dTHX; - my_exit(1); - } + dTHX; + PerlIO_puts(Perl_error_log,"panic: sprintf overflow - memory corrupted!\n"); + my_exit(1); } } return val;