Fix H returning NIL on empty string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
diff --git a/html.lisp b/html.lisp
index 5d0eea6..6d7e515 100644
--- a/html.lisp
+++ b/html.lisp
@@ -37,44 +37,45 @@
(declare (optimize (safety 0) (debug 0) (speed 3))
(type fixnum start end)
(type string string))
- (unless (emptyp string)
- (labels ((print-raw (raw i)
- (declare (type fixnum raw i))
- (when (< raw i)
- (write-string string stream :start raw :end i)))
- (chr (i)
- (typecase string
- (simple-array (char string i))
- (simple-string (char string i))
- (string (char string i))))
- (skip (raw i)
- (declare (type fixnum raw i))
- (cond ((= i end) (print-raw raw i))
- (t (let* ((char (chr i))
- (entity (char-entity char)))
- (cond (entity (print-raw raw i)
- (write-string entity stream)
- (incf i)
- (skip i i))
- (t (skip raw (1+ i))))))))
- (stream-or-string (i)
- (declare (type fixnum i))
- (cond ((= i end) (if (and (= 0 start)
- (= end (length string)))
- string
- (subseq string start end)))
- (t (let* ((char (chr i))
- (entity (char-entity char)))
- (cond (entity (with-output-to-string (out)
- (setq stream out)
- (print-raw start i)
+ (if (emptyp string)
+ ""
+ (labels ((print-raw (raw i)
+ (declare (type fixnum raw i))
+ (when (< raw i)
+ (write-string string stream :start raw :end i)))
+ (chr (i)
+ (typecase string
+ (simple-array (char string i))
+ (simple-string (char string i))
+ (string (char string i))))
+ (skip (raw i)
+ (declare (type fixnum raw i))
+ (cond ((= i end) (print-raw raw i))
+ (t (let* ((char (chr i))
+ (entity (char-entity char)))
+ (cond (entity (print-raw raw i)
(write-string entity stream)
(incf i)
- (skip i i)))
- (t (stream-or-string (1+ i)))))))))
- (if stream
- (skip start start)
- (stream-or-string start)))))
+ (skip i i))
+ (t (skip raw (1+ i))))))))
+ (stream-or-string (i)
+ (declare (type fixnum i))
+ (cond ((= i end) (if (and (= 0 start)
+ (= end (length string)))
+ string
+ (subseq string start end)))
+ (t (let* ((char (chr i))
+ (entity (char-entity char)))
+ (cond (entity (with-output-to-string (out)
+ (setq stream out)
+ (print-raw start i)
+ (write-string entity stream)
+ (incf i)
+ (skip i i)))
+ (t (stream-or-string (1+ i)))))))))
+ (if stream
+ (skip start start)
+ (stream-or-string start)))))
(define-compiler-macro quote-html (&whole whole string &key stream
(start 0)