From 3a99f966dc2dc9fb3922340caa0016b305789977 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 23 Aug 2020 21:23:45 +0300 Subject: Improve handling of coding-system mnemonic indicators This fixes assertion violations when the mnemonic is given as a string, and allows non-ASCII characters be used as mode-line mnemonic of a coding-system. * src/xdisp.c (decode_mode_spec_coding): Handle multibyte characters as coding-system's mnemonic. (display_mode_element): If decode_mode_spec returns a multibyte string, display it as multibyte. * src/coding.c (Fdefine_coding_system_internal) (Fcoding_system_put): If :mnemonic is a string, use its first character. This avoids assertion violations if someone uses a string as the mnemonic of a coding-system. --- src/coding.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 51bd441de9d..221a9cad898 100644 --- a/src/coding.c +++ b/src/coding.c @@ -10895,7 +10895,10 @@ usage: (define-coding-system-internal ...) */) ASET (attrs, coding_attr_base_name, name); Lisp_Object val = args[coding_arg_mnemonic]; - if (! STRINGP (val)) + /* decode_mode_spec_coding assumes the mnemonic is a single character. */ + if (STRINGP (val)) + val = make_fixnum (STRING_CHAR (SDATA (val))); + else CHECK_CHARACTER (val); ASET (attrs, coding_attr_mnemonic, val); @@ -11408,7 +11411,10 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, attrs = AREF (spec, 0); if (EQ (prop, QCmnemonic)) { - if (! STRINGP (val)) + /* decode_mode_spec_coding assumes the mnemonic is a single character. */ + if (STRINGP (val)) + val = make_fixnum (STRING_CHAR (SDATA (val))); + else CHECK_CHARACTER (val); ASET (attrs, coding_attr_mnemonic, val); } -- cgit v1.2.1