summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-01-14 09:09:45 +0100
committerTyge Løvset <[email protected]>2022-01-14 09:09:45 +0100
commitc0359b2d99be860370a3520cbddf11cd3dd1ade9 (patch)
tree152a04e3ef9e0b9e5be13f5ffee4cab51905c2d6 /include
parent379c01f19e186dbd9889bc9dd43d6d867a2a33be (diff)
downloadSTC-modified-c0359b2d99be860370a3520cbddf11cd3dd1ade9.tar.gz
STC-modified-c0359b2d99be860370a3520cbddf11cd3dd1ade9.zip
Renamed *_v() methods to *_sv(). Note: this breaks API, hopefully not too intrusive.
The change was needed to be consistent in using 'sv' as a shorthand for "string view" everywhere, and is easier to understand than _v().
Diffstat (limited to 'include')
-rw-r--r--include/stc/csview.h24
-rw-r--r--include/stc/utf8.h2
2 files changed, 13 insertions, 13 deletions
diff --git a/include/stc/csview.h b/include/stc/csview.h
index d8bb567e..e65821bb 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -95,36 +95,36 @@ STC_INLINE csview utf8_substr(const char* str, size_t pos, size_t n) {
STC_INLINE csview csview_from_s(cstr s)
{ return c_make(csview){s.str, _cstr_rep(&s)->size}; }
-STC_INLINE cstr cstr_from_v(csview sv)
+STC_INLINE cstr cstr_from_sv(csview sv)
{ return cstr_from_n(sv.str, sv.size); }
-STC_INLINE cstr cstr_from_replace_all_v(csview sv, csview find, csview repl)
+STC_INLINE cstr cstr_from_replace_all_sv(csview sv, csview find, csview repl)
{ return cstr_from_replace_all(sv.str, sv.size, find.str, find.size,
repl.str, repl.size); }
-STC_INLINE csview cstr_to_v(const cstr* self)
+STC_INLINE csview cstr_to_sv(const cstr* self)
{ return c_make(csview){self->str, _cstr_rep(self)->size}; }
STC_INLINE csview cstr_substr(cstr s, intptr_t pos, size_t n)
{ return csview_substr(csview_from_s(s), pos, n); }
STC_INLINE csview cstr_slice(cstr s, intptr_t p1, intptr_t p2)
{ return csview_slice(csview_from_s(s), p1, p2); }
-STC_INLINE cstr* cstr_assign_v(cstr* self, csview sv)
+STC_INLINE cstr* cstr_assign_sv(cstr* self, csview sv)
{ return cstr_assign_n(self, sv.str, sv.size); }
-STC_INLINE cstr* cstr_append_v(cstr* self, csview sv)
+STC_INLINE cstr* cstr_append_sv(cstr* self, csview sv)
{ return cstr_append_n(self, sv.str, sv.size); }
-STC_INLINE void cstr_insert_v(cstr* self, size_t pos, csview sv)
+STC_INLINE void cstr_insert_sv(cstr* self, size_t pos, csview sv)
{ cstr_replace_n(self, pos, 0, sv.str, sv.size); }
-STC_INLINE void cstr_replace_v(cstr* self, csview sub, csview with)
+STC_INLINE void cstr_replace_sv(cstr* self, csview sub, csview with)
{ cstr_replace_n(self, sub.str - self->str, sub.size, with.str, with.size); }
-STC_INLINE bool cstr_equals_v(cstr s, csview sv)
+STC_INLINE bool cstr_equals_sv(cstr s, csview sv)
{ return sv.size == cstr_size(s) && !memcmp(s.str, sv.str, sv.size); }
-STC_INLINE size_t cstr_find_v(cstr s, csview needle)
+STC_INLINE size_t cstr_find_sv(cstr s, csview needle)
{ char* res = c_strnstrn(s.str, needle.str, cstr_size(s), needle.size);
return res ? res - s.str : cstr_npos; }
-STC_INLINE bool cstr_contains_v(cstr s, csview needle)
+STC_INLINE bool cstr_contains_sv(cstr s, csview needle)
{ return c_strnstrn(s.str, needle.str, cstr_size(s), needle.size) != NULL; }
-STC_INLINE bool cstr_starts_with_v(cstr s, csview sub)
+STC_INLINE bool cstr_starts_with_sv(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)
+STC_INLINE bool cstr_ends_with_sv(cstr s, csview sub)
{ if (sub.size > cstr_size(s)) return false;
return !memcmp(s.str + cstr_size(s) - sub.size, sub.str, sub.size); }
#endif
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index a064b906..93f8461a 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -9,7 +9,7 @@ int main()
{
c_auto (cstr, s1) {
s1 = cstr_new("hell😀 w😀rld");
- cstr_replace_v(&s1, utf8_substr(s1.str, 7, 1), c_sv("x"));
+ cstr_replace_sv(&s1, utf8_substr(s1.str, 7, 1), c_sv("x"));
printf("%s\n", s1.str);
csview sv = csview_from_s(s1);