projects
/
libs
/
core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6dcf422
)
Add some error checks to Console functions
author
Mikko Rasa
<tdb@tdb.fi>
Wed, 30 May 2012 18:16:18 +0000
(18:16 +0000)
committer
Mikko Rasa
<tdb@tdb.fi>
Wed, 30 May 2012 18:16:18 +0000
(18:16 +0000)
source/io/console.cpp
patch
|
blob
|
history
diff --git
a/source/io/console.cpp
b/source/io/console.cpp
index 447377b32ebe08d057c5e1f121601ffde893dd64..d06b894e10dda771f11773999b18e8ee92c2d204 100644
(file)
--- a/
source/io/console.cpp
+++ b/
source/io/console.cpp
@@
-93,14
+93,18
@@
void Console::set_line_buffer(bool l)
#ifdef WIN32
DWORD m;
#ifdef WIN32
DWORD m;
- GetConsoleMode(*handle, &m);
- SetConsoleMode(*handle, (m&~ENABLE_LINE_INPUT) | (l?ENABLE_LINE_INPUT:0));
+ if(!GetConsoleMode(*handle, &m))
+ throw system_error("GetConsoleMode");
+ if(!SetConsoleMode(*handle, (m&~ENABLE_LINE_INPUT) | (l?ENABLE_LINE_INPUT:0)))
+ throw system_error("SetConsoleMode");
#else
// XXX ICANON does more than just set line buffering, may need a bit more thought
termios t;
#else
// XXX ICANON does more than just set line buffering, may need a bit more thought
termios t;
- tcgetattr(*handle, &t);
+ if(tcgetattr(*handle, &t)==-1)
+ throw system_error("tcgetattr");
t.c_lflag = (t.c_lflag&~ICANON) | (l?ICANON:0);
t.c_lflag = (t.c_lflag&~ICANON) | (l?ICANON:0);
- tcsetattr(*handle, TCSADRAIN, &t);
+ if(tcsetattr(*handle, TCSADRAIN, &t)==-1)
+ throw system_error("tcsetattr");
#endif
}
#endif
}
@@
-114,7
+118,8
@@
void Console::get_size(unsigned &rows, unsigned &cols)
cols = 80;
#else
struct winsize wsz;
cols = 80;
#else
struct winsize wsz;
- ioctl(*handle, TIOCGWINSZ, &wsz);
+ if(ioctl(*handle, TIOCGWINSZ, &wsz)==-1)
+ throw system_error("ioctl TIOCGWINSZ");
rows = wsz.ws_row;
cols = wsz.ws_col;
#endif
rows = wsz.ws_row;
cols = wsz.ws_col;
#endif