<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -333,7 +333,7 @@
     (push :tpd2-has-swank *features*)
     nil)
 
-#+start-tpd2 (progn
+(progn
   (let ((socket (tpd2.io:make-con-listen :port 8888)))
     (tpd2.io:launch-io 'tpd2.io:accept-forever socket 'tpd2.http::http-serve))
 
@@ -346,5 +346,5 @@
 	   (tpd2.io:event-loop)))
      :name &quot;MOPOKO-EVENT-LOOP&quot;)))
 
-(defpage &quot;/test&quot; ()
-  (&lt;p &quot;hello&quot;))
\ No newline at end of file
+(defpage &quot;/test&quot; (name)
+  (&lt;p &quot;hello &quot; (&lt;b name)))
\ No newline at end of file</diff>
      <filename>src/game/web.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,7 @@
 	  (f
 	   (funcall f me con done path params))
 	  (t
-	   (format *error-output* &quot;LOST ~A~&amp;&quot; (strcat (my canonical-name) &quot;/&quot; path))
+	   ;(format *error-output* &quot;LOST ~A~&amp;&quot; (strcat (my canonical-name) &quot;/&quot; path))
 	   (respond-http con done :code  404 :banner  &quot;Not found&quot;
 			 :body (funcall (my error-responder) me path params))))
       (error (e)</diff>
      <filename>src/http/dispatcher.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,16 @@
 (in-package #:tpd2.http)
 
+(defun match-int (value)
+  (match-bind ((len (integer))) value
+	      len))
+(defun match-each-word (value func)
+  (match-bind ( (+ word (or (+ (space)) (last))
+		   '(funcall func word)))
+	      value))
+
+(declaim (inline match-int))
+(declaim (inline match-each-word))
+
 (defprotocol process-headers (con process-header-func)
   (let ((last-header-name))
     (loop for line = (io 'recvline con)</diff>
      <filename>src/http/headers.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -29,27 +29,28 @@
 	(flet ((decode (bytes)
 		 (cond (gzip (error &quot;Sorry; haven't implemented GZIP decompression yet&quot;))
 		       (t (funcall done bytes :response-code code)))))
+
 	  (when (not (or (&lt; 1 version-major) (and (= 1 version-major) (&lt; 0 version-minor))))
 	    (setf connection-close t))
 
-	  (io 'process-headers con (lambda(name value)
-				     (when (length value)
-				       (case-match-fold-ascii-case name
-								   (&quot;content-length&quot;
-								    (match-bind ((len (integer))) value
-								      (setf content-length len)))
-								   (&quot;connection&quot;
-								    (match-bind ( (+ word (or (+ (space)) (last))
-										     '(case-match-fold-ascii-case word
-										       (&quot;close&quot; (setf connection-close t))
-										       (&quot;keep-alive&quot; (setf connection-close nil))) ))
-									value))
-								   (&quot;transfer-encoding&quot;
-								    (match-bind ( (+ word (or (+ (space)) (last))
-										     '(case-match-fold-ascii-case word
-										       (&quot;chunked&quot; (setf chunked t))
-										       (&quot;gzip&quot; (setf gzip t)))))
-									    value))))))
+	  (io 'process-headers con 
+	      (without-call/cc (lambda(name value)
+				 (unless (zerop (length value))
+				   (case-match-fold-ascii-case name
+							       (&quot;content-length&quot;
+								(setf content-length (match-int value)))
+							       (&quot;connection&quot;
+								(match-each-word value
+										 (lambda(word)
+										   (case-match-fold-ascii-case word
+													       (&quot;close&quot; (setf connection-close t))
+													       (&quot;keep-alive&quot; (setf connection-close nil))) )))
+							       (&quot;transfer-encoding&quot;
+								(match-each-word value
+										 (lambda(word)
+										   (case-match-fold-ascii-case word
+													       (&quot;chunked&quot; (setf chunked t))
+													       (&quot;gzip&quot; (setf gzip t)))))))))))
 	  (decode
 	   (cond 
 	     (chunked</diff>
      <filename>src/http/request.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -15,21 +15,19 @@
     (let ((request-content-length 0)
 	  host
 	  (connection-close (not (or (&lt; 1 version-major) (and (= 1 version-major) (&lt; 0 version-minor))))))
-      (flet ((process-header (name value)
-	       (when (length value)
-		 (case-match-fold-ascii-case name
-		  (&quot;content-length&quot; 
-		   (match-bind ((len (integer))) value
-		     (setf request-content-length len)))
-		  (&quot;host&quot;
-		   (setf host value))
-		  (&quot;connection&quot;
-		   (match-bind ( (+ word (or (+ (space)) (last))
-				    '(case-match-fold-ascii-case word
-				      (&quot;close&quot; (setf connection-close t))
-				      (&quot;keep-alive&quot; (setf connection-close nil))) ))
-		       value))))))
-	(io 'process-headers con #'process-header))
+	(io 'process-headers con (without-call/cc (lambda(name value)
+						    (unless (zerop (length value))
+						      (case-match-fold-ascii-case name
+										  (&quot;content-length&quot; 
+										   (setf request-content-length (match-int value)))
+										  (&quot;host&quot;
+										   (setf host value))
+										  (&quot;connection&quot;
+										   (match-each-word value
+												    (lambda(word)
+												      (case-match-fold-ascii-case word
+																  (&quot;close&quot; (setf connection-close t))
+																  (&quot;keep-alive&quot; (setf connection-close nil))) ))))))))
       (let ((request-body
 	     (unless (zerop request-content-length)
 	       (io 'recv con request-content-length))))</diff>
      <filename>src/http/serve.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,5 @@
 (in-package #:tpd2.lib)
 
-(eval-always
-  (defun make-byte-vector (len)
-    (declare (optimize speed))
-    (declare (type (unsigned-byte *) len))
-    (make-array len :element-type '(unsigned-byte 8))))
-
-(declaim (inline make-byte-vector))
-
-(deftype byte-vector (&amp;optional (len '*))
-  `(vector (unsigned-byte 8) ,len))
-(deftype simple-byte-vector (&amp;optional (len '*))
-  `(simple-array (unsigned-byte 8) (,len)))
-
-(declaim (ftype (function ((unsigned-byte *)) simple-byte-vector) make-byte-vector)) 
-
 (defmacro with-pointer-to-vector-data ((ptr lisp-vector) &amp;body body)
   (check-symbols ptr)
   (once-only (lisp-vector)
@@ -68,7 +53,6 @@
 
 (declaim (ftype (function ( (unsigned-byte 8)) (integer -1 36)) byte-to-digit-consistent-internal))
 
-
 (defun byte-vector-parse-integer (string &amp;optional (base 10))
   (declare (optimize speed))
   (declare (type byte-vector string))</diff>
      <filename>src/lib/byte-vector.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -19,14 +19,15 @@
      ,@(loop for n in names collect
 	     `(cl-cont-pass-through-one-construct ,n))))
   
-
-(cl-cont-pass-through-constructs
- handler-case
- handler-bind
- restart-case
- restart-bind
-
- cl-irregsexp::with-match)
+(eval-always
+  (cl-cont-pass-through-constructs
+   handler-case
+   handler-bind
+   restart-case
+   restart-bind
+   
+   without-call/cc
+   cl-irregsexp::with-match))
 
 #+extra-bugs-please 
 (defmacro cl-cont:call/cc (cc)</diff>
      <filename>src/lib/callcc.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -71,16 +71,17 @@
      ,result-form))
 
 (defun generate-case-key (keyform &amp;key test (transform 'identity) clauses)
-  (once-only (keyform)
+  (with-unique-names (xkeyform)
     (flet ((apply-transform (form)
 	     `(,transform ,form)))
-      `(cond ,@(mapcar 
-		(lambda(clause) 
-		  (list* (typecase (first clause)
-			   ((member t otherwise) t)
-			     (list `(member ,keyform (list ,(mapcar #'apply-transform (first clause))) :test (function ,test)))
-			     (t `(funcall (function ,test) ,keyform ,(apply-transform (first clause)))))
-			 (rest clause))) clauses)))))
+      `(let ((,xkeyform ,(apply-transform keyform)))
+	 (cond ,@(mapcar 
+		  (lambda(clause) 
+		    (list* (typecase (first clause)
+			     ((member t otherwise) t)
+			     (list `(member ,xkeyform (list ,(mapcar #'apply-transform (first clause))) :test (function ,test)))
+			     (t `(funcall (function ,test) ,xkeyform ,(apply-transform (first clause)))))
+			   (rest clause))) clauses))))))
 
 (defmacro case-func (keyform func &amp;rest clauses)
   (generate-case-key keyform :test func :clauses clauses))</diff>
      <filename>src/lib/macros.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,23 @@
 (in-package #:tpd2.lib)
 
-(defun utf8-char-length (code)
-  (cond ((&gt; #x80 code) 1)
-	((&gt; #x800 code) 2)
-	((&gt; #x10000 code) 3)
-	(t 4)))
+(defun utf8-char-length (char)
+  (declare (type character char))
+  (let ((code (char-code char)))
+    (cond ((&gt; #x80 code) 1)
+	  ((&gt; #x800 code) 2)
+	  ((&gt; #x10000 code) 3)
+	  (t 4))))
 (declaim (inline utf8-char-length))
+(declaim (ftype (function (character) (integer 1 4)) utf8-char-length))
 
 (defun utf8-encode-really (string)
   (declare (optimize speed))
   (declare (type simple-string string))
   (let ((dest-len
-	 (loop for c across string summing (utf8-char-length (char-code c)))) )
+	 (loop for c across string summing (utf8-char-length c))))
     (let ((vec (make-byte-vector dest-len)))
       (let ((i 0))
+	(declare (type fixnum i))
 	(flet ((out (val)
 		 (setf (aref vec i) val)
 		 (incf i)))</diff>
      <filename>src/lib/utf8.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -1,66 +1,5 @@
 (in-package #:tpd2.lib)
 
-(def-if-unbound defun-consistent utf8-decode (vec)
-  (map 'string 'code-char vec))
-
-(def-if-unbound defun-consistent utf8-encode (string)
-  (map 'byte-vector 'char-code string))
-
-(defun-consistent byte-vector-to-simple-byte-vector (val)
-  (declare (optimize speed (safety 0)))
-  (declare (type (and byte-vector (not simple-byte-vector)) val))
-  (let ((ret (make-byte-vector (length val))))
-    (replace ret val)
-    ret))
-
-(declaim (ftype (function ((and byte-vector (not simple-byte-vector))) simple-byte-vector) byte-vector-to-simple-byte-vector-consistent-internal))
-
-(defun-consistent force-string (val)
-  (declare (optimize speed (safety 0)))
-  (let ((str
-	 (the string
-	   (typecase val
-	     (null &quot;&quot;)
-	     (symbol (symbol-name val))
-	     (string val)
-	     (simple-byte-vector (utf8-decode val))
-	     (byte-vector (utf8-decode (byte-vector-to-simple-byte-vector val)))
-	     (t  (let ((*print-pretty* nil)) (princ-to-string val)))))))
-    (etypecase str
-      (simple-string str)
-      (string 
-       (locally 
-	   (declare (type (and string (not simple-string)) str))
-	 (replace (make-string (length str)) str))))))
-
-(declaim (ftype (function (t) simple-string) force-string-consistent-internal))
-
-
-(defun-consistent force-byte-vector (val)
-  (declare (optimize speed (safety 0)))
-  (typecase val
-    (null #.(make-byte-vector 0))
-    (simple-string (utf8-encode val))
-    (string (utf8-encode val))
-    (character (utf8-encode (string val)))
-    (byte-vector val)
-    (sequence (map 'byte-vector 'identity val))
-    (t (utf8-encode (force-string val)))))
-
-(declaim (ftype (function (t) byte-vector) force-byte-vector-consistent-internal))
-
-(defun-consistent force-simple-byte-vector (val)
-  (declare (optimize speed (safety 0)))
-  (let ((val (force-byte-vector val)))
-    (etypecase val
-      (simple-byte-vector val)
-      (byte-vector 
-       (byte-vector-to-simple-byte-vector val)))))
-
-(declaim (ftype (function (t) simple-byte-vector) force-simple-byte-vector-consistent-internal))
-
-(defun-consistent byte-vector-to-string (vec)
-  (utf8-decode (force-simple-byte-vector vec)))
 
 (defun byte-vector-cat (&amp;rest args)
   (declare (optimize speed))</diff>
      <filename>src/lib/utils.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@
     (raw-ml-sendbuf
      value)
     (t
-     (macrolet ((f (x) `(force-byte-vector ,x)))
+     (macrolet ((f (x) `(force-simple-byte-vector ,x)))
        (match-replace-all (f value)
 			  (#\&lt; (f &quot;&amp;lt;&quot;))
 			  (#\&gt; (f &quot;&amp;gt;&quot;))</diff>
      <filename>src/ml/output.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@
 
 (defpackage #:teepeedee2.lib
   (:nicknames #:tpd2.lib)
-  (:use #:common-lisp #:iter)
+  (:use #:common-lisp #:iter #:cl-irregsexp-bytestrings)
   (:import-from #:cl-utilities #:with-unique-names)
   (:import-from #:trivial-garbage #:finalize #:cancel-finalization)
   (:import-from #:cl-cont #:call/cc #:with-call/cc)</diff>
      <filename>src/packages.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -38,13 +38,12 @@
 							    (:file &quot;macros&quot; :depends-on (&quot;once-only&quot; &quot;one-liners&quot;)) 
 							    (:file &quot;once-only&quot;)
 							    (:file &quot;one-liners&quot;)
-							    (:file &quot;utils&quot; :depends-on (&quot;utf8&quot;))
-							    (:file &quot;utf8&quot; :depends-on (&quot;macros&quot; &quot;byte-vector&quot;))
+							    (:file &quot;utils&quot; :depends-on (&quot;macros&quot; &quot;byte-vector&quot;))
 							    (:file &quot;superquote&quot; :depends-on (&quot;utils&quot;))
 							    (:file &quot;strcat&quot; :depends-on (&quot;macros&quot; &quot;utils&quot;))
 							    (:file &quot;my&quot; :depends-on (&quot;macros&quot; &quot;once-only&quot; &quot;strcat&quot; &quot;one-liners&quot;))
 							    (:file &quot;byte-vector&quot; :depends-on (&quot;macros&quot;))
-							    (:file &quot;callcc&quot;)
+							    (:file &quot;callcc&quot; :depends-on (&quot;macros&quot;))
 							    (:file &quot;quick-queue&quot; :depends-on (&quot;utils&quot; &quot;my&quot;))
 							    (:file &quot;timeout&quot; :depends-on (&quot;quick-queue&quot;))))
 				     
@@ -114,7 +113,6 @@
 			:components (
 				     (:file &quot;suite&quot;)
 				     (:file &quot;io&quot; :depends-on (&quot;suite&quot;))
-				     (:file &quot;utf8&quot; :depends-on (&quot;suite&quot;))
 				     (:file &quot;http&quot; :depends-on (&quot;suite&quot;))
 				     )))
   :depends-on (</diff>
      <filename>teepeedee2.asd</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>t/utf8.lisp</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>90026a5f1407824303c3aeacabb9b3314fa7aa87</id>
    </parent>
  </parents>
  <author>
    <name>John Fremlin</name>
    <email>john@fremlin.org</email>
  </author>
  <url>http://github.com/vii/teepeedee2/commit/7c1074b767425f45efebcda02cd027bbb0b649de</url>
  <id>7c1074b767425f45efebcda02cd027bbb0b649de</id>
  <committed-date>2008-10-12T23:18:27-07:00</committed-date>
  <authored-date>2008-10-12T23:18:27-07:00</authored-date>
  <message>working on sbcl again</message>
  <tree>c2cd3ffb3aa7419c0a03bc235f451ef73c1ea97b</tree>
  <committer>
    <name>John Fremlin</name>
    <email>john@fremlin.org</email>
  </committer>
</commit>
