From e414d9a2c1048fcb544bb76532dc17339b0ae0a3 Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 8 Jun 2005 17:48:59 +0000 Subject: fix getdata with dbcs_aware bug --This line, and those beflow, will be ignored-- M mbbsd/io.c git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2811 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/io.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/io.c b/mbbsd/io.c index 3032fc3b..4526620f 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -767,6 +767,10 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) #define MAXLASTCMD 12 static char lastcmd[MAXLASTCMD][80]; +#ifdef DBCSAWARE_GETDATA + unsigned int dbcsincomplete = 0; +#endif + strip_ansi(buf, buf, STRIP_ALL); if (prompt) { @@ -920,10 +924,27 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) default: if (isprint2(ch) && clen < len && x + clen < scr_cols) { #ifdef DBCSAWARE_GETDATA - /* to prevent single byte input */ - if(ISDBCSAWARE() && - clen >= len-1 && ch >= 0x80) - break; + if(ISDBCSAWARE()) + { + /* to prevent single byte input */ + if(dbcsincomplete) + { + dbcsincomplete = 0; + } + else if (ch >= 0x80) + { + dbcsincomplete = 1; + if(clen + 2 > len) + { + /* we can't print this. ignore and eat key. */ + igetch(); + dbcsincomplete = 0; + break; + } + } else { + /* nothing, normal key. */ + } + } #endif for (i = clen + 1; i > currchar; i--) buf[i] = buf[i - 1]; -- cgit v1.2.3