From: Sage Weil Date: Thu, 24 Dec 2015 15:41:08 +0000 (-0500) Subject: common/buffer: make hexdump look like 'hexdump -C ...' X-Git-Tag: v10.0.3~154^2~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5c6269081eb75613576e7d2c57c58ff788e6924b;p=ceph.git common/buffer: make hexdump look like 'hexdump -C ...' ...the better to diff them with. Signed-off-by: Sage Weil --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 9e6a8e76049a..b9bf48a6c125 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