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 | |
| parent | a6dfc269d93cdf557f6dac62b03b886d694faecd (diff) | |
Disable exceptions
| -rw-r--r-- | configure.ac | 5 | ||||
| -rw-r--r-- | src/event_main.cc | 26 |
2 files changed, 12 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac index 7a691e0..abdf761 100644 --- a/configure.ac +++ b/configure.ac @@ -10,8 +10,7 @@ AM_PROG_CC_C_O AC_LANG([C++]) DEFINES= -#-fno-exceptions -AX_APPEND_COMPILE_FLAGS([-fno-rtti],DEFINES) +AX_APPEND_COMPILE_FLAGS([-fno-rtti -fno-exceptions],DEFINES) # Test c++11 OLDCXXFLAGS="$CXXFLAGS" @@ -31,7 +30,7 @@ std::shared_ptr<int> j(i); [AC_MSG_RESULT([yes]) DEFINES="$DEFINES -std=c++11"], [AC_MSG_RESULT([no]) - CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" + CXXFLAGS="-std=c++11 -stdlib=libc++ $OLDCXXFLAGS" AC_MSG_CHECKING([for C++11 using (-std=c++11 -stdlib=libc++)]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <memory> 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()) { |
