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:
Thomas Goyne 2014-04-28 10:16:28 -07:00
parent 8aa3c8761c
commit a5a6d5da86
2 changed files with 7 additions and 1 deletions

View file

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

View file

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