summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-09-16 10:50:18 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-09-16 10:50:18 +0800
commit50374a66e62e9b9471928726536efb86e316eb1d (patch)
tree18fc23f3780eaa5daeca7854629675c4fe022938
parente66641d118d32c1cbb202b4e18198b502fe627a5 (diff)
downloadpttbbs-50374a66e62e9b9471928726536efb86e316eb1d.tar
pttbbs-50374a66e62e9b9471928726536efb86e316eb1d.tar.gz
pttbbs-50374a66e62e9b9471928726536efb86e316eb1d.tar.bz2
pttbbs-50374a66e62e9b9471928726536efb86e316eb1d.tar.lz
pttbbs-50374a66e62e9b9471928726536efb86e316eb1d.tar.xz
pttbbs-50374a66e62e9b9471928726536efb86e316eb1d.tar.zst
pttbbs-50374a66e62e9b9471928726536efb86e316eb1d.zip
Fix buffer size bug and correcting output.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2196 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/angel.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/util/angel.c b/util/angel.c
index fca4c0d7..57417d0e 100644
--- a/util/angel.c
+++ b/util/angel.c
@@ -5,8 +5,8 @@
int main(){ return 0; }
#else
-int total[MAX_USERS];
-unsigned char reject[MAX_USERS];
+int total[MAX_USERS + 1];
+unsigned char reject[MAX_USERS + 1];
int nReject[4];
int rej_question;
int double_rej;
@@ -90,12 +90,12 @@ void readData(){
list = (int(*)[2]) malloc(count * sizeof(int[2]));
rej_list = (int*) malloc(double_rej * sizeof(int));
k = j = 0;
- for (i = 0; i < MAX_USERS; ++i)
+ for (i = 1; i <= MAX_USERS; ++i)
if (total[i] > 0) {
list[j][0] = total[i] - 1;
list[j][1] = i;
++j;
- if (reject[i])
+ if (reject[i] >= 2)
rej_list[k++] = i;
}
@@ -158,7 +158,7 @@ void sendResult(){
"連續兩次統計都不開放的有 %d 位:\n",
count - rej_question, rej_question, double_rej);
for (i = 0; i < double_rej; ++i) {
- fprintf(fp, "%13s %d 次", SHM->userid[rej_list[i] - 1],
+ fprintf(fp, "%13s %3d 次", SHM->userid[rej_list[i] - 1],
reject[rej_list[i]]);
if (i % 4 == 3) fputc('\n', fp);
}