-
Notifications
You must be signed in to change notification settings - Fork 1
/
character.c
40 lines (32 loc) · 1.65 KB
/
character.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* -*- coding: utf-8 -*-
character.c --- defines character handling mechanism of ISLisp processor KISS.
Copyright (C) 2017, 2018, 2019 Yuji Minejima <yuji@minejima.jp>
This file is part of ISLisp processor KISS.
KISS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KISS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "kiss.h"
/* function: (characterp obj) -> boolean
Returns t if OBJ is a character (instance of class <character>);
otherwise, returns nil. OBJ may be any ISLISP object. */
inline kiss_obj* kiss_characterp (const kiss_obj* const obj) {
return KISS_IS_CHARACTER(obj) ? KISS_T : KISS_NIL;
}
/* function: (char= char1 char2) → boolean
tests whether char1 is the same character as char2.
If the test is satisfied, t is returned; otherwise, nil is returned.
An error shall be signaled if either char1 or char2 is not a character
(error-id. domain-error). */
inline kiss_obj* kiss_char_eq(const kiss_obj* const character1, const kiss_obj* const character2) {
return Kiss_Character(character1) == Kiss_Character(character2) ? KISS_T : KISS_NIL;
}
inline kiss_obj* kiss_char_lessthan(const kiss_obj* const character1, const kiss_obj* const character2)
{
return Kiss_Character(character1) < Kiss_Character(character2) ? KISS_T : KISS_NIL;
}