diff options
-rw-r--r-- | mbbsd/bbs.c | 22 | ||||
-rw-r--r-- | sample/pttbbs.conf | 3 |
2 files changed, 21 insertions, 4 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index a14c197c..1bda4b80 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -828,11 +828,13 @@ do_general(int isbid) struct stat st; postfile.multi.money = aborted; +#ifdef USE_TEXTLEN if (stat(fpath, &st) != -1) { /* put original file (text) length. */ postfile.textlen = st.st_size; } +#endif } strlcpy(postfile.owner, owner, sizeof(postfile.owner)); @@ -1161,13 +1163,17 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) setdirpath(genbuf, direct, fhdr->filename); local_article = fhdr->filemode & FILE_LOCAL; - if(fhdr->textlen <= 0) - Copy(genbuf, fpath); - else +#ifdef USE_TEXTLEN + if(fhdr->textlen > 0) { /* TODO SYSOP may need some function to edit entire file. */ CopyN(genbuf, fpath, fhdr->textlen); } + else +#endif + { + Copy(genbuf, fpath); + } strlcpy(save_title, fhdr->title, sizeof(save_title)); @@ -1182,7 +1188,11 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) /* check textlen */ if(fhdr->textlen > 0) { - int gotnewstat = 0; + int gotnewstat = -1; + +#ifdef USE_TEXTLEN + /* TODO should we reload textlen info? + * multiple editing will make textlen invalid. */ if(fhdr->textlen != newstat.st_size) { #ifdef DEBUG @@ -1195,12 +1205,16 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) } else { gotnewstat = stat(fpath, &newstat); } +#endif + /* now update the record. */ if(gotnewstat != -1) fhdr->textlen = newstat.st_size; else fhdr->textlen = 0; + recordTouched = 1; + } else /* old flavor, no textlen info */ if (oldstat.st_mtime != newstat.st_mtime) { diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf index 3f85bb7e..6b815e31 100644 --- a/sample/pttbbs.conf +++ b/sample/pttbbs.conf @@ -142,6 +142,9 @@ /* "不"使用新式的 pmore (piaip's more) 代替舊式 bug 抓不完的 more */ //#define USE_TRADITIONAL_MORE +/* 使用 textlen 欄位來確定文章實際長度,避免蓋掉推文等。 */ +// #define USE_TEXTLEN + /* 使用 rfork()取代 fork() . 目前只在 FreeBSD上有效 */ //#define USE_RFORK |