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:
parent
b05c1e1111
commit
ca815af077
15 changed files with 84 additions and 27 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -10,8 +10,14 @@
|
|||
.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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
/* We must slice the block found. Cut off space from the upper
|
||||
* end, so we can leave the actual free block chain intact.
|
||||
*/
|
||||
|
||||
/* 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;
|
||||
}
|
||||
/* 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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue