1 | ;;; chars.lisp |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 2003-2004 Peter Graves |
---|
4 | ;;; $Id: chars.lisp,v 1.13 2004-04-23 00:51:39 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 alphanumericp (char) |
---|
25 | (or (digit-char-p char) (alpha-char-p char))) |
---|
26 | |
---|
27 | (defun char/= (character &rest more-characters) |
---|
28 | (do* ((head character (car list)) |
---|
29 | (list more-characters (cdr list))) |
---|
30 | ((atom list) T) |
---|
31 | (unless (do* ((l list (cdr l))) ;inner loop returns T |
---|
32 | ((atom l) T) ; iff head /= rest. |
---|
33 | (if (eql head (car l)) (return nil))) |
---|
34 | (return nil)))) |
---|
35 | |
---|
36 | (defun char< (character &rest more-characters) |
---|
37 | (do* ((c character (car list)) |
---|
38 | (list more-characters (cdr list))) |
---|
39 | ((atom list) T) |
---|
40 | (unless (< (char-int c) |
---|
41 | (char-int (car list))) |
---|
42 | (return nil)))) |
---|
43 | |
---|
44 | (defun char> (character &rest more-characters) |
---|
45 | (do* ((c character (car list)) |
---|
46 | (list more-characters (cdr list))) |
---|
47 | ((atom list) T) |
---|
48 | (unless (> (char-int c) |
---|
49 | (char-int (car list))) |
---|
50 | (return nil)))) |
---|
51 | |
---|
52 | (defun char>= (character &rest more-characters) |
---|
53 | (do* ((c character (car list)) |
---|
54 | (list more-characters (cdr list))) |
---|
55 | ((atom list) T) |
---|
56 | (unless (>= (char-int c) |
---|
57 | (char-int (car list))) |
---|
58 | (return nil)))) |
---|
59 | |
---|
60 | (defmacro equal-char-code (character) |
---|
61 | `(let ((ch (char-code ,character))) |
---|
62 | (if (< 96 ch 123) (- ch 32) ch))) |
---|
63 | |
---|
64 | (defun char-not-equal (character &rest more-characters) |
---|
65 | (do* ((head character (car list)) |
---|
66 | (list more-characters (cdr list))) |
---|
67 | ((atom list) T) |
---|
68 | (unless (do* ((l list (cdr l))) |
---|
69 | ((atom l) T) |
---|
70 | (if (= (equal-char-code head) |
---|
71 | (equal-char-code (car l))) |
---|
72 | (return nil))) |
---|
73 | (return nil)))) |
---|
74 | |
---|
75 | (eval-when (:execute) |
---|
76 | (when (and (fboundp 'jvm::jvm-compile) (not (autoloadp 'jvm::jvm-compile))) |
---|
77 | (mapcar #'jvm::jvm-compile '(alphanumericp |
---|
78 | char/= |
---|
79 | char< |
---|
80 | char> |
---|
81 | char>= |
---|
82 | char-not-equal)))) |
---|