commit bf26a633636ba2058b6bb747b0dd4ab17cb185a8 from: Omar Polo date: Thu Oct 05 09:32:14 2023 UTC gotwebd: inline the only use of TM_RFC822 commit - f82755119394cfc406b17844a3a159cc75369275 commit + bf26a633636ba2058b6bb747b0dd4ab17cb185a8 blob - 7dfcab373f2846a43c2eeefc605fae2754869e12 blob + 31ec1b7671fbb5d5b67b5d5ef6f6ac7742ca1782 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -1413,19 +1413,7 @@ gotweb_render_age(struct template *tp, time_t committe if (tp_writes(tp, datebuf) == -1 || tp_writes(tp, " UTC") == -1) - return -1; - break; - case TM_RFC822: - if (gmtime_r(&committer_time, &tm) == NULL) - return -1; - - r = strftime(datebuf, sizeof(datebuf), - "%a, %d %b %Y %H:%M:%S GMT", &tm); - if (r == 0) return -1; - - if (tp_writes(tp, datebuf) == -1) - return -1; break; } return 0; blob - ac6c5c8b552e91a539cec6f809ae7ca9d3e6cded blob + 908f76ea062a793a125040df6011a8852db3b00a --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -438,7 +438,6 @@ enum query_actions { enum gotweb_ref_tm { TM_DIFF, TM_LONG, - TM_RFC822, }; extern struct gotwebd *gotwebd_env; blob - 21a20e0bd45cda02ff863e1b5f884ab7813bb4a3 blob + 675bb083cd6fc3a41a5fcd288e910040a637d289 --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -989,6 +989,9 @@ static inline int rss_author(struct template *, char * struct request *c = tp->tp_arg; struct transport *t = c->t; struct repo_dir *repo_dir = t->repo_dir; + struct tm tm; + char rfc822[128]; + int r; char *tag_name = rt->tag_name; struct gotweb_url tag = { .action = TAG, @@ -1000,6 +1003,12 @@ static inline int rss_author(struct template *, char * if (strncmp(tag_name, "refs/tags/", 10) == 0) tag_name += 10; + + if (gmtime_r(&rt->tagger_time, &tm) == NULL) + return -1; + r = strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S GMT", &tm); + if (r == 0) + return 0; !} {{ repo_dir->name }} {{" "}} {{ tag_name }} @@ -1014,7 +1023,7 @@ static inline int rss_author(struct template *, char * {{ render rss_author(tp, rt->tagger) }} {{ rt->commit_id }} - {{ render gotweb_render_age(tp, rt->tagger_time, TM_RFC822) }} + {{ rfc822 }} {{ end }}