lseek: Return EINVAL if new position is less than 0 or greater than 2^24 - 1.
Also, implemented @greg-king5's suggestion to save a byte on error paths.
This commit is contained in:
committed by
Oliver Schmidt
parent
59a4ab8778
commit
b37d0a444c
@@ -22,6 +22,7 @@ _lseek:
|
|||||||
jsr popptr1
|
jsr popptr1
|
||||||
jsr popax
|
jsr popax
|
||||||
sta ptr2
|
sta ptr2
|
||||||
|
stx ptr2+1
|
||||||
|
|
||||||
; Get and process fd
|
; Get and process fd
|
||||||
jsr popax
|
jsr popax
|
||||||
@@ -78,6 +79,9 @@ seek_common:
|
|||||||
tya
|
tya
|
||||||
adc ptr2
|
adc ptr2
|
||||||
sta mliparam + MLI::MARK::POSITION+2
|
sta mliparam + MLI::MARK::POSITION+2
|
||||||
|
lda #$00
|
||||||
|
adc ptr2+1
|
||||||
|
bne einval ; less than 0 or greater than 2^24 - 1
|
||||||
|
|
||||||
; Set file pointer
|
; Set file pointer
|
||||||
lda #SET_MARK_CALL
|
lda #SET_MARK_CALL
|
||||||
@@ -103,13 +107,13 @@ seek_common:
|
|||||||
einval: lda #EINVAL
|
einval: lda #EINVAL
|
||||||
|
|
||||||
; Set __errno
|
; Set __errno
|
||||||
errno: ldx #$FF
|
errno: jsr __directerrno ; leaves -1 in AX
|
||||||
stx sreg
|
stx sreg ; extend return value to 32 bits
|
||||||
stx sreg+1
|
stx sreg+1
|
||||||
jmp __directerrno
|
rts
|
||||||
|
|
||||||
; Set __oserror
|
; Set __oserror
|
||||||
oserr: ldx #$FF
|
oserr: jsr __mappederrno ; leaves -1 in AX
|
||||||
stx sreg
|
stx sreg ; extend return value to 32 bits
|
||||||
stx sreg+1
|
stx sreg+1
|
||||||
jmp __mappederrno
|
rts
|
||||||
|
|||||||
Reference in New Issue
Block a user