Handle multibyte mode line spec chars (bug#76517)

* src/xdisp.c (display_mode_element): Make 'c' an 'int'.  Use
'string_char_and_length' to fetch the character from a multibyte
string, not 'SREF'.
This commit is contained in:
Pip Cet 2025-02-24 20:46:49 +00:00
parent 6f3067324a
commit 1f891898d4

View file

@ -27755,7 +27755,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
case Lisp_String:
{
/* A string: output it and check for %-constructs within it. */
unsigned char c;
int c;
ptrdiff_t offset = 0;
if (SCHARS (elt) > 0
@ -27926,6 +27926,15 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
while ((c = SREF (elt, offset++)) >= '0' && c <= '9')
field = field * 10 + c - '0';
/* "%" could be followed by a multibyte character. */
if (STRING_MULTIBYTE (elt))
{
int length;
offset--;
c = string_char_and_length (SDATA (elt) + offset, &length);
offset += length;
}
/* Don't pad beyond the total padding allowed. */
if (field_width - n > 0 && field > field_width - n)
field = field_width - n;