From bda9ffdf608c090e6338ecf68875ee2c10783416 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Fri, 13 Jun 2014 23:39:20 -0400 Subject: [PATCH] Fix that skipping fails if target is 2nd frame With bSeekForwardOnly the current file position should be an inclusive boundary, but because the binary search stops if the search region (high-low) becomes header_size, the current frame wasn't found. Because trjconv always reads the first frame before calling seek, it failed if the target was the 2nd frame. Fixes #1154 Change-Id: Id4151f0106abdb68d6067f02fe2927a4ec6d77a0 --- src/gmxlib/libxdrf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmxlib/libxdrf.c b/src/gmxlib/libxdrf.c index d320928024..dd56225b54 100644 --- a/src/gmxlib/libxdrf.c +++ b/src/gmxlib/libxdrf.c @@ -1466,7 +1466,7 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms, gmx_bool bSeek if (bSeekForwardOnly) { - low = gmx_ftell(fp); + low = gmx_ftell(fp)-header_size; } if (gmx_fseek(fp, 0, SEEK_END)) { -- 2.22.0