mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user