summaryrefslogtreecommitdiffstats
path: root/mbbsd/io.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-06 19:03:14 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-06 19:03:14 +0800
commit525ac36db85be7dd442b654f789582fa12dab91e (patch)
tree30948211b18de9dd6ca37efe0002b83f0fcf8f8c /mbbsd/io.c
parent0480bbc1fe207b2d056b522f1e64423dc1dffbad (diff)
downloadpttbbs-525ac36db85be7dd442b654f789582fa12dab91e.tar
pttbbs-525ac36db85be7dd442b654f789582fa12dab91e.tar.gz
pttbbs-525ac36db85be7dd442b654f789582fa12dab91e.tar.bz2
pttbbs-525ac36db85be7dd442b654f789582fa12dab91e.tar.lz
pttbbs-525ac36db85be7dd442b654f789582fa12dab91e.tar.xz
pttbbs-525ac36db85be7dd442b654f789582fa12dab91e.tar.zst
pttbbs-525ac36db85be7dd442b654f789582fa12dab91e.zip
- fixed: peek_input keeps waiting for new input. (due to buf control)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3799 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/io.c')
-rw-r--r--mbbsd/io.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 030509e7..64d5b1a1 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -325,7 +325,8 @@ _debug_check_keyinput()
} else {
outs("Waiting for key input. 'q' to exit, 'd' to try dbcs-aware");
}
- wait_input(-1, 1);
+ refresh();
+ wait_input(-1, 0);
switch(dogetch())
{
case 'd':
@@ -647,21 +648,18 @@ igetch(void)
* Return 1 if anything available.
*/
int
-wait_input(float f, int flDoRefresh)
+wait_input(float f, int bIgnoreBuf)
{
int sel = 0;
fd_set readfds;
struct timeval tv, *ptv = &tv;
- if(num_in_buf() > 0) // for EINTR
+ if(!bIgnoreBuf && num_in_buf() > 0)
return 1;
FD_ZERO(&readfds);
FD_SET(0, &readfds);
- if(flDoRefresh)
- refresh();
-
if(f > 0)
{
tv.tv_sec = (long) f;
@@ -674,7 +672,7 @@ wait_input(float f, int flDoRefresh)
#endif
do {
- if(num_in_buf() > 0)
+ if(!bIgnoreBuf && num_in_buf() > 0)
return 1;
sel = select(1, &readfds, NULL, NULL, ptv);
} while (sel < 0 && errno == EINTR);
@@ -699,7 +697,7 @@ peek_input(float f, int c)
assert (c > 0 && c < ' '); // only ^x keys are safe to be detected.
// other keys may fall into escape sequence.
- if (wait_input(f, 0) && (IBUFSIZE > ibufsize))
+ if (wait_input(f, 1) && (IBUFSIZE > ibufsize))
{
int len = tty_read(inbuf + ibufsize, IBUFSIZE - ibufsize);
#ifdef CONVERT