Bug fixes

Fix broken UTF-8-BOM remover.
Fix Gist upload for Clash/ClashR.
Optimize codes.
This commit is contained in:
Tindy X committed 2019-12-21 21:10:26 +08:00
1 parent d31bdd9597
commit 889af53215
4 files changed
+19 -4

No files matched your search

+16 -1
View File
@@ -1,10 +1,14 @@
#ifndef INI_READER_H_INCLUDED
#define INI_READER_H_INCLUDED
#include <string>
#include <sstream>
#include <map>
#include <vector>
#include <algorithm>
#include "misc.h"
typedef std::map<std::string, std::multimap<std::string, std::string>> ini_data_struct;
typedef std::multimap<std::string, std::string> string_multimap;
typedef std::vector<std::string> string_array;
@@ -119,7 +123,8 @@ public:
return -1;
//remove UTF-8 BOM
removeUTF8BOM(content);
if(content.compare(0, 3, "\xEF\xBB\xBF") == 0)
content = content.substr(3);
bool inExcludedSection = false;
std::string strLine, thisSection, curSection, itemName, itemVal;
@@ -615,6 +620,16 @@ public:
return current_section.size() ? SetArray(current_section, itemName, separator, Array) : -1;
}
int RenameSection(std::string oldName, std::string newName)
{
if(!SectionExist(oldName))
return -1;
auto nodeHandler = ini_content.extract(oldName);
nodeHandler.key() = newName;
ini_content.insert(std::move(nodeHandler));
return 0;
}
/**
* @brief Erase all items with the given name.
*/