Commit eec22d29 authored by Boris Smilga's avatar Boris Smilga
Browse files

Added version-string comparison functions.

parent 566d0704
(in-package #:parenscript)
(defparameter *js-target-version* 1.3)
(defparameter *js-target-version* "1.3")
(defvar *parenscript-stream* nil)
......@@ -57,3 +57,32 @@ paren-script becomes parenScript, *some-global* becomes SOMEGLOBAL."
(or (tree-search A (car x))
(unless (listp (cdr x))
(equal A (cdr x))))))))
(labels ((compare (a b op equality)
(if (not (stringp a)) (setf a (format nil "~A" a)))
(if (not (stringp b)) (setf b (format nil "~A" b)))
(loop with i := 0 and j := 0 and m and n
while (or i j)
do (multiple-value-setq (m i)
(if (and i (< i (length a)))
(parse-integer a :start i :junk-allowed t)))
(multiple-value-setq (n j)
(if (and j (< j (length b)))
(parse-integer b :start j :junk-allowed t)))
if (not m) do (setf m -1) else do (incf i)
if (not n) do (setf n -1) else do (incf j)
do (let ((op-p (funcall op m n))
(rev-op-p (funcall op n m)))
((and op-p (not (and rev-op-p equality)))
(return t))
((and rev-op-p (not (and op-p equality)))
(return nil))
((and (not (or op-p rev-op-p)) equality)
(return nil))))
finally (return equality))))
(defun vstring< (a b) (compare a b #'< nil))
(defun vstring<= (a b) (compare a b #'<= t))
(defun vstring= (a b) (compare a b #'= t))
(defun vstring>= (a b) (compare a b #'>= t))
(defun vstring> (a b) (compare a b #'> nil)))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment