[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: |
Eli Zaretskii |
Subject: |
bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key |
Date: |
Tue, 19 Oct 2021 14:43:28 +0300 |
> From: Stefan Kangas <stefan@marxist.se>
> Date: Mon, 18 Oct 2021 20:22:18 -0700
> Cc: Eli Zaretskii <eliz@gnu.org>, Shuguang Sun <shuguang79@qq.com>,
> 50752@debbugs.gnu.org
>
> If anyone has any preferences or further ideas here, that would be much
> appreciated, otherwise I'll keep investigating.
>
> The attached patch is what I have so far. It's obviously not yet
> finished, but all tests pass except for the one for "I->i" conversion in
> the Turkish language environment.
Don't give up, you are close.
> + memcpy (dst, SSDATA (lc_key), SBYTES (lc_key));
> + for (int i = 0; i < SBYTES (lc_key); ++i)
> + {
> + if (*(dst + i) == ' ')
> + *(dst + i) = '-';
> + }
If you want to use an index to walk the string data, as you did above,
please use dst[i] instead of *(dst + i); the latter is correct, but
ugly and un-C-ish. Or you could use a pointer to walk, like this:
unsigned char *p = dst, *dst_end = dst + SBYTES (lc_key);
for ( ; p < dst_end; p++)
{
if (*p == ' ')
*p = '-';
}
> > We could use the equivalent of
> >
> > (get-char-code-property ?I 'lowercase)
> >
> > If the above returns nil, it means the lower-case variant is the
> > character itself.
> >
> > In C, this means to use uniprop_table, like bidi.c and casefiddle.c
> > do. This accesses the database generated from UnicodeData.txt.
>
> I didn't try this approach, mostly because it sounds more difficult to
> implement than what Lars said. I think? Wouldn't it amount to
> basically re-implementing Fdowncase? Sorry, I didn't look too closely
> at this. Perhaps this would be the better approach.
It shouldn't be hard. You need to call uniprop_table to get a
char-table:
Lisp_Object unicode_case_table = uniprop_table (intern ("lowercase"));
which you then reference with
int low_ch = XFIXNUM (CHAR_TABLE_REF (unicode_case_table, ch));
to get the codepoint of the lower-case character that corresponds to
the (possibly upper-case) character whose codepoint is CH. Then
downcasing a string boils down to a loop that fetches characters one
by one with fetch_string_char_advance and then stores the lower-case
characters, obtained as above, with CHAR_STRING. (It's a bit more
complicated than that, because CHAR_TABLE_REF can return nil for the
characters that are either already lower-case or don't have case
variants. And the uniprop_table call should be done once, at startup
time, or upon first usage, and stored in a staticpro'd variable, see
bidi_initialize for an example.)
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, (continued)
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Stefan Kangas, 2021/10/28
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/28
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Stefan Kangas, 2021/10/28
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/28
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Stefan Kangas, 2021/10/28
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/20
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/21
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/21
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/20
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/20
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key,
Eli Zaretskii <=
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Stefan Kangas, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/20
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/13
bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/15
bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Stefan Kangas, 2021/10/18