diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-06-29 21:11:50 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-01 15:58:57 +0300 |
commit | 0eebdd4b7b3c45890953ecc12cc9692bc8012e9d (patch) | |
tree | a2ead8b871f66a78f77d41d237b0e7ed9d5fa893 /bpkg | |
parent | 9a1351808c7443a65f876d2b7808ebdea7d9c814 (diff) |
Port to MSVC
Diffstat (limited to 'bpkg')
-rw-r--r-- | bpkg/manifest.cxx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx index ac6fafb..ce36b9b 100644 --- a/bpkg/manifest.cxx +++ b/bpkg/manifest.cxx @@ -4,8 +4,6 @@ #include <bpkg/manifest> -#include <strings.h> // strncasecmp() - #include <string> #include <ostream> #include <sstream> @@ -1387,10 +1385,21 @@ namespace bpkg { using protocol = url_parts::protocol; + // Check if the location starts with the specified schema. The argument + // must be in the lower case (we don't use str[n]casecmp() since it's not + // portable). + // + auto schema = [&location](const char* s) -> bool + { + size_t i (0); + for (; s[i] != '\0' && s[i] == lowercase (location[i]); ++i) ; + return s[i] == '\0'; + }; + optional<protocol> p; - if (strncasecmp (location.c_str (), "http://", 7) == 0) + if (schema ("http://")) p = protocol::http; - else if (strncasecmp (location.c_str (), "https://", 8) == 0) + else if (schema ("https://")) p = protocol::https; return p; |