diff options
-rw-r--r-- | pttbbs/include/proto.h | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbslua.c | 4 | ||||
-rw-r--r-- | pttbbs/mbbsd/ccw.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/edit.c | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/io.c | 6 | ||||
-rw-r--r-- | pttbbs/mbbsd/vtuikit.c | 5 |
6 files changed, 15 insertions, 6 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 4f7291ec..4828c6a3 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -291,7 +291,7 @@ void vkey_purge(); // identical to drop_input int vkey_is_full(); // identical to input_isfull int vkey_detach(void); // works like to add_io(0, 0) int vkey_attach(int fd); // works like add_io(fd, ...) -// int vkey_is_ready(); // works like (num_in_buf() > 0) +int vkey_is_ready(); // works like (num_in_buf() > 0) /* kaede */ char*Ptt_prints(char *str, size_t size, int mode); diff --git a/pttbbs/mbbsd/bbslua.c b/pttbbs/mbbsd/bbslua.c index cbf2c553..414096b0 100644 --- a/pttbbs/mbbsd/bbslua.c +++ b/pttbbs/mbbsd/bbslua.c @@ -462,7 +462,7 @@ bl_kbhit(lua_State *L) if (f > BLCONF_KBHIT_TMAX) f = BLCONF_KBHIT_TMAX; refresh(); - if (num_in_buf() || wait_input(f, 0)) + if (vkey_is_ready() || wait_input(f, 0)) lua_pushboolean(L, 1); else lua_pushboolean(L, 0); @@ -550,7 +550,7 @@ bl_kball(lua_State *L) } #else // next, collect all input and return. - if (num_in_buf() < 1) + if (!vkey_is_ready()) return 0; oldr = num_in_buf() +1; diff --git a/pttbbs/mbbsd/ccw.c b/pttbbs/mbbsd/ccw.c index 8dc57dd0..218601e6 100644 --- a/pttbbs/mbbsd/ccw.c +++ b/pttbbs/mbbsd/ccw.c @@ -1005,7 +1005,7 @@ ccw_chat_anti_flood(CCW_CTX *ctx) vkey_purge(); while (wait_input(1, 0)) { - if (num_in_buf()) + if (vkey_is_ready()) vkey_purge(); else tty_read(garbage, sizeof(garbage)); diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c index f0af0beb..89f1b400 100644 --- a/pttbbs/mbbsd/edit.c +++ b/pttbbs/mbbsd/edit.c @@ -3418,7 +3418,7 @@ upload_file(void) "請在您的電腦本機端複製好內容後貼上即可開始傳送。\n"); do { - if (!num_in_buf()) + if (!vkey_is_ready()) { move(10, 0); clrtobot(); prints("\n\n資料接收中... %u 位元組。\n", (unsigned int)szdata); diff --git a/pttbbs/mbbsd/io.c b/pttbbs/mbbsd/io.c index 9cabf489..dca4381e 100644 --- a/pttbbs/mbbsd/io.c +++ b/pttbbs/mbbsd/io.c @@ -401,6 +401,12 @@ num_in_buf(void) } inline int +vkey_is_ready(void) +{ + return num_in_buf() > 0; +} + +inline int vkey_is_full(void) { return ibufsize >= IBUFSIZE; diff --git a/pttbbs/mbbsd/vtuikit.c b/pttbbs/mbbsd/vtuikit.c index 050387ec..0af08fd9 100644 --- a/pttbbs/mbbsd/vtuikit.c +++ b/pttbbs/mbbsd/vtuikit.c @@ -1310,9 +1310,10 @@ vgetstring(char *_buf, int len, int flags, const char *defstr, const VGET_CALLBA } // prevent incomplete DBCS - if (c > 0x80 && num_in_buf() && + if (c > 0x80 && vkey_is_ready() && len - rt.iend < 3) // we need 3 for DBCS+NUL. { + // XXX should we purge here, or wait the final DBCS_safe_trim? vkey_purge(); bell(); continue; } @@ -1337,6 +1338,8 @@ vgetstring(char *_buf, int len, int flags, const char *defstr, const VGET_CALLBA assert(rt.iend >= 0 && rt.iend < len); buf[rt.iend] = 0; + DBCS_safe_trim(buf); + // final filtering if (rt.iend && (flags & VGET_LOWERCASE)) buf[0] = tolower(buf[0]); |