Module Name:    src
Committed By:   rin
Date:           Sat Sep  4 01:34:32 UTC 2021

Modified Files:
        src/tests/lib/libcurses/slave: commands.c

Log Message:
Cosmetic fixes. No functional changes intended.
- Reorganize logic to reduce indent levels significantly.
- Use ``for'' rather than ``while''.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/commands.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libcurses/slave/commands.c
diff -u src/tests/lib/libcurses/slave/commands.c:1.15 src/tests/lib/libcurses/slave/commands.c:1.16
--- src/tests/lib/libcurses/slave/commands.c:1.15	Sun Jun 13 12:46:01 2021
+++ src/tests/lib/libcurses/slave/commands.c	Sat Sep  4 01:34:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: commands.c,v 1.15 2021/06/13 12:46:01 rillig Exp $	*/
+/*	$NetBSD: commands.c,v 1.16 2021/09/04 01:34:32 rin Exp $	*/
 
 /*-
  * Copyright 2009 Brett Lymn <bl...@netbsd.org>
@@ -53,32 +53,32 @@ command_execute(char *func, int nargs, c
 {
 	size_t i, j;
 
-	i = 0;
-	while (i < ncmds) {
-		if (strcmp(func, commands[i].name) == 0) {
-			/* Check only restricted set of functions is called before
-			 * initscr/newterm */
-			if (!initdone) {
-				j = 0;
-				while (j < nrcmds) {
-					if (strcmp(func, restricted_commands[j]) == 0) {
-						if (strcmp(func, "initscr") == 0  ||
-							strcmp(func, "newterm") == 0)
-							initdone = 1;
-						/* matched function */
-						commands[i].func(nargs, args);
-						return;
-					}
-					j++;
-				}
-				report_status("YOU NEED TO CALL INITSCR/NEWTERM FIRST");
-				return;
-			}
+	for (i = 0; i < ncmds; i++) {
+		if (strcmp(func, commands[i].name) != 0)
+			continue;
+
+		/* Check only restricted set of functions is called before
+		 * initscr/newterm */
+		if (initdone) {
 			/* matched function */
 			commands[i].func(nargs, args);
 			return;
 		}
-		i++;
+
+		for (j = 0; j < nrcmds; j++) {
+			if (strcmp(func, restricted_commands[j]) != 0)
+				continue;
+
+			if (strcmp(func, "initscr") == 0  ||
+			    strcmp(func, "newterm") == 0)
+				initdone = 1;
+
+			/* matched function */
+			commands[i].func(nargs, args);
+			return;
+		}
+		report_status("YOU NEED TO CALL INITSCR/NEWTERM FIRST");
+		return;
 	}
 
 	report_status("UNKNOWN_FUNCTION");

Reply via email to