crunched BOM skipping

This commit is contained in:
jclc
2018-04-07 06:04:32 +03:00
parent fe2ca0e89a
commit 4034a6d65a

View File

@ -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;