diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-12-22 15:11:17 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-12-22 15:11:17 +0000 |
commit | a0d1d361c93b39102154ecff3ddb8a1be74034b8 (patch) | |
tree | dfaebc9b3aeb99aeff08a4362dbd216eee3438cc /perlio.c | |
parent | ba7abf9d1538e18db741ea51e49e01e9ac1ea8a2 (diff) | |
download | perl-a0d1d361c93b39102154ecff3ddb8a1be74034b8.tar.gz |
The CR at EOF fix earlier broke CR at end-of-buffer.
This should be okay for both?
p4raw-id: //depot/perlio@13848
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -3520,11 +3520,13 @@ PerlIOCrlf_get_cnt(pTHX_ PerlIO *f) /* * Blast - found CR as last char in buffer */ + if (b->ptr < nl) { /* * They may not care, defer work as long as * possible */ + c->nl = nl; return (nl - b->ptr); } else { @@ -3545,6 +3547,7 @@ PerlIOCrlf_get_cnt(pTHX_ PerlIO *f) /* * CR at EOF - just fall through */ + /* Should we clear EOF though ??? */ } } } @@ -3563,12 +3566,15 @@ PerlIOCrlf_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt) if (!b->buf) PerlIO_get_base(f); if (!ptr) { - if (c->nl) + if (c->nl) { ptr = c->nl + 1; + if (ptr == b->end && *c->nl == 0xd) { + /* Defered CR at end of buffer case - we lied about count */ + ptr--; + } + } else { ptr = b->end; - if ((flags & PERLIO_F_CRLF) && ptr > b->buf && ptr[-1] == 0xd) - ptr--; } ptr -= cnt; } @@ -3577,10 +3583,14 @@ PerlIOCrlf_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt) * Test code - delete when it works ... */ STDCHAR *chk = (c->nl) ? (c->nl+1) : b->end; + if (ptr+cnt == c->nl && c->nl+1 == b->end && *c->nl == 0xd) { + /* Defered CR at end of buffer case - we lied about count */ + chk--; + } chk -= cnt; - if (ptr != chk) { - Perl_croak(aTHX_ "ptr wrong %p != %p fl=%08" UVxf + if (ptr != chk ) { + Perl_warn(aTHX_ "ptr wrong %p != %p fl=%08" UVxf " nl=%p e=%p for %d", ptr, chk, flags, c->nl, b->end, cnt); } |