Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/stand/efiboot No need to re-print the countdown timer if...



details:   https://anonhg.NetBSD.org/src/rev/7039e18ba8d5
branches:  trunk
changeset: 445526:7039e18ba8d5
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Oct 31 23:49:34 2018 +0000

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

diffstat:

 sys/stand/efiboot/prompt.c |  21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diffs (42 lines):

diff -r cd21f10ac1bf -r 7039e18ba8d5 sys/stand/efiboot/prompt.c
--- a/sys/stand/efiboot/prompt.c        Wed Oct 31 20:00:56 2018 +0000
+++ b/sys/stand/efiboot/prompt.c        Wed Oct 31 23:49:34 2018 +0000
@@ -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 @@
 awaitkey(int timeout, int tell)
 {
        int i = timeout * POLL_FREQ;
+       int last_secs = -1, secs;
        char c = 0;
 
        for (;;) {
@@ -80,13 +81,17 @@
                        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()) {



Home | Main Index | Thread Index | Old Index