summary refs log tree commit diff
path: root/ui-stats.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-06-08 14:27:44 -0400
committerJune McEnroe <june@causal.agency>2021-06-08 14:27:44 -0400
commit5213546273ee798369ff594ad60077f1bef4655e (patch)
tree37e7aec5ddc583047da1126ffdc41a81f20cf1f6 /ui-stats.c
parentSquashed 'www/git.causal.agency/cgit/' content from commit 02221fd3 (diff)
downloadsrc-5213546273ee798369ff594ad60077f1bef4655e.tar.gz
src-5213546273ee798369ff594ad60077f1bef4655e.zip
Squashed 'www/git.causal.agency/cgit/' changes from 55fa25ad..5258c297
5258c297 git: update to v2.32.0
6dbbffe0 git: update to v2.31.1
62eb8db4 md2html: use proper formatting for hr
d889cae8 git: update to v2.31.0
4ffadc1e git: update to v2.30.1
bd6f5683 tests: t0107: support older and/or non-GNU tar
f69626c6 md2html: use sane_lists extension
cef27b67 git: update to v2.30.0
b1739247 git: update to v2.29.2
fe99c76e git: update to v2.29.1
adcc4f82 tests: try with commit-graph
a1039ab1 tests: do not copy snapshots to /tmp/
a4de0e81 global: replace hard coded hash length
779631c6 global: replace references to 'sha1' with 'oid'
629659d2 git: update to v2.29.0
205837d4 git: update to v2.28.0
f780396c git: update to v2.27.0
0462f08d git: update to v2.26.0

git-subtree-dir: www/git.causal.agency/cgit
git-subtree-split: 5258c297ba6fb604ae1415fbc19a3fe42457e49e
Diffstat (limited to 'ui-stats.c')
-rw-r--r--ui-stats.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/ui-stats.c b/ui-stats.c
index 7272a61a..09b3625e 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -166,7 +166,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
 	struct authorstat *authorstat;
 	struct string_list *items;
 	char *tmp;
-	struct tm *date;
+	struct tm date;
 	time_t t;
 	uintptr_t *counter;
 
@@ -180,9 +180,9 @@ static void add_commit(struct string_list *authors, struct commit *commit,
 	authorstat = author->util;
 	items = &authorstat->list;
 	t = info->committer_date;
-	date = gmtime(&t);
-	period->trunc(date);
-	tmp = xstrdup(period->pretty(date));
+	gmtime_r(&t, &date);
+	period->trunc(&date);
+	tmp = xstrdup(period->pretty(&date));
 	item = string_list_insert(items, tmp);
 	counter = (uintptr_t *)&item->util;
 	if (*counter)
@@ -215,15 +215,15 @@ static struct string_list collect_stats(const struct cgit_period *period)
 	int argc = 3;
 	time_t now;
 	long i;
-	struct tm *tm;
+	struct tm tm;
 	char tmp[11];
 
 	time(&now);
-	tm = gmtime(&now);
-	period->trunc(tm);
+	gmtime_r(&now, &tm);
+	period->trunc(&tm);
 	for (i = 1; i < period->count; i++)
-		period->dec(tm);
-	strftime(tmp, sizeof(tmp), "%Y-%m-%d", tm);
+		period->dec(&tm);
+	strftime(tmp, sizeof(tmp), "%Y-%m-%d", &tm);
 	argv[2] = xstrdup(fmt("--since=%s", tmp));
 	if (ctx.qry.path) {
 		argv[3] = "--";
@@ -261,21 +261,21 @@ static void print_combined_authorrow(struct string_list *authors, int from,
 	struct string_list_item *date;
 	time_t now;
 	long i, j, total, subtotal;
-	struct tm *tm;
+	struct tm tm;
 	char *tmp;
 
 	time(&now);
-	tm = gmtime(&now);
-	period->trunc(tm);
+	gmtime_r(&now, &tm);
+	period->trunc(&tm);
 	for (i = 1; i < period->count; i++)
-		period->dec(tm);
+		period->dec(&tm);
 
 	total = 0;
 	htmlf("<tr><td class='%s'>%s</td>", leftclass,
 		fmt(name, to - from + 1));
 	for (j = 0; j < period->count; j++) {
-		tmp = period->pretty(tm);
-		period->inc(tm);
+		tmp = period->pretty(&tm);
+		period->inc(&tm);
 		subtotal = 0;
 		for (i = from; i <= to; i++) {
 			author = &authors->items[i];
@@ -300,20 +300,20 @@ static void print_authors(struct string_list *authors, int top,
 	struct string_list_item *date;
 	time_t now;
 	long i, j, total;
-	struct tm *tm;
+	struct tm tm;
 	char *tmp;
 
 	time(&now);
-	tm = gmtime(&now);
-	period->trunc(tm);
+	gmtime_r(&now, &tm);
+	period->trunc(&tm);
 	for (i = 1; i < period->count; i++)
-		period->dec(tm);
+		period->dec(&tm);
 
 	html("<table class='stats'><tr><th>Author</th>");
 	for (j = 0; j < period->count; j++) {
-		tmp = period->pretty(tm);
+		tmp = period->pretty(&tm);
 		htmlf("<th>%s</th>", tmp);
-		period->inc(tm);
+		period->inc(&tm);
 	}
 	html("<th>Total</th></tr>\n");
 
@@ -329,10 +329,10 @@ static void print_authors(struct string_list *authors, int top,
 		items = &authorstat->list;
 		total = 0;
 		for (j = 0; j < period->count; j++)
-			period->dec(tm);
+			period->dec(&tm);
 		for (j = 0; j < period->count; j++) {
-			tmp = period->pretty(tm);
-			period->inc(tm);
+			tmp = period->pretty(&tm);
+			period->inc(&tm);
 			date = string_list_lookup(items, tmp);
 			if (!date)
 				html("<td>0</td>");