Merge remote-tracking branch 'origin/master' into feature_slice_to_png

This commit is contained in:
tamasmeszaros 2018-07-18 10:14:15 +02:00
commit 9559ad77e5
121 changed files with 18093 additions and 3459 deletions

View file

@ -20,6 +20,7 @@
namespace Slic3r {
// Escape \n, \r and backslash
std::string escape_string_cstyle(const std::string &str)
{
// Allocate a buffer twice the input string length,
@ -28,9 +29,15 @@ std::string escape_string_cstyle(const std::string &str)
char *outptr = out.data();
for (size_t i = 0; i < str.size(); ++ i) {
char c = str[i];
if (c == '\n' || c == '\r') {
if (c == '\r') {
(*outptr ++) = '\\';
(*outptr ++) = 'r';
} else if (c == '\n') {
(*outptr ++) = '\\';
(*outptr ++) = 'n';
} else if (c == '\\') {
(*outptr ++) = '\\';
(*outptr ++) = '\\';
} else
(*outptr ++) = c;
}
@ -69,7 +76,10 @@ std::string escape_strings_cstyle(const std::vector<std::string> &strs)
if (c == '\\' || c == '"') {
(*outptr ++) = '\\';
(*outptr ++) = c;
} else if (c == '\n' || c == '\r') {
} else if (c == '\r') {
(*outptr ++) = '\\';
(*outptr ++) = 'r';
} else if (c == '\n') {
(*outptr ++) = '\\';
(*outptr ++) = 'n';
} else
@ -84,6 +94,7 @@ std::string escape_strings_cstyle(const std::vector<std::string> &strs)
return std::string(out.data(), outptr - out.data());
}
// Unescape \n, \r and backslash
bool unescape_string_cstyle(const std::string &str, std::string &str_out)
{
std::vector<char> out(str.size(), 0);
@ -94,8 +105,12 @@ bool unescape_string_cstyle(const std::string &str, std::string &str_out)
if (++ i == str.size())
return false;
c = str[i];
if (c == 'n')
if (c == 'r')
(*outptr ++) = '\r';
else if (c == 'n')
(*outptr ++) = '\n';
else
(*outptr ++) = c;
} else
(*outptr ++) = c;
}
@ -134,7 +149,9 @@ bool unescape_strings_cstyle(const std::string &str, std::vector<std::string> &o
if (++ i == str.size())
return false;
c = str[i];
if (c == 'n')
if (c == 'r')
c = '\r';
else if (c == 'n')
c = '\n';
}
buf.push_back(c);
@ -188,7 +205,10 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys
throw UnknownOptionException(opt_key);
}
const ConfigOption *other_opt = other.option(opt_key);
if (other_opt != nullptr)
if (other_opt == nullptr) {
// The key was not found in the source config, therefore it will not be initialized!
// printf("Not found, therefore not initialized: %s\n", opt_key.c_str());
} else
my_opt->set(other_opt);
}
}