]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle multibyte mode line spec chars (bug#76517)
authorPip Cet <pipcet@protonmail.com>
Mon, 24 Feb 2025 20:46:49 +0000 (20:46 +0000)
committerEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 09:39:07 +0000 (10:39 +0100)
* 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'.

(cherry picked from commit 1f891898d490380ea59f21fa8ea4e7f7364a1a79)

src/xdisp.c

index a7124d02044fbf651f0f6aeef315c58a61cdfa68..dc2e1c168fb4e255ff29623516201748c1518e7b 100644 (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;