From c1dfc037b337a648ae01dd004523703ca5f0b5c2 Mon Sep 17 00:00:00 2001 From: victor Date: Fri, 20 Feb 2004 03:51:35 +0000 Subject: forget to rename git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1549 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/vote.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 4d652e0a..263f8989 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -32,15 +32,17 @@ convert_to_newversion(FILE *fp, char *file, char *ballots) if ((fd = open(ballots, O_RDONLY)) != -1) { sprintf(buf, "%s.new", ballots); - fdw = open(buf, O_WRONLY); + fdw = open(buf, O_WRONLY | O_CREAT); flock(fd, LOCK_EX); /* Thor: 防止多人同時算 */ while (read(fd, &buf2[0], 1) == 1) { - buf2[0] -= 'A'; + if (buf2[0] >= 'A') + buf2[0] -= 'A'; write(fdw, &buf2[0], 1); } flock(fd, LOCK_UN); close(fd); close(fdw); + Rename(buf, ballots); } @@ -101,6 +103,8 @@ b_count(char *buf, int counts[], short item_num, int *total) if ((fd = open(buf, O_RDONLY)) != -1) { flock(fd, LOCK_EX); /* Thor: 防止多人同時算 */ while (read(fd, &choice, sizeof(short)) == sizeof(short)) { + if (choice >= item_num) + continue; counts[choice]++; (*total)++; } -- cgit v1.2.3