hirc

IRC client
Log | Files | Refs

commit 43239b4a882fac90bfbb3ebcb4bc205734382610
parent 8dd8a0ff54e4099c1922da6e2e0c14c371d48074
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 10 Apr 2022 13:18:53 +0100

Add HIST_NIGN for immunity to ignores (/ignore's output should not be ignored)

Diffstat:
Msrc/commands.c | 4++--
Msrc/hist.c | 16+++++++++-------
Msrc/struct.h | 21+++++++++++----------
Msrc/ui.c | 8++++----
4 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -1860,7 +1860,7 @@ command_ignore) { hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_START :Ignoring:"); for (p = ignores, i = 1; p; p = p->next, i++) if (!serv || !p->server || strcmp(server->name, p->server) == 0) - hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_LIST %d %s :%s", + hist_format(selected.history, Activity_none, HIST_UI|HIST_NIGN, "SELF_IGNORES_LIST %d %s :%s", i, p->server ? p->server : "ANY", p->text); hist_format(selected.history, Activity_none, HIST_UI, "SELF_IGNORES_END :End of ignore list"); return; @@ -1901,7 +1901,7 @@ command_ignore) { } ign = emalloc(sizeof(struct Ignore)); - ign->next = NULL; + ign->next = ign->prev = NULL; if ((ret = regcomp(&ign->regex, str, regopt)) != 0) { regerror(ret, &ign->regex, errbuf, sizeof(errbuf)); ui_error("%s: %s", errbuf, str); diff --git a/src/hist.c b/src/hist.c @@ -129,21 +129,23 @@ hist_add(struct HistInfo *histinfo, if (options & HIST_MAIN) { if (options & HIST_TMP && histinfo == main_buf) { - hist_add(main_buf, msg, activity, timestamp, HIST_SHOW); + hist_add(main_buf, msg, activity, timestamp, options & ~(HIST_MAIN|HIST_TMP|HIST_LOG)); new = NULL; goto ui; } else if (histinfo != main_buf) { - hist_add(main_buf, msg, activity, timestamp, HIST_SHOW); + hist_add(main_buf, msg, activity, timestamp, options & ~(HIST_MAIN|HIST_TMP|HIST_LOG)); } else { ui_error("HIST_MAIN specified, but history is &main_buf", NULL); } } - for (ign = ignores; ign; ign = ign->next) { - if (!ign->server || (histinfo->server && strcmp_n(ign->server, histinfo->server->name))) { - if (regexec(&ign->regex, msg, 0, NULL, 0) == 0) { - options |= HIST_IGN; - break; + if (!(options & HIST_NIGN)) { + for (ign = ignores; ign; ign = ign->next) { + if (!ign->server || (histinfo->server && strcmp_n(ign->server, histinfo->server->name))) { + if (regexec(&ign->regex, msg, 0, NULL, 0) == 0) { + options |= HIST_IGN; + break; + } } } } diff --git a/src/struct.h b/src/struct.h @@ -47,16 +47,17 @@ enum Activity { }; enum HistOpt { - HIST_SHOW = 1, /* show in buffer */ - HIST_LOG = 2, /* log to server->logfd */ - HIST_MAIN = 4, /* copy to &main_buf */ - HIST_SELF = 8, /* from = self */ - HIST_TMP = 16, /* purge later */ - HIST_GREP = 32, /* generated by /grep */ - HIST_ERR = 64, /* generated by ui_error and friends */ - HIST_SERR = 128,/* generated by 400-599 numerics (which should be errors) */ - HIST_RLOG = 256,/* messages read from log, useful for clearing the log */ - HIST_IGN = 512,/* added to ignored messages */ + HIST_SHOW = 1, /* show in buffer */ + HIST_LOG = 2, /* log to server->logfd */ + HIST_MAIN = 4, /* copy to &main_buf */ + HIST_SELF = 8, /* from = self */ + HIST_TMP = 16, /* purge later */ + HIST_GREP = 32, /* generated by /grep */ + HIST_ERR = 64, /* generated by ui_error and friends */ + HIST_SERR = 128, /* generated by 400-599 numerics (which should be errors) */ + HIST_RLOG = 256, /* messages read from log, useful for clearing the log */ + HIST_IGN = 512, /* added to ignored messages */ + HIST_NIGN = 1024,/* immune to ignoring (SELF_IGNORES_LIST & SELF_ERROR) */ HIST_DFL = HIST_SHOW|HIST_LOG, HIST_UI = HIST_SHOW|HIST_TMP|HIST_MAIN, HIST_ALL = 0xFFFF diff --git a/src/ui.c b/src/ui.c @@ -288,14 +288,14 @@ ui_error_(char *file, int line, const char *func, char *format, ...) { vsnprintf(msg, sizeof(msg), format, ap); va_end(ap); - hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR|HIST_NIGN, "SELF_ERROR %s %d %s :%s", file, line, func, msg); } void ui_perror_(char *file, int line, const char *func, char *str) { - hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR|HIST_NIGN, "SELF_ERROR %s %d %s :%s: %s", file, line, func, str, strerror(errno)); } @@ -303,14 +303,14 @@ ui_perror_(char *file, int line, const char *func, char *str) { #ifdef TLS void ui_tls_config_error_(char *file, int line, const char *func, struct tls_config *config, char *str) { - hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR|HIST_NIGN, "SELF_ERROR %s %d %s :%s: %s", file, line, func, str, tls_config_error(config)); } void ui_tls_error_(char *file, int line, const char *func, struct tls *ctx, char *str) { - hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR|HIST_NIGN, "SELF_ERROR %s %d %s :%s: %s", file, line, func, str, tls_error(ctx)); }