Re: User menu: pattern matching acts not as expected
"Yury V. Zaytsev via mc" <[email protected]> Wed, 12 Mar 2025 16:29:32 +0100
| Newsgroups | gmane.comp.gnome.apps.mc.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_90314926-3522-4B2E-AFAA-A8A0C0BF5AE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 12. Mar 2025, at 16:03, Yury V. Zaytsev via mc = <[email protected]> wrote: >=20 >> I tried my old mc on one system (4.8.22 too) and *[[:space:]]* = selects the file with "nonlocal" chars if I try, assume Eugen's renaming = should work as well (although I didn't check, whether the regex = interpretion works similar in both cases) >>=20 >> But being in an utf charset too I can't imagine why "=C3=A0" or "=C3=A1= " shall be "nonlocal" here. Seems more likely there is some charset = mismatch on Eugen's system, at least for the acting user. Maybe there = are "invisible" chars in the name in his environment=E2=80=A6 >=20 > ... but thanks for reproducing it. I can confirm that it doesn't seem = to work correctly on 4.8.33. I'll try a debug build on the master to see = what happens. Looking deeper into the code, it does mc_search (arg, DEFAULT_CHARSET, fe->fname->str, search_type); where DEFAULT_CHARSET is ASCII. The attached patch "fixes" the problem, = but I'm afraid it's much more complicated. Even if we declare that menu files must be UTF-8 and that's it, I'm not = sure that this takes care of correct matching when single-byte locales = are used. Maybe the source string should be recoded somehow as well? It = would be good to hear what Andrew has to say about this. --Apple-Mail=_90314926-3522-4B2E-AFAA-A8A0C0BF5AE0 Content-Disposition: attachment; filename=fix-usermenu-matching.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="fix-usermenu-matching.patch" Content-Transfer-Encoding: 7bit diff --git a/src/usermenu.c b/src/usermenu.c index 13749f538..ffd76004e 100644 --- a/src/usermenu.c +++ b/src/usermenu.c @@ -265,10 +265,9 @@ test_condition (const Widget *edit_widget, char *p, gboolean *condition) #ifdef USE_INTERNAL_EDIT if (e != NULL) { - const char *edit_filename; - edit_filename = edit_get_file_name (e); - *condition = mc_search (arg, DEFAULT_CHARSET, edit_filename, search_type); + const char *edit_filename = edit_get_file_name (e); + *condition = mc_search (arg, "UTF-8", edit_filename, search_type); } else #endif @@ -277,11 +276,10 @@ test_condition (const Widget *edit_widget, char *p, gboolean *condition) *condition = FALSE; else { - const file_entry_t *fe; - fe = panel_current_entry (panel); + const file_entry_t *fe = panel_current_entry (panel); *condition = - fe != NULL && mc_search (arg, DEFAULT_CHARSET, fe->fname->str, search_type); + fe != NULL && mc_search (arg, "UTF-8", fe->fname->str, search_type); } } break; @@ -295,7 +293,7 @@ test_condition (const Widget *edit_widget, char *p, gboolean *condition) if (syntax_type != NULL) { p = extract_arg (p, arg, sizeof (arg)); - *condition = mc_search (arg, DEFAULT_CHARSET, syntax_type, MC_SEARCH_T_NORMAL); + *condition = mc_search (arg, "UTF-8", syntax_type, MC_SEARCH_T_NORMAL); } } #endif @@ -303,7 +301,7 @@ test_condition (const Widget *edit_widget, char *p, gboolean *condition) case 'd': p = extract_arg (p, arg, sizeof (arg)); *condition = panel != NULL - && mc_search (arg, DEFAULT_CHARSET, vfs_path_as_str (panel->cwd_vpath), + && mc_search (arg, "UTF-8", vfs_path_as_str (panel->cwd_vpath), search_type); break; case 't': --Apple-Mail=_90314926-3522-4B2E-AFAA-A8A0C0BF5AE0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- mc mailing list [email protected] https://lists.midnight-commander.org/mailman/listinfo/mc --Apple-Mail=_90314926-3522-4B2E-AFAA-A8A0C0BF5AE0--