pre-commit run --show-diff-on-failure --color=always --all-files

This commit is contained in:
Artem Pavlenko 2023-11-17 16:33:01 +00:00
parent 7d2029165e
commit d745e43eb1
3 changed files with 8 additions and 9 deletions

View file

@ -127,7 +127,8 @@ void ogr_datasource::init(mapnik::parameters const& params)
}
std::string driver = *params.get<std::string>("driver", "");
std::vector<ogr_utils::option_ptr> open_options_map = ogr_utils::split_open_options(*params.get<std::string>("open_options", ""));
std::vector<ogr_utils::option_ptr> open_options_map =
ogr_utils::split_open_options(*params.get<std::string>("open_options", ""));
char** open_options = ogr_utils::open_options_for_ogr(open_options_map);
if (!driver.empty())

View file

@ -40,16 +40,18 @@ std::vector<ogr_utils::option_ptr> ogr_utils::split_open_options(const std::stri
}
escaped = !escaped;
}
else if (current != ' ') {
else if (current != ' ')
{
unescaped_str.push_back(current);
}
if (current == ' ' || i + 1 == options.size())
{
if (!escaped) {
if (!escaped)
{
size_t count = unescaped_str.size();
if (count > 0)
{
option_ptr opt (new char[count + 1], [](char* arr) { delete[] arr; });
option_ptr opt(new char[count + 1], [](char* arr) { delete[] arr; });
unescaped_str.copy(opt.get(), count);
opt[count] = '\0';
opts.push_back(std::move(opt));
@ -71,7 +73,6 @@ std::vector<ogr_utils::option_ptr> ogr_utils::split_open_options(const std::stri
return opts;
}
char** ogr_utils::open_options_for_ogr(std::vector<ogr_utils::option_ptr>& options)
{
char** for_ogr = new char*[options.size() + 1];
@ -82,4 +83,3 @@ char** ogr_utils::open_options_for_ogr(std::vector<ogr_utils::option_ptr>& optio
for_ogr[options.size()] = nullptr;
return for_ogr;
}

View file

@ -38,6 +38,4 @@ char** open_options_for_ogr(std::vector<ogr_utils::option_ptr>& options);
} // namespace ogr_utils
#endif /* PLUGINS_INPUT_OGR_OGR_UTILS_HPP_ */