src: Rename startsWith as starts_with

This commit is contained in:
Tatsuhiro Tsujikawa 2015-11-28 00:31:42 +09:00
parent 1ba28bef1f
commit de247f7d33
8 changed files with 37 additions and 37 deletions

View File

@ -108,7 +108,7 @@ bool path_match(const std::string &pattern, const std::string &path) {
if (pattern.back() != '/') {
return pattern == path;
}
return util::startsWith(path, pattern);
return util::starts_with(path, pattern);
}
} // namespace

View File

@ -454,7 +454,7 @@ std::string rewrite_location_uri(const std::string &uri,
return "";
}
auto field = &u.field_data[UF_HOST];
if (!util::startsWith(std::begin(match_host), std::end(match_host),
if (!util::starts_with(std::begin(match_host), std::end(match_host),
&uri[field->off], &uri[field->off] + field->len) ||
(match_host.size() != field->len && match_host[field->len] != ':')) {
return "";

View File

@ -325,11 +325,11 @@ void exec_binary(SignalServer *ssv) {
}
for (size_t i = 0; i < envlen; ++i) {
if (util::startsWith(environ[i], ENV_LISTENER4_FD) ||
util::startsWith(environ[i], ENV_LISTENER6_FD) ||
util::startsWith(environ[i], ENV_PORT) ||
util::startsWith(environ[i], ENV_UNIX_FD) ||
util::startsWith(environ[i], ENV_UNIX_PATH)) {
if (util::starts_with(environ[i], ENV_LISTENER4_FD) ||
util::starts_with(environ[i], ENV_LISTENER6_FD) ||
util::starts_with(environ[i], ENV_PORT) ||
util::starts_with(environ[i], ENV_UNIX_FD) ||
util::starts_with(environ[i], ENV_UNIX_PATH)) {
continue;
}

View File

@ -519,7 +519,7 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
auto type = log_var_lookup_token(var_name, var_namelen);
if (type == SHRPX_LOGF_NONE) {
if (util::istartsWith(var_name, var_namelen, "http_")) {
if (util::istarts_with(var_name, var_namelen, "http_")) {
if (util::streq("host", var_name + str_size("http_"),
var_namelen - str_size("http_"))) {
// Special handling of host header field. We will use
@ -1342,7 +1342,7 @@ int parse_config(const char *opt, const char *optarg,
pat_delim = optarg + optarglen;
}
DownstreamAddr addr;
if (util::istartsWith(optarg, SHRPX_UNIX_PATH_PREFIX)) {
if (util::istarts_with(optarg, SHRPX_UNIX_PATH_PREFIX)) {
auto path = optarg + str_size(SHRPX_UNIX_PATH_PREFIX);
addr.host = strcopy(path, pat_delim);
addr.host_unix = true;
@ -1368,7 +1368,7 @@ int parse_config(const char *opt, const char *optarg,
return 0;
}
case SHRPX_OPTID_FRONTEND: {
if (util::istartsWith(optarg, SHRPX_UNIX_PATH_PREFIX)) {
if (util::istarts_with(optarg, SHRPX_UNIX_PATH_PREFIX)) {
auto path = optarg + str_size(SHRPX_UNIX_PATH_PREFIX);
mod_config()->host = strcopy(path);
mod_config()->port = 0;

View File

@ -792,7 +792,7 @@ bool tls_hostname_match(const char *pattern, const char *hostname) {
// Don't attempt to match a presented identifier where the wildcard
// character is embedded within an A-label.
if (ptLeftLabelEnd == 0 || strchr(ptLeftLabelEnd + 1, '.') == 0 ||
ptLeftLabelEnd < ptWildcard || util::istartsWith(pattern, "xn--")) {
ptLeftLabelEnd < ptWildcard || util::istarts_with(pattern, "xn--")) {
wildcardEnabled = false;
}
if (!wildcardEnabled) {
@ -807,7 +807,7 @@ bool tls_hostname_match(const char *pattern, const char *hostname) {
if (hnLeftLabelEnd - hostname < ptLeftLabelEnd - pattern) {
return false;
}
return util::istartsWith(hostname, hnLeftLabelEnd, pattern, ptWildcard) &&
return util::istarts_with(hostname, hnLeftLabelEnd, pattern, ptWildcard) &&
util::iendsWith(hostname, hnLeftLabelEnd, ptWildcard + 1,
ptLeftLabelEnd);
}

View File

@ -353,7 +353,7 @@ void streq_advance(const char **ap, const char **bp) {
}
} // namespace
bool istartsWith(const char *a, const char *b) {
bool istarts_with(const char *a, const char *b) {
if (!a || !b) {
return false;
}
@ -509,7 +509,7 @@ void show_candidates(const char *unkopt, option *options) {
for (size_t i = 0; options[i].name != nullptr; ++i) {
auto optnamelen = strlen(options[i].name);
// Use cost 0 for prefix match
if (istartsWith(options[i].name, options[i].name + optnamelen, unkopt,
if (istarts_with(options[i].name, options[i].name + optnamelen, unkopt,
unkopt + unkoptlen)) {
if (optnamelen == static_cast<size_t>(unkoptlen)) {
// Exact match, then we don't show any condidates.

View File

@ -169,7 +169,7 @@ inline char lowcase(char c) {
}
template <typename InputIterator1, typename InputIterator2>
bool startsWith(InputIterator1 first1, InputIterator1 last1,
bool starts_with(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
if (last1 - first1 < last2 - first2) {
return false;
@ -177,12 +177,12 @@ bool startsWith(InputIterator1 first1, InputIterator1 last1,
return std::equal(first2, last2, first1);
}
inline bool startsWith(const std::string &a, const std::string &b) {
return startsWith(std::begin(a), std::end(a), std::begin(b), std::end(b));
inline bool starts_with(const std::string &a, const std::string &b) {
return starts_with(std::begin(a), std::end(a), std::begin(b), std::end(b));
}
inline bool startsWith(const char *a, const char *b) {
return startsWith(a, a + strlen(a), b, b + strlen(b));
inline bool starts_with(const char *a, const char *b) {
return starts_with(a, a + strlen(a), b, b + strlen(b));
}
struct CaseCmp {
@ -192,7 +192,7 @@ struct CaseCmp {
};
template <typename InputIterator1, typename InputIterator2>
bool istartsWith(InputIterator1 first1, InputIterator1 last1,
bool istarts_with(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
if (last1 - first1 < last2 - first2) {
return false;
@ -200,16 +200,16 @@ bool istartsWith(InputIterator1 first1, InputIterator1 last1,
return std::equal(first2, last2, first1, CaseCmp());
}
inline bool istartsWith(const std::string &a, const std::string &b) {
return istartsWith(std::begin(a), std::end(a), std::begin(b), std::end(b));
inline bool istarts_with(const std::string &a, const std::string &b) {
return istarts_with(std::begin(a), std::end(a), std::begin(b), std::end(b));
}
template <typename InputIt>
bool istartsWith(InputIt a, size_t an, const char *b) {
return istartsWith(a, a + an, b, b + strlen(b));
bool istarts_with(InputIt a, size_t an, const char *b) {
return istarts_with(a, a + an, b, b + strlen(b));
}
bool istartsWith(const char *a, const char *b);
bool istarts_with(const char *a, const char *b);
template <typename InputIterator1, typename InputIterator2>
bool endsWith(InputIterator1 first1, InputIterator1 last1,

View File

@ -344,15 +344,15 @@ void test_util_format_duration(void) {
}
void test_util_starts_with(void) {
CU_ASSERT(util::startsWith("foo", "foo"));
CU_ASSERT(util::startsWith("fooo", "foo"));
CU_ASSERT(util::startsWith("ofoo", ""));
CU_ASSERT(!util::startsWith("ofoo", "foo"));
CU_ASSERT(util::starts_with("foo", "foo"));
CU_ASSERT(util::starts_with("fooo", "foo"));
CU_ASSERT(util::starts_with("ofoo", ""));
CU_ASSERT(!util::starts_with("ofoo", "foo"));
CU_ASSERT(util::istartsWith("FOO", "fOO"));
CU_ASSERT(util::startsWith("ofoo", ""));
CU_ASSERT(util::istartsWith("fOOo", "Foo"));
CU_ASSERT(!util::istartsWith("ofoo", "foo"));
CU_ASSERT(util::istarts_with("FOO", "fOO"));
CU_ASSERT(util::starts_with("ofoo", ""));
CU_ASSERT(util::istarts_with("fOOo", "Foo"));
CU_ASSERT(!util::istarts_with("ofoo", "foo"));
}
void test_util_ends_with(void) {