uiFormat() passes time through multiple functions up into the flow()
where it is assigned per line doing nothing.
flow(), where actual messages are wrapped and marked up, seems to
be the wrong place to handle time(stamps) anyway since at this point
the nick/action/etc. was already printed.
The following warning will be dealt with in the next commit:
ui.c:591:41: warning: unused parameter 'time' [-Wunused-parameter]
uint id, enum Heat heat, const time_t *time, const char *format, ...
No functional change.
---
buffer.c | 5 +----
chat.h | 4 ++--
handle.c | 4 ++--
ui.c | 13 ++++++-------
4 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/buffer.c b/buffer.c
index ef175b8..7ef52fe 100644
--- a/buffer.c
+++ b/buffer.c
@@ -103,7 +103,6 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) {
struct Line *line = linesNext(hard);
line->heat = soft->heat;
- line->time = soft->time;
line->str = strdup(soft->str);
if (!line->str) err(EX_OSERR, "strdup");
@@ -178,7 +177,6 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) {
flowed++;
line = linesNext(hard);
line->heat = soft->heat;
- line->time = soft->time;
size_t cap = StyleCap + align + strlen(&wrap[n]) + 1;
line->str = malloc(cap);
@@ -200,11 +198,10 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) {
int bufferPush(
struct Buffer *buffer, int cols, enum Heat thresh,
- enum Heat heat, time_t time, const char *str
+ enum Heat heat, const char *str
) {
struct Line *soft = linesNext(&buffer->soft);
soft->heat = heat;
- soft->time = time;
soft->str = strdup(str);
if (!soft->str) err(EX_OSERR, "strdup");
if (heat < thresh) return 0;
diff --git a/chat.h b/chat.h
index 1b1c338..a1bc77e 100644
--- a/chat.h
+++ b/chat.h
@@ -290,7 +290,7 @@ void uiMoveID(uint id, uint num);
void uiCloseID(uint id);
void uiCloseNum(uint id);
void uiRead(void);
-void uiWrite(uint id, enum Heat heat, const time_t *time, const char *str);
+void uiWrite(uint id, enum Heat heat, const char *str);
void uiFormat(
uint id, enum Heat heat, const time_t *time, const char *format, ...
) __attribute__((format(printf, 4, 5)));
@@ -310,7 +310,7 @@ const struct Line *bufferSoft(const struct Buffer *buffer, size_t i);
const struct Line *bufferHard(const struct Buffer *buffer, size_t i);
int bufferPush(
struct Buffer *buffer, int cols, enum Heat thresh,
- enum Heat heat, time_t time, const char *str
+ enum Heat heat, const char *str
);
int bufferReflow(
struct Buffer *buffer, int cols, enum Heat thresh, size_t tail
diff --git a/handle.c b/handle.c
index ddf43e8..5989d98 100644
--- a/handle.c
+++ b/handle.c
@@ -317,7 +317,7 @@ static void handleErrorNoMOTD(struct Message *msg) {
static void handleReplyHelp(struct Message *msg) {
require(msg, false, 3);
urlScan(Network, NULL, msg->params[2]);
- uiWrite(Network, Warm, tagTime(msg), msg->params[2]);
+ uiWrite(Network, Warm, msg->params[2]);
}
static void handleJoin(struct Message *msg) {
@@ -565,7 +565,7 @@ static void handleReplyWho(struct Message *msg) {
static void handleReplyEndOfWho(struct Message *msg) {
require(msg, false, 2);
- uiWrite(idFor(msg->params[1]), Cold, tagTime(msg), whoBuf);
+ uiWrite(idFor(msg->params[1]), Cold, whoBuf);
whoCat.len = 0;
}
diff --git a/ui.c b/ui.c
index e3fd467..d84265b 100644
--- a/ui.c
+++ b/ui.c
@@ -558,16 +558,15 @@ static void notify(uint id, const char *str) {
_exit(EX_CONFIG);
}
-void uiWrite(uint id, enum Heat heat, const time_t *src, const char *str) {
+void uiWrite(uint id, enum Heat heat, const char *str) {
struct Window *window = windows.ptrs[windowFor(id)];
- time_t ts = (src ? *src : time(NULL));
if (heat >= window->thresh) {
if (!window->unreadSoft++) window->unreadHard = 0;
}
if (window->mark && heat > Cold) {
if (!window->unreadWarm++) {
- int lines = bufferPush(window->buffer, COLS, false, Warm, ts, "");
+ int lines = bufferPush(window->buffer, COLS, false, Warm, "");
if (window->scroll) windowScroll(window, lines);
if (window->unreadSoft > 1) {
window->unreadSoft++;
@@ -577,7 +576,7 @@ void uiWrite(uint id, enum Heat heat, const time_t *src, const char *str) {
if (heat > window->heat) window->heat = heat;
statusUpdate();
}
- int lines = bufferPush(window->buffer, COLS, window->thresh, heat, ts, str);
+ int lines = bufferPush(window->buffer, COLS, window->thresh, heat, str);
window->unreadHard += lines;
if (window->scroll) windowScroll(window, lines);
if (window == windows.ptrs[windows.show]) windowUpdate();
@@ -597,7 +596,7 @@ void uiFormat(
int len = vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
assert((size_t)len < sizeof(buf));
- uiWrite(id, heat, time, buf);
+ uiWrite(id, heat, buf);
}
static void resize(void) {
@@ -848,7 +847,7 @@ static void keyCode(int code) {
break; case KeyMetaD: edit(id, EditDeleteNextWord, 0);
break; case KeyMetaF: edit(id, EditNextWord, 0);
break; case KeyMetaL: bufferList(window->buffer);
- break; case KeyMetaM: uiWrite(id, Cold, NULL, "");
+ break; case KeyMetaM: uiWrite(id, Cold, "");
break; case KeyMetaN: windowScrollHot(window, +1);
break; case KeyMetaP: windowScrollHot(window, -1);
break; case KeyMetaQ: edit(id, EditCollapse, 0);
@@ -1061,7 +1060,7 @@ void uiLoad(const char *name) {
if (!time) break;
enum Heat heat = (version > 2 ? readTime(file) : Cold);
readString(file, &buf, &cap);
- bufferPush(window->buffer, COLS, window->thresh, heat, time, buf);
+ bufferPush(window->buffer, COLS, window->thresh, heat, buf);
}
window->unreadHard = bufferReflow(
window->buffer, COLS, window->thresh, window->unreadSoft
--
2.30.0