summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-30 19:44:45 -0400
committerJune McEnroe <june@causal.agency>2020-03-30 19:44:45 -0400
commitff783628268470acc02e52126d6a357691723fba (patch)
treeafde924a98359080d9fc329ea4bd133e50ee735d
parentAdd text macros (diff)
downloadcatgirl-ff783628268470acc02e52126d6a357691723fba.tar.gz
catgirl-ff783628268470acc02e52126d6a357691723fba.zip
Replace some declaration; while loops with for loops
I should have been using this for getopt loops already but the call here
is slightly too long to fit on one line as a for loop.
Diffstat (limited to '')
-rw-r--r--chat.c9
-rw-r--r--handle.c6
-rw-r--r--ui.c3
3 files changed, 6 insertions, 12 deletions
diff --git a/chat.c b/chat.c
index 258dde2..b7bf91b 100644
--- a/chat.c
+++ b/chat.c
@@ -88,8 +88,7 @@ static void execRead(void) {
 	if (len < 0) err(EX_IOERR, "read");
 	if (!len) return;
 	buf[len] = '\0';
-	char *ptr = buf;
-	while (ptr) {
+	for (char *ptr = buf; ptr;) {
 		char *line = strsep(&ptr, "\n");
 		if (line[0]) command(execID, line);
 	}
@@ -101,8 +100,7 @@ static void utilRead(void) {
 	if (len < 0) err(EX_IOERR, "read");
 	if (!len) return;
 	buf[len] = '\0';
-	char *ptr = buf;
-	while (ptr) {
+	for (char *ptr = buf; ptr;) {
 		char *line = strsep(&ptr, "\n");
 		if (line[0]) uiFormat(Network, Warm, NULL, "%s", line);
 	}
@@ -287,8 +285,7 @@ int main(int argc, char *argv[]) {
 
 		if (signals[SIGCHLD]) {
 			signals[SIGCHLD] = 0;
-			int status;
-			while (0 < waitpid(-1, &status, WNOHANG)) {
+			for (int status; 0 < waitpid(-1, &status, WNOHANG);) {
 				if (WIFEXITED(status) && WEXITSTATUS(status)) {
 					uiFormat(
 						Network, Warm, NULL,
diff --git a/handle.c b/handle.c
index a090ca2..84a2927 100644
--- a/handle.c
+++ b/handle.c
@@ -383,8 +383,7 @@ static void handleNick(struct Message *msg) {
 		set(&self.nick, msg->params[0]);
 		uiRead(); // Update prompt.
 	}
-	uint id;
-	while (None != (id = completeID(msg->nick))) {
+	for (uint id; (id = completeID(msg->nick));) {
 		if (!strcmp(idNames[id], msg->nick)) {
 			set(&idNames[id], msg->params[0]);
 		}
@@ -404,8 +403,7 @@ static void handleNick(struct Message *msg) {
 
 static void handleQuit(struct Message *msg) {
 	require(msg, true, 0);
-	uint id;
-	while (None != (id = completeID(msg->nick))) {
+	for (uint id; (id = completeID(msg->nick));) {
 		urlScan(id, msg->nick, msg->params[0]);
 		uiFormat(
 			id, Cold, tagTime(msg),
diff --git a/ui.c b/ui.c
index 9c1b238..02f8979 100644
--- a/ui.c
+++ b/ui.c
@@ -945,10 +945,9 @@ void uiRead(void) {
 		}
 	}
 
-	int ret;
 	wint_t ch;
 	static bool paste, style;
-	while (ERR != (ret = wget_wch(input, &ch))) {
+	for (int ret; ERR != (ret = wget_wch(input, &ch));) {
 		if (ret == KEY_CODE_YES && ch == KeyPasteOn) {
 			paste = true;
 		} else if (ret == KEY_CODE_YES && ch == KeyPasteOff) {