Move skipBOM function outside to prevent shadowing warning (#16585)

This commit is contained in:
mogemimi 2016-09-20 15:52:15 +09:00 committed by minggo
parent 1d3a40f8be
commit e8c3082229
1 changed files with 16 additions and 11 deletions

View File

@ -844,20 +844,25 @@ int LuaStack::luaLoadChunksFromZIP(lua_State *L)
return 1;
}
namespace {
void skipBOM(const char*& chunk, int& chunkSize)
{
// UTF-8 BOM? skip
if (static_cast<unsigned char>(chunk[0]) == 0xEF &&
static_cast<unsigned char>(chunk[1]) == 0xBB &&
static_cast<unsigned char>(chunk[2]) == 0xBF)
{
chunk += 3;
chunkSize -= 3;
}
}
} // end anonymous namespace
int LuaStack::luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, const char *chunkName)
{
int r = 0;
auto skipBOM = [](const char*& chunk, int& chunkSize){
// UTF-8 BOM? skip
if (static_cast<unsigned char>(chunk[0]) == 0xEF &&
static_cast<unsigned char>(chunk[1]) == 0xBB &&
static_cast<unsigned char>(chunk[2]) == 0xBF)
{
chunk += 3;
chunkSize -= 3;
}
};
if (_xxteaEnabled && strncmp(chunk, _xxteaSign, _xxteaSignLen) == 0)
{