fixing clisp compatibility - cl-yag - Common Lisp Yet Another website Generator | |
git clone git://bitreich.org/cl-yag/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit da8e0af550cd5a47d4fccc399636d47287b143dd | |
parent e94fc554f9a4f95d8b8df4ea8629a330ef129d13 | |
Author: Solene Rapenne <[email protected]> | |
Date: Tue, 3 May 2016 15:54:02 +0200 | |
fixing clisp compatibility | |
Diffstat: | |
M generator.lisp | 22 ++++++++++------------ | |
1 file changed, 10 insertions(+), 12 deletions(-) | |
--- | |
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 :out… | |
@@ -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() |