From c01426efecb82375c7c732f8c385b38cb9259168 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sat, 26 Nov 2016 15:23:32 +0000 Subject: [PATCH] Make position optional in dev::validate --- libdevcore/UTF8.h | 6 ++++++ libsolidity/ast/ASTJsonConverter.cpp | 3 +-- libsolidity/ast/Types.cpp | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libdevcore/UTF8.h b/libdevcore/UTF8.h index 9bdc2b4f2..b82fd1c6d 100644 --- a/libdevcore/UTF8.h +++ b/libdevcore/UTF8.h @@ -32,4 +32,10 @@ namespace dev /// @returns false if it is invalid and the first invalid position in invalidPosition bool validate(std::string const& _input, size_t& _invalidPosition); +inline bool validate(std::string const& _input) +{ + size_t invalidPos; + return validate(_input, invalidPos); +} + } diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 030b32bae..cf60c76a9 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -417,9 +417,8 @@ bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) bool ASTJsonConverter::visit(Literal const& _node) { char const* tokenString = Token::toString(_node.token()); - size_t invalidPos = 0; Json::Value value{_node.value()}; - if (!dev::validate(_node.value(), invalidPos)) + if (!dev::validate(_node.value())) value = Json::nullValue; Token::Value subdenomination = Token::Value(_node.subDenomination()); addJsonNode(_node, "Literal", { diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index b22f3c086..4c8463b57 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -909,8 +909,7 @@ TypePointer StringLiteralType::mobileType() const bool StringLiteralType::isValidUTF8() const { - size_t dontCare {}; - return dev::validate(m_value, dontCare); + return dev::validate(m_value); } shared_ptr FixedBytesType::smallestTypeForLiteral(string const& _literal)