[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#51541] [PATCH] services: configuration: Fix interpose implementatio

From: Andrew Tropin
Subject: [bug#51541] [PATCH] services: configuration: Fix interpose implementation.
Date: Mon, 1 Nov 2021 10:43:12 +0300

* gnu/services/configuration.scm (interpose, serialize-text-config): Fix
interpose implementation, move file-like object code to
This gexp reading file-like object content doesn't belong to interpose
function, moved that part of code out of it.

 gnu/services/configuration.scm | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index e8c55b6e4d..0de350a4df 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -359,10 +359,7 @@ (define* (interpose ls  #:optional (delimiter "\n") 
(grammar 'infix))
       (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.")
   (fold-right (lambda (e acc)
-                (cons #~(begin
-                          (use-modules (ice-9 rdelim))
-                          (with-fluids ((%default-port-encoding "UTF-8"))
-                            (with-input-from-file #$e read-string)))
+                (cons e
                       (if (and (null? acc) (eq? grammar 'infix))
                           (cons delimiter acc))))
@@ -387,7 +384,16 @@ (define serialize-file-like empty-serializer)
 (define (text-config? config)
   (list-of file-like?))
 (define (serialize-text-config field-name val)
-  #~(string-append #$@(interpose val "\n" 'suffix)))
+  #~(string-append
+     #$@(interpose
+         (map
+          (lambda (e)
+            #~(begin
+                (use-modules (ice-9 rdelim))
+                (with-fluids ((%default-port-encoding "UTF-8"))
+                  (with-input-from-file #$e read-string))))
+          val)
+         "\n" 'suffix)))
 (define ((generic-serialize-alist-entry serialize-field) entry)
   "Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY."

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]