properly force string prefs to be quoted on win/linux

This commit is contained in:
2025-01-14 16:21:26 -06:00
committed by Celtic Minstrel
parent aa58b3cb41
commit 80aa0341a1
3 changed files with 4 additions and 7 deletions

View File

@@ -163,9 +163,9 @@ std::string read_maybe_quoted_string(std::istream& from) {
return result;
}
std::string maybe_quote_string(std::string which) {
std::string maybe_quote_string(std::string which, bool force) {
if(which.empty()) return "''";
if(which.find_first_of(" \t\n\f") != std::string::npos || which[0] == '"' || which[0] == '\'') {
if(force || which.find_first_of(" \t\n\f") != std::string::npos || which[0] == '"' || which[0] == '\'') {
// The string contains spaces or starts with a quote, so quote it.
// We may have to escape quotes or backslashes.
int apos = 0, quot = 0, bslash = 0, newline = 0, formfeed = 0;

View File

@@ -33,7 +33,7 @@ bool save_party(fs::path dest_file, const cUniverse& univ);
void init_directories(const char* exec_path);
std::string read_maybe_quoted_string(std::istream& from);
std::string maybe_quote_string(std::string which);
std::string maybe_quote_string(std::string which, bool force = false);
template<typename T>
struct array_value_type{