diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-04 23:45:14 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-04 23:45:14 +0800 |
commit | 2ae816ba355067d1545cdd5fc5351c588419b40b (patch) | |
tree | 5998f924de2083a94956f596aa64bfb61451a879 | |
parent | 4b23515004b96426b06646ca37b6475c0eaf37e5 (diff) | |
download | pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.tar pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.tar.gz pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.tar.bz2 pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.tar.lz pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.tar.xz pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.tar.zst pttbbs-2ae816ba355067d1545cdd5fc5351c588419b40b.zip |
fix error when .fav4 and .fav3 don't exist
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1577 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/fav.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 25618b9c..639eae42 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -150,15 +150,17 @@ static char *get_item_class(fav_type_t *ft) return NULL; } -#ifdef MEM_CHECK inline static void fav_set_memcheck(int n) { +#ifdef MEM_CHECK memcheck = n; +#endif } inline static int fav_memcheck(void) { +#ifdef MEM_CHECK return memcheck; -} #endif +} /* ---*/ static int get_type_size(int type) @@ -392,10 +394,16 @@ int fav_load(void) if (fav_stack_num > 0) return -1; setuserfile(buf, FAV4); - fd = open(buf, O_RDONLY); - if (fd < 0){ - return -1; + + if (!dashf(buf)) { + fp = (fav_t *)fav_malloc(sizeof(fav_t)); + fav_stack_push_fav(fp); + fav_set_memcheck(MEM_CHECK); + return 0; } + + if ((fd = open(buf, O_RDONLY)) < 0) + return -1; fp = (fav_t *)fav_malloc(sizeof(fav_t)); read_favrec(fd, fp); fav_stack_push_fav(fp); @@ -944,9 +952,13 @@ int fav_v3_to_v4(void) { int i, fd, fdw; char buf[128]; - short nDatas; char nLines; + + setuserfile(buf, FAV3); + if (!dashf(buf)) + return -1; + fav_t *fav4 = (fav_t *)fav_malloc(sizeof(fav_t)); fav3_board_t *brd; |