From 3023b7f57a3003242bc770bcfe55f666227680ff Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Fri, 27 Jan 2017 21:43:21 -0500 Subject: [PATCH] bees: types: improve serialization of byte ranges Use () instead of [] when the respective end of the byte range touches the beginning or end of the file. Also omit the '0' at beginning of file. Signed-off-by: Zygo Blaxell --- src/bees-types.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bees-types.cc b/src/bees-types.cc index 54a4959..b418fda 100644 --- a/src/bees-types.cc +++ b/src/bees-types.cc @@ -71,7 +71,18 @@ operator<<(ostream &os, const BeesFileRange &bfr) if (bfr.end() == numeric_limits::max()) { os << "- [" << to_hex(bfr.begin()) << "..eof]"; } else { - os << pretty(bfr.size()) << " [" << to_hex(bfr.begin()) << ".." << to_hex(bfr.end()) << "]"; + os << pretty(bfr.size()) << " "; + if (bfr.begin() != 0) { + os << "[" << to_hex(bfr.begin()); + } else { + os << "("; + } + os << ".." << to_hex(bfr.end()); + if (!!bfr.m_fd && bfr.end() >= bfr.file_size()) { + os << ")"; + } else { + os << "]"; + } } if (bfr.m_fid) { os << " fid = " << bfr.m_fid;