wm: teppich

Download patch

ref: 97ec62235b22bebe63c08c659bbdfdf052bb8afe
parent: 7f062a8fea451fcaf1629e9c71c5af0ecc2adfb4
author: mkf <mkf@cloud9p.org>
date: Wed Dec 6 19:20:36 EST 2023

rc: check harder, remove buggy code and don't iterate too much!

--- a/cmd/rc.c
+++ b/cmd/rc.c
@@ -14,7 +14,7 @@
 	int status;
 
 	status = NO_SUCH_CMD;
-	for(int i = 0 ; i < sizeof(cmdtab) ; i++)
+	for(int i = 0 ; i < (sizeof(cmdtab) / sizeof(prog_t)) ; i++)
 	{
 		if(!strcmp(argv0, cmdtab[i].name))
 			status = cmdtab[i].main(argc, argv);
@@ -37,10 +37,13 @@
 	check for nil pointers */
 	
 	argv0 = strcntok(cmd, ' ', 0);
-	
+
 	if(argv0 == nil)
 	{
-		argv0 = strdup(cmd); /* it still may be nil */
+		argv0 = strdup(cmd);
+		if(argv0 == nil)
+			return OK;
+
 		argc = 0;
 		/* shouldn't we do something regarding argv here? one wonders */
 	}
@@ -83,9 +86,6 @@
 
 			printf("%s> ", cuser.name);
 		}
-		/* ignore spaces as first character and ignore more than one space */
-		else if((c == ' ') && (i == 0 || cmd[i - 1] == ' '))
-			continue;
 		else if(c != '\b')
 		{
 			cmd[i] = c;