Commit f8ce1246 authored by nanahira's avatar nanahira

format LoadLFListFromLineProvider

parent f1b62cc7
...@@ -13,10 +13,11 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz ...@@ -13,10 +13,11 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
auto cur = loadedLists.rend(); auto cur = loadedLists.rend();
char linebuf[256]{}; char linebuf[256]{};
wchar_t strBuffer[256]{}; wchar_t strBuffer[256]{};
if(true) {
while (getLine(linebuf, sizeof(linebuf))) { while(getLine(linebuf, sizeof linebuf)) {
if (linebuf[0] == '#') continue; if(linebuf[0] == '#')
if (linebuf[0] == '!') { continue;
if(linebuf[0] == '!') {
auto len = std::strcspn(linebuf, "\r\n"); auto len = std::strcspn(linebuf, "\r\n");
linebuf[len] = 0; linebuf[len] = 0;
BufferIO::DecodeUTF8(&linebuf[1], strBuffer); BufferIO::DecodeUTF8(&linebuf[1], strBuffer);
...@@ -27,27 +28,30 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz ...@@ -27,27 +28,30 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
cur = loadedLists.rbegin(); cur = loadedLists.rbegin();
continue; continue;
} }
if (cur == loadedLists.rend()) continue; if (cur == loadedLists.rend())
continue;
char* pos = linebuf; char* pos = linebuf;
errno = 0; errno = 0;
auto result = std::strtoul(pos, &pos, 10); auto result = std::strtoul(pos, &pos, 10);
if (errno || result > UINT32_MAX) continue; if (errno || result > UINT32_MAX)
if (pos == linebuf || *pos != ' ') continue; continue;
if (pos == linebuf || *pos != ' ')
continue;
uint32_t code = static_cast<uint32_t>(result); uint32_t code = static_cast<uint32_t>(result);
errno = 0; errno = 0;
int count = std::strtol(pos, &pos, 10); int count = std::strtol(pos, &pos, 10);
if (errno) continue; if (errno)
if (count < 0 || count > 2) continue; continue;
if (count < 0 || count > 2)
continue;
cur->content[code] = count; cur->content[code] = count;
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
^ ((code << (27 + count)) | (code >> (5 - count)));
} }
}
if (insert) { if(insert)
_lfList.insert(_lfList.begin(), loadedLists.begin(), loadedLists.end()); _lfList.insert(_lfList.begin(), loadedLists.begin(), loadedLists.end());
} else { else
_lfList.insert(_lfList.end(), loadedLists.begin(), loadedLists.end()); _lfList.insert(_lfList.end(), loadedLists.begin(), loadedLists.end());
}
} }
void DeckManager::LoadLFListSingle(const char* path, bool insert) { void DeckManager::LoadLFListSingle(const char* path, bool insert) {
FILE* fp = myfopen(path, "r"); FILE* fp = myfopen(path, "r");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment