Commit 3a2b7affdce247e978f7a48dda4160e034dc136e

Thomas de Grivel 2014-06-10T20:15:28

Fix H returning NIL on empty string.

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)