mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 14:49:18 +02:00
Handling streams separately in file-position since fseek doesn't
return the same value as lseek. Fixes issue #220.
This commit is contained in:
parent
719af372f9
commit
72a9782c80
2 changed files with 13 additions and 0 deletions
|
@ -419,6 +419,8 @@ sexp sexp_seek (sexp ctx, sexp self, sexp x, off_t offset, int whence) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sexp sexp_tell (sexp ctx, sexp self, sexp x) {
|
sexp sexp_tell (sexp ctx, sexp self, sexp x) {
|
||||||
|
if (sexp_portp(x) && sexp_stream_portp(x))
|
||||||
|
return sexp_make_integer(ctx, ftell(sexp_port_stream(x)));
|
||||||
return sexp_seek(ctx, self, x, 0, SEEK_CUR);
|
return sexp_seek(ctx, self, x, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,4 +140,15 @@
|
||||||
(flush-output out)
|
(flush-output out)
|
||||||
(test 106 sum))
|
(test 106 sum))
|
||||||
|
|
||||||
|
(test "file-position"
|
||||||
|
'(0 1 2)
|
||||||
|
(let* ((p (open-input-file "tests/io-tests.scm"))
|
||||||
|
(t0 (file-position p)))
|
||||||
|
(read-char p)
|
||||||
|
(let ((t1 (file-position p)))
|
||||||
|
(read-char p)
|
||||||
|
(let ((t2 (file-position p)))
|
||||||
|
(close-input-port p)
|
||||||
|
(list t0 t1 t2)))))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
Loading…
Add table
Reference in a new issue