summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-02-20 12:17:11 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-02-20 12:17:11 +0800
commit9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2 (patch)
treed0b0cba5cffa3b69d5dc4fb5bacf0a67a82b23ba /mbbsd
parentd1bf6043e30457e19cade2d089e1a33642b27f57 (diff)
downloadpttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.tar
pttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.tar.gz
pttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.tar.bz2
pttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.tar.lz
pttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.tar.xz
pttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.tar.zst
pttbbs-9bbf2d58515eb0aa0c95a7ecf7cb408cb6d568e2.zip
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1551 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/vote.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index 8700c2ab..01e518f1 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -31,6 +31,16 @@ convert_to_newversion(FILE *fp, char *file, char *ballots)
int count = -1, tmp, fd, fdw;
FILE *fpw;
+ assert(fp);
+ flock(fileno(fp), LOCK_EX);
+ rewind(fp);
+ fgets(buf, sizeof(buf), fp);
+ if (index(buf, ',')) {
+ rewind(fp);
+ flock(fileno(fp), LOCK_UN);
+ return;
+ }
+
if ((fd = open(ballots, O_RDONLY)) != -1) {
sprintf(buf, "%s.new", ballots);
fdw = open(buf, O_WRONLY | O_CREAT, 0600);
@@ -47,16 +57,6 @@ convert_to_newversion(FILE *fp, char *file, char *ballots)
Rename(buf, ballots);
}
-
- assert(fp);
- flock(fileno(fp), LOCK_EX);
- rewind(fp);
- fgets(buf, sizeof(buf), fp);
- if (index(buf, ',')) {
- rewind(fp);
- flock(fileno(fp), LOCK_UN);
- return;
- }
sscanf(buf, " %d", &tmp);
sprintf(buf2, "%s.new", file);
if (!(fpw = fopen(buf2, "w"))) {