Skip to content

Commit

Permalink
buffer: add no-newline hexdump option
Browse files Browse the repository at this point in the history
Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Jun 1, 2016
1 parent 7f6174e commit 46522cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/common/buffer.cc
Expand Up @@ -2339,7 +2339,7 @@ void buffer::list::write_stream(std::ostream &out) const
}


void buffer::list::hexdump(std::ostream &out) const
void buffer::list::hexdump(std::ostream &out, bool trailing_newline) const
{
if (!length())
return;
Expand Down Expand Up @@ -2377,7 +2377,8 @@ void buffer::list::hexdump(std::ostream &out) const
did_star = false;
}
}

if (o)
out << "\n";
out << std::hex << std::setw(8) << o << " ";

unsigned i;
Expand All @@ -2400,9 +2401,12 @@ void buffer::list::hexdump(std::ostream &out) const
else
out << '.';
}
out << '|' << std::dec << std::endl;
out << '|' << std::dec;
}
if (trailing_newline) {
out << "\n" << std::hex << std::setw(8) << length();
out << "\n";
}
out << std::hex << std::setw(8) << length() << "\n";

out.flags(original_flags);
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/buffer.h
Expand Up @@ -580,7 +580,7 @@ namespace buffer CEPH_BUFFER_API {
void decode_base64(list& o);

void write_stream(std::ostream &out) const;
void hexdump(std::ostream &out) const;
void hexdump(std::ostream &out, bool trailing_newline = true) const;
int read_file(const char *fn, std::string *error);
ssize_t read_fd(int fd, size_t len);
int read_fd_zero_copy(int fd, size_t len);
Expand Down

0 comments on commit 46522cf

Please sign in to comment.