From mboxrd@z Thu Jan 1 00:00:00 1970 From: "pelzflorian (Florian Pelz)" Subject: bug#39970: guix commands broken on Azerbaijani 'az_AZ' and Turkish 'tr_TR' locales Date: Thu, 12 Mar 2020 12:02:06 +0100 Message-ID: <20200312110206.2hsinzejnmcefmot@pelzflorian.localdomain> References: <20200307120052.ocwzphlvemvmb2ts@pelzflorian.localdomain> <20200307152003.myj7jkjthokbmark@pelzflorian.localdomain> <20200308070804.ylpb5yrwpgbc3p3w@pelzflorian.localdomain> <8736ah1mxb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="n32ce3wcv3t3334v" Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:45255) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCLcG-0007dy-AY for bug-guix@gnu.org; Thu, 12 Mar 2020 07:03:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCLcE-0008Cv-VI for bug-guix@gnu.org; Thu, 12 Mar 2020 07:03:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jCLcE-0008Co-Sa for bug-guix@gnu.org; Thu, 12 Mar 2020 07:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jCLcE-0004nC-QQ for bug-guix@gnu.org; Thu, 12 Mar 2020 07:03:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Content-Disposition: inline In-Reply-To: <8736ah1mxb.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane-mx.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 39970@debbugs.gnu.org --n32ce3wcv3t3334v Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Mar 09, 2020 at 06:02:40PM +0100, Ludovic Courtès wrote: > To me it’s not a bug in Guile, but simply the fact that regexps, as > implemented by the C library, are locale-dependent. > (use-modules (ice-9 regex)) (regexp-exec (make-regexp "^([a-z]+)$") "iyiyim") ⇒ #f Guile’s behavior that i is not among [a-z] has been confirmed as unexpected by a natively Turkish friend of mine. It is different from the behavior of current glibc: florian@florianmacbook ~$ cat iyiyim.c #include #include #include #define STR "iyiyım" int main (int argc, char** argv) { regex_t only_letters; int r = regcomp (&only_letters, "[a-z]+", REG_EXTENDED); if (r != 0) printf ("This error does not happen.\n"); r = regexec (&only_letters, STR, 1, malloc (sizeof (regmatch_t)), 0); if (r == 0) printf ("The string " STR " matched!\n"); else printf ("No match for " STR ".\n"); } florian@florianmacbook ~$ gcc -o iyiyim iyiyim.c florian@florianmacbook ~$ LANG=tr_TR.utf8 ./iyiyim The string iyiyım matched! Apparently Guile uses a bundled regular expression library rather than glibc. I can try making Guile use a newer GNUlib for its regular expressions, maybe that helps. Shall I file a separate bug for Guile? > The patch you proposed looks good to me, though perhaps we could > explicitly list all the alphabet in the regexp? > > A better option is to reimplement ‘store-path-package-name’ in a way > similar to ‘store-path-hash-part’, as in commit > 35eb77b09d957019b2437e7681bd88013d67d3cd. I suppose it would be better to cache the compiled regexp. What is this mcached syntax inside (guix store)? Or do I use Scheme’s 'delay' and 'force' for caching? The attached patch fixes the regexp. Shall I push the attached patch and then try making it cache the compiled regexp or do you still prefer an implementation without regexps? Why would not using a regexp be better? Regards, Florian --n32ce3wcv3t3334v Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-store-Fix-many-guix-commands-failing-on-some-locales.patch" From: Florian Pelz Date: Thu, 12 Mar 2020 11:08:16 +0100 Subject: [PATCH] store: Fix many guix commands failing on some locales. Fixes bug #39970 (see: https://bugs.gnu.org/39970). At least 'guix environment', 'guix install' and 'guix pull' on 'az_AZ.utf8' and 'tr_TR.utf8' are affected. * guix/store.scm (store-regexp*): Avoid dependence on locale. --- guix/store.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guix/store.scm b/guix/store.scm index f99fa581a8..82d7403bb6 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -1949,7 +1949,8 @@ valid inputs." (mlambda (store) "Return a regexp matching a file in STORE." (make-regexp (string-append "^" (regexp-quote store) - "/([0-9a-df-np-sv-z]{32})-([^/]+)$")))) + "\ +/([0-9abcdfghijklmnpqrsvwxyz]{32})-([^/]+)$")))) (define (store-path-package-name path) "Return the package name part of PATH, a file name in the store." -- 2.25.1 --n32ce3wcv3t3334v--