diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-05-30 14:40:11 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-05-30 14:40:11 +0000 |
commit | 313e59c8f773fc5f3cb2659752fdcf7e00b2ec27 (patch) | |
tree | c822f6f54198a6766d4776e3f01efb81f88314e0 /perlio.c | |
parent | 263e6544cd19da603ae491527de0a534296ee280 (diff) | |
download | perl-313e59c8f773fc5f3cb2659752fdcf7e00b2ec27.tar.gz |
Play safe and avoid writes to stdio's buffer (for glibc2.3)
p4raw-id: //depot/perlio@16895
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -2388,6 +2388,14 @@ PerlIO_funcs PerlIO_unix = { * stdio as a layer */ +#if defined(VMS) && !defined(STDIO_BUFFER_WRITABLE) +/* perl5.8 - This ensures the last minute VMS ungetc fix is not + broken by the last second glibc 2.3 fix + */ +#define STDIO_BUFFER_WRITABLE +#endif + + typedef struct { struct _PerlIO base; FILE *stdio; /* The stream */ @@ -2639,6 +2647,7 @@ PerlIOStdio_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count) SSize_t unread = 0; FILE *s = PerlIOSelf(f, PerlIOStdio)->stdio; +#ifdef STDIO_BUFFER_WRITABLE if (PerlIO_fast_gets(f) && PerlIO_has_base(f)) { STDCHAR *buf = ((STDCHAR *) vbuf) + count; STDCHAR *base = PerlIO_get_base(f); @@ -2658,7 +2667,9 @@ PerlIOStdio_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count) PerlSIO_clearerr(s); } } - else if (PerlIO_has_cntptr(f)) { + else +#endif + if (PerlIO_has_cntptr(f)) { /* We can get pointer to buffer but not its base Do ungetc() but check chars are ending up in the buffer @@ -2852,6 +2863,8 @@ PerlIOStdio_fill(pTHX_ PerlIO *f) return EOF; #if (defined(STDIO_PTR_LVALUE) && (defined(STDIO_CNT_LVALUE) || defined(STDIO_PTR_LVAL_SETS_CNT))) + +#ifdef STDIO_BUFFER_WRITABLE if (PerlIO_fast_gets(f) && PerlIO_has_base(f)) { /* Fake ungetc() to the real buffer in case system's ungetc goes elsewhere @@ -2867,7 +2880,9 @@ PerlIOStdio_fill(pTHX_ PerlIO *f) return 0; } } - else if (PerlIO_has_cntptr(f)) { + else +#endif + if (PerlIO_has_cntptr(f)) { STDCHAR ch = c; if (PerlIOStdio_unread(aTHX_ f,&ch,1) == 1) { return 0; |