1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

iscntrl was not mentioned in the Makefile and therefor not built.

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
This commit is contained in:
cuz 2000-06-08 18:35:04 +00:00
parent b05c1e1111
commit ca815af077
15 changed files with 84 additions and 27 deletions

View 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\ 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\ 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\ _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) all: $(C_OBJS) $(S_OBJS)

View File

@ -58,7 +58,7 @@ void _hadd (void* mem, size_t size)
*/ */
if (right) { if (right) {
/* Check if we must merge the block with the right one */ /* 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 */ /* Merge with the right block */
f->size += right->size; f->size += right->size;
if (f->next = right->next) { if (f->next = right->next) {
@ -79,7 +79,7 @@ void _hadd (void* mem, size_t size)
} }
if (left) { if (left) {
/* Check if we must merge the block with the left one */ /* 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 */ /* Merge with the left block */
left->size += f->size; left->size += f->size;
if (left->next = f->next) { if (left->next = f->next) {
@ -104,3 +104,4 @@ void _hadd (void* mem, size_t size)

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_isalnum: _isalnum:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$07 ; Mask character/digit bits and #$07 ; Mask character/digit bits
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_isalpha: _isalpha:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$03 ; Mask character bits and #$03 ; Mask character bits
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -10,8 +10,14 @@
.import __ctype .import __ctype
_isblank: _isblank:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$80 ; Mask blank bit and #$80 ; Mask blank bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,9 +8,14 @@
.import __ctype .import __ctype
_iscntrl: _iscntrl:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$10 ; Mask control character bit and #$10 ; Mask control character bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_isdigit: _isdigit:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$04 ; Mask digit bit and #$04 ; Mask digit bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,9 +8,15 @@
.import __ctype .import __ctype
_isgraph: _isgraph:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
eor #$30 ; NOT control and NOT space eor #$30 ; NOT control and NOT space
and #$30 ; Mask character bits and #$30 ; Mask character bits
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_islower: _islower:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$01 ; Mask lower char bit and #$01 ; Mask lower char bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,9 +8,15 @@
.import __ctype .import __ctype
_isprint: _isprint:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
eor #$10 ; NOT a control char eor #$10 ; NOT a control char
and #$10 ; Mask control char bit and #$10 ; Mask control char bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,9 +8,15 @@
.import __ctype .import __ctype
_ispunct: _ispunct:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
eor #$37 ; NOT (space | control | digit | char) eor #$37 ; NOT (space | control | digit | char)
and #$37 ; Mask relevant bits and #$37 ; Mask relevant bits
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_isspace: _isspace:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$60 ; Mask space bits and #$60 ; Mask space bits
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_isupper: _isupper:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$02 ; Mask upper char bit and #$02 ; Mask upper char bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -8,8 +8,14 @@
.import __ctype .import __ctype
_isxdigit: _isxdigit:
cpx #$00 ; Char range ok?
bne @L1 ; Jump if no
tay tay
lda __ctype,y ; Get character classification lda __ctype,y ; Get character classification
and #$08 ; Mask xdigit bit and #$08 ; Mask xdigit bit
rts rts
@L1: lda #$00 ; Return false
tax
rts

View File

@ -69,34 +69,19 @@ void* malloc (size_t size)
} else { } else {
/* We must slice the block found */ /* We must slice the block found. Cut off space from the upper
struct freeblock* newblock; * end, so we can leave the actual free block chain intact.
newblock = (struct freeblock*) ((unsigned) f) + size; */
/* Insert the new block (the remaining space) instead of the /* Decrement the size of the block */
* old one. f->size -= size;
*/
newblock->size = f->size - size; /* Remaining size */ /* Set f to the now unused space above the current block */
newblock->next = f->next; f = (struct freeblock*) (((unsigned) f) + f->size);
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;
}
} }
/* Setup the pointer for the bock */ /* Setup the pointer for the block */
p = (unsigned*) f; p = (unsigned*) f;
} else { } else {