mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2025-04-13 07:37:09 +00:00
Clear the IO error indicator as part of rewind().
The C standards require it to do this, in addition to calling fseek. Here is a test that can show the issue (in a realistic program, the indicator would be set due to an actual IO error, but for testing purposes this just sets it explicitly): #include <stdio.h> int main(void) { FILE *f = tmpfile(); if (!f) return 0; f->_flag |= _IOERR; if (!ferror(f)) puts("bad ferror"); rewind(f); if (ferror(f)) puts("rewind does not reset ferror"); fclose(f); }
This commit is contained in:
parent
997e430562
commit
ab2f17c249
21
stdio.asm
21
stdio.asm
@ -2473,31 +2473,34 @@ cpNewPathName ds 4
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* int rewind(stream)
|
||||
* void rewind(stream)
|
||||
* FILE *stream;
|
||||
*
|
||||
* Change the read/write location for the stream.
|
||||
* Rewind the read/write location for the stream.
|
||||
*
|
||||
* Inputs:
|
||||
* stream - file to change
|
||||
*
|
||||
* Outputs:
|
||||
* Returns non-zero for error
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
rewind start
|
||||
err equ 1 return code
|
||||
csubroutine (4:stream),0
|
||||
|
||||
csubroutine (4:stream),2
|
||||
ph4 stream verify that stream exists
|
||||
jsl ~VerifyStream
|
||||
bcs ret
|
||||
|
||||
ph2 #SEEK_SET
|
||||
ph4 #0
|
||||
ph4 stream
|
||||
jsl __fseek
|
||||
sta err
|
||||
|
||||
ldy #FILE_flag clear the error flag
|
||||
lda [stream],Y
|
||||
and #$FFFF-_IOERR
|
||||
sta [stream],Y
|
||||
|
||||
creturn 2:err
|
||||
ret creturn
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user