summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-25 21:20:12 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-25 21:20:12 -0800
commitf57429096f6cd9f96a749e72fd99b2bf1252b463 (patch)
tree0a372bdacf63bdb98769640291ba01e014626c52 /sysif.c
parent1ba633898340b2abf04b3ffdb4f3790118e85677 (diff)
downloadtxr-f57429096f6cd9f96a749e72fd99b2bf1252b463.tar.gz
txr-f57429096f6cd9f96a749e72fd99b2bf1252b463.tar.bz2
txr-f57429096f6cd9f96a749e72fd99b2bf1252b463.zip
streams: use Boolean return value for stdio_fseek.
* stream.c (stdio_seek): Handle new-style Boolean return from stdio_fseek. * sysif.c (stdio_fseek): Return an int indication that is 1 for success, 0 for failure. There was a mistaken assumption here that fseeko returns the file offset, and the return value in the fseek case was mistakenly harmonized, using a wasteful call to stdio_ftell. The only call to this function relies only on a Boolean success/fail indication. * sysif.h (stdio_fseek): Declaration updated.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sysif.c b/sysif.c
index ae469b07..04ed6ea5 100644
--- a/sysif.c
+++ b/sysif.c
@@ -1364,14 +1364,13 @@ val stdio_ftell(FILE *f)
#endif
}
-val stdio_fseek(FILE *f, val off, int whence)
+int stdio_fseek(FILE *f, val off, int whence)
{
val self = lit("seek-stream");
#if HAVE_FSEEKO
- return num_off_t(fseeko(f, off_t_num(off, self), whence));
+ return fseeko(f, off_t_num(off, self), whence) == 0;
#else
- int ret = fseek(f, c_long(off, self), whence);
- return (ret == -1) ? num_fast(ret) : stdio_ftell(f);
+ return fseek(f, c_long(off, self), whence) == 0;
#endif
}