From 2cba1d5be56c4768ac1a7dfb422c9f7c4c6611b9 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 4 Jun 2015 00:45:45 +0200 Subject: Disable exceptions --- configure.ac | 5 ++--- 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 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 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