]> git.sur5r.net Git - cc65/commitdiff
Use constants for the bits in the _ctype array.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 8 Sep 2001 14:00:41 +0000 (14:00 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 8 Sep 2001 14:00:41 +0000 (14:00 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@865 b7a2c559-68d2-44c3-8de9-860c34a00d81

13 files changed:
libsrc/common/ctype.inc [new file with mode: 0644]
libsrc/common/isalnum.s
libsrc/common/isalpha.s
libsrc/common/isblank.s
libsrc/common/iscntrl.s
libsrc/common/isdigit.s
libsrc/common/isgraph.s
libsrc/common/islower.s
libsrc/common/isprint.s
libsrc/common/ispunct.s
libsrc/common/isspace.s
libsrc/common/isupper.s
libsrc/common/isxdigit.s

diff --git a/libsrc/common/ctype.inc b/libsrc/common/ctype.inc
new file mode 100644 (file)
index 0000000..e8a41da
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Definitions for the character type tables
+;
+; Ullrich von Bassewitz, 08.09.2001
+;
+
+; Make the __ctype table an exported/imported symbol
+
+        .global           __ctype
+
+; Define bitmapped constants for the table entries
+
+CT_LOWER       = $01           ; 0 - Lower case char
+CT_UPPER       = $02           ; 1 - Upper case char
+CT_DIGIT       = $04           ; 2 - Numeric digit
+CT_XDIGIT      = $08           ; 3 - Hex digit (both, lower and upper)
+CT_CTRL                = $10           ; 4 - Control character
+CT_SPACE       = $20           ; 5 - The space character itself
+CT_OTHER_WS    = $40           ; 6 - Other whitespace ('\f', '\n', '\r', '\t' and '\v')
+CT_SPACE_TAB   = $80           ; 7 - Space or tab character
+
+; Combined stuff
+CT_ALNUM       = (CT_LOWER | CT_UPPER | CT_DIGIT)
+CT_ALPHA       = (CT_LOWER | CT_UPPER)
+CT_CTRL_SPACE  = (CT_CTRL | CT_SPACE)
+CT_NOT_PUNCT   = (CT_SPACE | CT_CTRL | CT_DIGIT | CT_UPPER | CT_LOWER)
+
+
index 8c29964edd673781214ccfe280b079b21360af1c..26fd7a24c83a6c2c5eeae2511d0bc7776af6f802 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _isalnum
-       .import         __ctype
+       .include        "ctype.inc"
 
 _isalnum:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       and     #$07            ; Mask character/digit bits
+       and     #CT_ALNUM       ; Mask character/digit bits
        rts
 
 @L1:   lda     #$00            ; Return false
index d0fcf97b2a58b9326088299ed51792a37976510d..624dec682ae5e61faa29e12610c70b4d5c18965b 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _isalpha
-       .import         __ctype
+       .include        "ctype.inc"
 
 _isalpha:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       and     #$03            ; Mask character bits
+               and     #CT_ALPHA       ; Mask character bits
        rts
 
 @L1:   lda     #$00            ; Return false
index 5568a547db812eba164beef6d1d650ed06c66e37..6da645a92c55a8a18d8c3c64016e4fc13387490d 100644 (file)
@@ -7,14 +7,14 @@
 ;
 
        .export         _isblank
-       .import         __ctype
+       .include        "ctype.inc"
 
 _isblank:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-               and     #$80            ; Mask blank bit
+               and     #CT_SPACE_TAB   ; Mask blank bit
        rts
 
 @L1:   lda     #$00            ; Return false
index 55307bd5a6b156f7d89e620af271b06adaa0d754..d94fddc272d92700eb323b742b5f00986818d347 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _iscntrl
-       .import         __ctype
+       .include        "ctype.inc"
 
 _iscntrl:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       and     #$10            ; Mask control character bit
+               and     #CT_CTRL        ; Mask control character bit
        rts
 
 @L1:   lda     #$00            ; Return false
index b0608ba7208277c3b95d7c5932260323d9fa74ec..339fef61f9308f39b24bd7ad45e702d84d316d2c 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _isdigit
-       .import         __ctype
+               .include        "ctype.inc"
 
 _isdigit:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       and     #$04            ; Mask digit bit
+               and     #CT_DIGIT       ; Mask digit bit
        rts
 
 @L1:   lda     #$00            ; Return false
index e2073aea2274b641babb487589503c812872ff75..e52ae34858a5b43b0c48ade9fa57bf1ced1ed09f 100644 (file)
@@ -5,15 +5,15 @@
 ;
 
        .export         _isgraph
-       .import         __ctype
+       .include        "ctype.inc"
 
 _isgraph:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       eor     #$30            ; NOT control and NOT space
-       and     #$30            ; Mask character bits
+               eor     #CT_CTRL_SPACE  ; NOT control and NOT space
+       and     #CT_CTRL_SPACE  ; Mask character bits
        rts
 
 @L1:   lda     #$00            ; Return false
index c8b131600d3d32c9557096f1fe50f8d811a6e074..0078366b8213395b02dc33d3ec32623193499e8d 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _islower
-       .import         __ctype
+               .include        "ctype.inc"
 
 _islower:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       and     #$01            ; Mask lower char bit
+               and     #CT_LOWER       ; Mask lower char bit
        rts
 
 @L1:   lda     #$00            ; Return false
index 37657df92c4782ab1b755b5b60caf20b9558a8ce..956b54b887dfdfed19410265c9956aa0a2d559da 100644 (file)
@@ -5,15 +5,15 @@
 ;
 
        .export         _isprint
-       .import         __ctype
+               .include        "ctype.inc"
 
 _isprint:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       eor     #$10            ; NOT a control char
-               and     #$10            ; Mask control char bit
+               eor     #CT_CTRL        ; NOT a control char
+               and     #CT_CTRL        ; Mask control char bit
        rts
 
 @L1:   lda     #$00            ; Return false
index c2d6c2338c9fa0704fa5bbd3016160a0f78b8d36..380cf38ccc2dedbe3cdd84f454f9db91923283c8 100644 (file)
@@ -5,15 +5,15 @@
 ;
 
        .export         _ispunct
-       .import         __ctype
+               .include        "ctype.inc"
 
 _ispunct:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-               eor     #$37            ; NOT (space | control | digit | char)
-               and     #$37            ; Mask relevant bits
+               eor     #CT_NOT_PUNCT   ; NOT (space | control | digit | alpha)
+               and     #CT_NOT_PUNCT   ; Mask relevant bits
        rts
 
 @L1:   lda     #$00            ; Return false
index 62be7d59eca544d8ab76ed3ca55e1ab106e30346..67530c95e388c773f92f5fb5a93749dec28ffdcd 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _isspace
-       .import         __ctype
+               .include        "ctype.inc"
 
 _isspace:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-               and     #$60            ; Mask space bits
+               and     #(CT_SPACE | CT_OTHER_WS)   ; Mask space bits
        rts
 
 @L1:   lda     #$00            ; Return false
index 0eb4915c639d9781e53a7f8fb3556c56060954db..b9d53a61470bee6de5b2a6c7bf465dc89be3433e 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _isupper
-       .import         __ctype
+               .include        "ctype.inc"
 
 _isupper:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-       and     #$02            ; Mask upper char bit
+       and     #CT_UPPER       ; Mask upper char bit
        rts
 
 @L1:   lda     #$00            ; Return false
index 91b041ca701c0a7c1fb1a4ba9e9b54ba09f39488..50146e82e366caf56982c9e231d3c3e5e24cd42b 100644 (file)
@@ -5,14 +5,14 @@
 ;
 
        .export         _isxdigit
-       .import         __ctype
+       .include        "ctype.inc"
 
 _isxdigit:
        cpx     #$00            ; Char range ok?
        bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
-               and     #$08            ; Mask xdigit bit
+               and     #CT_XDIGIT      ; Mask xdigit bit
        rts
 
 @L1:   lda     #$00            ; Return false