From 93eade5fc5346b11805fa13db6147409d4932b03 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 24 Oct 2013 13:00:32 +0200 Subject: slice: allow zero-length size --- slice.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/slice.c b/slice.c index 119ecef..005084d 100644 --- a/slice.c +++ b/slice.c @@ -34,7 +34,7 @@ int main(int argc, char **argv) { bytes_end += seekpos; } - if (bytes_end <= seekpos) { + if (bytes_end < seekpos) { fprintf(stderr, "The last byte must be greater than the first byte.\n"); return 1; } @@ -60,6 +60,7 @@ int main(int argc, char **argv) { if (bytes_end - read_bytes < read_count) read_count = bytes_end - read_bytes; + /* if fseek failed, discard some bytes */ if (read_bytes < seekpos) skip_bytes = seekpos - read_bytes; -- cgit v1.2.1