15dfecf96Smrg;; 25dfecf96Smrg;; Copyright (c) 2001 by The XFree86 Project, Inc. 35dfecf96Smrg;; 45dfecf96Smrg;; Permission is hereby granted, free of charge, to any person obtaining a 55dfecf96Smrg;; copy of this software and associated documentation files (the "Software"), 65dfecf96Smrg;; to deal in the Software without restriction, including without limitation 75dfecf96Smrg;; the rights to use, copy, modify, merge, publish, distribute, sublicense, 85dfecf96Smrg;; and/or sell copies of the Software, and to permit persons to whom the 95dfecf96Smrg;; Software is furnished to do so, subject to the following conditions: 105dfecf96Smrg;; 115dfecf96Smrg;; The above copyright notice and this permission notice shall be included in 125dfecf96Smrg;; all copies or substantial portions of the Software. 135dfecf96Smrg;; 145dfecf96Smrg;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 155dfecf96Smrg;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 165dfecf96Smrg;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 175dfecf96Smrg;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 185dfecf96Smrg;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 195dfecf96Smrg;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 205dfecf96Smrg;; SOFTWARE. 215dfecf96Smrg;; 225dfecf96Smrg;; Except as contained in this notice, the name of the XFree86 Project shall 235dfecf96Smrg;; not be used in advertising or otherwise to promote the sale, use or other 245dfecf96Smrg;; dealings in this Software without prior written authorization from the 255dfecf96Smrg;; XFree86 Project. 265dfecf96Smrg;; 275dfecf96Smrg;; Author: Paulo César Pereira de Andrade 285dfecf96Smrg;; 295dfecf96Smrg;; 305dfecf96Smrg;; $XFree86: xc/programs/xedit/lisp/modules/lisp.lsp,v 1.9 2002/12/04 05:28:01 paulo Exp $ 315dfecf96Smrg;; 325dfecf96Smrg(provide "lisp") 335dfecf96Smrg 345dfecf96Smrg(in-package "LISP") 355dfecf96Smrg 365dfecf96Smrg(export '( 375dfecf96Smrg second third fourth fifth sixth seventh eighth ninth tenth 385dfecf96Smrg pathname merge-pathnames 395dfecf96Smrg logtest signum 405dfecf96Smrg alphanumericp copy-seq push pop prog prog* 415dfecf96Smrg with-open-file with-output-to-string 425dfecf96Smrg)) 435dfecf96Smrg 445dfecf96Smrg(defun second (a) (nth 1 a)) 455dfecf96Smrg(defun third (a) (nth 2 a)) 465dfecf96Smrg(defun fourth (a) (nth 3 a)) 475dfecf96Smrg(defun fifth (a) (nth 4 a)) 485dfecf96Smrg(defun sixth (a) (nth 5 a)) 495dfecf96Smrg(defun seventh (a) (nth 6 a)) 505dfecf96Smrg(defun eighth (a) (nth 7 a)) 515dfecf96Smrg(defun ninth (a) (nth 8 a)) 525dfecf96Smrg(defun tenth (a) (nth 9 a)) 535dfecf96Smrg 545dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 555dfecf96Smrg;; pathnames 565dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 575dfecf96Smrg(defun pathname (filename) 585dfecf96Smrg (values (parse-namestring filename))) 595dfecf96Smrg 605dfecf96Smrg(defun merge-pathnames (pathname &optional defaults default-version) 615dfecf96Smrg (if (null default-version) 625dfecf96Smrg (parse-namestring pathname nil defaults) 635dfecf96Smrg (parse-namestring pathname nil 645dfecf96Smrg (make-pathname :defaults defaults :version default-version)))) 655dfecf96Smrg 665dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 675dfecf96Smrg;; math 685dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 695dfecf96Smrg(defun logtest (integer1 integer2) 705dfecf96Smrg (not (zerop (logand integer1 integer2)))) 715dfecf96Smrg 725dfecf96Smrg(defun signum (number) 735dfecf96Smrg (if (zerop number) number (/ number (abs number)))) 745dfecf96Smrg 755dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 765dfecf96Smrg;; misc functions/macros 775dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 785dfecf96Smrg(defun alphanumericp (char) 795dfecf96Smrg (or (alpha-char-p char) (not (null (digit-char-p char))))) 805dfecf96Smrg 815dfecf96Smrg(defun copy-seq (sequence) 825dfecf96Smrg (subseq sequence 0)) 835dfecf96Smrg 845dfecf96Smrg(defmacro prog (init &rest body) 855dfecf96Smrg `(block nil (let ,init (tagbody ,@body)))) 865dfecf96Smrg 875dfecf96Smrg(defmacro prog* (init &rest body) 885dfecf96Smrg `(block nil (let* ,init (tagbody ,@body)))) 895dfecf96Smrg 905dfecf96Smrg(defmacro with-open-file (file &rest body) 915dfecf96Smrg `(let ((,(car file) (open ,@(cdr file)))) 925dfecf96Smrg (unwind-protect 935dfecf96Smrg (progn ,@body) 945dfecf96Smrg (if ,(car file) (close ,(car file)))))) 955dfecf96Smrg 965dfecf96Smrg(defmacro with-output-to-string (stream &rest body) 975dfecf96Smrg `(let ((,(car stream) (make-string-output-stream))) 985dfecf96Smrg (unwind-protect 995dfecf96Smrg (progn ,@body (get-output-stream-string ,(car stream))) 1005dfecf96Smrg (and ,(car stream) (close ,(car stream)))))) 1015dfecf96Smrg 1025dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1035dfecf96Smrg;; setf 1045dfecf96Smrg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1055dfecf96Smrg(defsetf car (list) (value) `(progn (rplaca ,list ,value) ,value)) 1065dfecf96Smrg(defsetf cdr (list) (value) `(progn (rplacd ,list ,value) ,value)) 1075dfecf96Smrg 1085dfecf96Smrg(defsetf caar (list) (value) `(progn (rplaca (car ,list) ,value) ,value)) 1095dfecf96Smrg(defsetf cadr (list) (value) `(progn (rplaca (cdr ,list) ,value) ,value)) 1105dfecf96Smrg(defsetf cdar (list) (value) `(progn (rplacd (car ,list) ,value) ,value)) 1115dfecf96Smrg(defsetf cddr (list) (value) `(progn (rplacd (cdr ,list) ,value) ,value)) 1125dfecf96Smrg(defsetf caaar (list) (value) `(progn (rplaca (caar ,list) ,value) ,value)) 1135dfecf96Smrg(defsetf caadr (list) (value) `(progn (rplaca (cadr ,list) ,value) ,value)) 1145dfecf96Smrg(defsetf cadar (list) (value) `(progn (rplaca (cdar ,list) ,value) ,value)) 1155dfecf96Smrg(defsetf caddr (list) (value) `(progn (rplaca (cddr ,list) ,value) ,value)) 1165dfecf96Smrg(defsetf cdaar (list) (value) `(progn (rplacd (caar ,list) ,value) ,value)) 1175dfecf96Smrg(defsetf cdadr (list) (value) `(progn (rplacd (cadr ,list) ,value) ,value)) 1185dfecf96Smrg(defsetf cddar (list) (value) `(progn (rplacd (cdar ,list) ,value) ,value)) 1195dfecf96Smrg(defsetf cdddr (list) (value) `(progn (rplacd (cddr ,list) ,value) ,value)) 1205dfecf96Smrg(defsetf caaaar (list) (value) `(progn (rplaca (caaar ,list) ,value) ,value)) 1215dfecf96Smrg(defsetf caaadr (list) (value) `(progn (rplaca (caadr ,list) ,value) ,value)) 1225dfecf96Smrg(defsetf caadar (list) (value) `(progn (rplaca (cadar ,list) ,value) ,value)) 1235dfecf96Smrg(defsetf caaddr (list) (value) `(progn (rplaca (caddr ,list) ,value) ,value)) 1245dfecf96Smrg(defsetf cadaar (list) (value) `(progn (rplaca (cdaar ,list) ,value) ,value)) 1255dfecf96Smrg(defsetf cadadr (list) (value) `(progn (rplaca (cdadr ,list) ,value) ,value)) 1265dfecf96Smrg(defsetf caddar (list) (value) `(progn (rplaca (cddar ,list) ,value) ,value)) 1275dfecf96Smrg(defsetf cadddr (list) (value) `(progn (rplaca (cdddr ,list) ,value) ,value)) 1285dfecf96Smrg(defsetf cdaaar (list) (value) `(progn (rplacd (caaar ,list) ,value) ,value)) 1295dfecf96Smrg(defsetf cdaadr (list) (value) `(progn (rplacd (caadr ,list) ,value) ,value)) 1305dfecf96Smrg(defsetf cdadar (list) (value) `(progn (rplacd (cadar ,list) ,value) ,value)) 1315dfecf96Smrg(defsetf cdaddr (list) (value) `(progn (rplacd (caddr ,list) ,value) ,value)) 1325dfecf96Smrg(defsetf cddaar (list) (value) `(progn (rplacd (cdaar ,list) ,value) ,value)) 1335dfecf96Smrg(defsetf cddadr (list) (value) `(progn (rplacd (cdadr ,list) ,value) ,value)) 1345dfecf96Smrg(defsetf cdddar (list) (value) `(progn (rplacd (cddar ,list) ,value) ,value)) 1355dfecf96Smrg(defsetf cddddr (list) (value) `(progn (rplacd (cdddr ,list) ,value) ,value)) 1365dfecf96Smrg 1375dfecf96Smrg(defsetf first (list) (value) `(progn (rplaca ,list ,value) ,value)) 1385dfecf96Smrg(defsetf second (list) (value) `(progn (rplaca (nthcdr 1 ,list) ,value) ,value)) 1395dfecf96Smrg(defsetf third (list) (value) `(progn (rplaca (nthcdr 2 ,list) ,value) ,value)) 1405dfecf96Smrg(defsetf fourth (list) (value) `(progn (rplaca (nthcdr 3 ,list) ,value) ,value)) 1415dfecf96Smrg(defsetf fifth (list) (value) `(progn (rplaca (nthcdr 4 ,list) ,value) ,value)) 1425dfecf96Smrg(defsetf sixth (list) (value) `(progn (rplaca (nthcdr 5 ,list) ,value) ,value)) 1435dfecf96Smrg(defsetf seventh (list) (value) `(progn (rplaca (nthcdr 6 ,list) ,value) ,value)) 1445dfecf96Smrg(defsetf eighth (list) (value) `(progn (rplaca (nthcdr 7 ,list) ,value) ,value)) 1455dfecf96Smrg(defsetf ninth (list) (value) `(progn (rplaca (nthcdr 8 ,list) ,value) ,value)) 1465dfecf96Smrg(defsetf tenth (list) (value) `(progn (rplaca (nthcdr 9 ,list) ,value) ,value)) 1475dfecf96Smrg 1485dfecf96Smrg(defsetf rest (list) (value) `(progn (rplacd ,list ,value) ,value)) 1495dfecf96Smrg 1505dfecf96Smrg(defun lisp::nth-store (index list value) 1515dfecf96Smrg (rplaca (nthcdr index list) value) value) 1525dfecf96Smrg(defsetf nth lisp::nth-store) 1535dfecf96Smrg 1545dfecf96Smrg(defsetf aref (array &rest indices) (value) 1555dfecf96Smrg `(lisp::vector-store ,array ,@indices ,value)) 1565dfecf96Smrg 1575dfecf96Smrg(defsetf get (symbol key &optional default) (value) 1585dfecf96Smrg `(lisp::put ,symbol ,key ,value)) 1595dfecf96Smrg 1605dfecf96Smrg(defsetf symbol-plist lisp::set-symbol-plist) 1615dfecf96Smrg 1625dfecf96Smrg(defsetf gethash (key hash-table &optional default) (value) 1635dfecf96Smrg `(lisp::puthash ,key ,hash-table ,value)) 1645dfecf96Smrg 1655dfecf96Smrg(defsetf char lisp::char-store) 1665dfecf96Smrg(defsetf schar lisp::char-store) 1675dfecf96Smrg(defsetf elt lisp::elt-store) 1685dfecf96Smrg(defsetf svref lisp::elt-store) 1695dfecf96Smrg(defsetf documentation lisp::documentation-store) 1705dfecf96Smrg 1715dfecf96Smrg(defsetf symbol-value set) 1725dfecf96Smrg 1735dfecf96Smrg(defsetf subseq (sequence start &optional end) (value) 1745dfecf96Smrg `(progn (replace ,sequence ,value :start1 ,start :end1 ,end) ,value)) 175