p4raw-id: //depot/perl@4740
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]
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)) == '<') {