用 A/a 搜寻作者时会发生找到包含要查的 id 的长 id 的情况。
对此我修改系统为完全匹配 id,而 id 前置 '?' 则使用以前那样的部分匹配。
另外,在信箱中搜寻时只判断 id 不判断昵称。
例如输入 bbs 将只搜寻 bbs 发的文章/信件,
而输入 ?bbs 将会认为 bbs, BBS0, smthbbs 等 id 都匹配。
请指教。
diff 的结果如下:
--- old/read.c
+++ read.c
@@ -1,3 +1,7 @@
+/* Last Update : 2002.5.10 Andor
+ 在版面和信箱搜寻作者支持完全匹配和部分匹配.
+ 对信件需要特殊处理, 其owner = id + " (" + nick + ")", 需将 id 截出.
+*/
/*
Pirate Bulletin Board System
Copyright (C) 1990, Edward Luke, lush@Athena.EE.MsState.EDU
@@ -675,6 +679,7 @@
return FULLUPDATE;
}
+/* Modified by Andor, 2002.5.10. */
int
search_author( locmem, offset ,powner)
struct keeploc *locmem;
@@ -686,8 +691,16 @@
char currauth[STRLEN];
strcpy( currauth, powner);
+/* BEGIN Andor 2002.5.10 */
+ if (in_mail)
+ {
+ char *pc;
+ for (pc=currauth; '\0'!=*pc && ' '!=*pc; ++pc);
+ *pc = '\0';
+ }
+/* END Andor 2002.5.10 */
- sprintf( pmt, "%s的文章搜寻作者 [%s]: ", offset > 0 ? "往后来" : "往先
前", currauth );
+ sprintf( pmt, "%s搜寻作者(部分匹配请前置'?') [%s]: ", offset > 0 ? "往
后" : "往前", currauth );
move(t_lines-1,0);
clrtoeol();
getdata( t_lines-1, 0, pmt, ans, IDLEN, DOECHO, NULL ,YEA);
@@ -1040,6 +1053,7 @@
return NA;
}
+/* Modified by Andor, 2002.5.10. */
int
search_articles( locmem, query, offset, aflag )
struct keeploc *locmem;
@@ -1050,7 +1064,9 @@
int now, match = 0;
int complete_search;
int ssize = sizeof(struct fileheader);
+ char upper_ptr[STRLEN],upper_query[STRLEN];
+ get_upper_str(upper_query,query);
if(aflag>=2)
{
@@ -1106,10 +1122,19 @@
}
}else
{
- char upper_ptr[STRLEN],upper_query[STRLEN];
get_upper_str(upper_ptr,ptr);
- get_upper_str(upper_query,query);
- if( strstr( upper_ptr, upper_query ) != NULL ) {
+ /* COMMAN : move upper_query out of loop */
+ /* BEGIN Andor 2002.5.10 */
+ if (1==aflag && in_mail)
+ {
+ char *pc;
+ for (pc=upper_ptr; '\0'!=*pc && ' '!=*pc; ++pc);
+ *pc = '\0';
+ }
+ if(1==aflag && '?'!=query[0] ?
+ !strcmp(upper_ptr, upper_query) :
+ strstr(upper_ptr, upper_query+(1==aflag)) != NULL) {
+ /* END Andor 2002.5.10 */
match = cursor_pos( locmem, now, 10 );
break;
}
--
修改:Andor FROM 166.111.137.58
FROM 166.111.137.58