Restore the BOM-skipping logic to the Lua script reader
And add BOM to one of the test files to verify it works.
This commit is contained in:
parent
8aa3c8761c
commit
a5a6d5da86
2 changed files with 7 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
-- Copyright (c) 2007, Niels Martin Hansen, Rodrigo Braz Monteiro
|
||||
-- Copyright (c) 2007, Niels Martin Hansen, Rodrigo Braz Monteiro
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -38,6 +38,12 @@ namespace agi { namespace lua {
|
|||
auto buff = file.read();
|
||||
size_t size = static_cast<size_t>(file.size());
|
||||
|
||||
// Discard the BOM if present
|
||||
if (size >= 3 && buff[0] == -17 && buff[1] == -69 && buff[2] == -65) {
|
||||
buff += 3;
|
||||
size -= 3;
|
||||
}
|
||||
|
||||
if (!agi::fs::HasExtension(filename, "moon"))
|
||||
return luaL_loadbuffer(L, buff, size, filename.string().c_str()) == 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue