From 2cba1d5be56c4768ac1a7dfb422c9f7c4c6611b9 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 4 Jun 2015 00:45:45 +0200 Subject: Disable exceptions --- src/event_main.cc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/event_main.cc b/src/event_main.cc index 85c35eb..2a43086 100644 --- a/src/event_main.cc +++ b/src/event_main.cc @@ -199,18 +199,14 @@ template bool append_indexes(Iterator begin, Iterator end, std::vector* out) { for (auto it = begin; it != end; ++it) { - try { - size_t end; - auto tmp = std::stoul(*it, &end); - if (end != it->size()) { - Http::response(200, "Bad index: " + *it); - return false; - } - out->push_back(tmp); - } catch (std::invalid_argument& e) { + char* end = nullptr; + errno = 0; + auto tmp = strtoul(it->c_str(), &end, 10); + if (errno || !end || *end) { Http::response(200, "Bad index: " + *it); return false; } + out->push_back(tmp); } return true; } @@ -428,13 +424,11 @@ bool going(const std::string& channel, if (args.empty()) { event = Event::next(db); } else if (args.size() == 1) { - try { - size_t end; - auto tmp = std::stoul(args.front(), &end); - if (end == args.front().size()) { - indexes.push_back(tmp); - } - } catch (std::invalid_argument& e) { + char* end = nullptr; + errno = 0; + auto tmp = strtoul(args.front().c_str(), &end, 10); + if (errno == 0 && end && !*end) { + indexes.push_back(tmp); } if (indexes.empty()) { -- cgit v1.2.3-70-g09d2