bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key


From: Lars Ingebrigtsen
Subject: bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key
Date: Tue, 19 Oct 2021 15:24:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Nope.  The loop can just check whether we get a multibyte result when
> downcasing unibyte (ASCII), and then defer to the multibyte version to
> do the computation.

I.e., this change, which even passes all the case tests:

diff --git a/src/casefiddle.c b/src/casefiddle.c
index a7a2541490..b46d42f5e2 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -310,11 +310,12 @@ do_casify_unibyte_string (struct casing_context *ctx, 
Lisp_Object obj)
       cased = case_single_character (ctx, ch);
       if (ch == cased)
        continue;
-      cased = make_char_unibyte (cased);
-      /* If the char can't be converted to a valid byte, just don't
-        change it.  */
-      if (SINGLE_BYTE_CHAR_P (cased))
-       SSET (obj, i, cased);
+      /* If downcasing changed an ASCII character into a non-ASCII
+        character (this can happen in some locales, like the Turkish
+        "I"), use the multibyte algorithm.  */
+      if (SINGLE_BYTE_CHAR_P (ch) && !SINGLE_BYTE_CHAR_P (cased))
+       return do_casify_multibyte_string (ctx, obj);
+      SSET (obj, i, make_char_unibyte (cased));
     }
   return obj;
 }

It's a wonder that Emacs works at all in a Turkish environment -- I
instrumented the function and made it spit out every time it translated
"I" to "1" during startup, and it was a huge stream of

Got multi: jISX0208.1983-0
Got multi: bIG5-0
Got multi: jISX0208.1983-0
Got multi: jISX0208.1983-0
Got multi: bIG5-0
Got multi: jISX0208.1983-0
Got multi: bIG5-0
Got multi: jISX0208.1983-0

etc.  But I guess it doesn't trip up anything really vital.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]