summary refs log tree commit diff
path: root/command.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-01 20:09:10 -0500
committerJune McEnroe <june@causal.agency>2021-01-01 20:09:10 -0500
commit4b883177dc025db24473e62469f97631a12ad536 (patch)
tree0039251bc3093c68c44eb95fb7a1051168fe3acf /command.c
parentFactor out reply count checking and decrementing (diff)
downloadcatgirl-4b883177dc025db24473e62469f97631a12ad536.tar.gz
catgirl-4b883177dc025db24473e62469f97631a12ad536.zip
Split ignore fields to avoid over-eager * matching
Split ignore fields and match each separately to avoid an early *
eagerly matching across several fields. For example, "* JOIN * *" should
not match messages which happen to contain the word "JOIN" followed by
two other words.

Ignore capacity is reduced to 64 to keep the size of the array the same.
I don't think it's an issue.
Diffstat (limited to '')
-rw-r--r--command.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/command.c b/command.c
index 43870f1..c71bebc 100644
--- a/command.c
+++ b/command.c
@@ -388,16 +388,19 @@ static void commandCopy(uint id, char *params) {
 
 static void commandIgnore(uint id, char *params) {
 	if (params) {
-		const char *pattern = ignoreAdd(params);
+		struct Ignore ignore = ignoreAdd(params);
 		uiFormat(
-			id, Cold, NULL, "Ignoring \3%02d%s\3",
-			Brown, pattern
+			id, Cold, NULL, "Ignoring \3%02d%s %s %s %s",
+			Brown, ignore.mask,
+			(ignore.cmd ?: ""), (ignore.chan ?: ""), (ignore.mesg ?: "")
 		);
 	} else {
-		for (size_t i = 0; i < ignore.len; ++i) {
+		for (size_t i = 0; i < IgnoreCap && ignores[i].mask; ++i) {
 			uiFormat(
-				Network, Warm, NULL, "Ignoring \3%02d%s\3",
-				Brown, ignore.patterns[i]
+				Network, Warm, NULL, "Ignoring \3%02d%s %s %s %s",
+				Brown, ignores[i].mask,
+				(ignores[i].cmd ?: ""), (ignores[i].chan ?: ""),
+				(ignores[i].mesg ?: "")
 			);
 		}
 	}
@@ -405,14 +408,13 @@ static void commandIgnore(uint id, char *params) {
 
 static void commandUnignore(uint id, char *params) {
 	if (!params) return;
-	if (ignoreRemove(params)) {
-		uiFormat(
-			id, Cold, NULL, "No longer ignoring \3%02d%s\3",
-			Brown, params
-		);
-	} else {
-		uiFormat(id, Cold, NULL, "Not ignoring \3%02d%s\3", Brown, params);
-	}
+	struct Ignore ignore = ignoreParse(params);
+	bool found = ignoreRemove(ignore);
+	uiFormat(
+		id, Cold, NULL, "%s ignoring \3%02d%s %s %s %s",
+		(found ? "No longer" : "Not"), Brown, ignore.mask,
+		(ignore.cmd ?: ""), (ignore.chan ?: ""), (ignore.mesg ?: "")
+	);
 }
 
 static void commandExec(uint id, char *params) {
263cab0a41f467f01&follow=1'>Add r to psfed for invertJune McEnroe 2018-09-24Add psfed, a PSF2 font editorJune McEnroe 2018-09-21Add scheme -i to swap white and blackJune McEnroe 2018-09-21Map caps lock to escape on Linux consoleJune McEnroe 2018-09-19Fix README mandoc lintsJune McEnroe 2018-09-19Un-NOT trans.alpha values in pngoJune McEnroe 2018-09-18Refactor reads in pngo and clear palette between filesJune McEnroe 2018-09-17Add tRNS support to pngoJune McEnroe 2018-09-11Move gfx man pages to gfx/manJune McEnroe 2018-09-11Move bin man pages to bin/manJune McEnroe 2018-09-11Rewrite gfx.7 and render plaintext READMEJune McEnroe 2018-09-11Remove GAMES from BINSJune McEnroe 2018-09-11Rewrite bin.7 and render to plaintext READMEJune McEnroe 2018-09-11Add "blank" lines to man pagesJune McEnroe 2018-09-10Add mdoc syntax fileJune McEnroe 2018-09-08Fix Nm usage in multi-name man pagesJune McEnroe 2018-09-08Put real dates on man pagesJune McEnroe 2018-09-08Replace gfx README with REAMDE.7June McEnroe 2018-09-08Link gfx man pages in ~/.localJune McEnroe