From 4034a6d65a99b2daf85655a6d344f0ec243d1063 Mon Sep 17 00:00:00 2001 From: jclc Date: Sat, 7 Apr 2018 06:04:32 +0300 Subject: [PATCH] crunched BOM skipping --- src/vm/wren_compiler.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/vm/wren_compiler.c b/src/vm/wren_compiler.c index 3937d1d2..75d0136e 100644 --- a/src/vm/wren_compiler.c +++ b/src/vm/wren_compiler.c @@ -3417,26 +3417,25 @@ ObjFn* wrenCompile(WrenVM* vm, ObjModule* module, const char* source, bool isExpression, bool printErrors) { // Skip potential UTF-8 BOM - size_t sourceOffset = 0; - if (source[0] == (char) 0xef && source[1] == (char) 0xbb && source[2] == (char) 0xbf) + if (strncmp(source, "\xEF\xBB\xBF", 3) == 0) { - sourceOffset = 3; + source += 3; } Parser parser; parser.vm = vm; parser.module = module; - parser.source = source + sourceOffset; + parser.source = source; - parser.tokenStart = source + sourceOffset; - parser.currentChar = source + sourceOffset; + parser.tokenStart = source; + parser.currentChar = source; parser.currentLine = 1; parser.numParens = 0; // Zero-init the current token. This will get copied to previous when // advance() is called below. parser.current.type = TOKEN_ERROR; - parser.current.start = source + sourceOffset; + parser.current.start = source; parser.current.length = 0; parser.current.line = 0; parser.current.value = UNDEFINED_VAL;