From f1df3dee537e827bc4f74ed92ab8a58cd4cf2ac0 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 8 Aug 2016 19:12:52 +0100 Subject: Use size_t in dev::utf8::validate() --- libdevcore/UTF8.cpp | 10 +++++----- libdevcore/UTF8.h | 2 +- libsolidity/ast/Types.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libdevcore/UTF8.cpp b/libdevcore/UTF8.cpp index 0c385e81..a71693a8 100644 --- a/libdevcore/UTF8.cpp +++ b/libdevcore/UTF8.cpp @@ -31,18 +31,18 @@ namespace utf8 { -bool validate(std::string const& _input, int& _invalidPosition) +bool validate(std::string const& _input, size_t& _invalidPosition) { - const int length = _input.length(); + const size_t length = _input.length(); bool valid = true; - int i = 0; + size_t i = 0; for (; i < length; i++) { if ((unsigned char)_input[i] < 0x80) continue; - int count = 0; + size_t count = 0; switch(_input[i] & 0xe0) { case 0xc0: count = 1; break; case 0xe0: count = 2; break; @@ -62,7 +62,7 @@ bool validate(std::string const& _input, int& _invalidPosition) break; } - for (int j = 0; j < count; j++) + for (size_t j = 0; j < count; j++) { i++; if ((_input[i] & 0xc0) != 0x80) diff --git a/libdevcore/UTF8.h b/libdevcore/UTF8.h index 2824d5bf..d6959f3e 100644 --- a/libdevcore/UTF8.h +++ b/libdevcore/UTF8.h @@ -33,7 +33,7 @@ namespace utf8 /// Validate an input for UTF8 encoding /// @returns true if it is invalid and the first invalid position in invalidPosition -bool validate(std::string const& _input, int& _invalidPosition); +bool validate(std::string const& _input, size_t& _invalidPosition); } diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index d6f6225c..aae18934 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -855,7 +855,7 @@ bool StringLiteralType::operator==(const Type& _other) const std::string StringLiteralType::toString(bool) const { - int invalidSequence; + size_t invalidSequence; if (!dev::utf8::validate(m_value, invalidSequence)) return "literal_string (contains invalid UTF-8 sequence at position " + dev::toString(invalidSequence) + ")"; -- cgit v1.2.3