diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-07-21 18:34:23 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-07-21 18:50:53 +0300 |
commit | 969dab4c1af666d381124fd481821bc936fc94ed (patch) | |
tree | b7bc4b2e75b8cc3f64e240162f3bedff23e9c58b /seek.c | |
parent | 0c0ae29bc7a71fc2cb6d0acf403b1e72715fbe48 (diff) | |
download | runcap-969dab4c1af666d381124fd481821bc936fc94ed.tar.gz runcap-969dab4c1af666d381124fd481821bc936fc94ed.tar.bz2 |
Fix tell/seek operations
* Makefile (clean): descend into t as well.
* t/Makefile (clean): New goal.
* runcap.h (runcap_seek): Return off_t.
* seek.c (runcap_seek): Change return value. Fix operation.
* tell.c (runcap_tell): Bugfix.
* t/rt.c: New option -r for testing seek.
* t/08seek.t: New testcase.
* t/09seek.t: New testcase.
Diffstat (limited to 'seek.c')
-rw-r--r-- | seek.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -19,7 +19,7 @@ #include <errno.h> #include "runcap.h" -int +off_t runcap_seek(struct runcap *rc, int sd, off_t off, int whence) { struct stream_capture *cap; @@ -32,7 +32,7 @@ runcap_seek(struct runcap *rc, int sd, off_t off, int whence) cur = runcap_tell(rc, sd); switch (whence) { case SEEK_CUR: - off = cur; + off = cur + off; break; case SEEK_END: @@ -52,8 +52,8 @@ runcap_seek(struct runcap *rc, int sd, off_t off, int whence) return -1; } - cur -= cap->sc_level; - + cur -= cap->sc_cur; + if (cur <= off && off <= cur + cap->sc_level) { cap->sc_cur = off - cur; } else if (cap->sc_storfd != -1) { @@ -65,7 +65,7 @@ runcap_seek(struct runcap *rc, int sd, off_t off, int whence) errno = EINVAL; return -1; } - return 0; + return off; } |