]> git.sur5r.net Git - cc65/blob - include/ctype.h
Use && and || in preprocessor #if statements. Other minor changes.
[cc65] / include / ctype.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  ctype.h                                  */
4 /*                                                                           */
5 /*                            Character handling                             */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2000 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _CTYPE_H
37 #define _CTYPE_H
38
39
40
41 int __fastcall__ isalnum (int c);
42 int __fastcall__ isalpha (int c);
43 int __fastcall__ iscntrl (int c);
44 int __fastcall__ isdigit (int c);
45 int __fastcall__ isgraph (int c);
46 int __fastcall__ islower (int c);
47 int __fastcall__ isprint (int c);
48 int __fastcall__ ispunct (int c);
49 int __fastcall__ isspace (int c);
50 int __fastcall__ isupper (int c);
51 int __fastcall__ isxdigit (int c);
52 #ifndef __STRICT_ANSI__
53 int __fastcall__ isblank (int c);       /* cc65 (and GNU) extension */
54 #endif
55
56 int __fastcall__ toupper (int c);       /* Always external */
57 int __fastcall__ tolower (int c);       /* Always external */
58
59
60
61 /* When inlining of known function is enabled, overload most of the above
62  * functions by macros. The function prototypes are again available after
63  * #undef'ing the macros.
64 */
65 #ifdef __OPT_s__
66
67
68 extern unsigned char _ctype[256];
69
70 #define isalnum(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$07"), __AX__)
71 #define isalpha(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$03"), __AX__)
72 #define isblank(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$80"), __AX__)
73 #define iscntrl(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$10"), __AX__)
74 #define isdigit(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$04"), __AX__)
75 #define isgraph(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n eor #$30\n and #$30"), __AX__)
76 #define islower(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$01"), __AX__)
77 #define isprint(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n eor #$10\n and #$10"), __AX__)
78 #define ispunct(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n eor #$37\n and #$37"), __AX__)
79 #define isspace(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$60"), __AX__)
80 #define isupper(c)  (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$02"), __AX__)
81 #define isxdigit(c) (__AX__ = (c), __asm__ ("tay\n lda __ctype,y\n and #$08"), __AX__)
82
83
84
85 #endif
86
87
88
89 /* End of ctype.h */
90 #endif
91
92
93