summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-10-16 17:04:53 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-10-16 17:04:53 +0800
commit308ad7194aa1632322c33d695198fefd7d4f3b79 (patch)
treea523ad1f22d35e4a7557609281fc39353cd0b8e5 /mbbsd
parent6c39455827991ffd8a4f6916e776c862cc2aefdf (diff)
downloadpttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar
pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.gz
pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.bz2
pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.lz
pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.xz
pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.zst
pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.zip
strip none-big5 char in user's nick
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2257 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/io.c33
-rw-r--r--mbbsd/mbbsd.c2
2 files changed, 26 insertions, 9 deletions
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 57d639c2..1f7658f2 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -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;