diff options
-rw-r--r-- | include/proto.h | 2 | ||||
-rw-r--r-- | mbbsd/io.c | 33 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 2 |
3 files changed, 27 insertions, 10 deletions
diff --git a/include/proto.h b/include/proto.h index 221b71f0..68b39f86 100644 --- a/include/proto.h +++ b/include/proto.h @@ -288,7 +288,7 @@ int getdata_buf(int line, int col, char *prompt, char *buf, int len, int echo); void add_io(int fd, int timeout); void oflush(void); int strip_ansi(char *buf, char *str, int mode); -void strip_iac(unsigned char *str, int maxlen); +void strip_nonebig5(unsigned char *str, int maxlen); int oldgetdata(int line, int col, char *prompt, char *buf, int len, int echo); void output(char *s, int len); int num_in_buf(void); @@ -485,16 +485,33 @@ strip_ansi(char *buf, char *str, int mode) } void -strip_iac(unsigned char *str, int maxlen) +strip_nonebig5(unsigned char *str, int maxlen) { - int i,len=0; - - for(i=0;i<maxlen && str[i]; i++) - if(str[i]!=255) { - str[len++]=str[i]; + int i; + int len=0; + for(i=0;i<maxlen && str[i];i++) { + if(32<=str[i] && str[i]<128) + str[len++]=str[i]; + else if(str[i]==255) { + if(i+1<maxlen) + if(251<=str[i+1] && str[i+1]<=254) { + i++; + if(i+1<maxlen && str[i+1]) + i++; } - if(len<maxlen) - str[len]='\0'; + continue; + } else if(str[i]&0x80) { + if(i+1<maxlen) + if((0x40<=str[i+1] && str[i+1]<=0x7e) || + (0xa1<=str[i+1] && str[i+1]<=0xfe)) { + str[len++]=str[i]; + str[len++]=str[i+1]; + i++; + } + } + } + if(len<maxlen) + str[len]='\0'; } int diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 101299c9..2a0e8167 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -734,7 +734,7 @@ setup_utmp(int mode) strlcpy(uinfo.userid, cuser.userid, sizeof(uinfo.userid)); //strlcpy(uinfo.realname, cuser.realname, sizeof(uinfo.realname)); strlcpy(uinfo.username, cuser.username, sizeof(uinfo.username)); - strip_iac(uinfo.username, sizeof(uinfo.username)); + strip_nonebig5(uinfo.username, sizeof(uinfo.username)); strlcpy(uinfo.from, fromhost, sizeof(uinfo.from)); uinfo.five_win = cuser.five_win; uinfo.five_lose = cuser.five_lose; |