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)
*/
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) {
}
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) {
+
.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
+
.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
+
.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
+
.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
.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
+
.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
+
.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
+
.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
+
.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
+
.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
+
.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
+
.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
+
} 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 {