aboutsummaryrefslogtreecommitdiff
path: root/src/property/file.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-31 11:39:17 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-31 14:17:45 -0700
commitea65968c79bf0709664081e4c116dee0d9c536ab (patch)
treed5020ad301052db98d873584565352089cbcbe7a /src/property/file.lisp
parent47aa65619025242b26cf3473efe25f88c24ae323 (diff)
downloadconsfigurator-ea65968c79bf0709664081e4c116dee0d9c536ab.tar.gz
add & use WORDS, UNWORDS
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/file.lisp')
-rw-r--r--src/property/file.lisp42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp
index 4af2e27..a54d38c 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -439,25 +439,23 @@ not NO-SOURCE and the corresponding member of ENTRIES is STRING= to either
NO-SOURCE or \"PLACEHOLDER\", use the existing field value."
(let ((unknown (list no-source "PLACEHOLDER"))
(pending (make-hash-table :test #'equal)))
- (flet ((fields (entry)
- (remove "" (split-string entry) :test #'string=)))
- (dolist (entry entries)
- (setf (gethash (nth target (fields entry)) pending) entry))
- (map-file-lines
- file
- (lambda (lines)
- (loop for line in lines
- for line-fields = (fields line)
- for line-source = (nth source line-fields)
- and line-target = (nth target line-fields)
- for entry = (when-let* ((entry (gethash line-target pending))
- (fields (fields entry)))
- (when (and (member (nth source fields)
- unknown :test #'string=)
- (not (string= line-source no-source)))
- (setf (nth source fields) line-source))
- (format nil "~{~A~^ ~}" fields))
- if entry
- collect it into accum and do (remhash line-target pending)
- else collect line into accum
- finally (return (nconc accum (hash-table-values pending)))))))))
+ (dolist (entry entries)
+ (setf (gethash (nth target (words entry)) pending) entry))
+ (map-file-lines
+ file
+ (lambda (lines)
+ (loop for line in lines
+ for line-fields = (words line)
+ for line-source = (nth source line-fields)
+ and line-target = (nth target line-fields)
+ for entry = (when-let* ((entry (gethash line-target pending))
+ (fields (words entry)))
+ (when (and (member (nth source fields)
+ unknown :test #'string=)
+ (not (string= line-source no-source)))
+ (setf (nth source fields) line-source))
+ (format nil "~{~A~^ ~}" fields))
+ if entry
+ collect it into accum and do (remhash line-target pending)
+ else collect line into accum
+ finally (return (nconc accum (hash-table-values pending))))))))