From cee96425899826a23caefa3f52c0302e3af2ae94 Mon Sep 17 00:00:00 2001 From: lum Date: Tue, 2 Mar 2021 15:03:35 +0000 Subject: [PATCH] This diff soaks up the user input while the the maximum character 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c index de93d454176..ced1a2dc4a9 100644 --- a/usr.bin/mg/echo.c +++ b/usr.bin/mg/echo.c @@ -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) { -- 2.20.1