Index: src/parsing/scanner-character-streams.cc |
diff --git a/src/parsing/scanner-character-streams.cc b/src/parsing/scanner-character-streams.cc |
index b5e9c171da0561ee81dcdd5be0a388cce419c883..d3162dfbb2263bfd5bcb29a0b85346df3ce4d2c1 100644 |
--- a/src/parsing/scanner-character-streams.cc |
+++ b/src/parsing/scanner-character-streams.cc |
@@ -15,6 +15,10 @@ |
namespace v8 { |
namespace internal { |
+namespace { |
+const unibrow::uchar kUtf8Bom = 0xfeff; |
+} // namespace |
+ |
// ---------------------------------------------------------------------------- |
// BufferedUtf16CharacterStreams |
// |
@@ -263,7 +267,9 @@ bool Utf8ExternalStreamingStream::SkipToPosition(size_t position) { |
while (it < chunk.length && chars < position) { |
unibrow::uchar t = |
unibrow::Utf8::ValueOfIncremental(chunk.data[it], &incomplete_char); |
- if (t != unibrow::Utf8::kIncomplete) { |
+ if (t == kUtf8Bom && current_.pos.chars == 0) { |
+ // BOM detected at beginning of the stream. Don't copy it. |
vogelheim
2017/01/30 18:59:32
copy -> count. This loop doesn't copy anything; it
|
+ } else if (t != unibrow::Utf8::kIncomplete) { |
chars++; |
if (t > unibrow::Utf16::kMaxNonSurrogateCharCode) chars++; |
} |
@@ -304,8 +310,6 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() { |
return; |
} |
- static const unibrow::uchar kUtf8Bom = 0xfeff; |
- |
unibrow::Utf8::Utf8IncrementalBuffer incomplete_char = |
current_.pos.incomplete_char; |
size_t it; |