diff --git a/Util/IniFileUtil.h b/Util/IniFileUtil.h index 812db8e6a..08f1aae5f 100644 --- a/Util/IniFileUtil.h +++ b/Util/IniFileUtil.h @@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include @@ -40,21 +41,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. inline std::string ReadIniFileAndLowerContents(const boost::filesystem::path &path) { boost::filesystem::fstream config_stream(path); - std::string input_str((std::istreambuf_iterator(config_stream)), + std::string ini_file_content((std::istreambuf_iterator(config_stream)), std::istreambuf_iterator()); - std::regex regex("\\w+="); - - std::string output = input_str; - const std::sregex_token_iterator end; - for (std::sregex_token_iterator i(input_str.begin(), input_str.end(), regex); i != end; ++i) - { - std::string match = *i; - std::string new_regex = *i; - std::transform(new_regex.begin(), new_regex.end(), new_regex.begin(), ::tolower); - SimpleLogger().Write() << match << " - " << new_regex; - output = std::regex_replace(output, std::regex(match), new_regex); - } - return output; + boost::regex regex( "^([^=]*)" ); //match from start of line to '=' + std::string format( "\\L$1\\E" ); //replace with downcased substring + return boost::regex_replace( ini_file_content, regex, format ); } #endif // INI_FILE_UTIL_H