diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2023-06-27 13:58:46 +0300 |
---|---|---|
committer | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2023-06-28 18:08:06 +0300 |
commit | ec99f03ae8623be40a13b45b646745d0c8a4b06d (patch) | |
tree | ce7649403a6b54e777512663c4d6e9d00ac4e200 /docs | |
parent | 1602a45b797908025dc71e6a07149a39fdb12a48 (diff) | |
download | busybox-w32-ec99f03ae8623be40a13b45b646745d0c8a4b06d.tar.gz busybox-w32-ec99f03ae8623be40a13b45b646745d0c8a4b06d.tar.bz2 busybox-w32-ec99f03ae8623be40a13b45b646745d0c8a4b06d.zip |
win32: UTF8 input: avoid timeout when delivering UTF8 bytes
When windows_read_key - which is the sole consumer of
readConsoleInput_utf8 - is called with a timeout value, it uses
WaitForSingleObject to test whether the console has pending input.
Previously, readConsoleInput_utf8 consumed the input record before
it delivered the UTF8 bytes which are generated from it.
It's not an issue with ASCII-7 input - because indeed there are no
buffered bytes once it's delivered, and, except for console bugs
(when only key-up record exists) also not an issue with 2 or 3 bytes
UTF8 codepoints - because these are generated from a single wchar_t
input record on key-down, and the key-up event is not yet dequeued
while delivering the key-down UTF8 bytes.
But with a surrogate pair, which consumes two wchar_t records to
realize the UTF8 sequence, we previously consumed the records
up to and including the key-up event of the 2nd surrogate half.
This could result in a timeout if there are no further records at
the queue - eventhough some UTF8 bytes are still buffered/pending.
Such timeout can result in the shell aborting - windows_read_key
returns -1, which is later interpreted as EOF of the shell input,
and quits the shell.
Now readConsoleInput_utf8 dequeues an input record only once the
last byte which was generated from this record is delivered,
which we do using PeekConsoleInputW instead of ReadConsoleInputW.
This avoid a timeout as long as there are input bytes to deliver.
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions