diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-07-10 16:54:17 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-07-10 17:01:08 +0200 |
commit | fdc1bf659d9834fce6c78d31680b580eab3f4235 (patch) | |
tree | 647c4dc2bee902cffd64099db95b3fb57fe2986d /guix/scripts | |
parent | c0edcc3c1926497919e6eefed32dbe5fdc55d045 (diff) | |
download | gnu-guix-fdc1bf659d9834fce6c78d31680b580eab3f4235.tar gnu-guix-fdc1bf659d9834fce6c78d31680b580eab3f4235.tar.gz |
records: Add `recutils->alist' for public consumption.
* guix/records.scm (%recutils-field-rx): New variable.
(recutils->alist): New procedure, formerly known as `fields->alist'.
* guix/scripts/substitute-binary.scm (fields->alist): Use it.
* tests/records.scm ("recutils->alist"): New test.
Diffstat (limited to 'guix/scripts')
-rwxr-xr-x | guix/scripts/substitute-binary.scm | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm index 24e5d68c4f..fb2eb4dbe8 100755 --- a/guix/scripts/substitute-binary.scm +++ b/guix/scripts/substitute-binary.scm @@ -102,23 +102,8 @@ output port, and PROC's result is returned." (define (fields->alist port) "Read recutils-style record from PORT and return them as a list of key/value pairs." - (define field-rx - (make-regexp "^([[:graph:]]+): (.*)$")) - - (let loop ((line (read-line port)) - (result '())) - (cond ((eof-object? line) - (reverse result)) - ((with-mutex %regexp-exec-mutex - (regexp-exec field-rx line)) - => - (lambda (match) - (loop (read-line port) - (alist-cons (match:substring match 1) - (match:substring match 2) - result)))) - (else - (error "unmatched line" line))))) + (with-mutex %regexp-exec-mutex + (recutils->alist port))) (define %fetch-timeout ;; Number of seconds after which networking is considered "slow". |