From 179abe13e836ecfd85ee724c9ac77b6ad8b07d78 Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 23 Jul 2011 07:05:46 +0000 Subject: trim keyword in search. git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5380 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/mbbsd/board.c | 1 + pttbbs/mbbsd/read.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c index 28f963c3..ba83e890 100644 --- a/pttbbs/mbbsd/board.c +++ b/pttbbs/mbbsd/board.c @@ -1680,6 +1680,7 @@ choose_board(int newflag) } else { getdata_buf(b_lines - 1, 0, "請輸入看板中文關鍵字:", keyword, sizeof(keyword), DOECHO); + trim(keyword); } brdnum = -1; break; diff --git a/pttbbs/mbbsd/read.c b/pttbbs/mbbsd/read.c index 9b3b81e9..bfc899a9 100644 --- a/pttbbs/mbbsd/read.c +++ b/pttbbs/mbbsd/read.c @@ -480,6 +480,12 @@ mail_forward(const fileheader_t * fhdr, const char *direct, int mode) } #endif +static int +trim_blank(char *buf) { + trim(buf); + return *buf == 0; +} + static int select_read(const keeploc_t * locmem, int sr_mode) { @@ -507,14 +513,14 @@ select_read(const keeploc_t * locmem, int sr_mode) { if(!getdata(b_lines, 0, currmode & MODE_SELECT ? "增加條件 作者: ":"搜尋作者: ", - keyword, IDLEN+1, DOECHO)) + keyword, IDLEN+1, DOECHO) || trim_blank(keyword)) return READ_REDRAW; } else if(sr_mode & RS_KEYWORD) { if(!getdata(b_lines, 0, currmode & MODE_SELECT ? "增加條件 標題: ":"搜尋標題: ", - keyword, TTLEN, DOECHO)) + keyword, TTLEN, DOECHO) || trim_blank(keyword)) return READ_REDRAW; #ifdef KEYWORD_LOG log_filef("keyword_search_log", LOG_CREAT, @@ -527,7 +533,8 @@ select_read(const keeploc_t * locmem, int sr_mode) // let's use TTLEN-4 here. if(!(currmode & MODE_SELECT) || !getdata(b_lines, 0, "增加條件 排除標題: ", - keyword, TTLEN-4, DOECHO)) + keyword, TTLEN-4, DOECHO) || + trim_blank(keyword)) return READ_REDRAW; } else if (sr_mode & RS_RECOMMEND) -- cgit v1.2.3