From 8bbcf109b6cbdfd4c92fe06cc181c56f408b8b82 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 13 Jul 2003 04:56:12 +0000 Subject: [PATCH 01/16] r5301: *** empty log message *** --- listener.lisp | 74 ++++++++++++++++++++++++++++---------------------- processes.lisp | 6 +++- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/listener.lisp b/listener.lisp index 19c7b0c..a757cc1 100644 --- a/listener.lisp +++ b/listener.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Jun 2003 ;;;; -;;;; $Id: listener.lisp,v 1.5 2003/07/11 06:58:32 kevin Exp $ +;;;; $Id: listener.lisp,v 1.6 2003/07/13 04:53:32 kevin Exp $ ;;;; ************************************************************************* (in-package #:kmrcl) @@ -69,41 +69,16 @@ (case state (:start (when (member listener *active-listeners*) - (warn "~&listener already started") - (return-from init/listener listener)) - (handler-case - (progn - (setf (name listener) (next-server-name (base-name listener))) - (make-socket-server listener)) - (error (e) - (format t "~&Error while trying to start listener~& ~A" e) - (decf *listener-count*) - nil) - (:no-error (res) - (declare (ignore res)) - (push listener *active-listeners*) - listener))) + (cmsg "~&listener ~A already initialized" listener) + (return-from init/listener)) + (when (listener-startup listener) + (push listener *active-listeners*) + listener)) (:stop (unless (member listener *active-listeners*) - (warn "~&listener is not in active list") + (cmsg "~&listener ~A is not in active list" listener) (return-from init/listener listener)) - (dolist (worker (workers listener)) - (when (and (typep worker 'worker) - (connection worker)) - (errorset (close-active-socket - (connection worker)) nil) - (setf (connection worker) nil)) - (when (process worker) - (errorset (destroy-process (process worker)) nil) - (setf (process worker) nil))) - (setf (workers listener) nil) - (with-slots (process socket) listener - (when socket - (errorset (close-passive-socket socket) nil) - (setf socket nil)) - (when process - (errorset (destroy-process process) nil) - (setf process nil))) + (listener-shutdown listener) (setq *active-listeners* (remove listener *active-listeners*))) (:restart (init/listener listener :stop) @@ -114,6 +89,39 @@ (ignore-errors (init/listener listener :stop)))) +(defun listener-startup (listener) + (handler-case + (progn + (setf (name listener) (next-server-name (base-name listener))) + (make-socket-server listener)) + (error (e) + (format t "~&Error while trying to start listener on port ~A~& ~A" + (port listener) e) + (decf *listener-count*) + nil) + (:no-error (res) + (declare (ignore res)) + listener))) + +(defun listener-shutdown (listener) + (dolist (worker (workers listener)) + (when (and (typep worker 'worker) + (connection worker)) + (errorset (close-active-socket + (connection worker)) nil) + (setf (connection worker) nil)) + (when (process worker) + (errorset (destroy-process (process worker)) nil) + (setf (process worker) nil))) + (setf (workers listener) nil) + (with-slots (process socket) listener + (when socket + (errorset (close-passive-socket socket) nil) + (setf socket nil)) + (when process + (errorset (destroy-process process) nil) + (setf process nil)))) + ;; Low-level functions (defun next-server-name (base-name) diff --git a/processes.lisp b/processes.lisp index 547b862..1cc6a47 100644 --- a/processes.lisp +++ b/processes.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: June 2003 ;;;; -;;;; $Id: processes.lisp,v 1.3 2003/07/11 02:37:33 kevin Exp $ +;;;; $Id: processes.lisp,v 1.4 2003/07/13 04:53:32 kevin Exp $ ;;;; ************************************************************************* (in-package #:kmrcl) @@ -60,3 +60,7 @@ `(progn ,@body) ) +(defun process-sleep (n) + #+allegro (mp:process-sleep n) + #-allegro (sleep n)) + -- 2.34.1 From 2ffbc18c75d4b31c58fad32950658c90e256b556 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 14 Jul 2003 04:10:02 +0000 Subject: [PATCH 02/16] r5304: *** empty log message *** --- io.lisp | 5 ++++- package.lisp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/io.lisp b/io.lisp index c444e0f..2d4f3da 100644 --- a/io.lisp +++ b/io.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: io.lisp,v 1.10 2003/06/20 08:50:38 kevin Exp $ +;;;; $Id: io.lisp,v 1.11 2003/07/14 04:10:02 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -169,3 +169,6 @@ #-allegro (write-string (write-to-string n) s)) +(defun null-output-stream () + (when (probe-file #p"/dev/null") + (open #p"/dev/null" :direction :output :if-exists :supersede))) diff --git a/package.lisp b/package.lisp index 754aef5..d11e68f 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.49 2003/07/11 06:58:32 kevin Exp $ +;;;; $Id: package.lisp,v 1.50 2003/07/14 04:10:02 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -73,7 +73,8 @@ #:write-fixnum #:file-subst #:stream-subst - + #:null-output-stream + ;; lists.lisp #:remove-tree-if #:find-tree -- 2.34.1 From 79ce9975800c5c9e968c5db342add2d01a5cd83b Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 16 Jul 2003 16:02:21 +0000 Subject: [PATCH 03/16] r5315: *** empty log message *** --- listener.lisp | 6 +++--- package.lisp | 7 ++++++- strings.lisp | 55 ++++++++++++++++++++++++++++++++++++++++++--------- symbols.lisp | 21 ++++++++++++++------ tests.lisp | 8 +++++++- 5 files changed, 77 insertions(+), 20 deletions(-) diff --git a/listener.lisp b/listener.lisp index a757cc1..36d7fd3 100644 --- a/listener.lisp +++ b/listener.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Jun 2003 ;;;; -;;;; $Id: listener.lisp,v 1.6 2003/07/13 04:53:32 kevin Exp $ +;;;; $Id: listener.lisp,v 1.7 2003/07/16 16:01:37 kevin Exp $ ;;;; ************************************************************************* (in-package #:kmrcl) @@ -125,10 +125,10 @@ ;; Low-level functions (defun next-server-name (base-name) - (format nil "~A-socket-server-~D" base-name (incf *listener-count*))) + (format nil "~D-~A-socket-server" (incf *listener-count*) base-name)) (defun next-worker-name (base-name) - (format nil "~A-worker-~D" base-name (incf *worker-count*))) + (format nil "~D-~A-worker" (incf *worker-count*) base-name)) (defun make-socket-server (listener) #+lispworks diff --git a/package.lisp b/package.lisp index d11e68f..89f583a 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.50 2003/07/14 04:10:02 kevin Exp $ +;;;; $Id: package.lisp,v 1.51 2003/07/16 16:01:37 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -60,6 +60,7 @@ #:last-char #:ensure-string #:string-right-trim-one-char + #:string-strip-ending #:flatten @@ -215,6 +216,10 @@ #:init/listener #:stop-all/listener #:listener + + ;; fformat.lisp + #:fformat + )) diff --git a/strings.lisp b/strings.lisp index cadd1ac..19389e1 100644 --- a/strings.lisp +++ b/strings.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: strings.lisp,v 1.47 2003/07/09 19:19:19 kevin Exp $ +;;;; $Id: strings.lisp,v 1.48 2003/07/16 16:01:37 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -403,9 +403,11 @@ for characters in a string" (declare (type (integer 0 15) n)) (schar +hex-chars+ n)) -(defconstant +char-code-0+ (char-code #\0)) +(defconstant +char-code-lower-a+ (char-code #\a)) (defconstant +char-code-upper-a+ (char-code #\A)) -(declaim (type fixnum +char-code-0+ +char-code-upper-a+)) +(defconstant +char-code-0+ (char-code #\0)) +(declaim (type fixnum +char-code-0+ +char-code-upper-a+ + +char-code-0)) (defun charhex (ch) "convert hex character to decimal" @@ -462,16 +464,39 @@ for characters in a string" (setf (schar str dpos) ch))))) -(defconstant +char-code-a+ (char-code #\a)) -(defun random-string (&optional (len 10)) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defvar +unambigous-charset+ + "abcdefghjkmnpqrstuvwxyz123456789ABCDEFGHJKLMNPQSRTUVWXYZ") + (defconstant +unambigous-length+ (length +unambigous-charset+))) + +(defun random-char (&optional (set :lower-alpha)) + (ecase set + (:lower-alpha + (code-char (+ +char-code-lower-a+ (random 26)))) + (:lower-alphanumeric + (let ((n (random 36))) + (if (>= n 26) + (code-char (+ +char-code-0+ (- n 26))) + (code-char (+ +char-code-lower-a+ n))))) + (:upper-alpha + (code-char (+ +char-code-upper-a+ (random 26)))) + (:unambigous + (schar +unambigous-charset+ (random +unambigous-length+))) + (:upper-lower-alpha + (let ((n (random 52))) + (if (>= n 26) + (code-char (+ +char-code-upper-a+ (- n 26))) + (code-char (+ +char-code-lower-a+ n))))))) + + +(defun random-string (&key (length 10) (set :lower-alpha)) "Returns a random lower-case string." (declare (optimize (speed 3))) - (let ((s (make-string len))) + (let ((s (make-string length))) (declare (simple-string s)) - (dotimes (i len s) - (setf (schar s i) - (code-char (+ +char-code-a+ (random 26))))))) + (dotimes (i length s) + (setf (schar s i) (random-char set))))) (defun first-char (s) @@ -503,3 +528,15 @@ for characters in a string" str))) +(defun string-strip-ending (str endings) + (if (stringp endings) + (setq endings (list endings))) + (let ((len (length str))) + (dolist (ending endings str) + (when (and (>= len (length ending)) + (string-equal ending + (subseq str (- len + (length ending))))) + (return-from string-strip-ending + (subseq str 0 (- len (length ending)))))))) + diff --git a/symbols.lisp b/symbols.lisp index 7ec505f..5a8a348 100644 --- a/symbols.lisp +++ b/symbols.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: symbols.lisp,v 1.2 2003/06/06 21:59:30 kevin Exp $ +;;;; $Id: symbols.lisp,v 1.3 2003/07/16 16:01:37 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -45,6 +45,18 @@ ;;; Symbol functions +(eval-when (:compile-toplevel :load-toplevel :execute) + (when (char= #\a (symbol-name '#:a)) + (pushnew :lowercase-reader *features*))) + +(defun string-default-case (str) + #+(and (not case-sensitive) (not lowercase-reader)) + (string-upcase str) + #+(and (not case-sensitive) lowercase-reader) + (string-downcase str) + #+case-sensitive + str) + (defun concat-symbol-pkg (pkg &rest args) (declare (dynamic-extent args)) (flet ((stringify (arg) @@ -54,8 +66,7 @@ (symbol (symbol-name arg))))) (let ((str (apply #'concatenate 'string (mapcar #'stringify args)))) - (intern #-case-sensitive (string-upcase str) - #+case-sensitive str + (intern (string-default-case str) (if pkg pkg *package*))))) @@ -66,9 +77,7 @@ "Returns keyword for a name" (etypecase name (keyword name) - (string (intern #-case-sensitive (string-upcase name) - #+case-sensitive name - :keyword)) + (string (intern (string-default-case name) :keyword)) (symbol (intern (symbol-name name) :keyword)))) (defun show (&optional (what :variables) (package *package*)) diff --git a/tests.lisp b/tests.lisp index 2c944aa..c917615 100644 --- a/tests.lisp +++ b/tests.lisp @@ -7,7 +7,7 @@ ;;;; Author: Kevin M. Rosenberg ;;;; Date Started: Apr 2003 ;;;; -;;;; $Id: tests.lisp,v 1.21 2003/07/01 22:16:40 kevin Exp $ +;;;; $Id: tests.lisp,v 1.22 2003/07/16 16:01:37 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -178,6 +178,12 @@ (deftest duqs.4 (decode-uri-query-string "abc+d") "abc d") (deftest duqs.5 (decode-uri-query-string "abc%20d") "abc d") +(deftest sse.1 (string-strip-ending "" nil) "") +(deftest sse.2 (string-strip-ending "abc" nil) "abc") +(deftest sse.3 (string-strip-ending "abc" "ab") "abc") +(deftest sse.4 (string-strip-ending "abc" '("ab")) "abc") +(deftest sse.5 (string-strip-ending "abcd" '("a" "cd")) "ab") + ;;; MOP Testing (eval-when (:compile-toplevel :load-toplevel :execute) -- 2.34.1 From 91e3d8f38e4ccdfbfb9c351e05b487ee899c9e47 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sat, 19 Jul 2003 20:32:48 +0000 Subject: [PATCH 04/16] r5339: *** empty log message *** --- package.lisp | 4 +++- strings.lisp | 23 ++++++++++++++++++++++- symbols.lisp | 4 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/package.lisp b/package.lisp index 89f583a..68cd413 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.51 2003/07/16 16:01:37 kevin Exp $ +;;;; $Id: package.lisp,v 1.52 2003/07/19 20:32:48 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -61,6 +61,8 @@ #:ensure-string #:string-right-trim-one-char #:string-strip-ending + #:string-maybe-shorten + #:shrink-vector #:flatten diff --git a/strings.lisp b/strings.lisp index 19389e1..6ec3f5c 100644 --- a/strings.lisp +++ b/strings.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: strings.lisp,v 1.48 2003/07/16 16:01:37 kevin Exp $ +;;;; $Id: strings.lisp,v 1.49 2003/07/19 20:32:48 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -540,3 +540,24 @@ for characters in a string" (return-from string-strip-ending (subseq str 0 (- len (length ending)))))))) + +(defun string-maybe-shorten (str maxlen) + (let ((len (length str))) + (if (<= len maxlen) + str + (concatenate 'string (subseq str 0 (- maxlen 3)) "...")))) + + +(defun shrink-vector (str size) + #+allegro + (excl::.primcall 'sys::shrink-svector str size) + #+sbcl + (sb-kernel:shrink-vector str size) + #+cmu + (lisp::shrink-vector str size) + #+lispworks + (system::shrink-vector$vector str size) + #+(or allegro cmu sbcl lispworks) + str + #-(or allegro cmu sbcl lispworks) + (subseq str 0 size)) diff --git a/symbols.lisp b/symbols.lisp index 5a8a348..a619327 100644 --- a/symbols.lisp +++ b/symbols.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: symbols.lisp,v 1.3 2003/07/16 16:01:37 kevin Exp $ +;;;; $Id: symbols.lisp,v 1.4 2003/07/19 20:32:48 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -46,7 +46,7 @@ ;;; Symbol functions (eval-when (:compile-toplevel :load-toplevel :execute) - (when (char= #\a (symbol-name '#:a)) + (when (char= #\a (schar (symbol-name '#:a) 0)) (pushnew :lowercase-reader *features*))) (defun string-default-case (str) -- 2.34.1 From 5738e60dc3724dc7d022d0fd2d5f2dbe337be470 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 21 Jul 2003 00:53:27 +0000 Subject: [PATCH 05/16] r5354: *** empty log message *** --- kmrcl.asd | 3 ++- package.lisp | 8 +++++- sockets.lisp | 4 +-- strings.lisp | 49 +++++++++++++++++++++++++++++----- strmatch.lisp | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 strmatch.lisp diff --git a/kmrcl.asd b/kmrcl.asd index 6216a71..73c004c 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.40 2003/07/11 06:58:32 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.41 2003/07/21 00:52:56 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -40,6 +40,7 @@ (:file "io" :depends-on ("macros")) (:file "console" :depends-on ("macros")) (:file "strings" :depends-on ("macros" "seqs")) + (:file "strmatch" :depends-on ("strings")) (:file "buff-input" :depends-on ("macros")) (:file "random" :depends-on ("macros")) (:file "symbols" :depends-on ("macros")) diff --git a/package.lisp b/package.lisp index 68cd413..16b5ed0 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.52 2003/07/19 20:32:48 kevin Exp $ +;;;; $Id: package.lisp,v 1.53 2003/07/21 00:52:56 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -144,6 +144,12 @@ #:escape-backslashes #:concat-separated-strings #:print-separated-strings + #:lex-string + #:split-alphanumeric-string + + ;; strmatch.lisp + #:score-multiword-match + #:multiword-match ;; symbols.lisp #:ensure-keyword diff --git a/sockets.lisp b/sockets.lisp index 259b7b0..f7c8408 100644 --- a/sockets.lisp +++ b/sockets.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg with excerpts from portableaserve ;;;; Date Started: Jun 2003 ;;;; -;;;; $Id: sockets.lisp,v 1.4 2003/07/11 06:58:32 kevin Exp $ +;;;; $Id: sockets.lisp,v 1.5 2003/07/21 00:52:56 kevin Exp $ ;;;; ************************************************************************* (in-package #:kmrcl) @@ -35,7 +35,7 @@ setsockopt SO_REUSEADDR if :reuse is not nil" (defun create-inet-listener (port &key (format :text) (reuse-address t)) #+cmu (ext:create-inet-listener port) #+allegro - (socket:make-socket :connect :passive :local-port port :format :binary + (socket:make-socket :connect :passive :local-port port :format format :address-family (if (stringp port) :file diff --git a/strings.lisp b/strings.lisp index 6ec3f5c..6b6d9df 100644 --- a/strings.lisp +++ b/strings.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: strings.lisp,v 1.49 2003/07/19 20:32:48 kevin Exp $ +;;;; $Id: strings.lisp,v 1.50 2003/07/21 00:52:56 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -551,13 +551,48 @@ for characters in a string" (defun shrink-vector (str size) #+allegro (excl::.primcall 'sys::shrink-svector str size) - #+sbcl - (sb-kernel:shrink-vector str size) #+cmu (lisp::shrink-vector str size) #+lispworks (system::shrink-vector$vector str size) - #+(or allegro cmu sbcl lispworks) - str - #-(or allegro cmu sbcl lispworks) - (subseq str 0 size)) + #+sbcl + (sb-kernel:shrink-vector str size) + #+scl + (common-lisp::shrink-vector str size) + #-(or allegro cmu lispworks sbcl scl) + (setq str (subseq str 0 size)) + str) + +(defun lex-string (string &key (whitespace '(#\space #\newline))) + "Separates a string at whitespace and returns a list of strings" + (flet ((whitespace? (char) (member char whitespace :test #'char=))) + (let ((tokens nil)) + (do* ((token-start + (position-if-not #'whitespace? string) + (when token-end + (position-if-not #'whitespace? string :start (1+ token-end)))) + (token-end + (when token-start + (position-if #'whitespace? string :start token-start)) + (when token-start + (position-if #'whitespace? string :start token-start)))) + ((null token-start) (nreverse tokens)) + (push (subseq string token-start token-end) tokens))))) + +(defun split-alphanumeric-string (string) + "Separates a string at any non-alphanumeric chararacter" + (flet ((whitespace? (char) (non-alphanumericp char))) + (let ((tokens nil)) + (do* ((token-start + (position-if-not #'whitespace? string) + (when token-end + (position-if-not #'whitespace? string :start (1+ token-end)))) + (token-end + (when token-start + (position-if #'whitespace? string :start token-start)) + (when token-start + (position-if #'whitespace? string :start token-start)))) + ((null token-start) (nreverse tokens)) + (push (subseq string token-start token-end) tokens))))) + + diff --git a/strmatch.lisp b/strmatch.lisp new file mode 100644 index 0000000..a56f3bf --- /dev/null +++ b/strmatch.lisp @@ -0,0 +1,74 @@ +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: kmrcl -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: strings.lisp +;;;; Purpose: Strings utility functions for KMRCL package +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Apr 2000 +;;;; +;;;; $Id: strmatch.lisp,v 1.1 2003/07/21 00:52:56 kevin Exp $ +;;;; +;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; +;;;; KMRCL users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* + +(in-package #:kmrcl) + + +(defun score-multiword-match (s1 s2) + "Score a match between two strings with s1 being reference string" + (let* ((word-list-1 (split-alphanumeric-string s1)) + (word-list-2 (split-alphanumeric-string s2)) + (n1 (length word-list-1)) + (n2 (length word-list-2)) + (unmatched n1) + (score 0) + (nlong 0) + (nshort 0) + short-list long-list) + (declare (fixnum n1 n2 nshort nlong score unmatched)) + (if (> n1 n2) + (progn + (setq nlong n1) + (setq nshort n2) + (setq long-list word-list-1) + (setq short-list word-list-2)) + (progn + (setq nlong n2) + (setq nshort n1) + (setq long-list word-list-2) + (setq short-list word-list-1))) + (decf score (* 3 (- nlong nshort))) ;; reduce score for extra words + (dotimes (iword nshort) + (declare (fixnum iword)) + (kmrcl:aif (position (nth iword short-list) long-list :test #'string-equal) + (progn + (incf score (- 20 (abs (- kmrcl::it iword)))) + (decf unmatched)))) + (decf score (* 5 unmatched)) + score)) + + +(defun multiword-match (s1 s2) + "Matches two multiword strings, ignores case, word position, punctuation" + (let* ((word-list-1 (split-alphanumeric-string s1)) + (word-list-2 (split-alphanumeric-string s2)) + (n1 (length word-list-1)) + (n2 (length word-list-2))) + (when (= n1 n2) + ;; remove each word from word-list-2 as walk word-list-1 + (dolist (w word-list-1) + (let ((p (position w word-list-2 :test #'string-equal))) + (unless p + (return-from multiword-match nil)) + (setf (nth p word-list-2) ""))) + t))) + + + + + -- 2.34.1 From cf4d25858f4969025835e23008818d94c6e23208 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 21 Jul 2003 08:41:44 +0000 Subject: [PATCH 06/16] r5358: *** empty log message *** --- kmrcl.asd | 6 +++--- sockets.lisp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kmrcl.asd b/kmrcl.asd index 73c004c..39596fe 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.41 2003/07/21 00:52:56 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.42 2003/07/21 08:41:19 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -51,9 +51,9 @@ (:file "equal" :depends-on ("macros" #+kmr-mop "mop")) (:file "web-utils" :depends-on ("macros" "strings")) (:file "xml-utils" :depends-on ("macros")) - (:file "sockets" :depends-on ("macros")) + (:file "sockets" :depends-on ("strings")) (:file "processes" :depends-on ("macros")) - (:file "listener" :depends-on ("sockets" "processes")) + (:file "listener" :depends-on ("sockets" "processes" "console")) (:file "repl" :depends-on ("listener" "strings")) )) diff --git a/sockets.lisp b/sockets.lisp index f7c8408..0ab5d94 100644 --- a/sockets.lisp +++ b/sockets.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg with excerpts from portableaserve ;;;; Date Started: Jun 2003 ;;;; -;;;; $Id: sockets.lisp,v 1.5 2003/07/21 00:52:56 kevin Exp $ +;;;; $Id: sockets.lisp,v 1.6 2003/07/21 08:41:19 kevin Exp $ ;;;; ************************************************************************* (in-package #:kmrcl) @@ -127,13 +127,13 @@ setsockopt SO_REUSEADDR if :reuse is not nil" "Convert from dotted string to 32-bit integer." (declare (string dotted)) (if errorp - (let ((ll (string-tokens (substitute #\Space #\. dotted)))) + (let ((ll (delimited-string-to-list dotted #\.))) (+ (ash (first ll) 24) (ash (second ll) 16) (ash (third ll) 8) (fourth ll))) (ignore-errors - (let ((ll (string-tokens (substitute #\Space #\. dotted)))) - (+ (ash (first ll) 24) (ash (second ll) 16) - (ash (third ll) 8) (fourth ll)))))) + (let ((ll (delimited-string-to-list dotted #\.))) + (+ (ash (first ll) 24) (ash (second ll) 16) + (ash (third ll) 8) (fourth ll)))))) #+sbcl (defun ipaddr-to-hostname (ipaddr &key ignore-cache) -- 2.34.1 From 5093ad6645375d1d9259097ea5c9122e5592be2f Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 23 Jul 2003 22:08:21 +0000 Subject: [PATCH 07/16] r5379: *** empty log message *** --- kmrcl.asd | 3 ++- os.lisp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.lisp | 5 ++++- strmatch.lisp | 58 ++++++++++++++++++++++++++---------------------- 4 files changed, 99 insertions(+), 28 deletions(-) create mode 100644 os.lisp diff --git a/kmrcl.asd b/kmrcl.asd index 39596fe..a14a6e3 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.42 2003/07/21 08:41:19 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.43 2003/07/23 22:07:48 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -55,6 +55,7 @@ (:file "processes" :depends-on ("macros")) (:file "listener" :depends-on ("sockets" "processes" "console")) (:file "repl" :depends-on ("listener" "strings")) + (:file "os" :depends-on ("macros")) )) diff --git a/os.lisp b/os.lisp new file mode 100644 index 0000000..f7e600f --- /dev/null +++ b/os.lisp @@ -0,0 +1,61 @@ +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: os.lisp +;;;; Purpose: Operating System utilities +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Jul 2003 +;;;; +;;;; $Id: os.lisp,v 1.1 2003/07/23 22:08:21 kevin Exp $ +;;;; +;;;; ************************************************************************* + +(in-package #:kmrcl) + +(defun run-shell-command (control-string &rest args) + "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and +synchronously execute the result using a Bourne-compatible shell, +returns (VALUES string-output exit-code)" + (let ((command (apply #'format nil control-string args))) + #+sbcl + (sb-impl::process-exit-code + (sb-ext:run-program + "/bin/sh" + (list "-c" command) + :input nil :output nil)) + + #+(or cmu scl) + (ext:process-exit-code + (ext:run-program + "/bin/sh" + (list "-c" command) + :input nil :output nil)) + + #+allegro + (multiple-value-bind (output dummy exit) + (excl:run-shell-command command :input nil :output :stream + :wait nil) + (declare (ignore dummy)) + (values output exit)) + + #+lispworks + (system:call-system-showing-output + command + :shell-type "/bin/sh" + :output-stream output) + + #+clisp ;XXX not exactly *verbose-out*, I know + (ext:run-shell-command command :output :terminal :wait t) + + #+openmcl + (nth-value 1 + (ccl:external-process-status + (ccl:run-program "/bin/sh" (list "-c" command) + :input nil :output nil + :wait t))) + + #-(or openmcl clisp lispworks allegro scl cmu sbcl) + (error "RUN-SHELL-PROGRAM not implemented for this Lisp") + + )) diff --git a/package.lisp b/package.lisp index 16b5ed0..735662a 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.53 2003/07/21 00:52:56 kevin Exp $ +;;;; $Id: package.lisp,v 1.54 2003/07/23 22:07:48 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -227,6 +227,9 @@ ;; fformat.lisp #:fformat + + ;; os.lisp + #:run-shell-command )) diff --git a/strmatch.lisp b/strmatch.lisp index a56f3bf..69d28e4 100644 --- a/strmatch.lisp +++ b/strmatch.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: strmatch.lisp,v 1.1 2003/07/21 00:52:56 kevin Exp $ +;;;; $Id: strmatch.lisp,v 1.2 2003/07/23 22:07:48 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -20,36 +20,42 @@ (defun score-multiword-match (s1 s2) - "Score a match between two strings with s1 being reference string" - (let* ((word-list-1 (split-alphanumeric-string s1)) + "Score a match between two strings with s1 being reference string. +S1 can be a string or a list or strings/conses" + (let* ((word-list-1 (if (stringp s1) + (split-alphanumeric-string s1) + s1)) (word-list-2 (split-alphanumeric-string s2)) (n1 (length word-list-1)) (n2 (length word-list-2)) (unmatched n1) - (score 0) - (nlong 0) - (nshort 0) - short-list long-list) - (declare (fixnum n1 n2 nshort nlong score unmatched)) - (if (> n1 n2) - (progn - (setq nlong n1) - (setq nshort n2) - (setq long-list word-list-1) - (setq short-list word-list-2)) - (progn - (setq nlong n2) - (setq nshort n1) - (setq long-list word-list-2) - (setq short-list word-list-1))) - (decf score (* 3 (- nlong nshort))) ;; reduce score for extra words - (dotimes (iword nshort) + (score 0)) + (declare (fixnum n1 n2 score unmatched)) + (decf score (* 4 (abs (- n1 n2)))) + (dotimes (iword n1) (declare (fixnum iword)) - (kmrcl:aif (position (nth iword short-list) long-list :test #'string-equal) - (progn - (incf score (- 20 (abs (- kmrcl::it iword)))) - (decf unmatched)))) - (decf score (* 5 unmatched)) + (let ((w1 (nth iword word-list-1)) + pos) + (cond + ((consp w1) + (let ((first t)) + (dotimes (i-alt (length w1)) + (setq pos + (position (nth i-alt w1) word-list-2 + :test #'string-equal)) + (when pos + (incf score (- 30 + (if first 0 5) + (abs (- iword pos)))) + (decf unmatched) + (return)) + (setq first nil)))) + ((stringp w1) + (kmrcl:awhen (position w1 word-list-2 + :test #'string-equal) + (incf score (- 30 (abs (- kmrcl::it iword)))) + (decf unmatched)))))) + (decf score (* 4 unmatched)) score)) -- 2.34.1 From d1918433c6b93fbc85153da62aa6e31fd06461fa Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 30 Jul 2003 17:32:26 +0000 Subject: [PATCH 08/16] r5406: *** empty log message *** --- io.lisp | 4 ++-- mop.lisp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/io.lisp b/io.lisp index 2d4f3da..1900204 100644 --- a/io.lisp +++ b/io.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: io.lisp,v 1.11 2003/07/14 04:10:02 kevin Exp $ +;;;; $Id: io.lisp,v 1.12 2003/07/30 17:32:26 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -171,4 +171,4 @@ (defun null-output-stream () (when (probe-file #p"/dev/null") - (open #p"/dev/null" :direction :output :if-exists :supersede))) + (open #p"/dev/null" :direction :output :if-exists :overwrite))) diff --git a/mop.lisp b/mop.lisp index a274f48..ff4d217 100644 --- a/mop.lisp +++ b/mop.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2003 ;;;; -;;;; $Id: mop.lisp,v 1.16 2003/06/25 20:11:54 kevin Exp $ +;;;; $Id: mop.lisp,v 1.17 2003/07/30 17:32:26 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -44,7 +44,9 @@ #+lispworks #:clos #+scl #:clos #+openmcl #:openmcl-mop - )) + ) + #+openmcl (:shadowing-import-from #:ccl #:ensure-generic-function) + ) (in-package #:kmr-mop) -- 2.34.1 From 8cba9d956327e3de1e53d5ca58f81da5d6255978 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 30 Jul 2003 19:04:41 +0000 Subject: [PATCH 09/16] r5407: *** empty log message *** --- mop.lisp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mop.lisp b/mop.lisp index ff4d217..cd7c477 100644 --- a/mop.lisp +++ b/mop.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2003 ;;;; -;;;; $Id: mop.lisp,v 1.17 2003/07/30 17:32:26 kevin Exp $ +;;;; $Id: mop.lisp,v 1.18 2003/07/30 19:04:41 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -45,7 +45,6 @@ #+scl #:clos #+openmcl #:openmcl-mop ) - #+openmcl (:shadowing-import-from #:ccl #:ensure-generic-function) ) (in-package #:kmr-mop) -- 2.34.1 From e83a72f1e88062d7e17ac77c17cc9c32d51f3c13 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 30 Jul 2003 22:31:14 +0000 Subject: [PATCH 10/16] r5408: *** empty log message *** --- io.lisp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/io.lisp b/io.lisp index 1900204..9c591c7 100644 --- a/io.lisp +++ b/io.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: io.lisp,v 1.12 2003/07/30 17:32:26 kevin Exp $ +;;;; $Id: io.lisp,v 1.13 2003/07/30 22:23:25 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -169,6 +169,23 @@ #-allegro (write-string (write-to-string n) s)) +#+openmcl +(defun open-device-stream (path direction) + (let* ((mode (ecase direction + (:input #$O_RDONLY) + (:output #$O_WRONLY) + (:io #$O_RDWR))) + (fd (ccl::fd-open (ccl::native-translated-namestring path) mode))) + (if (< fd 0) + (ccl::signal-file-error fd path) + (ccl::make-fd-stream fd :direction direction)))) + + (defun null-output-stream () + #-openmcl + (when (probe-file #p"/dev/null") + (open #p"/dev/null" :direction :output :if-exists :overwrite)) + #+openmcl (when (probe-file #p"/dev/null") - (open #p"/dev/null" :direction :output :if-exists :overwrite))) + (open-device-stream #p"/dev/null" :output)) + ) -- 2.34.1 From c711146209cf9fbda5fe2f11368c6c43949798f7 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 30 Jul 2003 23:01:46 +0000 Subject: [PATCH 11/16] r5410: *** empty log message *** --- io-openmcl.lisp | 12 ++++++++++++ io.lisp | 13 +------------ kmrcl.asd | 5 +++-- 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 io-openmcl.lisp diff --git a/io-openmcl.lisp b/io-openmcl.lisp new file mode 100644 index 0000000..a42e98c --- /dev/null +++ b/io-openmcl.lisp @@ -0,0 +1,12 @@ +(in-package #:kmrcl) + +(defun open-device-stream (path direction) + (let* ((mode (ecase direction + (:input #$O_RDONLY) + (:output #$O_WRONLY) + (:io #$O_RDWR))) + (fd (ccl::fd-open (ccl::native-translated-namestring path) mode))) + (if (< fd 0) + (ccl::signal-file-error fd path) + (ccl::make-fd-stream fd :direction direction)))) + diff --git a/io.lisp b/io.lisp index 9c591c7..4134bd6 100644 --- a/io.lisp +++ b/io.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: io.lisp,v 1.13 2003/07/30 22:23:25 kevin Exp $ +;;;; $Id: io.lisp,v 1.14 2003/07/30 23:01:46 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -169,17 +169,6 @@ #-allegro (write-string (write-to-string n) s)) -#+openmcl -(defun open-device-stream (path direction) - (let* ((mode (ecase direction - (:input #$O_RDONLY) - (:output #$O_WRONLY) - (:io #$O_RDWR))) - (fd (ccl::fd-open (ccl::native-translated-namestring path) mode))) - (if (< fd 0) - (ccl::signal-file-error fd path) - (ccl::make-fd-stream fd :direction direction)))) - (defun null-output-stream () #-openmcl diff --git a/kmrcl.asd b/kmrcl.asd index a14a6e3..e62e5c9 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.43 2003/07/23 22:07:48 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.44 2003/07/30 23:01:46 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -37,7 +37,8 @@ (:file "functions" :depends-on ("macros")) (:file "lists" :depends-on ("macros")) (:file "seqs" :depends-on ("macros")) - (:file "io" :depends-on ("macros")) + (:file "io-openmcl" :depends-on ("macros")) + (:file "io" :depends-on ("macros" "io-openmcl")) (:file "console" :depends-on ("macros")) (:file "strings" :depends-on ("macros" "seqs")) (:file "strmatch" :depends-on ("strings")) -- 2.34.1 From 34af279a4b46f1543749915c1897438ea917be73 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 30 Jul 2003 23:02:53 +0000 Subject: [PATCH 12/16] r5411: *** empty log message *** --- kmrcl.asd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kmrcl.asd b/kmrcl.asd index e62e5c9..fcb7638 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.44 2003/07/30 23:01:46 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.45 2003/07/30 23:02:53 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -37,8 +37,8 @@ (:file "functions" :depends-on ("macros")) (:file "lists" :depends-on ("macros")) (:file "seqs" :depends-on ("macros")) - (:file "io-openmcl" :depends-on ("macros")) - (:file "io" :depends-on ("macros" "io-openmcl")) + #+openmcl (:file "io-openmcl" :depends-on ("macros")) + (:file "io" :depends-on ("macros" #+openmcl "io-openmcl")) (:file "console" :depends-on ("macros")) (:file "strings" :depends-on ("macros" "seqs")) (:file "strmatch" :depends-on ("strings")) -- 2.34.1 From 042a035d9708f98f43b41ac07171ee0570658c8b Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 31 Jul 2003 07:36:55 +0000 Subject: [PATCH 13/16] r5417: *** empty log message *** --- lists.lisp | 13 ++++++++++--- package.lisp | 3 ++- tests.lisp | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lists.lisp b/lists.lisp index 285bb39..77b6fa5 100644 --- a/lists.lisp +++ b/lists.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: lists.lisp,v 1.8 2003/07/05 02:32:08 kevin Exp $ +;;;; $Id: lists.lisp,v 1.9 2003/07/31 07:32:11 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -22,13 +22,20 @@ "Make into list if atom" (if (listp obj) obj (list obj))) -(defun filter (fn lst) - "Filter a list by function, eliminate elements where fn returns nil" +(defun map-and-remove-nils (fn lst) + "mao a list by function, eliminate elements where fn returns nil" (let ((acc nil)) (dolist (x lst (nreverse acc)) (let ((val (funcall fn x))) (when val (push val acc)))))) +(defun filter (fn lst) + "Filter a list by function, eliminate elements where fn returns nil" + (let ((acc nil)) + (dolist (x lst (nreverse acc)) + (when (funcall fn x) + (push x acc))))) + (defun appendnew (l1 l2) "Append two lists, filtering out elem from second list that are already in first list" (dolist (elem l2 l1) diff --git a/package.lisp b/package.lisp index 735662a..961bcb7 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.54 2003/07/23 22:07:48 kevin Exp $ +;;;; $Id: package.lisp,v 1.55 2003/07/31 07:32:11 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -25,6 +25,7 @@ #:ensure-integer #:mklist #:filter + #:map-and-remove-nils #:appendnew #:memo-proc #:memoize diff --git a/tests.lisp b/tests.lisp index c917615..dc5053f 100644 --- a/tests.lisp +++ b/tests.lisp @@ -7,7 +7,7 @@ ;;;; Author: Kevin M. Rosenberg ;;;; Date Started: Apr 2003 ;;;; -;;;; $Id: tests.lisp,v 1.22 2003/07/16 16:01:37 kevin Exp $ +;;;; $Id: tests.lisp,v 1.23 2003/07/31 07:36:55 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -102,8 +102,10 @@ (deftest css.4 (concat-separated-strings "|" '("ab" "cd") nil) "ab|cd") (deftest css.5 (concat-separated-strings "|" '("ab" "cd") nil '("ef")) "ab|cd|ef") -(deftest f.1 (filter #'(lambda (x) (when (oddp x) (* x x))) +(deftest f.1 (map-and-remove-nils #'(lambda (x) (when (oddp x) (* x x))) '(0 1 2 3 4 5 6 7 8 9)) (1 9 25 49 81)) +(deftest f.2 (filter #'(lambda (x) (when (oddp x) (* x x))) + '(0 1 2 3 4 5 6 7 8 9)) (1 3 5 7 9)) (deftest an.1 (appendnew '(a b c d) '(c c e f)) (a b c d e f)) -- 2.34.1 From f02806a9c747318814e3b46520d2ceebd6031488 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 31 Jul 2003 17:03:37 +0000 Subject: [PATCH 14/16] r5419: *** empty log message *** --- io-openmcl.lisp | 12 ------------ io.lisp | 14 +++++++++++++- kmrcl.asd | 5 ++--- 3 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 io-openmcl.lisp diff --git a/io-openmcl.lisp b/io-openmcl.lisp deleted file mode 100644 index a42e98c..0000000 --- a/io-openmcl.lisp +++ /dev/null @@ -1,12 +0,0 @@ -(in-package #:kmrcl) - -(defun open-device-stream (path direction) - (let* ((mode (ecase direction - (:input #$O_RDONLY) - (:output #$O_WRONLY) - (:io #$O_RDWR))) - (fd (ccl::fd-open (ccl::native-translated-namestring path) mode))) - (if (< fd 0) - (ccl::signal-file-error fd path) - (ccl::make-fd-stream fd :direction direction)))) - diff --git a/io.lisp b/io.lisp index 4134bd6..47fc178 100644 --- a/io.lisp +++ b/io.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: io.lisp,v 1.14 2003/07/30 23:01:46 kevin Exp $ +;;;; $Id: io.lisp,v 1.15 2003/07/31 17:03:37 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -170,6 +170,18 @@ +#+openmcl +(defun open-device-stream (path direction) + (let* ((mode (ecase direction + (:input #.(read-from-string "#$O_RDONLY")) + (:output #.(read-from-string "#$O_WRONLY")) + (:io #.(read-from-string "#$O_RDWR")))) + (fd (ccl::fd-open (ccl::native-translated-namestring path) mode))) + (if (< fd 0) + (ccl::signal-file-error fd path) + (ccl::make-fd-stream fd :direction direction)))) + + (defun null-output-stream () #-openmcl (when (probe-file #p"/dev/null") diff --git a/kmrcl.asd b/kmrcl.asd index fcb7638..06ff082 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.45 2003/07/30 23:02:53 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.46 2003/07/31 17:03:37 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -37,8 +37,7 @@ (:file "functions" :depends-on ("macros")) (:file "lists" :depends-on ("macros")) (:file "seqs" :depends-on ("macros")) - #+openmcl (:file "io-openmcl" :depends-on ("macros")) - (:file "io" :depends-on ("macros" #+openmcl "io-openmcl")) + (:file "io" :depends-on ("macros")) (:file "console" :depends-on ("macros")) (:file "strings" :depends-on ("macros" "seqs")) (:file "strmatch" :depends-on ("strings")) -- 2.34.1 From 20b7cbdc3324352b14760ffc86babad71c2fbf0e Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 31 Jul 2003 17:11:44 +0000 Subject: [PATCH 15/16] r5420: *** empty log message *** --- kmrcl.asd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kmrcl.asd b/kmrcl.asd index 06ff082..1c9801f 100644 --- a/kmrcl.asd +++ b/kmrcl.asd @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: kmrcl.asd,v 1.46 2003/07/31 17:03:37 kevin Exp $ +;;;; $Id: kmrcl.asd,v 1.47 2003/07/31 17:11:44 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -58,7 +58,6 @@ (:file "os" :depends-on ("macros")) )) - (defmethod perform ((o test-op) (c (eql (find-system 'kmrcl)))) (operate 'load-op 'kmrcl-tests) (operate 'test-op 'kmrcl-tests)) -- 2.34.1 From 38e70cafb37a90b112ffca9f7939416e0ea00804 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sat, 2 Aug 2003 22:10:55 +0000 Subject: [PATCH 16/16] r5441: Auto commit for Debian build --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 4ab1bc8..509a0be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-kmrcl (1.55-1) unstable; urgency=low + + * New upstream: byte-vector.lisp + + -- Kevin M. Rosenberg Sat, 2 Aug 2003 16:10:43 -0600 + cl-kmrcl (1.54-1) unstable; urgency=low * listener and repl improvements -- 2.34.1