From c69214eac725c2607a70ebd2df717cc200f876fd Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 25 Feb 2020 19:22:36 -0500 Subject: Add time tag to lines missing it If a line was produced by another client, it won't have one from the server. --- client.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client.c b/client.c index b81732d..9b55fdd 100644 --- a/client.c +++ b/client.c @@ -485,6 +485,16 @@ static Filter *Filters[] = { [CapUserhostInNamesBit] = filterUserhostInNames, }; +static bool hasTime(const char *line) { + if (!strncmp(line, "@time=", 6)) return true; + while (*line && *line != ' ') { + line += strcspn(line, "; "); + if (!strncmp(line, ";time=", 6)) return true; + if (*line == ';') line++; + } + return false; +} + void clientConsume(struct Client *client) { struct timeval time; const char *line = ringPeek(&time, client->consumer); @@ -503,7 +513,7 @@ void clientConsume(struct Client *client) { return; } - if (client->caps & CapServerTime && !(stateCaps & CapServerTime)) { + if (client->caps & CapServerTime && !hasTime(line)) { char ts[sizeof("YYYY-MM-DDThh:mm:ss")]; struct tm *tm = gmtime(&time.tv_sec); strftime(ts, sizeof(ts), "%FT%T", tm); -- cgit 1.4.1