Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1117)

Unified Diff: src/lexer/even-more-experimental-scanner.cc

Issue 80503002: Experimental lexer generator: Fix byte order mark detection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/lexer/lexer_py.re » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lexer/even-more-experimental-scanner.cc
diff --git a/src/lexer/even-more-experimental-scanner.cc b/src/lexer/even-more-experimental-scanner.cc
index 96c753f7d372b46c7072c3bc005f90cb6cbd50df..ac26d1d16bb1c6cabe012865138c19871372355b 100644
--- a/src/lexer/even-more-experimental-scanner.cc
+++ b/src/lexer/even-more-experimental-scanner.cc
@@ -69,32 +69,19 @@ const byte* ReadFile(const char* name, Isolate* isolate,
int file_size = ftell(file);
rewind(file);
- byte* file_contents = new byte[file_size];
+ *size = file_size * repeat;
+
+ byte* chars = new byte[*size];
for (int i = 0; i < file_size;) {
- int read =
- static_cast<int>(fread(&file_contents[i], 1, file_size - i, file));
+ int read = static_cast<int>(fread(&chars[i], 1, file_size - i, file));
i += read;
}
fclose(file);
- // If the file contains the UTF16 little endian magic bytes, skip them.
- // FIXME: what if we see big endian magic bytes? Do we do the right thing for
- // big endian anyway?
- byte* start = file_contents;
- if (*start == 0xff && *(start + 1) == 0xfe) {
- start += 2;
- file_size -= 2;
+ for (int i = file_size; i < *size; i++) {
+ chars[i] = chars[i - file_size];
}
- *size = file_size * repeat;
- byte* chars = new byte[*size];
-
- for (int i = 0; i < *size; i++) {
- chars[i] = start[i % file_size];
- }
-
- delete file_contents;
-
return chars;
}
« no previous file with comments | « no previous file | src/lexer/lexer_py.re » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698