Allow 'b' to come before '+' in freopen modes (e.g. "wb+").

Previously, only forms like "w+b" worked.
This commit is contained in:
Stephen Heumann 2020-01-30 21:16:48 -06:00
parent c77c5927d9
commit 27a32d82bd

View File

@ -1110,6 +1110,13 @@ nl1 cmp #'b'
lda #BIN lda #BIN
sta crFileType sta crFileType
iny iny
cpy #2
bne nl2
lda [type],Y
and #$00FF
cmp #'+'
bne nl2
iny
nl2 lda fileType check for 'x' in type string nl2 lda fileType check for 'x' in type string
cmp #'r' cmp #'r'
beq nl3 beq nl3
@ -1160,7 +1167,7 @@ ar1 ph4 #BUFSIZ get space for the file buffer
bne ar3 bne ar3
lda #ENOMEM memory error lda #ENOMEM memory error
sta >errno sta >errno
bra rt1 brl rt1
ar3 move4 stream,fileBuff set the file buffer address ar3 move4 stream,fileBuff set the file buffer address
lda buffStart set the start of the buffer lda buffStart set the start of the buffer
@ -1185,10 +1192,12 @@ ar3 move4 stream,fileBuff set the file buffer address
sta [fileBuff],Y sta [fileBuff],Y
ldy #1 set the flags ldy #1 set the flags
lda [type],Y lda [type],Y
cmp #'+b'
beq ar3a
and #$00FF and #$00FF
cmp #'+' cmp #'+'
bne ar4 bne ar4
lda #_IOFBF+_IORW+_IOMYBUF ar3a lda #_IOFBF+_IORW+_IOMYBUF
bra ar6 bra ar6
ar4 lda fileType ar4 lda fileType
cmp #'r' cmp #'r'