diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2000-07-14 01:33:59 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-07-14 01:33:59 +0000 |
commit | 78ae23f54fc4e301b66d2a32897cb42fa2633fe7 (patch) | |
tree | b9bd015bb6285c390cd910dbc545ec51d10dda05 /toke.c | |
parent | f42afb37e0361ff1bd23d58d09717867356f062c (diff) | |
download | perl-78ae23f54fc4e301b66d2a32897cb42fa2633fe7.tar.gz |
Fix the BOM bug: not a byteorder bug, a signedness bug.
p4raw-id: //depot/cfgperl@6394
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -7406,20 +7406,20 @@ Perl_yyerror(pTHX_ char *s) STATIC char* -S_swallow_bom(pTHX_ char *s) { +S_swallow_bom(pTHX_ U8 *s) { STRLEN slen; slen = SvCUR(PL_linestr); switch (*s) { - case -1: - if ((s[1] & 255) == 254) { + case 0xFF: + if (s[1] == 0xFE) { /* UTF-16 little-endian */ #ifdef PERL_UTF16_FILTER U8 *news; #endif - s+=2; - if (*s == 0 && s[1] == 0) /* UTF-32 little-endian */ + if (s[2] == 0 && s[3] == 0) /* UTF-32 little-endian */ Perl_croak(aTHX_ "Unsupported script encoding"); #ifdef PERL_UTF16_FILTER + s+=2; filter_add(S_utf16rev_textfilter, NULL); New(898, news, (PL_bufend - s) * 3 / 2 + 1, U8); PL_bufend = utf16_to_utf8((U16*)s, news, PL_bufend - s); @@ -7430,8 +7430,8 @@ S_swallow_bom(pTHX_ char *s) { } break; - case -2: - if ((s[1] & 255) == 255) { /* UTF-16 big-endian */ + case 0xFE: + if (s[1] == 0xFF) { /* UTF-16 big-endian */ #ifdef PERL_UTF16_FILTER U8 *news; filter_add(S_utf16_textfilter, NULL); @@ -7444,14 +7444,14 @@ S_swallow_bom(pTHX_ char *s) { } break; - case -17: - if ( slen>2 && (s[1] & 255) == 187 && (s[2] & 255) == 191) { + case 0xEF: + if (slen > 2 && s[1] == 0xBB && s[2] == 0xBF) { s+=3; /* UTF-8 */ } break; case 0: if (slen > 3 && s[1] == 0 && /* UTF-32 big-endian */ - s[2] & 255 == 254 && s[3] & 255 == 255) + s[2] == 0xFE && s[3] == 0xFF) Perl_croak(aTHX_ "Unsupported script encoding"); } return s; |