summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-11-18 09:53:56 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-11-18 09:53:56 +0800
commit1b847fadf913de1f7507cede237822a973b94029 (patch)
treeff8ef61d48e7f9ea18671a2fbf72ca98ee4909a4
parent540ae46da972dbbac64c293bbd5d7e1304ca837e (diff)
downloadpttbbs-victor.fav4.bak.tar
pttbbs-victor.fav4.bak.tar.gz
pttbbs-victor.fav4.bak.tar.bz2
pttbbs-victor.fav4.bak.tar.lz
pttbbs-victor.fav4.bak.tar.xz
pttbbs-victor.fav4.bak.tar.zst
pttbbs-victor.fav4.bak.zip
fix {folder, line}_id and {folder, line}_num misusevictor.fav4.bak
fix ugly display with ugly_flag ('c') for line and folder git-svn-id: http://opensvn.csie.org/pttbbs/branches/victor.fav4.bak@1350 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/include/proto.h1
-rw-r--r--pttbbs/mbbsd/board.c41
-rw-r--r--pttbbs/mbbsd/fav.c26
3 files changed, 46 insertions, 22 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 1f24894a..35e6f003 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -241,6 +241,7 @@ int is_visible_item(fav_type_t *ft);
int is_set_attr(fav_type_t *ft, char bit);
void cleanup(void);
char current_fav_at_root(void);
+fav_t *get_fav_folder(fav_type_t *ft);
/* friend */
void friend_edit(int type);
diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c
index 8780b9f9..58f46d21 100644
--- a/pttbbs/mbbsd/board.c
+++ b/pttbbs/mbbsd/board.c
@@ -272,6 +272,7 @@ void updatenewfav(int mode)
if( (fd = open(fname, O_RDWR, 0600)) != -1 ){
brd = (char *)malloc((numboards + 1) * sizeof(char));
+ memset(brd, 0, (numboards + 1) * sizeof(char));
read(fd, brd, (numboards + 1) * sizeof(char));
for(i = 0; i < numboards + 1 && brd[i] != BRD_END; i++){
@@ -761,16 +762,28 @@ show_brdlist(int head, int clsflag, int newflag)
if (head < brdnum) {
ptr = &nbrd[head++];
if (ptr->myattr & BRD_LINE){
- prints("%5d %c %s------------ ------------------------------------------\033[m", head, ptr->myattr & BRD_TAG ? 'D' : ' ', ptr->myattr & BRD_FAV ? "" : "\033[1;30m");
+ if( !newflag )
+ prints("%5d %c %s------------ ------------------------------------------\033[m",
+ head,
+ ptr->myattr & BRD_TAG ? 'D' : ' ',
+ ptr->myattr & BRD_FAV ? "" : "\033[1;30m");
+ else
+ prints(" %s------------ ------------------------------------------\033[m", ptr->myattr & BRD_FAV ? "" : "\033[1;30m");
continue;
}
else if (ptr->myattr & BRD_FOLDER){
char *title = get_folder_title(ptr->bid);
- prints("%5d %c %sMyFavFolder\033[m 目錄 □%-34s\033[m",
- head,
- ptr->myattr & BRD_TAG ? 'D' : ' ',
- !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
- title);
+ if( !newflag )
+ prints("%5d %c %sMyFavFolder\033[m 目錄 □%-34s\033[m",
+ head,
+ ptr->myattr & BRD_TAG ? 'D' : ' ',
+ !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
+ title);
+ else
+ prints("%6d %sMyFavFolder\033[m 目錄 □%-34s\033[m",
+ get_data_number(get_fav_folder(getfolder(ptr->bid))),
+ !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
+ title);
continue;
}
@@ -784,13 +797,11 @@ show_brdlist(int head, int clsflag, int newflag)
(B_BH(ptr)->brdattr & BRD_GROUPBOARD) ? " " :
unread[ptr->myattr & BRD_UNREAD ? 1 : 0]);
} else {
- if (newflag) {
- if ((B_BH(ptr)->brdattr & BRD_GROUPBOARD) || ptr->myattr & BRD_FOLDER)
- prints(" ");
- else
- prints("%6d%s", (int)(B_TOTAL(ptr)),
- unread[ptr->myattr & BRD_UNREAD]);
- }
+ if (B_BH(ptr)->brdattr & BRD_GROUPBOARD)
+ prints(" ");
+ else
+ prints("%6d%s", (int)(B_TOTAL(ptr)),
+ unread[ptr->myattr & BRD_UNREAD]);
}
if (class_bid != 1) {
prints("%s%-13s\033[m%s%5.5s\033[0;37m%2.2s\033[m"
@@ -1175,7 +1186,6 @@ choose_board(int newflag)
case 'K':
if (HAS_PERM(PERM_BASIC)) {
char c, fname[80], genbuf[256];
- int fd;
if (!current_fav_at_root()) {
vmsg("請到我的最愛最上層執行本功\能");
break;
@@ -1199,11 +1209,10 @@ choose_board(int newflag)
case '3':
setuserfile(fname, FAV4);
sprintf(genbuf, "%s.bak", fname);
- if((fd = open(genbuf, O_RDONLY)) < 0){
+ if (!dashf(genbuf)){
vmsg("你沒有備份你的最愛喔");
break;
}
- close(fd);
sprintf(genbuf, "cp -f %s.bak %s", fname, fname);
system(genbuf);
fav_free();
diff --git a/pttbbs/mbbsd/fav.c b/pttbbs/mbbsd/fav.c
index d6dac03c..6590e57e 100644
--- a/pttbbs/mbbsd/fav.c
+++ b/pttbbs/mbbsd/fav.c
@@ -44,7 +44,7 @@ inline fav_t *get_current_fav(void){
return fav_stack[fav_stack_num - 1];
}
-inline static fav_t *get_fav_folder(fav_type_t *ft){
+inline fav_t *get_fav_folder(fav_type_t *ft){
return cast_folder(ft)->this_folder;
}
@@ -101,6 +101,14 @@ inline static int get_folder_num(fav_t *fp) {
return fp->nFolders;
}
+inline static int get_folder_id(fav_t *fp) {
+ return fp->folderID;
+}
+
+inline static int get_line_id(fav_t *fp) {
+ return fp->lineID;
+}
+
inline static int get_line_num(fav_t *fp) {
return fp->nLines;
}
@@ -221,12 +229,13 @@ inline int is_visible_item(fav_type_t *ft){
*/
static void rebuild_fav(fav_t *fp)
{
- int i, j, bid;
+ int i, j, nData, bid;
fav_type_t *ft;
fav_number = 0;
fp->lineID = fp->folderID = 0;
fp->nLines = fp->nFolders = fp->nBoards = 0;
- for (i = 0, j = 0; i < fp->DataTail; i++){
+ nData = fp->DataTail;
+ for (i = 0, j = 0; i < nData; i++){
if (!(fp->favh[i].attr & FAVH_FAV))
continue;
ft = &fp->favh[i];
@@ -570,6 +579,7 @@ int fav_getid(fav_type_t *ft)
/* suppose we don't add too much fav_type_t at the same time. */
static int enlarge_if_full(fav_t *fp)
{
+ fav_type_t * p;
/* enlarge the volume if need. */
if (fav_number >= MAX_FAV)
return -1;
@@ -577,7 +587,11 @@ static int enlarge_if_full(fav_t *fp)
return 1;
/* realloc and clean the tail */
- fp->favh = (fav_type_t *)realloc(fp->favh, sizeof(fav_type_t) * (fp->nAllocs + FAV_PRE_ALLOC));
+ p = (fav_type_t *)realloc(fp->favh, sizeof(fav_type_t) * (fp->nAllocs + FAV_PRE_ALLOC));
+ if( p == NULL )
+ return -1;
+
+ fp->favh = p;
memset(fp->favh + fp->nAllocs, 0, sizeof(fav_type_t) * FAV_PRE_ALLOC);
fp->nAllocs += FAV_PRE_ALLOC;
return 0;
@@ -658,7 +672,7 @@ fav_type_t *fav_add_line(void)
fav_type_t *ft = init_add(fp, FAVT_LINE);
if (ft == NULL)
return NULL;
- cast_line(ft)->lid = get_line_num(fp);
+ cast_line(ft)->lid = get_line_id(fp);
return ft;
}
@@ -674,7 +688,7 @@ fav_type_t *fav_add_folder(void)
if (ft == NULL)
return NULL;
cast_folder(ft)->this_folder = alloc_folder_item();
- cast_folder(ft)->fid = get_folder_num(fp); // after fav_increase
+ cast_folder(ft)->fid = get_folder_id(fp); // after fav_increase
return ft;
}