Fixes to the code just written
git-svn-id: svn://svn.cc65.org/cc65/trunk@2276 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
; Ullrich von Bassewitz, 2003-08-12
|
; Ullrich von Bassewitz, 2003-08-12
|
||||||
;
|
;
|
||||||
; Place to store the current working directory.
|
; Place to store the current working directory.
|
||||||
;
|
; NOTE: Some of the code working with directories is not able to handle
|
||||||
|
; strings longer than 255 chars, so don't make __cwd_buf_size larger than 256
|
||||||
|
; without checking the other sources.
|
||||||
|
|
||||||
.export __cwd
|
.export __cwd
|
||||||
.export __cwd_buf_size
|
.export __cwd_buf_size
|
||||||
|
|||||||
@@ -37,17 +37,18 @@ loop: inc ptr2
|
|||||||
inc ptr2+1
|
inc ptr2+1
|
||||||
beq overflow
|
beq overflow
|
||||||
|
|
||||||
; Copy one character, end the loop if the zero terminator is reached
|
; Copy one character, end the loop if the zero terminator is reached. We
|
||||||
|
; don't support directories longer than 255 characters for now.
|
||||||
|
|
||||||
@L1: lda __cwd,y
|
@L1: lda __cwd,y
|
||||||
sta (ptr1),y
|
sta (ptr1),y
|
||||||
|
beq done
|
||||||
|
iny
|
||||||
bne loop
|
bne loop
|
||||||
|
|
||||||
; Current working dir copied ok, A contains zero
|
; For some reason the cwd is longer than 255 characters. This should not
|
||||||
|
; happen, we handle it as if the passed buffer was too short.
|
||||||
tax ; Return zero in a/x
|
;
|
||||||
rts
|
|
||||||
|
|
||||||
; String overflow, return ERANGE
|
; String overflow, return ERANGE
|
||||||
|
|
||||||
overflow:
|
overflow:
|
||||||
@@ -55,8 +56,13 @@ overflow:
|
|||||||
sta __errno
|
sta __errno
|
||||||
lda #>ERANGE
|
lda #>ERANGE
|
||||||
sta __errno+1
|
sta __errno+1
|
||||||
lda #$FF
|
tax ; High byte of ERANGE is zero, return zero
|
||||||
tax ; Return -1
|
rts
|
||||||
|
|
||||||
|
; Success, return buf
|
||||||
|
|
||||||
|
done: lda ptr1
|
||||||
|
ldx ptr1+1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|||||||
Reference in New Issue
Block a user