fixing clisp compatibility - cl-yag - Common Lisp Yet Another website Generator
HTML git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/cl-yag/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit da8e0af550cd5a47d4fccc399636d47287b143dd
DIR parent e94fc554f9a4f95d8b8df4ea8629a330ef129d13
HTML Author: Solene Rapenne <solene@dataswamp.org>
Date: Tue, 3 May 2016 15:54:02 +0200
fixing clisp compatibility
Diffstat:
M generator.lisp | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
---
DIR diff --git a/generator.lisp b/generator.lisp
@@ -27,21 +27,20 @@
(defun split-str (string &optional (separator " "))
(split-str-1 string separator))
-;; load a file as a string
-;; we escape ~ to avoid failures with format
-(defun load-file(path)
- (replace-all
- (with-open-file (stream path)
- (let ((data (make-string (file-length stream))))
- (read-sequence data stream)
- data))
- "~" "~~"))
-
;; we have to remove the quotes
;; when using collect in a loop
(defun strip-quotes(input)
(format nil "~{~d~}" input))
+;; load a file as a string
+;; we escape ~ to avoid failures with format
+(defun load-file(path)
+ (replace-all
+ (strip-quotes
+ (with-open-file (stream path)
+ (loop for line = (read-line stream nil) while line collect line)))
+ "~" "~~"))
+
;; save a string in a file
(defun save-file(path data)
(with-open-file (stream (concatenate 'string "output/" path) :direction :output :if-exists :supersede)
@@ -62,8 +61,7 @@
;; simplify the file saving by using the layout
(defmacro generate(name &body data)
`(progn
- (save-file ,name
- (generate-layout ,@data))))
+ (save-file ,name (generate-layout ,@data))))
;; generate the list of tags
(defun articles-by-tag()