diff mbox

[1/7] import cran: Remove more invalid characters from package names.

Message ID 1464017539-1478-1-git-send-email-ricardo.wurmus@mdc-berlin.de
State New
Headers show

Commit Message

Ricardo Wurmus May 23, 2016, 3:32 p.m. UTC
* guix/import/cran.scm (guix-name): Replace period and underscore with
  dash; always prepend package names with "r-".
---
 guix/import/cran.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ludovic Courtès May 23, 2016, 9:54 p.m. UTC | #1
Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:

> * guix/import/cran.scm (guix-name): Replace period and underscore with
>   dash; always prepend package names with "r-".

[...]

> +    (string-append "r-" (string-downcase
> +                         (regexp-substitute/global #f "(_|\\.)" name
> +                                                   'pre "-" 'post))))

I’d have a preference for ‘string-map’ here.  WDYT?

Otherwise looks good!

Ludo’.
diff mbox

Patch

diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index c1a9e8e..8b368af 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -151,9 +151,9 @@  empty list when the FIELD cannot be found."
   "Return the `package' s-expression for an R package published on REPOSITORY
 from the alist META, which was derived from the R package's DESCRIPTION file."
   (define (guix-name name)
-    (if (string-prefix? "r-" name)
-        (string-downcase name)
-        (string-append "r-" (string-downcase name))))
+    (string-append "r-" (string-downcase
+                         (regexp-substitute/global #f "(_|\\.)" name
+                                                   'pre "-" 'post))))
 
   (let* ((base-url   (case repository
                        ((cran)         %cran-url)