diff --git a/X11Exception.h b/X11Exception.h index c0468bf..3585570 100644 --- a/X11Exception.h +++ b/X11Exception.h @@ -13,7 +13,7 @@ class X11Exception : public std::exception { public: X11Exception() : _reason("unknown") {} - X11Exception(const std::string& what) : _reason(what) {} + explicit X11Exception(const std::string& what) : _reason(what) {} virtual ~X11Exception() throw () {}; virtual const char* what() const throw () { return _reason.c_str(); } @@ -21,9 +21,8 @@ private: std::string _reason; }; -#endif // GAMEEXCEPTION_H_FE39A315_6827_447B_AE62_5FA2C3FD391F +#endif // X11EXCEPTION_H_FE39A315_6827_447B_AE62_5FA2C3FD391F // Local Variables: // mode: c++ // End: - diff --git a/wrapper.cpp b/wrapper.cpp index bc3a46d..93fc636 100644 --- a/wrapper.cpp +++ b/wrapper.cpp @@ -59,7 +59,7 @@ bool print_status(XKeyboard& xkb, string format) { stringstream r; // resulting string for (size_t i = 0; i < format.length(); ++i) { - if (format[i] == '%' && i < format.length()-1) { + if (i < format.length()-2 && format[i] == '%') { switch (format[i+1]) { case 'c': r << xkb.currentGroupNum(); @@ -180,8 +180,8 @@ int main(int argc, char* argv[]) } } } - catch (exception e) { - cerr << e.what() << endl; + catch (const exception *e) { + cerr << e->what() << endl; return EXIT_FAILURE; } return EXIT_SUCCESS;