This diff soaks up the user input while the the maximum character
authorlum <lum@openbsd.org>
Tue, 2 Mar 2021 15:03:35 +0000 (15:03 +0000)
committerlum <lum@openbsd.org>
Tue, 2 Mar 2021 15:03:35 +0000 (15:03 +0000)
length boundary is crossed in the minbuffer and allows the user to see
the error message and respond accordingly.  The goto named "null"
changed to "skipkey" as per Emil Engler's suggestion on tech@.

usr.bin/mg/echo.c

index de93d45..ced1a2d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: echo.c,v 1.67 2021/03/01 10:51:14 lum Exp $   */
+/*     $OpenBSD: echo.c,v 1.68 2021/03/02 15:03:35 lum Exp $   */
 
 /* This file is in the public domain. */
 
@@ -336,8 +336,8 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
                                }
                                if (!dynbuf && epos + 1 >= nbuf) {
                                        dobeep();
-                                       ewprintf("Line too long");
-                                       return (emptyval);
+                                       ewprintf("Line too long. Press Control-g to escape.");
+                                       goto skipkey;
                                }
                                for (t = epos; t > cpos; t--)
                                        buf[t] = buf[t - 1];
@@ -492,8 +492,8 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
                        }
                        if (!dynbuf && epos + 1 >= nbuf) {
                                dobeep();
-                               ewprintf("Line too long");
-                               return (emptyval);
+                               ewprintf("Line too long. Press Control-g to escape.");
+                               goto skipkey;
                        }
                        for (i = epos; i > cpos; i--)
                                buf[i] = buf[i - 1];
@@ -507,6 +507,9 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
                        ttmove(rr, cc);
                        ttflush();
                }
+
+skipkey:       /* ignore key press */
+;
        }
 done:
        if (cwin == TRUE) {