summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-12-13 13:53:22 +0100
committerTyge Løvset <[email protected]>2021-12-13 13:53:22 +0100
commit17280f8177736c35b34e41556a307ca51e68d1e2 (patch)
tree96b0b7dfeede1dc0a6c6f36ec60f18e2ff3bd68a
parentc7a26eb5b5fef1c2706d5875a0603d352926487e (diff)
downloadSTC-modified-17280f8177736c35b34e41556a307ca51e68d1e2.tar.gz
STC-modified-17280f8177736c35b34e41556a307ca51e68d1e2.zip
Renamed constructor *cstr_lit()* to `cstr_new(lit)`.
Renamed *cstr_assign_fmt()* to `cstr_printf()`. Renamed cbits_from_str() to cbits_from().
-rw-r--r--README.md7
-rw-r--r--docs/cbits_api.md3
-rw-r--r--docs/ccommon_api.md6
-rw-r--r--docs/cmap_api.md14
-rw-r--r--docs/cstr_api.md8
-rw-r--r--docs/csview_api.md11
-rw-r--r--docs/cvec_api.md4
-rw-r--r--examples/astar.c2
-rw-r--r--examples/bits.c2
-rw-r--r--examples/csmap_erase.c10
-rw-r--r--examples/csmap_insert.c2
-rw-r--r--examples/cstr_match.c2
-rw-r--r--examples/demos.c2
-rw-r--r--examples/inits.c2
-rw-r--r--examples/ptr_elems.c4
-rw-r--r--examples/splitstr.c2
-rw-r--r--include/stc/alt/cstr.h2
-rw-r--r--include/stc/cbits.h11
-rw-r--r--include/stc/ccommon.h1
-rw-r--r--include/stc/cstr.h9
-rw-r--r--include/stc/csview.h6
21 files changed, 57 insertions, 53 deletions
diff --git a/README.md b/README.md
index 28ee068e..78043037 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,7 @@ STC - Smart Template Containers for C
News
----
+- Strings: Renamed constructor *cstr_lit()* to `cstr_new(lit)`. Renamed *cstr_assign_fmt()* to `cstr_printf()`.
- Added **cbox** type: container of one element: similar to [std::unique_ptr](https://en.cppreference.com/w/cpp/memory/unique_ptr)
- Replaced example for **csptr** in docs.
- Added [**c_forpair**](docs/ccommon_api.md) macro: for-loop with "structural binding" as in c++.
@@ -318,7 +319,7 @@ and non-emplace methods:
#include <stc/cvec.h> // vector of string (cstr)
...
c_auto (cvec_str, vec) // declare and call cvec_str_init() and defer cvec_str_del(&vec)
-c_autovar (cstr s = cstr_lit("a string literal"), cstr_del(&s)) // c_autovar is a more general c_auto.
+c_autovar (cstr s = cstr_new("a string literal"), cstr_del(&s)) // c_autovar is a more general c_auto.
{
const char* hello = "Hello";
cvec_str_push_back(&vec, cstr_from(hello); // construct and add string from const char*
@@ -347,9 +348,9 @@ cmap_str_emplace(&map, "Hello", "again");
// No cstr was constructed because "Hello" was already in the map.
cmap_str_emplace_or_assign(&map, "Hello", "there");
-// Only cstr_from("there") constructed. "world" was destructed and replaced.
+// Only cstr_new("there") constructed. "world" was destructed and replaced.
-cmap_str_insert(&map, cstr_from("Hello"), cstr_from("you"));
+cmap_str_insert(&map, cstr_new("Hello"), cstr_new("you"));
// Two cstr's constructed outside call, but both destructed by insert
// because "Hello" existed. No mem-leak but less efficient.
diff --git a/docs/cbits_api.md b/docs/cbits_api.md
index f13c5e8c..b369b5d1 100644
--- a/docs/cbits_api.md
+++ b/docs/cbits_api.md
@@ -18,9 +18,10 @@ All cbits definitions and prototypes are available by including a single header
```c
cbits cbits_init(void);
+cbits cbits_new(c_strlit literal);
+cbits cbits_from(const char* str);
cbits cbits_with_size(size_t size, bool value);
cbits cbits_with_values(size_t size, uint64_t pattern);
-cbits cbits_from_str(const char* str);
cbits cbits_clone(cbits other);
void cbits_clear(cbits* self);
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 8c749e8e..4dc099fb 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -22,7 +22,7 @@ macros, as one must always make sure to unwind temporary allocated resources bef
For multiple variables, use either multiple **c_autovar** in sequence, or declare variable outside
scope and use **c_autoscope**. Also, **c_auto** support up to 3 variables.
```c
-c_autovar (cstr s = cstr_lit("Hello"), cstr_del(&s))
+c_autovar (cstr s = cstr_new("Hello"), cstr_del(&s))
{
cstr_append(&s, " world");
printf("%s\n", s.str);
@@ -45,7 +45,7 @@ c_autoscope (mydata_init(&data), mydata_destroy(&data))
printf("%s\n", mydata.name.str);
}
-cstr s1 = cstr_lit("Hello"), s2 = cstr_lit("world");
+cstr s1 = cstr_new("Hello"), s2 = cstr_new("world");
c_autodefer (cstr_del(&s1), cstr_del(&s2))
{
printf("%s %s\n", s1.str, s2.str);
@@ -158,7 +158,7 @@ c_free(pnt);
int* array = c_alloc_n (int, 100);
c_free(array);
-cstr a = cstr_from("Hello"), b = cstr_from("World");
+cstr a = cstr_new("Hello"), b = cstr_new("World");
c_del(cstr, &a, &b);
```
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 51bcdcce..0fec365c 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -295,12 +295,12 @@ int main()
// Use a HashMap to store the vikings' health points.
cmap_vk vikings = cmap_vk_init();
- cmap_vk_insert(&vikings, (Viking){cstr_from("Einar"), cstr_from("Norway")}, 25);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Olaf"), cstr_from("Denmark")}, 24);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Harald"), cstr_from("Iceland")}, 12);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Einar"), cstr_from("Denmark")}, 21);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Norway")}, 25);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Olaf"), cstr_new("Denmark")}, 24);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Harald"), cstr_new("Iceland")}, 12);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Denmark")}, 21);
- Viking lookup = (Viking){cstr_from("Einar"), cstr_from("Norway")};
+ Viking lookup = (Viking){cstr_new("Einar"), cstr_new("Norway")};
printf("Lookup: Einar of Norway has %d hp\n\n", *cmap_vk_at(&vikings, lookup));
Viking_del(&lookup);
@@ -371,8 +371,8 @@ int main()
c_auto (cmap_vk, vikings) // RAII
{
// Insert works as before, takes a constructed Viking object
- cmap_vk_insert(&vikings, (Viking){cstr_from("Einar"), cstr_from("Norway")}, 25);
- cmap_vk_insert(&vikings, (Viking){cstr_from("Olaf"), cstr_from("Denmark")}, 24);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Norway")}, 25);
+ cmap_vk_insert(&vikings, (Viking){cstr_new("Olaf"), cstr_new("Denmark")}, 24);
// Emplace is simpler to use now - takes rawkey argument
cmap_vk_emplace(&vikings, (RViking){"Harald", "Iceland"}, 12);
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index acea7b6f..0004eeae 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -16,7 +16,7 @@ All cstr definitions and prototypes are available by including a single header f
```c
cstr cstr_init(void); // constructor; same as cstr_null.
-cstr cstr_lit(const char literal_only[]); // cstr from literal; no strlen().
+cstr cstr_new(const char literal_only[]); // cstr from literal; no strlen() call.
cstr cstr_from(const char* str); // constructor using strlen()
cstr cstr_from_n(const char* str, size_t n); // constructor with specified length
cstr cstr_with_capacity(size_t cap);
@@ -41,7 +41,7 @@ void cstr_clear(cstr* self);
cstr* cstr_assign(cstr* self, const char* str);
cstr* cstr_assign_n(cstr* self, const char* str, size_t n); // assign n first chars of str
-cstr* cstr_assign_fmt(cstr* self, const char* fmt, ...); // printf() formatting
+cstr* cstr_printf(cstr* self, const char* fmt, ...); // printf() formatting
cstr* cstr_copy(cstr* self, cstr s); // cstr_take(self, cstr_clone(s))
cstr* cstr_append(cstr* self, const char* str);
@@ -118,10 +118,10 @@ int c_strncasecmp(const char* str1, const char* str2, size_t n);
#include <stc/cstr.h>
int main() {
- cstr s0 = cstr_lit("Initialization without using strlen().");
+ cstr s0 = cstr_new("Initialization without using strlen().");
printf("%s\nLength: %zu\n\n", s0.str, cstr_size(s0));
- cstr s1 = cstr_from("one-nine-three-seven-five.");
+ cstr s1 = cstr_new("one-nine-three-seven-five.");
printf("%s\n", s1.str);
cstr_insert(&s1, 3, "-two");
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 1376b768..2653dafa 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -25,12 +25,11 @@ All csview definitions and prototypes are available by including a single header
## Methods
```c
+csview csview_new(const char literal_only[]); // make csview from literal, no strlen()
+csview csview_from_s(cstr s); // same as cstr_sv()
csview csview_from(const char* str); // make csview from const char*
csview csview_from_n(const char* str, size_t n); // construct
-csview csview_from_s(cstr s); // same as cstr_sv()
-
-csview csview_lit(const char literal_only[]); // make csview from literal, no strlen()
-csview c_sv(const char literal_only[]); // same as csview_lit()
+csview c_sv(const char literal_only[]); // same as csview_new()
size_t csview_size(csview sv);
size_t csview_length(csview sv);
@@ -104,7 +103,7 @@ uint64_t csview_hash(const csview* x, size_t dummy);
int main ()
{
- cstr str1 = cstr_lit("We think in generalities, but we live in details.");
+ cstr str1 = cstr_new("We think in generalities, but we live in details.");
// (quoting Alfred N. Whitehead)
csview sv1 = cstr_substr(str1, 3, 5); // "think"
@@ -113,7 +112,7 @@ int main ()
csview sv3 = cstr_slice(str1, -8, -1); // get "details"
printf("%.*s %.*s %.*s\n", csview_ARG(sv1), csview_ARG(sv2), csview_ARG(sv3));
- cstr s1 = cstr_lit("Apples are red");
+ cstr s1 = cstr_new("Apples are red");
cstr s2 = cstr_from_v(cstr_substr(s1, -3, 3)); // "red"
cstr s3 = cstr_from_v(cstr_substr(s1, 0, 6)); // "Apples"
printf("%s %s\n", s2, s3.str);
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index b3bc0f1b..8053b108 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -202,8 +202,8 @@ User User_clone(User user) {
int main(void) {
cvec_u vec = cvec_u_init();
- cvec_u_push_back(&vec, (User) {cstr_from("admin"), 0});
- cvec_u_push_back(&vec, (User) {cstr_from("joe"), 1});
+ cvec_u_push_back(&vec, (User) {cstr_new("admin"), 0});
+ cvec_u_push_back(&vec, (User) {cstr_new("joe"), 1});
cvec_u vec2 = cvec_u_clone(vec);
c_foreach (i, cvec_u, vec2)
diff --git a/examples/astar.c b/examples/astar.c
index 2bf136e3..88c602ef 100644
--- a/examples/astar.c
+++ b/examples/astar.c
@@ -132,7 +132,7 @@ astar(cstr* maze, int width)
int
main(void)
{
- c_autovar (cstr maze = cstr_lit(
+ c_autovar (cstr maze = cstr_new(
"#########################################################################\n"
"# # # # # # #\n"
"# # ######### # ##### ######### ##### ##### ##### # ! #\n"
diff --git a/examples/bits.c b/examples/bits.c
index 9263f88c..fbdee3e8 100644
--- a/examples/bits.c
+++ b/examples/bits.c
@@ -5,7 +5,7 @@ int main()
{
c_autovar (cbits set = cbits_with_size(23, true), cbits_del(&set)) {
printf("count %zu, %zu\n", cbits_count(set), set.size);
- cbits s1 = cbits_from_str("1110100110111");
+ cbits s1 = cbits_new("1110100110111");
char buf[256];
cbits_to_str(s1, buf, 0, -1);
printf("buf: %s: %zu\n", buf, cbits_count(s1));
diff --git a/examples/csmap_erase.c b/examples/csmap_erase.c
index 627c11d4..9cf65389 100644
--- a/examples/csmap_erase.c
+++ b/examples/csmap_erase.c
@@ -20,11 +20,11 @@ int main()
c_auto (mymap, m1)
{
// Fill in some data to test with, one at a time
- mymap_insert(&m1, 1, cstr_lit("A"));
- mymap_insert(&m1, 2, cstr_lit("B"));
- mymap_insert(&m1, 3, cstr_lit("C"));
- mymap_insert(&m1, 4, cstr_lit("D"));
- mymap_insert(&m1, 5, cstr_lit("E"));
+ mymap_insert(&m1, 1, cstr_new("A"));
+ mymap_insert(&m1, 2, cstr_new("B"));
+ mymap_insert(&m1, 3, cstr_new("C"));
+ mymap_insert(&m1, 4, cstr_new("D"));
+ mymap_insert(&m1, 5, cstr_new("E"));
puts("Starting data of map m1 is:");
printmap(m1);
diff --git a/examples/csmap_insert.c b/examples/csmap_insert.c
index 32f53377..920cf02d 100644
--- a/examples/csmap_insert.c
+++ b/examples/csmap_insert.c
@@ -83,7 +83,7 @@ int main()
// The templatized versions move-constructing elements
c_auto (csmap_istr, m3) {
- csmap_istr_value ip1 = {475, cstr_lit("blue")}, ip2 = {510, cstr_lit("green")};
+ csmap_istr_value ip1 = {475, cstr_new("blue")}, ip2 = {510, cstr_new("green")};
// single element
csmap_istr_insert(&m3, ip1.first, cstr_move(&ip1.second));
diff --git a/examples/cstr_match.c b/examples/cstr_match.c
index 9e5cc11c..041a2d84 100644
--- a/examples/cstr_match.c
+++ b/examples/cstr_match.c
@@ -3,7 +3,7 @@
int main()
{
- c_autovar (cstr ss = cstr_lit("The quick brown fox jumps over the lazy dog.JPG"), cstr_del(&ss)) {
+ c_autovar (cstr ss = cstr_new("The quick brown fox jumps over the lazy dog.JPG"), cstr_del(&ss)) {
size_t pos = cstr_find_n(ss, "brown", 0, 5);
printf("%zu [%s]\n", pos, pos == cstr_npos ? "<NULL>" : &ss.str[pos]);
printf("equals: %d\n", cstr_equals(ss, "The quick brown fox jumps over the lazy dog.JPG"));
diff --git a/examples/demos.c b/examples/demos.c
index 30250c5f..70aa722d 100644
--- a/examples/demos.c
+++ b/examples/demos.c
@@ -3,7 +3,7 @@
void stringdemo1()
{
printf("\nSTRINGDEMO1\n");
- c_autovar (cstr cs = cstr_from("one-nine-three-seven-five"), cstr_del(&cs))
+ c_autovar (cstr cs = cstr_new("one-nine-three-seven-five"), cstr_del(&cs))
{
printf("%s.\n", cs.str);
diff --git a/examples/inits.c b/examples/inits.c
index a9751ba5..43613198 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -63,7 +63,7 @@ int main(void)
int year = 2020;
c_auto (cmap_id, idnames) {
cmap_id_emplace(&idnames, 100, "Hello");
- cmap_id_insert(&idnames, 110, cstr_from("World"));
+ cmap_id_insert(&idnames, 110, cstr_new("World"));
cmap_id_insert(&idnames, 120, cstr_from_fmt("Howdy, -%d-", year));
c_foreach (i, cmap_id, idnames)
diff --git a/examples/ptr_elems.c b/examples/ptr_elems.c
index 47cdc7d1..c5416822 100644
--- a/examples/ptr_elems.c
+++ b/examples/ptr_elems.c
@@ -49,8 +49,8 @@ int main()
c_auto (cmap_str, map)
{
printf("\nMap with pointer elements:\n");
- cmap_str_insert(&map, cstr_lit("testing"), c_new(inttype, 999));
- cmap_str_insert(&map, cstr_lit("done"), c_new(inttype, 111));
+ cmap_str_insert(&map, cstr_new("testing"), c_new(inttype, 999));
+ cmap_str_insert(&map, cstr_new("done"), c_new(inttype, 111));
// Emplace: implicit key, val construction using i_keyfrom/i_valfrom:
cmap_str_emplace(&map, "hello", 200);
diff --git a/examples/splitstr.c b/examples/splitstr.c
index baa48d21..8bea911a 100644
--- a/examples/splitstr.c
+++ b/examples/splitstr.c
@@ -33,7 +33,7 @@ int main()
print_split(c_sv("This has no matching separator"), c_sv("xx")); puts("");
puts("Output from string_split():");
- cstr string = cstr_lit("Split,this,,string,now,");
+ cstr string = cstr_new("Split,this,,string,now,");
cvec_str vec = string_split(cstr_sv(string), c_sv(","));
c_autodefer (cvec_str_del(&vec), cstr_del(&string))
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h
index 39da2e6a..1dc895ff 100644
--- a/include/stc/alt/cstr.h
+++ b/include/stc/alt/cstr.h
@@ -84,7 +84,7 @@ STC_INLINE cstr_rep_t cstr_rep_(cstr* self) {
/**************************** PUBLIC API **********************************/
-#define cstr_lit(lit) cstr_from_n(lit, sizeof((cstr_literal_t){lit}) - 1)
+#define cstr_new(lit) cstr_from_n(lit, sizeof((cstr_literal_t){lit}) - 1)
#define cstr_npos (~(cstr_size_t)0 >> 1)
STC_API char* cstr_reserve(cstr* self, cstr_size_t cap);
diff --git a/include/stc/cbits.h b/include/stc/cbits.h
index 2843f7d0..1816f41a 100644
--- a/include/stc/cbits.h
+++ b/include/stc/cbits.h
@@ -61,9 +61,9 @@ struct cbits {
size_t size;
} typedef cbits;
+STC_API cbits cbits_from_n(const char* str, size_t n);
STC_API cbits cbits_with_size(size_t size, bool value);
STC_API cbits cbits_with_values(size_t size, uint64_t pattern);
-STC_API cbits cbits_from_str(const char* str);
STC_API char* cbits_to_str(cbits set, char* str, size_t start, intptr_t stop);
STC_API cbits cbits_clone(cbits other);
STC_API void cbits_resize(cbits* self, size_t size, bool value);
@@ -73,10 +73,14 @@ STC_API bool cbits_subset_of(cbits set, cbits other);
STC_API bool cbits_disjoint(cbits set, cbits other);
STC_INLINE cbits cbits_init() { return c_make(cbits){NULL, 0}; }
+STC_INLINE cbits cbits_from(const char* s) { return cbits_from_n(s, strlen(s)); }
STC_INLINE void cbits_clear(cbits* self) { self->size = 0; }
STC_INLINE void cbits_del(cbits* self) { c_free(self->data64); }
STC_INLINE size_t cbits_size(cbits set) { return set.size; }
+#define cbits_new(literal) \
+ cbits_from_n(literal, sizeof c_make(c_strlit){literal} - 1)
+
STC_INLINE cbits* cbits_take(cbits* self, cbits other) {
if (self->data64 != other.data64) {cbits_del(self); *self = other;}
return self;
@@ -190,9 +194,8 @@ STC_DEF cbits cbits_with_values(size_t size, uint64_t pattern) {
cbits_set_values(&set, pattern);
return set;
}
-STC_DEF cbits cbits_from_str(const char* str) {
- const char* p = str; while (*p) ++p;
- cbits set = cbits_with_size(p - str, false);
+STC_DEF cbits cbits_from_n(const char* str, size_t n) {
+ cbits set = cbits_with_size(n, false);
for (size_t i=0; i<set.size; ++i) if (str[i] == '1') cbits_set(&set, i);
return set;
}
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 70b2ff71..2942873f 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -92,6 +92,7 @@
# define c_free(p) free(p)
#endif
+typedef const char c_strlit[];
#define c_delete(T, ptr) do { T *_c_p = ptr; T##_del(_c_p); c_free(_c_p); } while (0)
#define c_swap(T, x, y) do { T _c_t = x; x = y; y = _c_t; } while (0)
#define c_arraylen(a) (sizeof (a)/sizeof (a)[0])
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index f47d8a02..41ab11ad 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -41,7 +41,6 @@ struct cstr_rep { size_t size, cap; char str[sizeof(size_t)]; };
#define _cstr_rep(self) c_container_of((self)->str, struct cstr_rep, str)
STC_STATIC_ONLY( static struct cstr_rep _cstr_nullrep = {0, 0, {0}};
static const cstr cstr_null = {_cstr_nullrep.str}; )
-typedef const char strlit_t[];
/* optimal memory: based on malloc_usable_size() sequence: 24, 40, 56, ... */
#define _cstr_opt_mem(cap) ((((offsetof(struct cstr_rep, str) + (cap) + 8)>>4)<<4) + 8)
/* optimal string capacity: 7, 23, 39, ... */
@@ -55,7 +54,7 @@ STC_API cstr cstr_from_replace_all(const char* str, size_t str_len,
STC_API size_t cstr_reserve(cstr* self, size_t cap);
STC_API void cstr_resize(cstr* self, size_t len, char fill);
STC_API cstr* cstr_assign_n(cstr* self, const char* str, size_t n);
-STC_API cstr* cstr_assign_fmt(cstr* self, const char* fmt, ...);
+STC_API cstr* cstr_printf(cstr* self, const char* fmt, ...);
STC_API cstr* cstr_append_n(cstr* self, const char* str, size_t n);
STC_API void cstr_replace_n(cstr* self, size_t pos, size_t len, const char* str, size_t n);
STC_API void cstr_replace_all(cstr* self, const char* find, const char* replace);
@@ -69,8 +68,8 @@ STC_API int c_strncasecmp(const char* s1, const char* s2, size_t nma
STC_INLINE cstr cstr_init() { return cstr_null; }
#define cstr_str(self) (self)->str
-#define cstr_lit(literal) \
- cstr_from_n(literal, sizeof c_make(strlit_t){literal} - 1)
+#define cstr_new(literal) \
+ cstr_from_n(literal, sizeof c_make(c_strlit){literal} - 1)
STC_INLINE cstr cstr_from(const char* str)
{ return cstr_from_n(str, strlen(str)); }
STC_INLINE char* cstr_data(cstr* self) { return self->str; }
@@ -244,7 +243,7 @@ cstr_from_fmt(const char* fmt, ...) {
}
STC_DEF cstr*
-cstr_assign_fmt(cstr* self, const char* fmt, ...) {
+cstr_printf(cstr* self, const char* fmt, ...) {
cstr ret = cstr_null;
va_list args; va_start(args, fmt);
cstr_vfmt(&ret, fmt, args);
diff --git a/include/stc/csview.h b/include/stc/csview.h
index ce08bd1a..872b6e1e 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -33,7 +33,7 @@ typedef char csview_value;
#define csview_npos cstr_npos
#define c_svfmt "%.*s"
#define c_svarg(sv) (int)(sv).size, (sv).str
-#define c_sv(literal) csview_lit(literal)
+#define c_sv(literal) csview_new(literal)
#define cstr_sv(s) csview_from_s(s)
STC_API csview csview_substr(csview sv, intptr_t pos, size_t n);
@@ -41,8 +41,8 @@ STC_API csview csview_slice(csview sv, intptr_t p1, intptr_t p2);
STC_API csview csview_first_token(csview sv, csview sep);
STC_API csview csview_next_token(csview sv, csview sep, csview tok);
-#define csview_lit(literal) \
- c_make(csview){literal, sizeof c_make(strlit_t){literal} - 1}
+#define csview_new(literal) \
+ c_make(csview){literal, sizeof c_make(c_strlit){literal} - 1}
STC_INLINE csview csview_from(const char* str)
{ return c_make(csview){str, strlen(str)}; }
STC_INLINE csview csview_from_n(const char* str, size_t n)