X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src.lisp;h=edb8afa5d8ef99b67eed37f8ac13283f9ca184ea;hb=37f961932721c8146f05bdfb1abc08d193824bf9;hp=e824ef4acff11d39d84e9467225596118f3e87d8;hpb=55a5a4735163dc9adc1e6ee9e49e4b0c335732e2;p=puri.git diff --git a/src.lisp b/src.lisp index e824ef4..edb8afa 100644 --- a/src.lisp +++ b/src.lisp @@ -22,7 +22,7 @@ ;; Original version from ACL 6.1: ;; uri.cl,v 2.3.6.4.2.1 2001/08/09 17:42:39 layer ;; -;; $Id: src.lisp,v 1.5 2003/07/19 13:34:12 kevin Exp $ +;; $Id: src.lisp,v 1.8 2003/07/20 16:25:21 kevin Exp $ (defpackage #:puri (:use #:cl) @@ -59,13 +59,29 @@ (in-package #:puri) -(eval-when (compile) (declaim (optimize (speed 3)))) +(eval-when (:compile-toplevel) + (declaim (optimize (speed 3)))) -#-(or allegro lispworks) -(define-condition parse-error (error) ()) +#-allegro +(defun parse-body (forms &optional env) + "Parses a body, returns (VALUES docstring declarations forms)" + (declare (ignore env)) + ;; fixme -- need to add parsing of multiple declarations + (let (docstring declarations) + (when (stringp (car forms)) + (setq docstring (car forms)) + (setq forms (cdr forms))) + (when (and (listp (car forms)) + (symbolp (caar forms)) + (string-equal (symbol-name '#:declare) + (symbol-name (caar forms)))) + (setq declarations (car forms)) + (setq forms (cdr forms))) + (values docstring declarations forms))) + (defun shrink-vector (str size) #+allegro (excl::.primcall 'sys::shrink-svector str size) @@ -78,26 +94,34 @@ #+(or allegro cmu sbcl lispworks) str #-(or allegro cmu sbcl lispworks) - (subseq new-string 0 (incf new-i))) + (subseq str 0 size)) +#-(or allegro lispworks) +(define-condition parse-error (error) + ((fmt-control :initarg :fmt-control + :reader fmt-control) + (fmt-args :initarg :fmt-args + :reader fmt-args)) + (:report (lambda (c stream) + (format stream "Parse error: ") + (apply #'format stream (fmt-control c) (fmt-args c))))) + +#-allegro (defun .parse-error (fmt &rest args) - #+allegro (apply #'excl::.parse-error fmt args) - #-allegro (error - (make-condition 'parse-error :format-control fmt - :format-arguments args))) + (error (make-condition 'parse-error :fmt-control fmt :fmt-args args))) +#-allegro (defun internal-reader-error (stream fmt &rest args) - #+allegro - (apply #'excl::internal-reader-error stream fmt args) - #-allegro - (apply #'format stream - "#u takes a string or list argument: ~s" args)) + (apply #'format stream fmt args)) #-allegro (defvar *current-case-mode* :case-insensitive-upper) -#+allegro (eval-when (compile load eval) +#+allegro (eval-when (:compile-toplevel :load-toplevel :execute) (import '(excl:*current-case-mode* excl:delimited-string-to-list + excl::.parse-error + excl::parse-body + excl::internal-reader-error excl:if*))) #-allegro @@ -223,7 +247,7 @@ ((nid :initarg :nid :initform nil :accessor urn-nid) (nss :initarg :nss :initform nil :accessor urn-nss))) -(eval-when (compile eval) +(eval-when (:compile-toplevel :execute) (defmacro clear-caching-on-slot-change (name) `(defmethod (setf ,name) :around (new-value (self uri)) (declare (ignore new-value)) @@ -374,7 +398,7 @@ (defparameter *reserved-fragment-characters* (reserved-char-vector (remove #\# *excluded-characters*))) -(eval-when (compile eval) +(eval-when (:compile-toplevel :execute) (defun gen-char-range-list (start end) (do* ((res '()) (endcode (1+ (char-int end))) @@ -818,13 +842,9 @@ URI ~s contains illegal character ~s at position ~d." host *reserved-authority-characters* escape)) (when port ":") (when port -;;;; too slow until ACL 6.0: -;;; (format nil "~d" port) -;;; (princ-to-string port) - #-allegro (princ-to-string port) - #+allegro - (with-output-to-string (s) - (excl::maybe-print-fast s port)) + #-allegro (format nil "~D" port) + #+allegro (with-output-to-string (s) + (excl::maybe-print-fast s port)) ) (when path (encode-escaped-encoding path @@ -1185,6 +1205,7 @@ URI ~s contains illegal character ~s at position ~d." ;; bootstrapping (uri= changed from function to method): (when (fboundp 'uri=) (fmakunbound 'uri=)) +(defgeneric uri= (uri1 uri2)) (defmethod uri= ((uri1 uri) (uri2 uri)) (when (not (eq (uri-scheme uri1) (uri-scheme uri2))) (return-from uri= nil)) @@ -1261,8 +1282,7 @@ Executes the forms once for each uri with var bound to the current uri" (let ((f (gensym)) (g-ignore (gensym)) (g-uri-space (gensym)) - (body #+allegro (third (excl::parse-body forms env)) - #-allegro forms)) + (body (third (parse-body forms env)))) `(let ((,g-uri-space (or ,uri-space *uris*))) (prog nil (flet ((,f (,var &optional ,g-ignore) @@ -1284,6 +1304,7 @@ Executes the forms once for each uri with var bound to the current uri" stream "#u takes a string or list argument: ~s" arg))))) + #+allegro excl:: #+allegro @@ -1301,7 +1322,17 @@ excl:: ;; timings ;; (don't run under emacs with M-x fi:common-lisp) -#+ignore +#+allegro +(eval-when (:compile-toplevel :load-toplevel :execute) + (import 'excl::gc)) + +#-allegro +(defun gc (&rest options) + (declare (ignore options)) + #+sbcl (sb-ext::gc) + #+cmu (ext::gc) + ) + (defun time-uri-module () (declare (optimize (speed 3) (safety 0) (debug 0))) (let ((uri "http://www.franz.com/a/b;x;y;z/c/foo?bar=baz&xxx#foo")