summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-02-20 11:51:35 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-02-20 11:51:35 +0800
commitc1dfc037b337a648ae01dd004523703ca5f0b5c2 (patch)
tree93e2d4f4fdca58a268a8e22b5c8d2350a9c661fa /mbbsd
parenteedb04eb15ca5970dc06a801a07dcf607ee87a7f (diff)
downloadpttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.tar
pttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.tar.gz
pttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.tar.bz2
pttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.tar.lz
pttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.tar.xz
pttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.tar.zst
pttbbs-c1dfc037b337a648ae01dd004523703ca5f0b5c2.zip
forget to rename
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1549 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/vote.c8
1 files changed, 6 insertions, 2 deletions
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)++;
}