Ticket #4872, #4873 and #4874: Fix 'insert control code' function.#5054
Ticket #4872, #4873 and #4874: Fix 'insert control code' function.#5054peripherium wants to merge 1 commit intoMidnightCommander:masterfrom
Conversation
|
Since you are fixing |
|
@egmontkob adding you, since this PR fixes 3 issues that you have reported... |
Validate input key codes, ignore special keys returned by get_key_code(). Fix handling of KEY_M_CTRL combinations and extend mapping for '@', '[', '\', ']', '^', '_'. Fixes: MidnightCommander#4872 Fixes: MidnightCommander#4873 Fixes: MidnightCommander#4874 Signed-off-by: Manuel Einfalt <einfalt1@proton.me> lib/util.c (keycode_to_cntrl): Rename from ascii_alpha_to_cntrl. Validate input key codes, ignore special keys returned by get_key_code(). Fix handling of KEY_M_CTRL combinations and extend mapping for '@', '[', '\', ']', '^', '_'. Fixes: MidnightCommander#4872 Fixes: MidnightCommander#4873 Fixes: MidnightCommander#4874 Signed-off-by: Manuel Einfalt <einfalt1@proton.me>
94db99e to
fc84480
Compare
|
I initially didn't add a test for this function because the previous implementation didn't have one, so I assumed that adding a test was not required. In the meantime, I have taken a closer look at the test suite and added the requested test here. If this test is not sufficient or needs adjustments, please let me know. |
| if (parm == XCTRL ('q')) | ||
| { | ||
| int control_code; | ||
| quote = TRUE; |
There was a problem hiding this comment.
Please add an empty line after variable declaration.
| utilunix__my_system_fork_child \ | ||
| x_basename | ||
| x_basename \ | ||
| util__keycode_to_cntrl |
There was a problem hiding this comment.
Please move this line upper to make this list sorted alphabetically.
| lib - keycode_to_cntrl() function testing | ||
|
|
||
| Copyright (C) 2011-2026 | ||
| Free Software Foundation, Inc. |
|
|
||
| START_PARAMETRIZED_TEST (keycode_test, test_keycodes) | ||
| { | ||
| int actual_result; |
There was a problem hiding this comment.
Please add an empty line after variable declaration.
The previous implementation used
ascii_alpha_to_cntrl(), which assumedalphabetic input and did not properly validate key codes returned by the
terminal libraries. The function has been renamed to
keycode_to_cntrl()and extended to correctly validate and convert key codes.
Changes
correctly handle
KEY_M_CTRLcombinations (e.g.Ctrl+J).Fixes mcedit: Display corruption (missing header) after inserting literal
^J#4872.ignore special keys returned by
get_key_code()(e.g. function or cursor keys).Fixes mcedit: Insert literal, followed by special key acts weirdly #4873.
extend control mappings for
@ [ \ ] ^ _.Fixes mcedit: Insert literal should accept plain non-letters #4874.
return
-1for invalid input and ignore it at the call sitesThe function is used both in the Insert literal dialog in
mceditand in the
mccommand line.Checklist
git commit --amend -smake indent && make check)