commit e028db8

Devine Lu Linvega  ·  2025-05-18 17:39:21 +0000 UTC
parent c567fbd
Improved console handlers
1 files changed,  +7, -7
+7, -7
 1@@ -362,14 +362,12 @@ start_fork(void)
 2 	start_fork_pipe();
 3 }
 4 
 5-static unsigned int
 6+static void
 7 console_input(int c, unsigned int type)
 8 {
 9-	if(c == EOF) c = 0, type = 4;
10 	dev[0x12] = c, dev[0x17] = type;
11 	if(console_vector)
12 		uxn_eval(console_vector);
13-	return type != 4;
14 }
15 
16 /*
17@@ -694,12 +692,14 @@ main(int argc, char **argv)
18 		return !fprintf(stdout, "Could not load %s.\n", argv[i - 1]);
19 	if(uxn_eval(0x100) && console_vector) {
20 		for(; i < argc; i++) {
21-			char *p = argv[i];
22-			while(*p)
23-				console_input(*p++, CONSOLE_ARG);
24+			char c, *p = argv[i];
25+			while(!dev[0x0f] && (c = *p++))
26+				console_input(c, CONSOLE_ARG);
27 			console_input('\n', i == argc - 1 ? CONSOLE_END : CONSOLE_EOA);
28 		}
29-		while(!dev[0x0f] && console_input(fgetc(stdin), 1));
30+		while(!dev[0x0f] && !feof(stdin))
31+			console_input(fgetc(stdin), 1);
32+		console_input(0, CONSOLE_END);
33 	}
34 	return dev[0x0f] & 0x7f;
35 }