Problem: is*() and to*() function may be unsafe
Solution: Add SAFE_* macros and start using those instead
(Keith Thompson)
Use SAFE_() macros for is*() and to*() functions
The standard is*() and to*() functions declared in <ctype.h> have
undefined behavior for negative arguments other than EOF. If plain char
is signed, passing an unchecked value from argv for from user input
to one of these functions has undefined behavior.
Solution: Add SAFE_*() macros that cast the argument to unsigned char.
Most implementations behave sanely for negative arguments, and most
character values in practice are non-negative, but it's still best
to avoid undefined behavior.
The change from #13347 has been omitted, as this has already been
separately fixed in commit ac709e2fc0
(v9.0.2054)
fixes: #13332closes: #13347
Signed-off-by: Keith Thompson <Keith.S.Thompson@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: LTCG compile error on Win/ARM64 for `write_chars()`
Solution: Explicitly initialise the storage to use data rather than BSS
(Saleem Abdulrasool)
win32: add a workaround for a LTCG issue on Windows ARM64
It appears that the implicit initialisation which would push `g_coords`
into BSS causes an aliasing issue with LTCG on ARM64. By explicitly
initialising the value, we use usual data storage but prevent the
aliasing. This allows the console version of VIM to run on Windows
ARM64 again.
fixes: #13453closes: #13775
Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: win32: issues with stable python ABI
Solution: if_python3,win32: Fix Python3 stable ABI
There were some issues in current stable ABI implementation on Windows:
* Python DLL name should be `python3.dll` instead of `python311.dll` and
so on. (See: https://docs.python.org/3/c-api/stable.html)
* Some non-stable API functions were used:
- `_PyObject_NextNotImplemented`
- `PyStdPrinter_Type`
* `reset_stdin()` and `hook_py_exit()` didn't work with `python3.dll`.
`python3.dll` is a special type of DLL called forwarder DLL.
It just forwards the functions to other DLL (e.g. `python311.dll`).
There were two issues regarding these functions:
- `python3.dll` doesn't have import tables. This caused a crash in
`get_imported_func_info()`. Add a check whether the specified DLL
has an import table.
- `reset_stdin()` and `hook_py_exit()` should be applied to the
forwarded DLL (e.g. `python311.dll`), not to `python3.dll`.
Check the export directory of `python3.dll` to find the forwarded
DLL and apply the functions to it.
closes: #13260
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ken Takata <kentkt@csc.jp>
Problem: win32: not correctly freeing environment
Solution: After we call GetEnvironmentStringsW, we should call
FreeEnvironmentStringsW
closes: #13096closes: #13094
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ken Takata <kentkt@csc.jp>
Problem: Win32: When 'encoding' is set $PATH has duplicate entries.
Solution: Only append the directory if it is not there yet. (Ken Takata,
closes#12400, closes#12372)
Problem: "clear" macros are not always used.
Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more
places. (Yegappan Lakshmanan, closes#12104)
Problem: FOR_ALL_ macros are defined in an unexpected file.
Solution: Move FOR_ALL_ macros to macros.h. Add FOR_ALL_HASHTAB_ITEMS.
(Yegappan Lakshmanan, closes#12109)
Problem: MS-Windows: scrollback cropped off on Vim exit.
Solution: Don't call SetConsoleScreenBufferInfoEx when using the alternate
screen buffer. (Christopher Plewright, closes#11882)
Problem: Some key+modifier tests fail on some AppVeyor images.
Solution: Adjust the tests for key movements and fix the revealed bugs.
(Christopher Plewright, closes#11798)
Problem: MS-Windows: various special keys and modifiers are not mappable.
Solution: Adjust the handling of keys with modifiers. (Christian Plewright,
closes#11768)
Problem: Display wrong in Windows terminal after exiting Vim.
Solution: Apply screen restore fix for Windows 11 also to Windows 10 builds.
(Christopher Plewright, closes#11713, closes#11706)
Problem: Code handling low level MS-Windows events cannot be tested.
Solution: Add test_mswin_event() and tests using it. (Christopher Plewright,
closes#11622)
Problem: It is not easy to see what client-server commands are doing.
Solution: Add channel log messages if ch_log() is available. Move the
channel logging and make it available with the +eval feature.
Problem: MS-Windows: mouse column limited to 223.
Solution: Use two bytes for each mouse coordinate. Add the mouse position
to scroll events. (Christopher Plewright, closes#11597)
Problem: MS-Windows: modifier keys do not work with mouse scroll events.
Solution: Use K_SPECIAL instead of CSI for the modifier keys. (Christopher
Plewright, closes#11587)
Problem: MS-Windows: after Vim exits console resizing does not work
properly.
Solution: Restore screen behavior checks for various WT and VTP
combinations. (Christopher Plewright, closes#11526,
closes#11507)
Problem: MS-Windows Terminal has unstable color control.
Solution: Do not try to read the old command prompt colortable, use modern
VT sequences. (Christopher Plewright, closes#11450,
closes#11373)
Problem: MS-Windows: mouse scroll events only work with the dll.
Solution: Accept CSI codes for MS-Windows without the GUI. (Christopher
Plewright, closes#11401)
Problem: MS-Windows: mouse scrolling in terminal misbehaves without dll.
Solution: Add #ifdef as a temporary solution. (Christopher Plewright,
closes#11392)
Problem: MS-Windows: mouse scrolling not supported in the console.
Solution: Add event handling for mouse scroll events. (Christopher
Plewright, closes#11374)
Problem: MS-Windows: cannot set cursor shape in Windows Terminal.
Solution: Make cursor shape work with Windows Terminal. (Ken Takata,
closes#11028, closes#6576)
Problem: Timeout handling is not optimal.
Solution: Avoid setting timeout_flag twice. Adjust the pointer when
stopping the regexp timeout. Adjust variable name.