diff options
| author | Tyge Løvset <[email protected]> | 2021-06-10 23:28:25 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-06-10 23:28:25 +0200 |
| commit | 5c8fc711e839287935b4090a55079496901d4626 (patch) | |
| tree | cec6e9d057bc5f0e31304745b0389a7a10830e24 | |
| parent | 9c42498b639976449cbeaaee33ed89df8971b6fd (diff) | |
| download | STC-modified-5c8fc711e839287935b4090a55079496901d4626.tar.gz STC-modified-5c8fc711e839287935b4090a55079496901d4626.zip | |
Renamed cstr/csview begin_with() to starts_with() : following c++ std namings.
| -rw-r--r-- | docs/cstr_api.md | 4 | ||||
| -rw-r--r-- | docs/csview_api.md | 4 | ||||
| -rw-r--r-- | examples/cstr_match.c | 2 | ||||
| -rw-r--r-- | include/stc/cstr.h | 4 | ||||
| -rw-r--r-- | include/stc/csview.h | 4 |
5 files changed, 9 insertions, 9 deletions
diff --git a/docs/cstr_api.md b/docs/cstr_api.md index a38718bc..8dec7f2f 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -64,13 +64,13 @@ bool cstr_equals_s(cstr s, cstr s2); size_t cstr_find(cstr s, const char* needle); size_t cstr_find_n(cstr s, const char* needle, size_t pos, size_t nmax); bool cstr_contains(cstr s, const char* needle); -bool cstr_begins_with(cstr s, const char* str); +bool cstr_starts_with(cstr s, const char* str); bool cstr_ends_with(cstr s, const char* str); bool cstr_iequals(cstr s, const char* str); // prefix i = case-insensitive size_t cstr_ifind_n(cstr s, const char* needle, size_t pos, size_t nmax); bool cstr_icontains(cstr s, const char* needle); -bool cstr_ibegins_with(cstr s, const char* str); +bool cstr_istarts_with(cstr s, const char* str); bool cstr_iends_with(cstr s, const char* str); void cstr_push_back(cstr* self, char ch); diff --git a/docs/csview_api.md b/docs/csview_api.md index 59c307b4..2a4260f7 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -48,7 +48,7 @@ csview csview_next_token(csview sv, csview sep, csview token); bool csview_equals(csview sv, csview sv2); size_t csview_find(csview sv, csview needle); bool csview_contains(csview sv, csview needle); -bool csview_begins_with(csview sv, csview sub); +bool csview_starts_with(csview sv, csview sub); bool csview_ends_with(csview sv, csview sub); csview_iter_t csview_begin(const csview* self); @@ -69,7 +69,7 @@ void cstr_replace_v(cstr* self, size_t pos, size_t len, csview sv); bool cstr_equals_v(cstr s, csview sv); size_t cstr_find_v(cstr s, csview needle); bool cstr_contains_v(cstr s, csview needle); -bool cstr_begins_with_v(cstr s, csview sub); +bool cstr_starts_with_v(cstr s, csview sub); bool cstr_ends_with_v(cstr s, csview sub); ``` #### Helper methods diff --git a/examples/cstr_match.c b/examples/cstr_match.c index 07a6b8d4..72bdd2d2 100644 --- a/examples/cstr_match.c +++ b/examples/cstr_match.c @@ -8,7 +8,7 @@ int main() printf("%zu [%s]\n", pos, pos == cstr_npos ? "<NULL>" : &ss.str[pos]);
printf("iequals: %d\n", cstr_iequals(ss, "the quick brown fox jumps over the lazy dog.jpg"));
printf("icontains: %d\n", cstr_icontains(ss, "uMPS Ove"));
- printf("ibegins_with: %d\n", cstr_ibegins_with(ss, "The Quick Brown"));
+ printf("istarts_with: %d\n", cstr_istarts_with(ss, "The Quick Brown"));
printf("iends_with: %d\n", cstr_iends_with(ss, ".Jpg"));
printf("ends_with: %d\n", cstr_ends_with(ss, ".JPG"));
}
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 8f5841eb..89d3921c 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -156,7 +156,7 @@ cstr_move(cstr* self) { }
STC_INLINE bool
-cstr_begins_with(cstr s, const char* sub) {
+cstr_starts_with(cstr s, const char* sub) {
while (*sub && *s.str == *sub) ++s.str, ++sub;
return *sub == 0;
}
@@ -168,7 +168,7 @@ cstr_ends_with(cstr s, const char* sub) { }
STC_INLINE bool
-cstr_ibegins_with(cstr s, const char* sub) {
+cstr_istarts_with(cstr s, const char* sub) {
while (*sub && tolower(*s.str) == tolower(*sub)) ++s.str, ++sub;
return *sub == 0;
}
diff --git a/include/stc/csview.h b/include/stc/csview.h index 3d517535..eb787a72 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -59,7 +59,7 @@ STC_INLINE size_t csview_find(csview sv, csview needle) return res ? res - sv.str : cstr_npos; }
STC_INLINE bool csview_contains(csview sv, csview needle)
{ return c_strnstrn(sv.str, needle.str, sv.size, needle.size) != NULL; }
-STC_INLINE bool csview_begins_with(csview sv, csview sub)
+STC_INLINE bool csview_starts_with(csview sv, csview sub)
{ if (sub.size > sv.size) return false;
return !memcmp(sv.str, sub.str, sub.size); }
STC_INLINE bool csview_ends_with(csview sv, csview sub)
@@ -123,7 +123,7 @@ STC_INLINE size_t cstr_find_v(cstr s, csview needle) return res ? res - s.str : cstr_npos; }
STC_INLINE bool cstr_contains_v(cstr s, csview needle)
{ return c_strnstrn(s.str, needle.str, cstr_size(s), needle.size) != NULL; }
-STC_INLINE bool cstr_begins_with_v(cstr s, csview sub)
+STC_INLINE bool cstr_starts_with_v(cstr s, csview sub)
{ if (sub.size > cstr_size(s)) return false;
return !memcmp(s.str, sub.str, sub.size); }
STC_INLINE bool cstr_ends_with_v(cstr s, csview sub)
|
