mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Fixed isgraph() and ispunct() (macroes and library functions).
This commit is contained in:
parent
42494c6323
commit
b225adaf03
@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2009, Ullrich von Bassewitz */
|
/* (C) 1998-2013, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@ -40,14 +40,14 @@
|
|||||||
/* The array containing character classification data */
|
/* The array containing character classification data */
|
||||||
extern unsigned char _ctype[256];
|
extern unsigned char _ctype[256];
|
||||||
|
|
||||||
/* Bits used to specify characters classes */
|
/* Bits used to specify character classes */
|
||||||
#define _CT_LOWER 0x01 /* 0 - Lower case char */
|
#define _CT_LOWER 0x01 /* 0 - Lower case char */
|
||||||
#define _CT_UPPER 0x02 /* 1 - Upper case char */
|
#define _CT_UPPER 0x02 /* 1 - Upper case char */
|
||||||
#define _CT_DIGIT 0x04 /* 2 - Numeric digit */
|
#define _CT_DIGIT 0x04 /* 2 - Numeric digit */
|
||||||
#define _CT_XDIGIT 0x08 /* 3 - Hex digit (both, lower and upper) */
|
#define _CT_XDIGIT 0x08 /* 3 - Hex digit (both lower and upper) */
|
||||||
#define _CT_CNTRL 0x10 /* 4 - Control character */
|
#define _CT_CNTRL 0x10 /* 4 - Control character */
|
||||||
#define _CT_SPACE 0x20 /* 5 - The space character itself */
|
#define _CT_SPACE 0x20 /* 5 - The space character itself */
|
||||||
#define _CT_OTHER_WS 0x40 /* 6 - Other whitespace ('\f', '\n', '\r', '\t' and '\v') */
|
#define _CT_OTHER_WS 0x40 /* 6 - Other whitespace ('\f', '\n', '\r', '\t', and '\v') */
|
||||||
#define _CT_SPACE_TAB 0x80 /* 7 - Space or tab character */
|
#define _CT_SPACE_TAB 0x80 /* 7 - Space or tab character */
|
||||||
|
|
||||||
/* Bit combinations */
|
/* Bit combinations */
|
||||||
@ -79,17 +79,17 @@ int __fastcall__ tolower (int c); /* Always external */
|
|||||||
|
|
||||||
#if __CC65_STD__ >= __CC65_STD_CC65__
|
#if __CC65_STD__ >= __CC65_STD_CC65__
|
||||||
unsigned char __fastcall__ toascii (unsigned char c);
|
unsigned char __fastcall__ toascii (unsigned char c);
|
||||||
/* Convert a target specific character to ascii */
|
/* Convert a target-specific character to ASCII. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* When inlining of known function is enabled, overload most of the above
|
/* When inlining-of-known-functions is enabled, overload most of the above
|
||||||
* functions by macros. The function prototypes are again available after
|
* functions by macroes. The function prototypes are available again after
|
||||||
* #undef'ing the macros.
|
* #undef'ing the macroes.
|
||||||
* Please note that the following macros do NOT handle EOF correctly, as
|
* Please note that the following macroes do NOT handle EOF correctly, as
|
||||||
* stated in the manual. If you need correct behaviour for EOF, don't
|
* stated in the manual. If you need correct behaviour for EOF, don't
|
||||||
* use -Os, or #undefine the following macros.
|
* use -Os, or #undefine the following macroes.
|
||||||
*/
|
*/
|
||||||
#ifdef __OPT_s__
|
#ifdef __OPT_s__
|
||||||
|
|
||||||
@ -128,8 +128,10 @@ unsigned char __fastcall__ toascii (unsigned char c);
|
|||||||
#define isgraph(c) (__AX__ = (c), \
|
#define isgraph(c) (__AX__ = (c), \
|
||||||
__asm__ ("tay"), \
|
__asm__ ("tay"), \
|
||||||
__asm__ ("lda %v,y", _ctype), \
|
__asm__ ("lda %v,y", _ctype), \
|
||||||
__asm__ ("eor #%b", _CT_NOT_GRAPH), \
|
__asm__ ("and #%b", _CT_NOT_GRAPH), \
|
||||||
__asm__ ("and #%b", _CT_NOT_GRAPH), \
|
__asm__ ("cmp #1"), \
|
||||||
|
__asm__ ("lda #1"), \
|
||||||
|
__asm__ ("sbc #1"), \
|
||||||
__AX__)
|
__AX__)
|
||||||
|
|
||||||
#define islower(c) (__AX__ = (c), \
|
#define islower(c) (__AX__ = (c), \
|
||||||
@ -141,15 +143,17 @@ unsigned char __fastcall__ toascii (unsigned char c);
|
|||||||
#define isprint(c) (__AX__ = (c), \
|
#define isprint(c) (__AX__ = (c), \
|
||||||
__asm__ ("tay"), \
|
__asm__ ("tay"), \
|
||||||
__asm__ ("lda %v,y", _ctype), \
|
__asm__ ("lda %v,y", _ctype), \
|
||||||
__asm__ ("eor #%b", _CT_NOT_PRINT), \
|
|
||||||
__asm__ ("and #%b", _CT_NOT_PRINT), \
|
__asm__ ("and #%b", _CT_NOT_PRINT), \
|
||||||
|
__asm__ ("eor #%b", _CT_NOT_PRINT), \
|
||||||
__AX__)
|
__AX__)
|
||||||
|
|
||||||
#define ispunct(c) (__AX__ = (c), \
|
#define ispunct(c) (__AX__ = (c), \
|
||||||
__asm__ ("tay"), \
|
__asm__ ("tay"), \
|
||||||
__asm__ ("lda %v,y", _ctype), \
|
__asm__ ("lda %v,y", _ctype), \
|
||||||
__asm__ ("eor #%b", _CT_NOT_PUNCT), \
|
|
||||||
__asm__ ("and #%b", _CT_NOT_PUNCT), \
|
__asm__ ("and #%b", _CT_NOT_PUNCT), \
|
||||||
|
__asm__ ("cmp #1"), \
|
||||||
|
__asm__ ("lda #1"), \
|
||||||
|
__asm__ ("sbc #1"), \
|
||||||
__AX__)
|
__AX__)
|
||||||
|
|
||||||
#define isspace(c) (__AX__ = (c), \
|
#define isspace(c) (__AX__ = (c), \
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 02.06.1998
|
; 1998-06-02, Ullrich von Bassewitz
|
||||||
|
; 2013-05-01, Greg King
|
||||||
;
|
;
|
||||||
; int isgraph (int c);
|
; int isgraph (int c);
|
||||||
;
|
;
|
||||||
@ -8,15 +9,17 @@
|
|||||||
.include "ctype.inc"
|
.include "ctype.inc"
|
||||||
|
|
||||||
_isgraph:
|
_isgraph:
|
||||||
cpx #$00 ; Char range ok?
|
cpx #>0 ; Char range OK?
|
||||||
bne @L1 ; Jump if no
|
bne @L1 ; Jump if no
|
||||||
tay
|
tay
|
||||||
lda __ctype,y ; Get character classification
|
lda __ctype,y ; Get character classification
|
||||||
eor #CT_CTRL_SPACE ; NOT control and NOT space
|
and #CT_CTRL_SPACE ; Mask character bits
|
||||||
and #CT_CTRL_SPACE ; Mask character bits
|
cmp #1 ; If false, then set "borrow" flag
|
||||||
rts
|
lda #0
|
||||||
|
sbc #0 ; Invert logic
|
||||||
|
rts ; Return NOT control and NOT space
|
||||||
|
|
||||||
@L1: lda #$00 ; Return false
|
@L1: lda #<0 ; Return false
|
||||||
tax
|
tax
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 02.06.1998
|
; 1998-06-02, Ullrich von Bassewitz
|
||||||
|
; 2013-05-01, Greg King
|
||||||
;
|
;
|
||||||
; int ispunct (int c);
|
; int ispunct (int c);
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _ispunct
|
.export _ispunct
|
||||||
.include "ctype.inc"
|
.include "ctype.inc"
|
||||||
|
|
||||||
_ispunct:
|
_ispunct:
|
||||||
cpx #$00 ; Char range ok?
|
cpx #>0 ; Char range OK?
|
||||||
bne @L1 ; Jump if no
|
bne @L1 ; Jump if no
|
||||||
tay
|
tay
|
||||||
lda __ctype,y ; Get character classification
|
lda __ctype,y ; Get character classification
|
||||||
eor #CT_NOT_PUNCT ; NOT (space | control | digit | alpha)
|
and #CT_NOT_PUNCT ; Mask relevant bits
|
||||||
and #CT_NOT_PUNCT ; Mask relevant bits
|
cmp #1 ; If false, then set "borrow" flag
|
||||||
rts
|
lda #0
|
||||||
|
sbc #0 ; Invert logic
|
||||||
|
rts ; Return NOT (space | control | digit | alpha)
|
||||||
|
|
||||||
@L1: lda #$00 ; Return false
|
@L1: lda #<0 ; Return false
|
||||||
tax
|
tax
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user