Skip to content

windows: increase WIN32textout internal buffer#562

Merged
gwsw merged 1 commit into
gwsw:masterfrom
avih:win32-uni-obuf-siz
Aug 28, 2024
Merged

windows: increase WIN32textout internal buffer#562
gwsw merged 1 commit into
gwsw:masterfrom
avih:win32-uni-obuf-siz

Conversation

@avih

@avih avih commented Aug 28, 2024

Copy link
Copy Markdown
Contributor

By default (*), the main console output (from win_flush using WIN32textout) is converted from UTF-8 to wchar_t.

The conversion uses a fixed-size buffer which was 1024, and now is 8K.

The size increase is required because win_flush can output the whole buffer in one call, especially with -Da where the internal SGR processor is bypassed - obuf is sent unmodified to WIN32textout.

obuf was changed recently from 1024 to 8K in commit 5854746 (windows: SGR processor: increase buffer size for less issues), and because the WIN32textout buffer did not increase till now, it could result in failed conversion due to insufficient result buffer, and no output.

Before 5854746, OUTBUF_SIZ was 1024 and used only for obuf, while the WIN32textout buffer was independently and luckily also 1024.

Now both obuf and WIN32textout use the same size OUTBUF_SIZE (which is not used elsewhere), and its 8K value is set in defines.wn .

(*) If the internal "less" charset is UTF8 (default on Windows), and
the console output CP is not UTF8 (also default), then conversion
from UTF8 to wchar_t happens before using WriteConsoleW.

By default (*), the main console output (from win_flush using
WIN32textout) is converted from UTF-8 to wchar_t.

The conversion uses a fixed-size buffer which was 1024, and now is 8K.

The size increase is required because win_flush can output the whole
buffer in one call, especially with -Da where the internal SGR
processor is bypassed - obuf is sent unmodified to WIN32textout.

obuf was changed recently from 1024 to 8K in commit 5854746 (windows:
SGR processor: increase buffer size for less issues), and because the
WIN32textout buffer did not increase till now, it could result in
failed conversion due to insufficient result buffer, and no output.

Before 5854746, OUTBUF_SIZ was 1024 and used only for obuf, while the
WIN32textout buffer was independently and luckily also 1024.

Now both obuf and WIN32textout use the same size OUTBUF_SIZE (which is
not used elsewhere), and its 8K value is set in defines.wn .

(*) If the internal "less" charset is UTF8 (default on Windows), and
    the console output CP is not UTF8 (also default), then conversion
    from UTF8 to wchar_t happens before using WriteConsoleW.
@gwsw gwsw merged commit 1f88659 into gwsw:master Aug 28, 2024
@avih avih deleted the win32-uni-obuf-siz branch August 29, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants