Commit d867fe64 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Rename endsWith as ends_with

parent de247f7d
......@@ -808,8 +808,8 @@ bool tls_hostname_match(const char *pattern, const char *hostname) {
return false;
}
return util::istarts_with(hostname, hnLeftLabelEnd, pattern, ptWildcard) &&
util::iendsWith(hostname, hnLeftLabelEnd, ptWildcard + 1,
ptLeftLabelEnd);
util::iends_with(hostname, hnLeftLabelEnd, ptWildcard + 1,
ptLeftLabelEnd);
}
} // namespace
......
......@@ -521,8 +521,8 @@ void show_candidates(const char *unkopt, option *options) {
}
// Use cost 0 for suffix match, but match at least 3 characters
if (unkoptlen >= 3 &&
iendsWith(options[i].name, options[i].name + optnamelen, unkopt,
unkopt + unkoptlen)) {
iends_with(options[i].name, options[i].name + optnamelen, unkopt,
unkopt + unkoptlen)) {
cands.emplace_back(0, options[i].name);
continue;
}
......@@ -754,7 +754,7 @@ bool check_path(const std::string &path) {
path.find('\\') == std::string::npos &&
path.find("/../") == std::string::npos &&
path.find("/./") == std::string::npos &&
!util::endsWith(path, "/..") && !util::endsWith(path, "/.");
!util::ends_with(path, "/..") && !util::ends_with(path, "/.");
}
int64_t to_time64(const timeval &tv) {
......
......@@ -212,29 +212,29 @@ bool istarts_with(InputIt a, size_t an, const char *b) {
bool istarts_with(const char *a, const char *b);
template <typename InputIterator1, typename InputIterator2>
bool endsWith(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
bool ends_with(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
if (last1 - first1 < last2 - first2) {
return false;
}
return std::equal(first2, last2, last1 - (last2 - first2));
}
inline bool endsWith(const std::string &a, const std::string &b) {
return endsWith(std::begin(a), std::end(a), std::begin(b), std::end(b));
inline bool ends_with(const std::string &a, const std::string &b) {
return ends_with(std::begin(a), std::end(a), std::begin(b), std::end(b));
}
template <typename InputIterator1, typename InputIterator2>
bool iendsWith(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
bool iends_with(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2) {
if (last1 - first1 < last2 - first2) {
return false;
}
return std::equal(first2, last2, last1 - (last2 - first2), CaseCmp());
}
inline bool iendsWith(const std::string &a, const std::string &b) {
return iendsWith(std::begin(a), std::end(a), std::begin(b), std::end(b));
inline bool iends_with(const std::string &a, const std::string &b) {
return iends_with(std::begin(a), std::end(a), std::begin(b), std::end(b));
}
int strcompare(const char *a, const uint8_t *b, size_t n);
......
......@@ -356,15 +356,15 @@ void test_util_starts_with(void) {
}
void test_util_ends_with(void) {
CU_ASSERT(util::endsWith("foo", "foo"));
CU_ASSERT(util::endsWith("foo", ""));
CU_ASSERT(util::endsWith("ofoo", "foo"));
CU_ASSERT(!util::endsWith("ofoo", "fo"));
CU_ASSERT(util::iendsWith("fOo", "Foo"));
CU_ASSERT(util::iendsWith("foo", ""));
CU_ASSERT(util::iendsWith("oFoo", "fOO"));
CU_ASSERT(!util::iendsWith("ofoo", "fo"));
CU_ASSERT(util::ends_with("foo", "foo"));
CU_ASSERT(util::ends_with("foo", ""));
CU_ASSERT(util::ends_with("ofoo", "foo"));
CU_ASSERT(!util::ends_with("ofoo", "fo"));
CU_ASSERT(util::iends_with("fOo", "Foo"));
CU_ASSERT(util::iends_with("foo", ""));
CU_ASSERT(util::iends_with("oFoo", "fOO"));
CU_ASSERT(!util::iends_with("ofoo", "fo"));
}
void test_util_parse_http_date(void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment