From b9c1b51e45b845debb76d8658edabca70ca56079 Mon Sep 17 00:00:00 2001 From: Kate Stone Date: Tue, 6 Sep 2016 20:57:50 +0000 Subject: *** This commit represents a complete reformatting of the LLDB source code *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751 --- lldb/source/Utility/UriParser.cpp | 111 ++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 60 deletions(-) (limited to 'lldb/source/Utility/UriParser.cpp') diff --git a/lldb/source/Utility/UriParser.cpp b/lldb/source/Utility/UriParser.cpp index 77e16b02aae..6a1f0303b97 100644 --- a/lldb/source/Utility/UriParser.cpp +++ b/lldb/source/Utility/UriParser.cpp @@ -23,72 +23,63 @@ using namespace lldb_private; //---------------------------------------------------------------------- // UriParser::Parse //---------------------------------------------------------------------- -bool -UriParser::Parse(const std::string& uri, - std::string& scheme, - std::string& hostname, - int& port, - std::string& path) -{ - std::string tmp_scheme, tmp_hostname, tmp_port, tmp_path; +bool UriParser::Parse(const std::string &uri, std::string &scheme, + std::string &hostname, int &port, std::string &path) { + std::string tmp_scheme, tmp_hostname, tmp_port, tmp_path; - static const char* kSchemeSep = "://"; - auto pos = uri.find(kSchemeSep); - if (pos == std::string::npos) - return false; + static const char *kSchemeSep = "://"; + auto pos = uri.find(kSchemeSep); + if (pos == std::string::npos) + return false; - // Extract path. - tmp_scheme = uri.substr(0, pos); - auto host_pos = pos + strlen(kSchemeSep); - auto path_pos = uri.find('/', host_pos); - if (path_pos != std::string::npos) - tmp_path = uri.substr(path_pos); - else - tmp_path = "/"; + // Extract path. + tmp_scheme = uri.substr(0, pos); + auto host_pos = pos + strlen(kSchemeSep); + auto path_pos = uri.find('/', host_pos); + if (path_pos != std::string::npos) + tmp_path = uri.substr(path_pos); + else + tmp_path = "/"; - auto host_port = uri.substr( - host_pos, ((path_pos != std::string::npos) ? path_pos : uri.size()) - host_pos); + auto host_port = uri.substr( + host_pos, + ((path_pos != std::string::npos) ? path_pos : uri.size()) - host_pos); - // Extract hostname - if (host_port[0] == '[') - { - // hostname is enclosed with square brackets. - pos = host_port.find(']'); - if (pos == std::string::npos) - return false; + // Extract hostname + if (host_port[0] == '[') { + // hostname is enclosed with square brackets. + pos = host_port.find(']'); + if (pos == std::string::npos) + return false; - tmp_hostname = host_port.substr(1, pos - 1); - host_port.erase(0, pos + 1); - } - else - { - pos = host_port.find(':'); - tmp_hostname = host_port.substr(0, (pos != std::string::npos) ? pos : host_port.size()); - host_port.erase(0, (pos != std::string::npos) ? pos : host_port.size()); - } + tmp_hostname = host_port.substr(1, pos - 1); + host_port.erase(0, pos + 1); + } else { + pos = host_port.find(':'); + tmp_hostname = host_port.substr( + 0, (pos != std::string::npos) ? pos : host_port.size()); + host_port.erase(0, (pos != std::string::npos) ? pos : host_port.size()); + } - // Extract port - tmp_port = host_port; - if (!tmp_port.empty()) - { - if (tmp_port[0] != ':') - return false; - tmp_port = tmp_port.substr(1); - bool success = false; - auto port_tmp = StringConvert::ToUInt32(tmp_port.c_str(), UINT32_MAX, 10, &success); - if (!success || port_tmp > 65535) - { - // there are invalid characters in port_buf - return false; - } - port = port_tmp; + // Extract port + tmp_port = host_port; + if (!tmp_port.empty()) { + if (tmp_port[0] != ':') + return false; + tmp_port = tmp_port.substr(1); + bool success = false; + auto port_tmp = + StringConvert::ToUInt32(tmp_port.c_str(), UINT32_MAX, 10, &success); + if (!success || port_tmp > 65535) { + // there are invalid characters in port_buf + return false; } - else - port = -1; + port = port_tmp; + } else + port = -1; - scheme = tmp_scheme; - hostname = tmp_hostname; - path = tmp_path; - return true; + scheme = tmp_scheme; + hostname = tmp_hostname; + path = tmp_path; + return true; } - -- cgit v1.2.3