From d8920e0602d46033d5949aa039a4f51a21eec2d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Fri, 19 Mar 2021 14:00:31 -0400
Subject: [PATCH] Better comment conformance in key parsing

There's a comment saying we set key=0 when we consume it... do so
in a couple cases where it wasn't done.

Range check the key before sending to the remote.

This should not actually do anything different, but in the future
if things are changed at least the comments won't be misleading.
---
 src/syncterm/term.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/syncterm/term.c b/src/syncterm/term.c
index 6e5db091b2..fab69fcf75 100644
--- a/src/syncterm/term.c
+++ b/src/syncterm/term.c
@@ -2770,6 +2770,7 @@ BOOL doterm(struct bbslist *bbs)
 					break;
 				case CIO_KEY_SHIFT_IC:	/* Shift-Insert - Paste */
 					do_paste();
+					key = 0;
 					break;
 				case 0x3000:	/* ALT-B - Scrollback */
 					setup_mouse_events(NULL);
@@ -2814,6 +2815,7 @@ BOOL doterm(struct bbslist *bbs)
 						}
 						showmouse();
 						_setcursortype(_NORMALCURSOR);
+						key = 0;
 					}
 					break;
 				case 0x2100:	/* ALT-F */
@@ -3331,7 +3333,7 @@ BOOL doterm(struct bbslist *bbs)
 						key='\b';
 						/* FALLTHROUGH to default */
 					default:
-						if(key<256) {
+						if(key<256 && key >= 0) {
 							ch[0]=key;
 							conn_send(ch,1,0);
 						}
-- 
GitLab