mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' of github.com:tfire/solidity into fix/remove-namespace-ast-annotations
This commit is contained in:
@@ -20,11 +20,12 @@
|
||||
* @date 2014
|
||||
*/
|
||||
|
||||
#include <libsolutil/Assertions.h>
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
#include <libsolutil/Assertions.h>
|
||||
#include <libsolutil/Keccak256.h>
|
||||
#include <libsolutil/FixedHash.h>
|
||||
#include <libsolutil/Keccak256.h>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
@@ -154,9 +155,9 @@ string solidity::util::getChecksummedAddress(string const& _addr)
|
||||
char addressCharacter = s[i];
|
||||
uint8_t nibble = hash[i / 2u] >> (4u * (1u - (i % 2u))) & 0xf;
|
||||
if (nibble >= 8)
|
||||
ret += static_cast<char>(toupper(addressCharacter));
|
||||
ret += toUpper(addressCharacter);
|
||||
else
|
||||
ret += static_cast<char>(tolower(addressCharacter));
|
||||
ret += toLower(addressCharacter);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -211,7 +212,7 @@ string solidity::util::escapeAndQuoteString(string const& _input)
|
||||
out += "\\r";
|
||||
else if (c == '\t')
|
||||
out += "\\t";
|
||||
else if (!isprint(c, locale::classic()))
|
||||
else if (!isPrint(c))
|
||||
{
|
||||
ostringstream o;
|
||||
o << "\\x" << std::hex << setfill('0') << setw(2) << (unsigned)(unsigned char)(c);
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/Numeric.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -197,4 +199,47 @@ inline std::optional<unsigned> toUnsignedInt(std::string const& _value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts parameter _c to its lowercase equivalent if c is an uppercase letter and has a lowercase equivalent. It uses the classic "C" locale semantics.
|
||||
/// @param _c value to be converted
|
||||
/// @return the converted value
|
||||
inline char toLower(char _c)
|
||||
{
|
||||
return tolower(_c, std::locale::classic());
|
||||
}
|
||||
|
||||
/// Converts parameter _c to its uppercase equivalent if c is an lowercase letter and has a uppercase equivalent. It uses the classic "C" locale semantics.
|
||||
/// @param _c value to be converted
|
||||
/// @return the converted value
|
||||
inline char toUpper(char _c)
|
||||
{
|
||||
return toupper(_c, std::locale::classic());
|
||||
}
|
||||
|
||||
/// Converts parameter _s to its lowercase equivalent. It uses the classic "C" locale semantics.
|
||||
/// @param _s value to be converted
|
||||
/// @return the converted value
|
||||
inline std::string toLower(std::string _s)
|
||||
{
|
||||
std::transform(_s.begin(), _s.end(), _s.begin(), [](char _c) {
|
||||
return toLower(_c);
|
||||
});
|
||||
return _s;
|
||||
}
|
||||
|
||||
/// Checks whether _c is a decimal digit character. It uses the classic "C" locale semantics.
|
||||
/// @param _c character to be checked
|
||||
/// @return true if _c is a decimal digit character, false otherwise
|
||||
inline bool isDigit(char _c)
|
||||
{
|
||||
return isdigit(_c, std::locale::classic());
|
||||
}
|
||||
|
||||
// Checks if character is printable using classic "C" locale
|
||||
/// @param _c character to be checked
|
||||
/// @return true if _c is a printable character, false otherwise.
|
||||
inline bool isPrint(char _c)
|
||||
{
|
||||
return isprint(_c, std::locale::classic());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user