GNU bug report logs - #42146
[PATCH core-updates 1/?] build: substitute: Don't fail silently.

Previous Next

Package: guix-patches;

Reported by: Jakub Kądziołka <kuba <at> kadziolka.net>

Date: Tue, 30 Jun 2020 22:10:01 UTC

Severity: normal

Tags: patch

Full log


Message #53 received at 42146 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 42146 <at> debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH v3 1/3] build: Relocate <regexp*> record and associated
 procedures here.
Date: Thu, 19 Oct 2023 20:57:38 -0400
* etc/teams.scm.in (<regexp*>, make-regexp*, regexp*-exec): Move to...
* guix/build/utils.scm: ... here.
(list-matches*): New procedure.

Change-Id: I566ac372f7d8ba08de94e19b54dcc68da2106a23
---
 etc/teams.scm.in     | 19 +------------------
 guix/build/utils.scm | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/etc/teams.scm.in b/etc/teams.scm.in
index 55242caad1..8af25b9802 100644
--- a/etc/teams.scm.in
+++ b/etc/teams.scm.in
@@ -34,29 +34,12 @@
              (srfi srfi-9)
              (srfi srfi-26)
              (ice-9 format)
-             (ice-9 regex)
              (ice-9 match)
              (ice-9 rdelim)
+             (guix build utils)
              (guix ui)
              (git))
 
-(define-record-type <regexp*>
-  (%make-regexp* pat flag rx)
-  regexp*?
-  (pat regexp*-pattern)
-  (flag regexp*-flag)
-  (rx regexp*-rx))
-
-;;; Work around regexp implementation.
-;;; This record allows to track the regexp pattern and then display it.
-(define* (make-regexp* pat #:optional (flag regexp/extended))
-  "Alternative to `make-regexp' producing annotated <regexp*> objects."
-  (%make-regexp* pat flag (make-regexp pat flag)))
-
-(define (regexp*-exec rx* str)
-  "Execute the RX* regexp, a <regexp*> object."
-  (regexp-exec (regexp*-rx rx*) str))
-
 (define-record-type <team>
   (make-team id name description members scope)
   team?
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 8e630ad586..2b3a8e278b 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021, 2022 Maxime Devos <maximedevos <at> telenet.be>
 ;;; Copyright © 2021 Brendan Tildesley <mail <at> brendan.scot>
+;;; Copyright © 2022 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2023 Carlo Zancanaro <carlo <at> zancanaro.id.au>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -28,6 +29,7 @@
 
 (define-module (guix build utils)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
@@ -55,6 +57,14 @@ (define-module (guix build utils)
             package-name->name+version
             parallel-job-count
 
+            make-regexp*
+            regexp*-exec
+            regexp*?
+            regexp*-pattern
+            regexp*-flag
+            regexp*-rx
+            list-matches*
+
             compressor
             tarball?
             %xz-parallel-args
@@ -163,6 +173,35 @@ (define-syntax-rule (define-constant name val)
    (module-replace! (current-module) '(setvbuf)))
   (else #f))
 
+
+;;;
+;;; Extend regexp objects with a pattern field.
+;;;
+(define-record-type <regexp*>
+  (%make-regexp* pat flag rx)
+  regexp*?
+  (pat regexp*-pattern)                 ;the regexp pattern, a string
+  (flag regexp*-flag)                   ;regexp flags
+  (rx regexp*-rx))                      ;the compiled regexp object
+
+;;; Work around regexp implementation.
+;;; This record allows to track the regexp pattern and then display it.
+(define* (make-regexp* pat #:optional (flag regexp/extended))
+  "Alternative to `make-regexp' producing annotated <regexp*> objects."
+  (%make-regexp* pat flag (make-regexp pat flag)))
+
+(define (regexp*-exec rx* str)
+  "Execute the RX* regexp, a <regexp*> object."
+  (regexp-exec (regexp*-rx rx*) str))
+
+(define* (list-matches* regexp str #:optional (flags regexp/extended))
+  "Like 'list-matches', but also accepting a regexp* as REGEXP."
+  (match regexp
+    ((or (? string?) (? regexp?))
+     (list-matches regexp str flags))
+    ((? regexp*?)
+     (list-matches (regexp*-rx regexp) str flags))))
+
 
 ;;;
 ;;; Compression helpers.

base-commit: d59653b7c9e43ebdbba20e2ca071429507f94c67
-- 
2.41.0





This bug report was last modified 1 year and 233 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.