diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2015-06-04 00:45:45 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2015-06-04 00:45:45 +0200 |
| commit | 2cba1d5be56c4768ac1a7dfb422c9f7c4c6611b9 (patch) | |
| tree | 7a38e488caccd78aa42d967d7937361b73341a77 /src/event_main.cc | |
| parent | a6dfc269d93cdf557f6dac62b03b886d694faecd (diff) | |
Disable exceptions
Diffstat (limited to 'src/event_main.cc')
| -rw-r--r-- | src/event_main.cc | 26 |
1 files changed, 10 insertions, 16 deletions
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<typename Iterator> bool append_indexes(Iterator begin, Iterator end, std::vector<unsigned long>* 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()) { |
