From 549c59ecf523a879f8a948e8ef0336c36a755fa7 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Wed, 14 Oct 2009 17:44:29 -0700 Subject: [PATCH] fix OutputFile::seek() for SEEK_SET and SEEK_END --- src/file.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/file.cpp b/src/file.cpp index c6ed419e..0d3e3011 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -396,6 +396,17 @@ void OutputFile::rewrite(const void *buf, int len) void OutputFile::seek(off_t off, int whence) { assert(!opt->to_stdout); + switch (whence) { + case SEEK_SET: { + if (bytes_written < off) { + bytes_written = off; + } + _length = bytes_written; // cheap, lazy update; needed? + } break; + case SEEK_END: { + _length = bytes_written; // necessary + } break; + } super::seek(off,whence); }