From 226017aa9f191225e17de7d54c163349da3c3065 Mon Sep 17 00:00:00 2001 From: David Dyck Date: Fri, 28 Jul 2000 10:19:16 -0700 Subject: [PATCH] Fix for Subject: [ID 20000728.005] perl -P broken Message-Id: <200007290019.RAA08484@dd.tc.fluke.com> (hopefully). The fix is also not complete, it seems to break BOM swallowing for libc5 systems, but until someone figures out a way to do this without ftell(), this will do. p4raw-id: //depot/perl@7570 --- toke.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/toke.c b/toke.c index 64b6925..98ef9b9 100644 --- a/toke.c +++ b/toke.c @@ -2520,8 +2520,26 @@ Perl_yylex(pTHX) goto retry; } do { - bool bof; - bof = PL_rsfp && (PerlIO_tell(PL_rsfp) == 0); /* *Before* read! */ + bool bof = PL_rsfp ? TRUE : FALSE; + if (bof) { +#ifdef PERLIO_IS_STDIO +# ifdef __GLIBC__ +# if __GLIBC__ == 1 /* Linux glibc5 */ +# define FTELL_FOR_PIPE_IS_BROKEN +# endif +# endif +#endif +#ifdef FTELL_FOR_PIPE_IS_BROKEN + /* This loses the possibility to detect the bof + * situation on perl -P when the libc5 is being used. + * Workaround? Maybe attach some extra state to PL_rsfp? + */ + if (!PL_preprocess) + bof = PerlIO_tell(PL_rsfp) == 0; +#else + bof = PerlIO_tell(PL_rsfp) == 0; +#endif + } s = filter_gets(PL_linestr, PL_rsfp, 0); if (s == Nullch) { fake_eof: -- 2.7.4