summaryrefslogtreecommitdiffstats
path: root/mbbsd/record.c
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-02-09 05:51:36 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-02-09 05:51:36 +0800
commit557b15f6cf039995ff56722a7a0438f01bda0bbd (patch)
tree5caec6029293d39d2af3092377815c27a72f1c0d /mbbsd/record.c
parent643e453cf2e0d8363e8767d7cd6a18797b50c057 (diff)
downloadpttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.tar
pttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.tar.gz
pttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.tar.bz2
pttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.tar.lz
pttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.tar.xz
pttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.tar.zst
pttbbs-557b15f6cf039995ff56722a7a0438f01bda0bbd.zip
* comment strange getindex() behavior.
* fix select_read() * don't incremental select if sr_mode = RE_MARK or RS_RECOMMEND * fix selection result repeating if timestamp match (or entry deleted?) * code revise git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3271 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r--mbbsd/record.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c
index b7ed123b..987b3e3d 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -67,7 +67,7 @@ get_record_keep(const char *fpath, void *rptr, int size, int id, int *fd)
/* 和 get_record() 一樣. 不過藉由 *fd, 可使同一個檔案不要一直重複開關 */
if (id >= 1 &&
(*fd > 0 ||
- ((*fd = open(fpath, O_RDONLY, 0)) > 0))){
+ ((*fd = open(fpath, O_RDONLY, 0)) > 0))){ // FIXME leak if *fd==0
if (lseek(*fd, (off_t) (size * (id - 1)), SEEK_SET) != -1) {
if (read(*fd, rptr, size) == size) {
return 0;
@@ -160,14 +160,20 @@ substitute_ref_record(const char *direct, fileheader_t * fhdr, int ent)
return num;
}
+/* return index>0 if thisstamp==stamp[index],
+ * return -index<0 if stamp[index-1]<thisstamp<stamp[index+1], XXX thisstamp ?<>? stamp[index]
+ * or XXX filename[index]=""
+ * return 0 if error
+ */
int
getindex(const char *direct, fileheader_t *fhdr, int end)
{ // Ptt: 從前面找很費力 太暴力
int fd = -1, begin = 1, i, s, times, stamp;
fileheader_t fh;
- if( end > (i = get_num_records(direct, sizeof(fileheader_t))) || end<=0 )
- end = i;
+ int n = get_num_records(direct, sizeof(fileheader_t));
+ if( end > n || end<=0 )
+ end = n;
stamp = atoi(fhdr->filename + 2);
for( i = (begin + end ) / 2, times = 0 ;
end >= begin && times < 20 ; /* 最多只找 20 次 */