1 | ;;; chars.lisp |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 2003-2004 Peter Graves |
---|
4 | ;;; $Id: chars.lisp,v 1.14 2004-09-27 13:57:28 piso Exp $ |
---|
5 | ;;; |
---|
6 | ;;; This program is free software; you can redistribute it and/or |
---|
7 | ;;; modify it under the terms of the GNU General Public License |
---|
8 | ;;; as published by the Free Software Foundation; either version 2 |
---|
9 | ;;; of the License, or (at your option) any later version. |
---|
10 | ;;; |
---|
11 | ;;; This program is distributed in the hope that it will be useful, |
---|
12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | ;;; GNU General Public License for more details. |
---|
15 | ;;; |
---|
16 | ;;; You should have received a copy of the GNU General Public License |
---|
17 | ;;; along with this program; if not, write to the Free Software |
---|
18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | (in-package #:system) |
---|
21 | |
---|
22 | ;;; From CMUCL. |
---|
23 | |
---|
24 | (defun char/= (character &rest more-characters) |
---|
25 | (do* ((head character (car list)) |
---|
26 | (list more-characters (cdr list))) |
---|
27 | ((atom list) T) |
---|
28 | (unless (do* ((l list (cdr l))) ;inner loop returns T |
---|
29 | ((atom l) T) ; iff head /= rest. |
---|
30 | (if (eql head (car l)) (return nil))) |
---|
31 | (return nil)))) |
---|
32 | |
---|
33 | (defun char< (character &rest more-characters) |
---|
34 | (do* ((c character (car list)) |
---|
35 | (list more-characters (cdr list))) |
---|
36 | ((atom list) T) |
---|
37 | (unless (< (char-int c) |
---|
38 | (char-int (car list))) |
---|
39 | (return nil)))) |
---|
40 | |
---|
41 | (defun char> (character &rest more-characters) |
---|
42 | (do* ((c character (car list)) |
---|
43 | (list more-characters (cdr list))) |
---|
44 | ((atom list) T) |
---|
45 | (unless (> (char-int c) |
---|
46 | (char-int (car list))) |
---|
47 | (return nil)))) |
---|
48 | |
---|
49 | (defun char>= (character &rest more-characters) |
---|
50 | (do* ((c character (car list)) |
---|
51 | (list more-characters (cdr list))) |
---|
52 | ((atom list) T) |
---|
53 | (unless (>= (char-int c) |
---|
54 | (char-int (car list))) |
---|
55 | (return nil)))) |
---|
56 | |
---|
57 | (defmacro equal-char-code (character) |
---|
58 | `(let ((ch (char-code ,character))) |
---|
59 | (if (< 96 ch 123) (- ch 32) ch))) |
---|
60 | |
---|
61 | (defun char-not-equal (character &rest more-characters) |
---|
62 | (do* ((head character (car list)) |
---|
63 | (list more-characters (cdr list))) |
---|
64 | ((atom list) T) |
---|
65 | (unless (do* ((l list (cdr l))) |
---|
66 | ((atom l) T) |
---|
67 | (if (= (equal-char-code head) |
---|
68 | (equal-char-code (car l))) |
---|
69 | (return nil))) |
---|
70 | (return nil)))) |
---|