summary refs log tree commit diff
path: root/complete.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-16 23:05:43 -0500
committerJune McEnroe <june@causal.agency>2020-02-16 23:05:43 -0500
commitb20be7cbad775ec2119e022ed8e4d225a488c90c (patch)
treecaba6234d7027c5d2090f6482c23f5411abef3eb /complete.c
parentReplace a lot of snprintf with a catf implementation (diff)
downloadcatgirl-b20be7cbad775ec2119e022ed8e4d225a488c90c.tar.gz
catgirl-b20be7cbad775ec2119e022ed8e4d225a488c90c.zip
Various small cleanups
Haven't really gone through ui.c yet.
Diffstat (limited to 'complete.c')
-rw-r--r--complete.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/complete.c b/complete.c
index b65d870..ad9bfd7 100644
--- a/complete.c
+++ b/complete.c
@@ -35,10 +35,10 @@ static struct Node *alloc(uint id, const char *str, enum Color color) {
 	if (!node) err(EX_OSERR, "malloc");
 	node->id = id;
 	node->str = strdup(str);
-	if (!node->str) err(EX_OSERR, "strdup");
 	node->color = color;
 	node->prev = NULL;
 	node->next = NULL;
+	if (!node->str) err(EX_OSERR, "strdup");
 	return node;
 }
 
@@ -75,7 +75,9 @@ static struct Node *append(struct Node *node) {
 
 static struct Node *find(uint id, const char *str) {
 	for (struct Node *node = head; node; node = node->next) {
-		if (node->id == id && !strcmp(node->str, str)) return node;
+		if (node->id != id) continue;
+		if (strcmp(node->str, str)) continue;
+		return node;
 	}
 	return NULL;
 }
@@ -86,7 +88,7 @@ void completeAdd(uint id, const char *str, enum Color color) {
 
 void completeTouch(uint id, const char *str, enum Color color) {
 	struct Node *node = find(id, str);
-	if (node && node->color != color) node->color = color;
+	if (node) node->color = color;
 	prepend(node ? detach(node) : alloc(id, str, color));
 }
 
@@ -128,11 +130,10 @@ void completeReplace(uint id, const char *old, const char *new) {
 		next = node->next;
 		if (id && node->id != id) continue;
 		if (strcmp(node->str, old)) continue;
-		if (match == node) match = NULL;
 		free(node->str);
 		node->str = strdup(new);
-		if (!node->str) err(EX_OSERR, "strdup");
 		prepend(detach(node));
+		if (!node->str) err(EX_OSERR, "strdup");
 	}
 }
 
d of the stringJune McEnroe 2018-09-13Fix weird tab-complete after commaJune McEnroe I have no idea why I did this. 2018-09-13Rewrite UI againJune McEnroe The persistent topic is gone and the status line is now at the top. The status formatting still needs to be reworked. I also want to try showing the nick in the input window so it really looks like your next message. 2018-09-12Add note about C-oJune McEnroe Why are there so few well usable ctrl key bindings? 2018-09-12Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe Ridiculous. 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe