From cd29a1da3cbeec80559309f8e16bba071137f2f8 Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 30 Jan 2008 05:59:36 +0000 Subject: - board: enable changing to MyFavorite in HotBoards - bugfix: snprintf() on UNIX takes directly sizeof(buf) and always append NUL. Warning: Windows port will not output NUL if truncated. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3883 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/aids.c | 3 +-- mbbsd/bbslua.c | 4 ---- mbbsd/board.c | 2 +- mbbsd/read.c | 3 +-- 4 files changed, 3 insertions(+), 9 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/aids.c b/mbbsd/aids.c index 53bca85b..2b5baac7 100644 --- a/mbbsd/aids.c +++ b/mbbsd/aids.c @@ -79,8 +79,7 @@ char *aidu2fn(char *fn, aidu_t aidu) if(fn == NULL) return NULL; - snprintf(fn, FNLEN - 1, "%c.%d.A.%03X", ((type == 0) ? 'M' : 'G'), (unsigned int)v1, (unsigned int)v2); - fn[FNLEN - 1] = '\0'; + snprintf(fn, FNLEN, "%c.%d.A.%03X", ((type == 0) ? 'M' : 'G'), (unsigned int)v1, (unsigned int)v2); return fn; } diff --git a/mbbsd/bbslua.c b/mbbsd/bbslua.c index 50eb69bc..ebe8e23c 100644 --- a/mbbsd/bbslua.c +++ b/mbbsd/bbslua.c @@ -744,7 +744,6 @@ bls_setfn(char *fn, size_t sz, const char *p) case BLS_GLOBAL: snprintf(fn, sz, "%s/" BLSCONF_PREFIX "U%08x", BLSCONF_GPATH, blrt.storename); - fn[sz-1] = 0; return 1; case BLS_USER: @@ -754,7 +753,6 @@ bls_setfn(char *fn, size_t sz, const char *p) snprintf(fn + strlen(fn), sz - strlen(fn), "/" BLSCONF_PREFIX "G%08x", blrt.storename); - fn[sz-1] = 0; return 1; } return 0; @@ -1337,7 +1335,6 @@ bbslua_logo(lua_State *L) snprintf(msg, sizeof(msg), " ▲ 此程式使用新版的 BBS-Lua 規格 (%0.3f),您可能無法正常執行", tocinterface); - msg[sizeof(msg)-1] = 0; fullmsg(msg); fullmsg(" 若執行出現錯誤,建議您重新登入 BBS 後再重試"); fullmsg(""); @@ -1386,7 +1383,6 @@ bbslua_logo(lua_State *L) snprintf(msg, sizeof(msg), " ■ BBS-Lua %.03f (Build " __DATE__ " " __TIME__") ", (double)BBSLUA_INTERFACE_VER); - msg[sizeof(msg)-1] = 0; fullmsg(msg); // system break key prompt diff --git a/mbbsd/board.c b/mbbsd/board.c index 2a4b3dd5..a6704199 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1609,7 +1609,7 @@ choose_board(int newflag) // MyFav Functionality (Require PERM_BASIC) /////////////////////////////////////////////////////// case 'y': - if (HasFavEditPerm() && IN_FAVORITE()) { + if (HasFavEditPerm() && !(IN_CLASS())) { if (get_current_fav() != NULL || !IS_LISTING_FAV()){ yank_flag ^= 1; /* FAV <=> BRD */ } diff --git a/mbbsd/read.c b/mbbsd/read.c index 52f010ee..66ea613f 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -1177,8 +1177,7 @@ get_records_and_bottom(char *direct, fileheader_t* headers, if (n > 0) { char directbottom[PATHLEN]; - snprintf(directbottom, sizeof(directbottom)-1, "%s.bottom", direct); - directbottom[sizeof(directbottom)-1] = 0; + snprintf(directbottom, sizeof(directbottom), "%s.bottom", direct); n = get_records(directbottom, headers+rv, sizeof(fileheader_t), 1, n); if (n < 0) n = 0; rv += n; -- cgit v1.2.3