diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-03-16 11:56:31 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-03-16 19:04:32 -0700 |
commit | 8fa41a15f184660ab5bda5f86d645ba9b2582389 (patch) | |
tree | b532dba4b6862c6ab8b47c99f06e8a498422dda7 /src/util.lisp | |
parent | 91c96c933523c1a6a622061682c26a936068b295 (diff) | |
download | consfigurator-8fa41a15f184660ab5bda5f86d645ba9b2582389.tar.gz |
support indented heredocs, add new "Reader macros" manual section
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/util.lisp b/src/util.lisp index 47ce5ac..20a3714 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -38,37 +38,6 @@ for result in new and i upfrom 0 do (setf (aref results i) (nreconc result (aref results i)))))) -(defun lines (text &optional trimfun (trimchars '(#\Space #\Tab))) - (with-input-from-string (stream text) - (let (bolp buffer) - (flet ((trim (line) - (if trimfun (funcall trimfun trimchars line) line)) - (reset () - (setq bolp t - buffer (make-array 0 :fill-pointer 0 - :element-type 'character)))) - ;; Split on either <CR>, <LF> or <CR><LF>; <LF><CR> would mean split - ;; with a blank line in between. Drop a single trailing blank line. - (loop initially (reset) - for char = (read-char stream nil nil) - if char - if (member char '(#\Return #\Newline) :test #'char=) - collect (trim buffer) - and do (reset) - (when (char= char #\Return) - (when-let ((next (peek-char nil stream nil nil))) - (when (char= next #\Newline) - (read-char stream)))) - else do (setq bolp nil) - (vector-push-extend char buffer) - end - else - unless bolp collect (trim buffer) end - and do (loop-finish)))))) - -(defun unlines (lines) - (format nil "~{~A~%~}" lines)) - (defun words (text) (delete "" (split-string text) :test #'string=)) |