mirror of
https://github.com/nineties/planckforth
synced 2024-12-26 21:58:42 +01:00
Fixed bugs of flush-file
This commit is contained in:
parent
7ee972882b
commit
ad5197f603
1 changed files with 9 additions and 10 deletions
19
bootstrap.fs
19
bootstrap.fs
|
@ -1511,7 +1511,7 @@ end-struct file%
|
|||
|
||||
: empty-write-buffer ( file -- )
|
||||
dup file>wbuf @ over file>wbeg !
|
||||
dup file>wbuf @ BUFSIZE + over file>wend !
|
||||
dup file>wbuf @ over file>wend !
|
||||
drop
|
||||
;
|
||||
|
||||
|
@ -1551,17 +1551,16 @@ end-struct file%
|
|||
\ Flush output buffer of file, return error-code.
|
||||
: flush-file ( file -- e )
|
||||
dup writable? unless FLUSH-FILE-ERROR exit then
|
||||
begin
|
||||
( file )
|
||||
dup write-buffer-content ( file buf u )
|
||||
dup 0= if 3drop success exit then
|
||||
2 pick file>fd @ 3 pick file>write @ execute
|
||||
( file n )
|
||||
begin
|
||||
( file buf u )
|
||||
dup 0= if 2drop empty-write-buffer success exit then
|
||||
2dup 4 pick file>fd @ 5 pick file>write @ execute
|
||||
( file buf u n )
|
||||
dup 0< if 2drop FLUSH-FILE-ERROR exit then
|
||||
over write-buffer-content
|
||||
( file n u )
|
||||
over > if not-reachable then
|
||||
over swap succ-write-buffer
|
||||
( file buf u n )
|
||||
2dup < if not-reachable then
|
||||
succ-write-buffer
|
||||
again
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in a new issue