summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2011-04-13 17:02:39 -0700
committerJan Dubois <jand@activestate.com>2011-04-13 17:03:45 -0700
commit6d51015587940c2032a6533d886163f69ca028f9 (patch)
tree7189b706bdcca169d0860646330ad594a1f7982a /toke.c
parent088225fdf76aeaafa844cf1a058d5c11106522c4 (diff)
downloadperl-6d51015587940c2032a6533d886163f69ca028f9.tar.gz
[perl #88420] BOM support on Windows broken in 5.13.11
When Perl reads the script in text mode, then the tell() position on the script handle may include stripped carriage return characters. Therefore the file position after reading the first line of the script may be one larger than the length of the input buffer.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index c4cda7b324..0f08d42ab4 100644
--- a/toke.c
+++ b/toke.c
@@ -4792,7 +4792,13 @@ Perl_yylex(pTHX)
*(U8*)s == 0xEF ||
*(U8*)s >= 0xFE ||
s[1] == 0)) {
- bof = PerlIO_tell(PL_rsfp) == (Off_t)SvCUR(PL_linestr);
+ IV offset = (IV)PerlIO_tell(PL_rsfp);
+ bof = (offset == SvCUR(PL_linestr));
+#if defined(PERLIO_USING_CRLF) && defined(PERL_TEXTMODE_SCRIPTS)
+ /* offset may include swallowed CR */
+ if (!bof)
+ bof = (offset == SvCUR(PL_linestr)+1);
+#endif
if (bof) {
PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
s = swallow_bom((U8*)s);