]> git.sur5r.net Git - cc65/commitdiff
iscntrl was not mentioned in the Makefile and therefor not built.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 8 Jun 2000 18:35:04 +0000 (18:35 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 8 Jun 2000 18:35:04 +0000 (18:35 +0000)
Change the isxxx functions to correctly handle values outside of character
range.

git-svn-id: svn://svn.cc65.org/cc65/trunk@33 b7a2c559-68d2-44c3-8de9-860c34a00d81

15 files changed:
libsrc/common/Makefile
libsrc/common/_hadd.c
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
libsrc/common/malloc.c

index 2bbeede0ba9388439dfc39e1ed380213f3db3911..fe1f6edbbf937a941ccb8b3b5a7a4823a454b342 100644 (file)
@@ -28,7 +28,7 @@ S_OBJS = isalpha.o isdigit.o _file.o fmisc.o strlower.o strchr.o tolower.o\
         longjmp.o rand.o atexit.o memset.o memcpy.o memchr.o memcmp.o\
         ltoa.o strcspn.o strncat.o strpbrk.o strspn.o abs.o labs.o jmpvec.o\
         _fdesc.o stkcheck.o zerobss.o copydata.o _swap.o strstr.o strcoll.o\
-        _sys.o getcpu.o _oserror.o strerror.o
+        _sys.o getcpu.o _oserror.o strerror.o iscntrl.o
 
 all:   $(C_OBJS) $(S_OBJS)
 
index 190875d642e295c6d606a04fa5d20aa689eb0079..c257ffcdf18aee8d05071e8e4bd2aed8cc49affc 100644 (file)
@@ -58,7 +58,7 @@ void _hadd (void* mem, size_t size)
             */
            if (right) {
                /* Check if we must merge the block with the right one */
-               if (((int) f) + size == (int) right) {
+                       if (((unsigned) f) + size == (unsigned) right) {
                    /* Merge with the right block */
                    f->size += right->size;
                    if (f->next = right->next) {
@@ -79,7 +79,7 @@ void _hadd (void* mem, size_t size)
            }
            if (left) {
                /* Check if we must merge the block with the left one */
-               if ((int) f == ((int) left) + left->size) {
+               if ((unsigned) f == ((unsigned) left) + left->size) {
                    /* Merge with the left block */
                    left->size += f->size;
                    if (left->next = f->next) {
@@ -104,3 +104,4 @@ void _hadd (void* mem, size_t size)
 
 
 
+                                             
index e8654ad9fbd0c26e4722d2de8360359ff4a28c32..8c29964edd673781214ccfe280b079b21360af1c 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _isalnum:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
        and     #$07            ; Mask character/digit bits
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index 420d6b3dc0fd1fe3fbee489081167a9a48b6b4ef..d0fcf97b2a58b9326088299ed51792a37976510d 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _isalpha:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
        and     #$03            ; Mask character bits
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index f3564ec637a6296c16597997cd5adf0ee2ba2ee9..5568a547db812eba164beef6d1d650ed06c66e37 100644 (file)
        .import         __ctype
 
 _isblank:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
                and     #$80            ; Mask blank bit
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index 6d29cb586a9ae55bb31929e74b1dbaf6dad79fc2..55307bd5a6b156f7d89e620af271b06adaa0d754 100644 (file)
@@ -8,9 +8,14 @@
        .import         __ctype
 
 _iscntrl:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
        and     #$10            ; Mask control character bit
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
 
index d8cc6d52214785c9d13d9df2983aa6f15bf423c4..b0608ba7208277c3b95d7c5932260323d9fa74ec 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _isdigit:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
        and     #$04            ; Mask digit bit
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index 91f482c5664d4fe91cc4c594d513cd729fab4e4a..e2073aea2274b641babb487589503c812872ff75 100644 (file)
@@ -8,9 +8,15 @@
        .import         __ctype
 
 _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
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index 565f0f85333386aa6393259e5b48943abb1f27cf..c8b131600d3d32c9557096f1fe50f8d811a6e074 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _islower:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
        and     #$01            ; Mask lower char bit
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index e82e6131274ae0851d6b2e4ed8492393d285f63d..37657df92c4782ab1b755b5b60caf20b9558a8ce 100644 (file)
@@ -8,9 +8,15 @@
        .import         __ctype
 
 _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
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index 71664f0d8616efcf4a49338da7c1b88174dbc5f1..c2d6c2338c9fa0704fa5bbd3016160a0f78b8d36 100644 (file)
@@ -8,9 +8,15 @@
        .import         __ctype
 
 _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
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index 1c6cc2e8a6aa763217177d71b8591c8c743c1b75..62be7d59eca544d8ab76ed3ca55e1ab106e30346 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _isspace:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
                and     #$60            ; Mask space bits
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index bb5ad07a2873f4e88f8ca588369059a5298cba69..0eb4915c639d9781e53a7f8fb3556c56060954db 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _isupper:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
        and     #$02            ; Mask upper char bit
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index a3184d17beb3731426389b8f90942efdbfb3a373..91b041ca701c0a7c1fb1a4ba9e9b54ba09f39488 100644 (file)
@@ -8,8 +8,14 @@
        .import         __ctype
 
 _isxdigit:
+       cpx     #$00            ; Char range ok?
+       bne     @L1             ; Jump if no
        tay
        lda     __ctype,y       ; Get character classification
                and     #$08            ; Mask xdigit bit
        rts
 
+@L1:   lda     #$00            ; Return false
+       tax
+       rts
+
index d7722d595bb8d1f80a9748f4101fe20a5e407f47..ca4044c47c8b0d9cd4516c1778b09e0c5c807861 100644 (file)
@@ -69,34 +69,19 @@ void* malloc (size_t size)
 
         } else {
 
-            /* We must slice the block found */
-            struct freeblock* newblock;
-                   newblock = (struct freeblock*) ((unsigned) f) + size;
-
-            /* Insert the new block (the remaining space) instead of the
-             * old one.
-             */
-            newblock->size = f->size - size;         /* Remaining size */
-            newblock->next = f->next;
-            newblock->prev = f->prev;
-            if (f->prev) {
-                /* We have a previous block */
-                f->prev->next = newblock;
-            } else {
-                /* This is the first block, correct the freelist pointer */
-                _hfirst = newblock;
-            }
-            if (f->next) {
-                /* We have a next block */
-                f->next->prev = newblock;
-            } else {
-                /* This is the last block, correct the freelist pointer */
-                _hlast = newblock;
-            }
+            /* We must slice the block found. Cut off space from the upper
+            * end, so we can leave the actual free block chain intact.
+            */
+
+           /* Decrement the size of the block */
+           f->size -= size;
+
+           /* Set f to the now unused space above the current block */
+           f = (struct freeblock*) (((unsigned) f) + f->size);
 
         }
 
-        /* Setup the pointer for the bock */
+        /* Setup the pointer for the block */
         p = (unsigned*) f;
 
     } else {