ldb: fix dump command to pad HEX output chars with 0.
Summary: The old code was omitting the 0 if the char is less than 16. Test Plan: Tried the following program: int main() { unsigned char c = 1; printf("%X\n", c); printf("%02X\n", c); return 0; } The output is: 1 01 Reviewers: dhruba Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D7437
This commit is contained in:
parent
7dc8bb710e
commit
3d9ff0e921
@ -245,12 +245,12 @@ void DBDumper::DoCommand() {
|
||||
if (hex_output_) {
|
||||
std::string str = iter->key().ToString();
|
||||
for (unsigned int i = 0; i < str.length(); ++i) {
|
||||
fprintf(stdout, "%X", str[i]);
|
||||
fprintf(stdout, "%02X", (unsigned char)str[i]);
|
||||
}
|
||||
fprintf(stdout, " ==> ");
|
||||
str = iter->value().ToString();
|
||||
for (unsigned int i = 0; i < str.length(); ++i) {
|
||||
fprintf(stdout, "%X", str[i]);
|
||||
fprintf(stdout, "%02X", (unsigned char)str[i]);
|
||||
}
|
||||
fprintf(stdout, "\n");
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user