Module Name:    src
Committed By:   jmcneill
Date:           Wed Oct 31 23:49:34 UTC 2018

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

Log Message:
No need to re-print the countdown timer if the number of seconds hasn't changed.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/sys/stand/efiboot/prompt.c:1.4
--- src/sys/stand/efiboot/prompt.c:1.3	Sat Sep 15 16:41:37 2018
+++ src/sys/stand/efiboot/prompt.c	Wed Oct 31 23:49:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: prompt.c,v 1.3 2018/09/15 16:41:37 jmcneill Exp $	*/
+/*	$NetBSD: prompt.c,v 1.4 2018/10/31 23:49:34 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -73,6 +73,7 @@ char
 awaitkey(int timeout, int tell)
 {
 	int i = timeout * POLL_FREQ;
+	int last_secs = -1, secs;
 	char c = 0;
 
 	for (;;) {
@@ -80,13 +81,17 @@ awaitkey(int timeout, int tell)
 			char buf[32];
 			int len;
 
-			len = snprintf(buf, sizeof(buf), "%d seconds. ", (i + POLL_FREQ - 1) / POLL_FREQ);
-			if (len > 0 && len < sizeof(buf)) {
-				char *p = buf;
-				printf("%s", buf);
-				while (*p)
-					*p++ = '\b';
-				printf("%s", buf);
+			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)) {
+					char *p = buf;
+					printf("%s", buf);
+					while (*p)
+						*p++ = '\b';
+					printf("%s", buf);
+				}
+				last_secs = secs;
 			}
 		}
 		if (ischar()) {

Reply via email to