From 0eebdd4b7b3c45890953ecc12cc9692bc8012e9d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 29 Jun 2016 21:11:50 +0300 Subject: Port to MSVC --- bpkg/manifest.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'bpkg') 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 -#include // strncasecmp() - #include #include #include @@ -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 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; -- cgit v1.1