diff --git a/src/ini_reader.h b/src/ini_reader.h index 6b71b82..753bf6f 100644 --- a/src/ini_reader.h +++ b/src/ini_reader.h @@ -223,7 +223,7 @@ public: if(do_utf8_to_gbk && is_str_utf8(content)) content = UTF8ToACP(content); //do conversion if flag is set - if(store_isolated_line) + if(store_isolated_line && isolated_items_section.size()) { curSection = isolated_items_section; //items before any section define will be store in this section //check this section first @@ -384,7 +384,7 @@ public: if(section != cached_section) { cached_section = section; - cached_section_content= ini_content.find(section); + cached_section_content = ini_content.find(section); } auto &cache = cached_section_content->second; return cache.find(itemName) != cache.end(); diff --git a/src/misc.cpp b/src/misc.cpp index 65ca226..ec80884 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -677,7 +677,7 @@ bool regMatch(const std::string &src, const std::string &match) bool regFind(const std::string &src, const std::string &match) { jp::Regex reg; - reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF).compile(); + reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF|PCRE2_ALT_BSUX).compile(); if(!reg) return false; return reg.match(src, "g"); @@ -686,7 +686,7 @@ bool regFind(const std::string &src, const std::string &match) std::string regReplace(const std::string &src, const std::string &match, const std::string &rep, bool global) { jp::Regex reg; - reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF|PCRE2_MULTILINE).compile(); + reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF|PCRE2_MULTILINE|PCRE2_ALT_BSUX).compile(); if(!reg) return src; return reg.replace(src, rep, global ? "gx" : "x"); @@ -694,14 +694,15 @@ std::string regReplace(const std::string &src, const std::string &match, const s bool regValid(const std::string ®) { - jp::Regex r(reg); + jp::Regex r; + r.setPattern(reg).addPcre2Option(PCRE2_UTF|PCRE2_ALT_BSUX).compile(); return !!r; } int regGetMatch(const std::string &src, const std::string &match, size_t group_count, ...) { jp::Regex reg; - reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF).compile(); + reg.setPattern(match).addModifier("m").addPcre2Option(PCRE2_UTF|PCRE2_ALT_BSUX).compile(); jp::VecNum vec_num; jp::RegexMatch rm; size_t count = rm.setRegexObject(®).setSubject(src).setNumberedSubstringVector(&vec_num).setModifier("g").match(); diff --git a/src/speedtestutil.cpp b/src/speedtestutil.cpp index 37e386f..5e10043 100644 --- a/src/speedtestutil.cpp +++ b/src/speedtestutil.cpp @@ -2002,7 +2002,7 @@ void filterNodes(std::vector &nodes, string_array &exclude_remarks, st for(i = 0; i < exclude_remarks.size(); i++) { - std::unique_ptr pattern(pcre2_compile(reinterpret_cast(exclude_remarks[i].c_str()), PCRE2_ZERO_TERMINATED | PCRE2_MULTILINE, 0, &errornumber, &erroroffset, NULL), &pcre2_code_free); + std::unique_ptr pattern(pcre2_compile(reinterpret_cast(exclude_remarks[i].c_str()), exclude_remarks[i].size(), PCRE2_UTF | PCRE2_MULTILINE | PCRE2_ALT_BSUX, &errornumber, &erroroffset, NULL), &pcre2_code_free); if(!pattern) return; exclude_patterns.emplace_back(std::move(pattern)); @@ -2012,7 +2012,7 @@ void filterNodes(std::vector &nodes, string_array &exclude_remarks, st } for(i = 0; i < include_remarks.size(); i++) { - std::unique_ptr pattern(pcre2_compile(reinterpret_cast(include_remarks[i].c_str()), PCRE2_ZERO_TERMINATED | PCRE2_MULTILINE, 0, &errornumber, &erroroffset, NULL), &pcre2_code_free); + std::unique_ptr pattern(pcre2_compile(reinterpret_cast(include_remarks[i].c_str()), include_remarks[i].size(), PCRE2_UTF | PCRE2_MULTILINE | PCRE2_ALT_BSUX, &errornumber, &erroroffset, NULL), &pcre2_code_free); if(!pattern) return; include_patterns.emplace_back(std::move(pattern));