duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit d429218cdf7dd37d4f4a2343930d0f982cc821aa
parent ce8e90f11401763c696763653ce371d80108c6a3
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Thu, 12 Jan 2023 16:20:56 -0500

sys/io: fix broken MemIO :readbuf

Diffstat:
Mfs/sys/io.fs | 3++-
Mfs/tests/sys/io.fs | 8++++++--
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/sys/io.fs b/fs/sys/io.fs @@ -61,7 +61,8 @@ extends IO struct[ SumIO extends IO struct[ MemIO sfield ptr - : _readbuf ( n hdl -- a? read-n ) ptr swap ; + : _readbuf ( n hdl -- a? read-n ) >r \ V1=self + dup if r@ ptr swap dup to+ r> ptr else rdrop then ; : _writebuf ( a n hdl -- written-n ) dup >r ptr ( src n dst ) over >r swap move r> dup r> ( written-n written-n hdl ) to+ ptr ; diff --git a/fs/tests/sys/io.fs b/fs/tests/sys/io.fs @@ -1,12 +1,16 @@ ?f<< /tests/harness.fs testbegin \ Tests for sys/io +\ MemIO create mymem ," hello there!" mymem MemIO :new structbind MemIO memio here 12 memio :read mymem here 12 []= # mymem to memio ptr -S" foobar" dup memio :puts ( s ) +S" foobar\n" dup memio :puts ( s ) c@+ ( a len ) mymem rot> []= # -mymem 6 + memio ptr #eq +mymem 7 + memio ptr #eq +mymem to memio ptr +memio :readline S" foobar" #s= + testend