summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-07-10 18:26:46 +0200
committerLudovic Courtès <ludo@gnu.org>2013-07-10 21:53:29 +0200
commit836d10f154275e56c7185c1fcd6daee2027b41de (patch)
treef4d3dd5bb2954232d8125555a17286b88536cf8d /guix
parentb0efe83a8f3d37600b9b31a67dd5265e3e1f1fa7 (diff)
records: `recutils->alist' recognizes lines starting with a `+'.
* guix/records.scm (%recutils-plus-rx): New variable. (recutils->alist): Use it to read + lines. * tests/records.scm ("recutils->alist with + lines"): New test.
Diffstat (limited to 'guix')
-rw-r--r--guix/records.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/guix/records.scm b/guix/records.scm
index 8dc733b8ff..d47bbf89f2 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -231,6 +231,9 @@ PORT, according to FIELDS. FIELDS must be a list of field name/getter pairs."
;; info "(recutils) Comments"
(make-regexp "^#"))
+(define %recutils-plus-rx
+ (make-regexp "^\\+ ?(.*)$"))
+
(define (recutils->alist port)
"Read a recutils-style record from PORT and return it as a list of key/value
pairs. Stop upon an empty line (after consuming it) or EOF."
@@ -244,6 +247,15 @@ pairs. Stop upon an empty line (after consuming it) or EOF."
(reverse result))) ; end-of-record marker
((regexp-exec %recutils-comment-rx line)
(loop (read-line port) result))
+ ((regexp-exec %recutils-plus-rx line)
+ =>
+ (lambda (m)
+ (match result
+ (((field . value) rest ...)
+ (loop (read-line port)
+ `((,field . ,(string-append value "\n"
+ (match:substring m 1)))
+ ,@rest))))))
((regexp-exec %recutils-field-rx line)
=>
(lambda (match)