From: Egor Date: Sun, 8 Feb 2026 01:26:11 +0000 (+0200) Subject: ircfmt: 64-bit time_t formatting X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=682b86a5ff183e93a247d1af54029b77d39d6f23;p=patchyircd.git ircfmt: 64-bit time_t formatting --- diff --git a/src/ircfmt.cpp b/src/ircfmt.cpp index 63b272c..5c8ce3b 100644 --- a/src/ircfmt.cpp +++ b/src/ircfmt.cpp @@ -354,9 +354,8 @@ void rpl_whoisoperator(Client *client, Client *cl) // 313 // 314 RPL_WHOWASUSER void rpl_whoisidle(Client *client, Client *cl) // 317 { - // FIXME: 64-bit time_t support - copy_strf(&databuf, ":%s 317 %s %s %u %u :seconds idle, signon time\r\n", - hostname, client->nick, cl->nick, (unsigned)(get_time()-cl->lastactivity), (unsigned)cl->signon); + copy_strf(&databuf, ":%s 317 %s %s %lu %lu :seconds idle, signon time\r\n", + hostname, client->nick, cl->nick, (unsigned long)(get_time()-cl->lastactivity), (unsigned long)cl->signon); } void rpl_endofwhois(Client *client, Client *cl) // 318 { @@ -400,8 +399,7 @@ void rpl_channelmodeis(Client *client, Channel *chan) // 324 } void rpl_creationtime(Client *client, Channel *chan) // 329 { - // FIXME: 64-bit time_t support - copy_strf(&databuf, ":%s 329 %s %s %u\r\n", hostname, client->nick, chan->name, (unsigned)chan->creation); + copy_strf(&databuf, ":%s 329 %s %s %lu\r\n", hostname, client->nick, chan->name, (unsigned long)chan->creation); } void rpl_whoisaccount(Client *client, Client *cl) // 330 { @@ -419,9 +417,8 @@ void rpl_topic(Client *client, Channel *chan) // 332 } void rpl_topicwhotime(Client *client, Channel *chan) // 333 { - // FIXME: 64-bit time_t support - copy_strf(&databuf, ":%s 333 %s %s %s %u\r\n", hostname, client->nick, - chan->name, chan->topic_who, (unsigned)chan->topic_when); + copy_strf(&databuf, ":%s 333 %s %s %s %lu\r\n", hostname, client->nick, + chan->name, chan->topic_who, (unsigned long)chan->topic_when); } void rpl_whoisbot(Client *client, Client *cl) // 335 { @@ -529,7 +526,6 @@ void rpl_youreoper(Client *client) // 381 // 382 RPL_REHASHING void rpl_time(Client *client, time_t ts) // 391 { - // FIXME: 64-bit time_t support char buf[26]; memcpy(buf, ctime(&ts), 26); buf[24] = '\0'; diff --git a/src/util.cpp b/src/util.cpp index 28497b6..7d31889 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -43,6 +43,14 @@ void append_strf(std::vector *v, const char *s, ...) { char c = static_cast(va_arg(ap, int)); append_strn(v, &c, 1); s = end + 2; + } else if (end[1] == 'l' && end[2] == 'u') { // %lu + append_strn(v, s, end-s); + unsigned long c = va_arg(ap, unsigned long); + char buf[21] = {0}; + auto res = std::to_chars(std::begin(buf), std::end(buf), c); + if (res.ec == std::errc()) + append_strn(v, buf, res.ptr-buf); + s = end + 3; } else if (end[1] == 'u') { // %u append_strn(v, s, end-s); unsigned c = va_arg(ap, unsigned);