[bug#34811] Make package name regexes case-insensitive

Message ID 87ftrther0.fsf@nckx
State Accepted
Headers show
Series [bug#34811] Make package name regexes case-insensitive | expand

Checks

Context Check Description
cbaines/comparison success View comparison
cbaines/applying patch fail Apply failed

Commit Message

Tobias Geerinckx-Rice March 11, 2019, 10:44 a.m. UTC
Guix,

I think they should.

All of our package names are lower case, and it doesn't add value 
that

  $ guix package -A ExifTool

matches zero, zip, zilch, nada, nothing, while

  $ guix package -A exiftool
  perl-image-exiftool	11.11	out 
  gnu/packages/photo.scm:208:2

does.

Kind regards,

T G-R

Comments

Ludovic Courtès March 15, 2019, 10:11 p.m. UTC | #1
Hello!

Tobias Geerinckx-Rice <somebody@not-sent-or-endorsed-by.tobias.gr>
skribis:

> I think they should.
>
> All of our package names are lower case, and it doesn't add value that
>
>  $ guix package -A ExifTool
>
> matches zero, zip, zilch, nada, nothing, while
>
>  $ guix package -A exiftool
>  perl-image-exiftool	11.11	out gnu/packages/photo.scm:208:2
>
> does.

Indeed.

>>From 5876eb1fe6d412d7f2a556e0903cd2d87994ab9e Mon Sep 17 00:00:00 2001
> From: Tobias Geerinckx-Rice <me@tobias.gr>
> Date: Mon, 11 Mar 2019 11:37:11 +0100
> Subject: [PATCH] ui: Match package names case-insensitively.
>
> * guix/ui.scm (make-package-name-regexp): New variable.
> * guix/scripts/package.scm (options->upgrade-predicate, process-query):
> Use it.

[...]

> -                   (make-regexp* (or regexp "")))
> +                   (make-package-name-regexp (or regexp "")))

I don’t think the abstraction brings much here; I’d prefer
‘regexp/icase’ to be inlined.  WDYT?

Otherwise LGTM, thanks!

Ludo’.
Ludovic Courtès May 21, 2019, 2:51 p.m. UTC | #2
Ping!

Ludovic Courtès <ludo@gnu.org> skribis:

> Hello!
>
> Tobias Geerinckx-Rice <somebody@not-sent-or-endorsed-by.tobias.gr>
> skribis:
>
>> I think they should.
>>
>> All of our package names are lower case, and it doesn't add value that
>>
>>  $ guix package -A ExifTool
>>
>> matches zero, zip, zilch, nada, nothing, while
>>
>>  $ guix package -A exiftool
>>  perl-image-exiftool	11.11	out gnu/packages/photo.scm:208:2
>>
>> does.
>
> Indeed.
>
>>>>From 5876eb1fe6d412d7f2a556e0903cd2d87994ab9e Mon Sep 17 00:00:00 2001
>> From: Tobias Geerinckx-Rice <me@tobias.gr>
>> Date: Mon, 11 Mar 2019 11:37:11 +0100
>> Subject: [PATCH] ui: Match package names case-insensitively.
>>
>> * guix/ui.scm (make-package-name-regexp): New variable.
>> * guix/scripts/package.scm (options->upgrade-predicate, process-query):
>> Use it.
>
> [...]
>
>> -                   (make-regexp* (or regexp "")))
>> +                   (make-package-name-regexp (or regexp "")))
>
> I don’t think the abstraction brings much here; I’d prefer
> ‘regexp/icase’ to be inlined.  WDYT?
>
> Otherwise LGTM, thanks!
>
> Ludo’.
Tobias Geerinckx-Rice Nov. 30, 2020, 10:10 p.m. UTC | #3
Done & forgotten as commit 
b56d160944ace6e06fcfe5a36310c98e6a213b87.

Closing now,

T G-R

Patch

From 5876eb1fe6d412d7f2a556e0903cd2d87994ab9e Mon Sep 17 00:00:00 2001
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Mon, 11 Mar 2019 11:37:11 +0100
Subject: [PATCH] ui: Match package names case-insensitively.

* guix/ui.scm (make-package-name-regexp): New variable.
* guix/scripts/package.scm (options->upgrade-predicate, process-query):
Use it.
---
 guix/scripts/package.scm | 9 +++++----
 guix/ui.scm              | 6 ++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index efff511299..563615938b 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -6,6 +6,7 @@ 
 ;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
 ;;; Copyright © 2016 Benz Schenk <benz.schenk@uzh.ch>
 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -526,14 +527,14 @@  upgrading, #f otherwise."
   (define upgrade-regexps
     (filter-map (match-lambda
                   (('upgrade . regexp)
-                   (make-regexp* (or regexp "")))
+                   (make-package-name-regexp (or regexp "")))
                   (_ #f))
                 opts))
 
   (define do-not-upgrade-regexps
     (filter-map (match-lambda
                   (('do-not-upgrade . regexp)
-                   (make-regexp* regexp))
+                   (make-package-name-regexp regexp))
                   (_ #f))
                 opts))
 
@@ -686,7 +687,7 @@  processed, #f otherwise."
        #t)
 
       (('list-installed regexp)
-       (let* ((regexp    (and regexp (make-regexp* regexp)))
+       (let* ((regexp    (and regexp (make-package-name-regexp regexp)))
               (manifest  (profile-manifest profile))
               (installed (manifest-entries manifest)))
          (leave-on-EPIPE
@@ -702,7 +703,7 @@  processed, #f otherwise."
          #t))
 
       (('list-available regexp)
-       (let* ((regexp    (and regexp (make-regexp* regexp)))
+       (let* ((regexp    (and regexp (make-package-name-regexp regexp)))
               (available (fold-available-packages
                           (lambda* (name version result
                                          #:key outputs location
diff --git a/guix/ui.scm b/guix/ui.scm
index 2fc001d2eb..eb4ea28d52 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -13,6 +13,7 @@ 
 ;;; Copyright © 2013, 2014 Free Software Foundation, Inc.
 ;;; Copyright © 2018 Sahithi Yarlagadda <sahi@swecha.net>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -79,6 +80,7 @@ 
             show-version-and-exit
             show-bug-report-information
             make-regexp*
+            make-package-name-regexp
             string->number*
             size->number
             show-derivation-outputs
@@ -548,6 +550,10 @@  nicely."
       (leave (G_ "'~a' is not a valid regular expression: ~a~%")
              regexp message))))
 
+(define (make-package-name-regexp regexp)
+  "Like 'make-regexp*' but specifically for package names (i.e. ignore case)"
+  (make-regexp* regexp regexp/icase))
+
 (define (string->number* str)
   "Like `string->number', but error out with an error message on failure."
   (or (string->number str)
-- 
2.20.1