From 3ecbd4823ea79347196c68de7b69dd5dd5f50f89 Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 9 Feb 2012 15:34:51 +0000 Subject: Fix divide-by-zero if the site population is small. Thanks to Moti@ptt2. git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5561 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/util/account.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pttbbs/util/account.c b/pttbbs/util/account.c index aad84aae..822969b8 100644 --- a/pttbbs/util/account.c +++ b/pttbbs/util/account.c @@ -154,6 +154,9 @@ output_today(struct tm *ptime, int act[27], int peak_hour_login, int day_login) int avg_len = ((day_login - peak_hour_login) / 23) + 1; int bar_unit = avg_len / (bar_max_width / 2 / 2); + if (bar_unit < 1) + bar_unit = 1; + printf("peak: %d, day_login: %d\n", peak_hour_login, day_login); printf("avg_len=%d, bar_unit=%d\n", avg_len, bar_unit); -- cgit v1.2.3