statusbar: display at most three consecutive alert messages

Cap the number of pauses when displaying ALERT messages, to avoid
making the user wait for ages when tens or hundreds of files were
specified on the command line.

This fixes https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/src/winio.c b/src/winio.c
index a0bf879..09141b1 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2088,6 +2088,7 @@
 void statusline(message_type importance, const char *msg, ...)
 {
     va_list ap;
+    static int alerts = 0;
     char *compound, *message;
     size_t start_col;
     bool bracketed;
@@ -2112,12 +2113,20 @@
 		(lastmessage == MILD && importance == HUSH))
 	return;
 
-    /* Delay another alert message, to allow an earlier one to be noticed. */
-    if (lastmessage == ALERT)
+    /* If the ALERT status has been reset, reset the counter. */
+    if (lastmessage == HUSH)
+	alerts = 0;
+
+    /* Shortly pause after each of the first three alert messages,
+     * to give the user time to read them. */
+    if (lastmessage == ALERT && alerts < 4)
 	napms(1200);
 
-    if (importance == ALERT)
+    if (importance == ALERT) {
+	if (++alerts > 3)
+	    msg = "Some warnings were suppressed";
 	beep();
+    }
 
     lastmessage = importance;