indent: fix ii line formting change - lchat - A line oriented chat front end fo… | |
git clone git://git.suckless.org/lchat | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 99b9e3343a2e550e2634aac6353143bb59546607 | |
parent 1242ea1d3350f961e9c9c113fb964caa34b11163 | |
Author: Jan Klemkow <[email protected]> | |
Date: Sat, 2 Sep 2017 14:47:12 +0200 | |
indent: fix ii line formting change | |
Diffstat: | |
M filter/indent.c | 14 ++++++++------ | |
1 file changed, 8 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/filter/indent.c b/filter/indent.c | |
@@ -17,24 +17,26 @@ main(void) | |
char old_nick[BUFSIZ] = ""; | |
char *fmt = "%H:%M"; | |
char *next, *nick, *word; | |
- struct tm tm; | |
int cols = 80; /* terminal width */ | |
int color = color1; | |
while (fgets(buf, sizeof buf, stdin) != NULL) { | |
- next = strptime(buf, "%Y-%m-%d %H:%M ", &tm); | |
+ time_t time = strtol(buf, &next, 10); | |
+ struct tm *tm = localtime(&time); | |
- if (next == NULL || next[0] == '-') { | |
+ next++; /* skip space */ | |
+ | |
+ if (next == NULL || next[0] == '-' || time == 0) { | |
fputs(buf, stdout); | |
fflush(stdout); | |
continue; | |
} | |
nick = strsep(&next, ">"); | |
- nick++; | |
- next++; | |
+ nick++; /* skip '>' */ | |
+ next++; /* skip space */ | |
- strftime(timestr, sizeof timestr, fmt, &tm); | |
+ strftime(timestr, sizeof timestr, fmt, tm); | |
/* swap color */ | |
if (strcmp(nick, old_nick) != 0) |