From: Jarkko Hietaniemi Date: Fri, 24 Nov 2000 03:07:01 +0000 (+0000) Subject: Integrate perlio: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d373e9d2eeca87d7e435472cf5e672954238d0dc;p=p5sagit%2Fp5-mst-13.2.git Integrate perlio: [ 7844] Win32/perlio Now just fails one io/argv.t test - lack of default :crlf on standard streams. [ 7843] Win32 passes all but t/lib/peek.t with perlio and home-grown crlf. peek fail is showing a real problem (multiple crlf layers are getting pushed.) [ 7842] Implement PerlIO_binmode() Fix PerlIOCrlf_unread() (*--ptr rather than *ptr-- ...) Test on UNIX with PERLIO="perlio crlf" to mimic Win32, make binmode in t/lib/io_tell.t unconditional so that works. Checkin just so Win32 machine can see these changes. [ 7836] Implement crlf layer - not ready for merge. p4raw-link: @7844 on //depot/perlio: de6cd452fde5aaf57e339f71b33b6a0852f0f96d p4raw-link: @7843 on //depot/perlio: 63dbdb066b93ac25a070d3a7942d248c23ec6088 p4raw-link: @7842 on //depot/perlio: 60382766f71ec2a2d8e34a951c5c77b494bd86bb p4raw-link: @7836 on //depot/perlio: 99efab1281ccea6f7df2a4d0affc5479291e2350 p4raw-id: //depot/perl@7847 --- d373e9d2eeca87d7e435472cf5e672954238d0dc diff --cc doio.c index 6cc238a,0da9856..a3a401f --- a/doio.c +++ b/doio.c @@@ -2078,16 -2058,16 +2047,21 @@@ Perl_do_shmio(pTHX_ I32 optype, SV **ma ** without checking the ungetc buffer. **/ ++/* Not threadsafe? */ static S64_IOB *s64_buffer = (S64_IOB *) NULL; /* initialize the buffer area */ /* required after a fork(2) call in order to remove side effects */ --void Perl_do_s64_init_buffer() { ++void ++Perl_do_s64_init_buffer(void) ++{ s64_buffer = (S64_IOB *) NULL; } /* get a buffered stream pointer */ - static S64_IOB *S_s64_get_buffer(pTHX_ PerlIO *fp) { -static S64_IOB *S_s64_get_buffer( PerlIO *fp) { ++STATIC S64_IOB* ++S_s64_get_buffer(pTHX_ PerlIO *fp) ++{ S64_IOB *ptr = s64_buffer; while( ptr && ptr->fp != fp) ptr = ptr->next; @@@ -2095,7 -2075,7 +2069,9 @@@ } /* create a buffered stream pointer */ - static S64_IOB *S_s64_create_buffer(pTHX_ PerlIO *f) { -static S64_IOB *S_s64_create_buffer( PerlIO *f) { ++STATIC S64_IOB* ++S_s64_create_buffer(pTHX_ PerlIO *f) ++{ S64_IOB *ptr = malloc( sizeof( S64_IOB)); if( ptr) { ptr->fp = f; @@@ -2110,8 -2090,8 +2086,10 @@@ } /* delete a buffered stream pointer */ - void Perl_do_s64_delete_buffer(pTHX_ PerlIO *f) { -void Perl_do_s64_delete_buffer( PerlIO *f) { - S64_IOB *ptr = _s64_get_buffer(f); ++void ++Perl_do_s64_delete_buffer(pTHX_ PerlIO *f) ++{ + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) { /* fix the stream pointer according to the bytes buffered */ /* required, if this is called in a seek-context */ @@@ -2126,21 -2106,21 +2104,26 @@@ } /* internal buffer management */ --#define _S64_BUFFER_SIZE 32 - static int S_s64_malloc(pTHX_ S64_IOB *ptr) { -static int S_s64_malloc( S64_IOB *ptr) { ++ ++#define S64_BUFFER_SIZE 32 ++ ++STATIC int ++S_s64_malloc(pTHX_ S64_IOB *ptr) ++{ if( ptr) { if( !ptr->buffer) { -- ptr->buffer = (int *) calloc( _S64_BUFFER_SIZE, sizeof( int)); ++ ptr->buffer = (int *) calloc( S64_BUFFER_SIZE, sizeof( int)); ptr->size = ptr->cnt = 0; } else { -- ptr->buffer = (int *) realloc( ptr->buffer, ptr->size + _S64_BUFFER_SIZE); ++ ptr->buffer = (int *) realloc( ptr->buffer, ++ ptr->size + S64_BUFFER_SIZE); } if( !ptr->buffer) return( 0); -- ptr->size += _S64_BUFFER_SIZE; - ++ ptr->size += S64_BUFFER_SIZE; + return( 1); } @@@ -2148,33 -2128,33 +2131,39 @@@ } /* SOCKS 64 bit getc replacement */ - int Perl_do_s64_getc(pTHX_ PerlIO *f) { -int Perl_do_s64_getc( PerlIO *f) { - S64_IOB *ptr = _s64_get_buffer(f); ++int ++Perl_do_s64_getc(pTHX_ PerlIO *f) ++{ + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) { - if( ptr->cnt) + if( ptr->cnt) return( ptr->buffer[--ptr->cnt]); } return( getc(f)); } /* SOCKS 64 bit ungetc replacement */ - int Perl_do_s64_ungetc(pTHX_ int ch, PerlIO *f) { -int Perl_do_s64_ungetc( int ch, PerlIO *f) { - S64_IOB *ptr = _s64_get_buffer(f); ++int ++Perl_do_s64_ungetc(pTHX_ int ch, PerlIO *f) ++{ + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); - if( !ptr) ptr=_s64_create_buffer(f); + if( !ptr) ptr = S_s64_create_buffer(aTHX_ f); if( !ptr) return( EOF); - if( !ptr->buffer || (ptr->buffer && ptr->cnt >= ptr->size)) + if( !ptr->buffer || (ptr->buffer && ptr->cnt >= ptr->size)) - if( !_s64_malloc( ptr)) return( EOF); + if( !S_s64_malloc(aTHX_ ptr)) return( EOF); ptr->buffer[ptr->cnt++] = ch; return( ch); } /* SOCKS 64 bit fread replacement */ - SSize_t Perl_do_s64_fread(pTHX_ void *buf, SSize_t count, PerlIO* f) { -SSize_t Perl_do_s64_fread(void *buf, SSize_t count, PerlIO* f) { ++SSize_t ++Perl_do_s64_fread(pTHX_ void *buf, SSize_t count, PerlIO* f) ++{ SSize_t len = 0; char *bufptr = (char *) buf; - S64_IOB *ptr = _s64_get_buffer(f); + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) { while( ptr->cnt && count) { *bufptr++ = ptr->buffer[--ptr->cnt]; @@@ -2188,8 -2168,8 +2177,10 @@@ } /* SOCKS 64 bit fseek replacement */ - int Perl_do_s64_seek(pTHX_ PerlIO* f, Off_t offset, int whence) { -int Perl_do_s64_seek(PerlIO* f, Off_t offset, int whence) { - S64_IOB *ptr = _s64_get_buffer(f); ++int ++Perl_do_s64_seek(pTHX_ PerlIO* f, Off_t offset, int whence) ++{ + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); /* Simply clear the buffer and seek if the position is absolute */ if( SEEK_SET == whence || SEEK_END == whence) { @@@ -2210,12 -2190,12 +2201,15 @@@ } /* SOCKS 64 bit ftell replacement */ - Off_t Perl_do_s64_tell(pTHX_ PerlIO* f) { -Off_t Perl_do_s64_tell(PerlIO* f) { ++Off_t ++Perl_do_s64_tell(pTHX_ PerlIO* f) ++{ Off_t offset = 0; - S64_IOB *ptr = _s64_get_buffer(f); + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) offset = ptr->cnt; return( ftello(f) - offset); } --#endif ++#endif /* SOCKS_64BIT_BUG */ ++