diff --git a/src/aspif_text.cpp b/src/aspif_text.cpp index 8873af5..8fbfa2e 100644 --- a/src/aspif_text.cpp +++ b/src/aspif_text.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -344,7 +345,7 @@ struct AspifTextOutput::Data { static int atomArity(const std::string& name, std::size_t* sepPos = 0) { if (name.empty() || name[0] == '&') return -1; std::size_t pos = std::min(name.find('('), name.size()); - POTASSCO_REQUIRE(pos == name.size() || name.back() == ')', "invalid name"); + POTASSCO_REQUIRE(pos == name.size() || *name.rbegin() == ')', "invalid name"); if (sepPos) *sepPos = pos; if (name.size() - pos <= 2) { return 0; @@ -659,7 +660,7 @@ void AspifTextOutput::writeDirectives() { } else if (last.second != arity || n->compare(0, ep, last.first) != 0) { last.first.resize(n->size()); - auto w = snprintf(&last.first[0], n->size(), "%.*s/%d", (int) ep, n->c_str(), arity); + int w = snprintf(&last.first[0], n->size(), "%.*s/%d", (int) ep, n->c_str(), arity); assert(w > ep); last.first.resize(w); if (data_->strings.insert(Data::StringMapVal(last.first, idMax)).second) { diff --git a/tests/test_string_convert.cpp b/tests/test_string_convert.cpp index 77dce8d..5715824 100644 --- a/tests/test_string_convert.cpp +++ b/tests/test_string_convert.cpp @@ -154,8 +154,9 @@ TEST_CASE("String conversion", "[string]") { std::string loc(it->first); loc.append(1, *s).append(it->second).append(*code); if (setlocale(LC_ALL, loc.c_str())) { - restore.second = std::locale::global(std::locale(loc)); + INFO("Set locale to " << loc); set = true; + CHECK_NOFAIL((restore.second = std::locale::global(std::locale(loc)), true)); } } }