From e246cd2d6a2eb7bf62edf16afbee8d288e83dd37 Mon Sep 17 00:00:00 2001 From: kcwu Date: Mon, 18 Jun 2007 17:14:53 +0000 Subject: * revise code. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3546 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/gamble.c | 3 +-- mbbsd/topsong.c | 3 +-- mbbsd/vote.c | 3 +-- mbbsd/voteboard.c | 6 +++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 79cb5be8..049bda74 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -50,8 +50,7 @@ show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],const char *direct, int *p fgets(genbuf, MAX_ITEM_LEN, fp); *price = atoi(genbuf); for (count = 0; fgets(betname[count], MAX_ITEM_LEN, fp) && count < MAX_ITEM; count++) { - char *newline = strpbrk(betname[count], "\r\n"); - if (newline) *newline = '\0'; + chomp(betname[count]); } fclose(fp); diff --git a/mbbsd/topsong.c b/mbbsd/topsong.c index 01163f24..a60a26c4 100644 --- a/mbbsd/topsong.c +++ b/mbbsd/topsong.c @@ -53,8 +53,7 @@ sortsong(void) totalcount = 0; /* XXX: 除了前 MAX_SONGS 首, 剩下不會排序 */ while (fgets(buf, 200, fp)) { - char *newline = strpbrk(buf, "\n\r"); - if (newline) *newline = '\0'; + chomp(buf); strip_blank(cbuf, buf); if (!cbuf[0] || !isprint2((int)cbuf[0])) continue; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 917865e8..d15ee08f 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -966,8 +966,7 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind) count = 0; for (i = 0; i < ITEM_PER_PAGE && fgets(inbuf, sizeof(inbuf), cfp); i++) { - char *newline = strpbrk(inbuf, "\r\n"); - if (newline) *newline = '\0'; + chomp(inbuf); move((count % 15) + 5, (count / 15) * 40); prints("%c%s", chosen[curr_page * ITEM_PER_PAGE + i] ? '*' : ' ', inbuf); diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 0b644a60..10594079 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -44,7 +44,7 @@ do_voteboardreply(const fileheader_t * fhdr) assert(fi); while (fgets(genbuf, sizeof(genbuf), fi)) { - char *newline; + char *space; if (yes>=0) { @@ -67,8 +67,8 @@ do_voteboardreply(const fileheader_t * fhdr) } if(yes>=0) continue; - newline = strpbrk(genbuf+4, " \n"); - if(newline) *newline='\0'; + space = strpbrk(genbuf+4, " \n"); + if(space) *space='\0'; if (!strncmp(genbuf + 4, cuser.userid, IDLEN)) { move(5, 10); outs("您已經連署過本篇了"); -- cgit v1.2.3