Skip to content

Commit

Permalink
Fix non-printable keyname printing to use <octal> syntax.
Browse files Browse the repository at this point in the history
The IsPrint() was grabbing values outside the range of a char.
Instead, restrict the range and fall back to the <octal> syntax, which
the muttrc actually accepts.
  • Loading branch information
kevin8t8 committed Nov 7, 2022
1 parent 5275370 commit 3c0f859
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,10 @@ static const char *km_keyname (int c)
}
else if (c >= KEY_F0 && c < KEY_F(256)) /* this maximum is just a guess */
sprintf (buf, "<F%d>", c - KEY_F0);
else if (IsPrint (c))
else if (c < 256 && c >= -128 && IsPrint (c))
snprintf (buf, sizeof (buf), "%c", (unsigned char) c);
else
snprintf (buf, sizeof (buf), "\\x%hx", (unsigned short) c);
snprintf (buf, sizeof (buf), "<%ho>", (unsigned short) c);
return (buf);
}

Expand Down

0 comments on commit 3c0f859

Please sign in to comment.