1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

do_bidi: initialise paragraphOverride correctly.

I'd forgotten to initialise it at all, which meant it was set to zero
by the initial memset of the whole BidiContext on creation. But in our
enumeration of bidi character types, zero corresponds to L (the most
common left-to-right alphabetic character class), and as a value for
paragraphOverride, that is not neutral.

As a result, a command such as this (assuming UTF-8)

  echo -e '\xD7\x90\xD7\x91'

would produce Hebrew aleph and beth in the correct display order
(aleph on the right), but aligned to the left margin of the terminal
instead of the right margin, because the overall direction of the line
was taken to be forcibly overridden to "left-to-right" instead of
being inferred dynamically from the line contents.

do_bidi() is a tiny wrapper on the inner function that does all the
real work. And the inner function has been subjected to the whole
Unicode 14 bidi conformance test. So naturally, the "trivial" but
untested function just outside it is where the embarrassing bug was.
This commit is contained in:
Simon Tatham 2022-05-24 17:43:48 +01:00
parent e06a3dda45
commit 01d8561446

View File

@ -3602,6 +3602,7 @@ void do_bidi(BidiContext *ctx, bidi_char *text, size_t textlen)
#ifdef REMOVE_FORMATTING_CHARACTERS
abort(); /* can't use the standard algorithm in a live terminal */
#else
ctx->paragraphOverride = ON;
do_bidi_new(ctx, text, textlen);
#endif
}