mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7538 from ghallak/7198-remove-padded-zeros
Remove trailing zeros from the output of BytesUtils::formatBytes
This commit is contained in:
commit
e626437d77
@ -263,7 +263,7 @@ string BytesUtils::formatBytes(
|
|||||||
os << formatHexString(_bytes);
|
os << formatHexString(_bytes);
|
||||||
break;
|
break;
|
||||||
case ABIType::String:
|
case ABIType::String:
|
||||||
os << formatString(_bytes);
|
os << formatString(_bytes, _bytes.size() - countRightPaddedZeros(_bytes));
|
||||||
break;
|
break;
|
||||||
case ABIType::Failure:
|
case ABIType::Failure:
|
||||||
break;
|
break;
|
||||||
@ -311,3 +311,12 @@ string BytesUtils::formatBytesRange(
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t BytesUtils::countRightPaddedZeros(bytes const& _bytes)
|
||||||
|
{
|
||||||
|
return find_if(
|
||||||
|
_bytes.rbegin(),
|
||||||
|
_bytes.rend(),
|
||||||
|
[](uint8_t b) { return b != '\0'; }
|
||||||
|
) - _bytes.rbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,10 @@ public:
|
|||||||
ParameterList const& _parameters,
|
ParameterList const& _parameters,
|
||||||
bool _highlight
|
bool _highlight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Count the number of zeros between the last non-zero byte and the end of
|
||||||
|
/// \param _bytes.
|
||||||
|
static size_t countRightPaddedZeros(bytes const& _bytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
TestFunctionCall(FunctionCall _call): m_call(std::move(_call)) {}
|
TestFunctionCall(FunctionCall _call): m_call(std::move(_call)) {}
|
||||||
|
|
||||||
/// Formats this function call test and applies the format that was detected during parsing.
|
/// Formats this function call test and applies the format that was detected during parsing.
|
||||||
/// If _renderResult is false, the expected result of the call will is used, if it's false
|
/// If _renderResult is false, the expected result of the call will be used, if it's true
|
||||||
/// the actual result is used.
|
/// the actual result is used.
|
||||||
/// If _highlight is false, it's formatted without colorized highlighting. If it's true, AnsiColorized is
|
/// If _highlight is false, it's formatted without colorized highlighting. If it's true, AnsiColorized is
|
||||||
/// used to apply a colorized highlighting.
|
/// used to apply a colorized highlighting.
|
||||||
|
Loading…
Reference in New Issue
Block a user