From c03bae9c450387cab3673827a21c7a607c5ed27b Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 5 Apr 2008 05:39:47 +0000 Subject: - (internal) code refine git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4084 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/friend.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/friend.c b/mbbsd/friend.c index 5ff03900..4f7a2987 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -47,6 +47,9 @@ static char * const friend_list[8] = { "看板好友名單" }; +/* sized in screen width */ +#define MAX_DESCLEN (40) + void setfriendfile(char *fpath, int type) { @@ -72,20 +75,17 @@ friend_add(const char *uident, int type, const char* des) return; if ((uident[0] > ' ') && !belong(fpath, uident)) { - char buf[STRLEN] = "", buf2[256]; + char buf[MAX_DESCLEN] = "", buf2[STRLEN]; char t_uident[IDLEN + 1]; - const int maxdesclen = 40; // bounded screen width (due to prompt) - - assert(maxdesclen <= sizeof(buf)); /* Thor: avoid uident run away when get data */ strlcpy(t_uident, uident, sizeof(t_uident)); if (type != FRIEND_ALOHA && type != FRIEND_POST){ if(!des) - getdata(2, 0, friend_desc[type], buf, maxdesclen, DOECHO); + getdata(2, 0, friend_desc[type], buf, sizeof(buf), DOECHO); else - getdata_str(2, 0, friend_desc[type], buf, maxdesclen, DOECHO, des); + getdata_str(2, 0, friend_desc[type], buf, sizeof(buf), DOECHO, des); } snprintf(buf2, sizeof(buf2), "%-13s%s\n", t_uident, buf); @@ -279,8 +279,8 @@ friend_editdesc(const char *uident, int type) if ((genbuf[0] > ' ') && strncmp(genbuf, uident, length)) fputs(genbuf, nfp); else if (!strncmp(genbuf, uident, length)) { - char buf[50] = ""; - getdata(2, 0, "修改描述:", buf, 40, DOECHO); + char buf[MAX_DESCLEN]; + getdata(2, 0, "修改描述:", buf, MAX_DESCLEN, DOECHO); fprintf(nfp, "%-13s%s\n", uident, buf); } } -- cgit v1.2.3