src: Rename endsWith as ends_with
This commit is contained in:
parent
de247f7d33
commit
d867fe64e3
|
@ -808,8 +808,8 @@ bool tls_hostname_match(const char *pattern, const char *hostname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return util::istarts_with(hostname, hnLeftLabelEnd, pattern, ptWildcard) &&
|
return util::istarts_with(hostname, hnLeftLabelEnd, pattern, ptWildcard) &&
|
||||||
util::iendsWith(hostname, hnLeftLabelEnd, ptWildcard + 1,
|
util::iends_with(hostname, hnLeftLabelEnd, ptWildcard + 1,
|
||||||
ptLeftLabelEnd);
|
ptLeftLabelEnd);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // 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
|
// Use cost 0 for suffix match, but match at least 3 characters
|
||||||
if (unkoptlen >= 3 &&
|
if (unkoptlen >= 3 &&
|
||||||
iendsWith(options[i].name, options[i].name + optnamelen, unkopt,
|
iends_with(options[i].name, options[i].name + optnamelen, unkopt,
|
||||||
unkopt + unkoptlen)) {
|
unkopt + unkoptlen)) {
|
||||||
cands.emplace_back(0, options[i].name);
|
cands.emplace_back(0, options[i].name);
|
||||||
continue;
|
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 &&
|
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) {
|
int64_t to_time64(const timeval &tv) {
|
||||||
|
|
16
src/util.h
16
src/util.h
|
@ -212,29 +212,29 @@ bool istarts_with(InputIt a, size_t an, const char *b) {
|
||||||
bool istarts_with(const char *a, const char *b);
|
bool istarts_with(const char *a, const char *b);
|
||||||
|
|
||||||
template <typename InputIterator1, typename InputIterator2>
|
template <typename InputIterator1, typename InputIterator2>
|
||||||
bool endsWith(InputIterator1 first1, InputIterator1 last1,
|
bool ends_with(InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2) {
|
InputIterator2 first2, InputIterator2 last2) {
|
||||||
if (last1 - first1 < last2 - first2) {
|
if (last1 - first1 < last2 - first2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return std::equal(first2, last2, last1 - (last2 - first2));
|
return std::equal(first2, last2, last1 - (last2 - first2));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool endsWith(const std::string &a, const std::string &b) {
|
inline bool ends_with(const std::string &a, const std::string &b) {
|
||||||
return endsWith(std::begin(a), std::end(a), std::begin(b), std::end(b));
|
return ends_with(std::begin(a), std::end(a), std::begin(b), std::end(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename InputIterator1, typename InputIterator2>
|
template <typename InputIterator1, typename InputIterator2>
|
||||||
bool iendsWith(InputIterator1 first1, InputIterator1 last1,
|
bool iends_with(InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2) {
|
InputIterator2 first2, InputIterator2 last2) {
|
||||||
if (last1 - first1 < last2 - first2) {
|
if (last1 - first1 < last2 - first2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return std::equal(first2, last2, last1 - (last2 - first2), CaseCmp());
|
return std::equal(first2, last2, last1 - (last2 - first2), CaseCmp());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool iendsWith(const std::string &a, const std::string &b) {
|
inline bool iends_with(const std::string &a, const std::string &b) {
|
||||||
return iendsWith(std::begin(a), std::end(a), std::begin(b), std::end(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);
|
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) {
|
void test_util_ends_with(void) {
|
||||||
CU_ASSERT(util::endsWith("foo", "foo"));
|
CU_ASSERT(util::ends_with("foo", "foo"));
|
||||||
CU_ASSERT(util::endsWith("foo", ""));
|
CU_ASSERT(util::ends_with("foo", ""));
|
||||||
CU_ASSERT(util::endsWith("ofoo", "foo"));
|
CU_ASSERT(util::ends_with("ofoo", "foo"));
|
||||||
CU_ASSERT(!util::endsWith("ofoo", "fo"));
|
CU_ASSERT(!util::ends_with("ofoo", "fo"));
|
||||||
|
|
||||||
CU_ASSERT(util::iendsWith("fOo", "Foo"));
|
CU_ASSERT(util::iends_with("fOo", "Foo"));
|
||||||
CU_ASSERT(util::iendsWith("foo", ""));
|
CU_ASSERT(util::iends_with("foo", ""));
|
||||||
CU_ASSERT(util::iendsWith("oFoo", "fOO"));
|
CU_ASSERT(util::iends_with("oFoo", "fOO"));
|
||||||
CU_ASSERT(!util::iendsWith("ofoo", "fo"));
|
CU_ASSERT(!util::iends_with("ofoo", "fo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_util_parse_http_date(void) {
|
void test_util_parse_http_date(void) {
|
||||||
|
|
Loading…
Reference in New Issue