diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/keycode.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/keycode.cpp b/src/keycode.cpp index 30d1dd5a2..c3c06bb7f 100644 --- a/src/keycode.cpp +++ b/src/keycode.cpp @@ -258,9 +258,10 @@ KeyPress::KeyPress(const char *name) try { Key = keyname_to_keycode(name); m_name = name; - if (strlen(name) > 8) - mbtowc(&Char, name + 8, 1); - else + if (strlen(name) > 8) { + int chars_read = mbtowc(&Char, name + 8, 1); + assert (chars_read == 1 && "unexpected multibyte character"); + } else Char = L'\0'; return; } catch (UnknownKeycode &e) {}; @@ -270,7 +271,8 @@ KeyPress::KeyPress(const char *name) m_name += name; try { Key = keyname_to_keycode(m_name.c_str()); - mbtowc(&Char, name, 1); + int chars_read = mbtowc(&Char, name, 1); + assert (chars_read == 1 && "unexpected multibyte character"); return; } catch (UnknownKeycode &e) {}; } @@ -279,7 +281,8 @@ KeyPress::KeyPress(const char *name) Key = irr::KEY_KEY_CODES_COUNT; - mbtowc(&Char, name, 1); + int mbtowc_ret = mbtowc(&Char, name, 1); + assert (mbtowc_ret == 1 && "unexpected multibyte character"); m_name = name[0]; } @@ -292,7 +295,8 @@ KeyPress::KeyPress(const irr::SEvent::SKeyInput &in) } else { size_t maxlen = wctomb(NULL, Char); m_name.resize(maxlen+1, '\0'); - wctomb(&m_name[0], Char); + int written = wctomb(&m_name[0], Char); + assert (written >= 0 && "unexpected multibyte character"); } } |