From 5c6269081eb75613576e7d2c57c58ff788e6924b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 24 Dec 2015 10:41:08 -0500 Subject: [PATCH] common/buffer: make hexdump look like 'hexdump -C ...' ...the better to diff them with. Signed-off-by: Sage Weil --- src/common/buffer.cc | 45 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 9e6a8e76049..b9bf48a6c12 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -2097,24 +2097,58 @@ void buffer::list::write_stream(std::ostream &out) const void buffer::list::hexdump(std::ostream &out) const { + if (!length()) + return; + std::ios_base::fmtflags original_flags = out.flags(); + // do our best to match the output of hexdump -C, for better + // diff'ing! + out.setf(std::ios::right); out.fill('0'); unsigned per = 16; - + bool was_zeros = false, did_star = false; for (unsigned o=0; o