Another thing I noticed while testing the fix is that in cl_term_init()
while processing the command mapping there is a missing NULL check.
However, the check _is_ present for the input mapping loop. The
following diff makes the two loops consistent.
I'm not sure whether this is worth doing since I don't think we can
end up with a NULL command mapping unless c_tklist[] is modified
directly.
- todd
Index: usr.bin/vi/cl/cl_term.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 cl_term.c
--- usr.bin/vi/cl/cl_term.c 20 Jul 2017 08:37:48 -0000 1.28
+++ usr.bin/vi/cl/cl_term.c 22 Apr 2022 15:22:57 -0000
@@ -84,10 +84,17 @@ cl_term_init(SCR *sp)
for (tkp = c_tklist; tkp->name != NULL; ++tkp) {
if ((t = tigetstr(tkp->ts)) == NULL || t == (char *)-1)
continue;
- if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t),
- tkp->output, strlen(tkp->output), SEQ_COMMAND,
- SEQ_NOOVERWRITE | SEQ_SCREEN))
- return (1);
+ if (tkp->output == NULL) {
+ if (seq_set(sp, tkp->name, strlen(tkp->name),
+ t, strlen(t), NULL, 0,
+ SEQ_COMMAND, SEQ_NOOVERWRITE | SEQ_SCREEN))
+ return (1);
+ } else {
+ if (seq_set(sp, tkp->name, strlen(tkp->name),
+ t, strlen(t), tkp->output, strlen(tkp->output),
+ SEQ_COMMAND, SEQ_NOOVERWRITE | SEQ_SCREEN))
+ return (1);
+ }
}
/* Input mappings that are already set or are text deletions. */