From: Gurusamy Sarathy Date: Thu, 30 Dec 1999 19:35:07 +0000 (+0000) Subject: leave DATA open in binmode if __END__ line doesn't have CRLF X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53129d29569a85455957955379fd49abdaaf8185;p=p5sagit%2Fp5-mst-13.2.git leave DATA open in binmode if __END__ line doesn't have CRLF p4raw-id: //depot/perl@4740 --- diff --git a/pod/perldelta.pod b/pod/perldelta.pod index d070aa2..47f7c26 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -1045,7 +1045,10 @@ has been added. Scripts are read in binary mode by default to allow ByteLoader (and the filter mechanism in general) to work properly. For compatibility, -the DATA filehandle continues to be set to text mode. +the DATA filehandle will be set to text mode if a carriage return is +detected at the end of the line containing the __END__ or __DATA__ +token; if not, the DATA filehandle will be left open in binary mode. +Earlier versions always opened the DATA filehandle in text mode. [TODO - GSAR] diff --git a/toke.c b/toke.c index da3c7fd..f35a042 100644 --- a/toke.c +++ b/toke.c @@ -3808,8 +3808,10 @@ Perl_yylex(pTHX) IoTYPE(GvIOp(gv)) = '<'; #if defined(WIN32) && !defined(PERL_TEXTMODE_SCRIPTS) /* if the script was opened in binmode, we need to revert - * it to text mode for compatibility. + * it to text mode for compatibility; but only iff it has CRs * XXX this is a questionable hack at best. */ + if (PL_bufend-PL_bufptr > 2 + && PL_bufend[-1] == '\n' && PL_bufend[-2] == '\r') { Off_t loc = 0; if (IoTYPE(GvIOp(gv)) == '<') {