Module Name:    src
Committed By:   jmcneill
Date:           Sat Jan 25 10:09:46 UTC 2020

Modified Files:
        src/sys/stand/efiboot: prompt.c

Log Message:
Fix for disappearing counters on graphics consoles


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/prompt.c

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

Modified files:

Index: src/sys/stand/efiboot/prompt.c
diff -u src/sys/stand/efiboot/prompt.c:1.5 src/sys/stand/efiboot/prompt.c:1.6
--- src/sys/stand/efiboot/prompt.c:1.5	Sun Sep 29 00:52:26 2019
+++ src/sys/stand/efiboot/prompt.c	Sat Jan 25 10:09:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: prompt.c,v 1.5 2019/09/29 00:52:26 jakllsch Exp $	*/
+/*	$NetBSD: prompt.c,v 1.6 2020/01/25 10:09:46 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -75,23 +75,27 @@ awaitkey(int timeout, int tell)
 {
 	int i = timeout * POLL_FREQ;
 	int last_secs = -1, secs;
+	int last_len = -1, n;
+	char buf[32];
 	char c = 0;
 
 	for (;;) {
 		if (tell) {
-			char buf[32];
 			int len;
 
 			secs = (i + POLL_FREQ - 1) / POLL_FREQ;
 			if (secs != last_secs) {
-				len = snprintf(buf, sizeof(buf), "%d seconds. ", (i + POLL_FREQ - 1) / POLL_FREQ);
-				if (len > 0 && len < sizeof(buf)) {
+				if (last_len != -1) {
 					char *p = buf;
-					printf("%s", buf);
-					while (*p)
+					for (n = 0; n < last_len; n++)
 						*p++ = '\b';
+					*p = '\0';
 					printf("%s", buf);
 				}
+				len = snprintf(buf, sizeof(buf), "%d seconds. ", (i + POLL_FREQ - 1) / POLL_FREQ);
+				if (len > 0 && len < sizeof(buf))
+					printf("%s", buf);
+				last_len = len;
 				last_secs = secs;
 			}
 		}
@@ -109,8 +113,16 @@ awaitkey(int timeout, int tell)
 	}
 
 out:
-	if (tell)
+	if (tell) {
+		if (last_len != -1) {
+			char *p = buf;
+			for (n = 0; n < last_len; n++)
+				*p++ = '\b';
+			*p = '\0';
+			printf("%s", buf);
+		}
 		printf("0 seconds.     \n");
+	}
 
 	return c;
 }

Reply via email to