Bug#972387: [Info-mtools] mtools does not work in Turkish locale
Hi, Thanks for the details, this is now fixed in 4.0.25 Regards, Alain On 22/10/2020 19:01, Pali Rohár wrote: Hello! On Thursday 22 October 2020 16:55:04 Chris Lamb wrote: $ LC_CTYPE=tr_TR.UTF-8 mtools Syntax error at line 5 for drive A: column 9 in file /etc/mtools.conf: unrecognized keyword $ echo $? 1 ... As I describe in my followup to that bug, I can confirm that this is indeed locale issue, as commenting out the setlocale(3) call at the top of the "main" entry point fixes this issue. The following "patch" against mtools.c also ""works"" for me: +#ifdef HAVE_SETLOCALE + char *old_locale = setlocale(LC_ALL, NULL); + setlocale(LC_ALL, "C"); + read_config(); + setlocale(LC_ALL, old_locale); +#else read_config(); +#endif .. but this is obviously not right, as it would mean that genuine syntax errors printed in read_config() would not be translated into, well, Turkish. Can't seem to get a "C" locale version of toupper(3) to work right this second, and am assuming you folks will have a cleaner solution anyway, hence forwarding this to you. IIRC toupper() for lowercase i with dot in Turkish locale returns uppercase I with dot. In English or C locale it is uppercase I without dot. I guess that for case-insensitive parsing of config options (which are written in English) should be used toupper() variant in C locale. There is a standard POSIX function toupper_l() which takes as a second argument locale. So I think that for reading config file it should be used function toupper_l() with C locale instead of locale-dependent toupper() function.
Bug#972387: [Info-mtools] mtools does not work in Turkish locale
Hi Pali, > IIRC toupper() for lowercase i with dot in Turkish locale returns > uppercase I with dot. In English or C locale it is uppercase I without > dot. > > I guess that for case-insensitive parsing of config options (which are > written in English) should be used toupper() variant in C locale. > > There is a standard POSIX function toupper_l() which takes as a second > argument locale. So I think that for reading config file it should be > used function toupper_l() with C locale instead of locale-dependent > toupper() function. Indeed. This all matches my own analysis and reflects where I had got to in previous email; apologies if that was not clearer. Regards, -- ,''`. : :' : Chris Lamb `. `'` la...@debian.org chris-lamb.co.uk `-
Bug#972387: [Info-mtools] mtools does not work in Turkish locale
Hello! On Thursday 22 October 2020 16:55:04 Chris Lamb wrote: > $ LC_CTYPE=tr_TR.UTF-8 mtools > Syntax error at line 5 for drive A: column 9 in file /etc/mtools.conf: > unrecognized keyword > > $ echo $? > 1 > ... > As I describe in my followup to that bug, I can confirm that this is > indeed locale issue, as commenting out the setlocale(3) call at the > top of the "main" entry point fixes this issue. > > The following "patch" against mtools.c also ""works"" for me: > > +#ifdef HAVE_SETLOCALE > + char *old_locale = setlocale(LC_ALL, NULL); > + setlocale(LC_ALL, "C"); > + read_config(); > + setlocale(LC_ALL, old_locale); > +#else > read_config(); > +#endif > > > .. but this is obviously not right, as it would mean that genuine > syntax errors printed in read_config() would not be translated into, > well, Turkish. Can't seem to get a "C" locale version of toupper(3) to > work right this second, and am assuming you folks will have a cleaner > solution anyway, hence forwarding this to you. IIRC toupper() for lowercase i with dot in Turkish locale returns uppercase I with dot. In English or C locale it is uppercase I without dot. I guess that for case-insensitive parsing of config options (which are written in English) should be used toupper() variant in C locale. There is a standard POSIX function toupper_l() which takes as a second argument locale. So I think that for reading config file it should be used function toupper_l() with C locale instead of locale-dependent toupper() function. -- Pali Rohár pali.ro...@gmail.com