summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-20 12:17:32 +0100
committerTyge Løvset <[email protected]>2022-12-20 12:17:32 +0100
commit1778629d92849af84239c4b8c1940ed76fd87b8a (patch)
treecbe600a280aee2405836c66413e234de071bb231 /docs
parent21817cae767d72e6007150b639f9365e35502173 (diff)
downloadSTC-modified-1778629d92849af84239c4b8c1940ed76fd87b8a.tar.gz
STC-modified-1778629d92849af84239c4b8c1940ed76fd87b8a.zip
Renamed (reverted) cstr_new(lit) => cstr_lit(lit). Old name is deprecated (supported for now).
Diffstat (limited to 'docs')
-rw-r--r--docs/ccommon_api.md8
-rw-r--r--docs/cmap_api.md10
-rw-r--r--docs/cstr_api.md6
-rw-r--r--docs/csview_api.md13
-rw-r--r--docs/cvec_api.md6
5 files changed, 22 insertions, 21 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 8f887626..2c6db85f 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -32,7 +32,7 @@ c_with (FILE* fp = fopen(fname, "rb"), fclose(fp))
}
}
-c_with (cstr str = cstr_new("Hello"), cstr_drop(&str))
+c_with (cstr str = cstr_lit("Hello"), cstr_drop(&str))
{
cstr_append(&str, " world");
printf("%s\n", cstr_str(&str));
@@ -50,7 +50,7 @@ c_auto (cstr, s1, s2)
printf("%s %s\n", cstr_str(&s1), cstr_str(&s2));
}
-c_autodrop (cstr, str, cstr_new("Hello"))
+c_autodrop (cstr, str, cstr_lit("Hello"))
{
cstr_append(&str, " world");
printf("%s\n", cstr_str(&str));
@@ -64,7 +64,7 @@ c_scope (pthread_mutex_lock(&mut), pthread_mutex_unlock(&mut))
}
// `c_defer` executes the expressions when leaving scope.
-cstr s1 = cstr_new("Hello"), s2 = cstr_new("world");
+cstr s1 = cstr_lit("Hello"), s2 = cstr_lit("world");
c_defer (cstr_drop(&s1), cstr_drop(&s2))
{
printf("%s %s\n", cstr_str(&s1), cstr_str(&s2));
@@ -330,7 +330,7 @@ c_free(pnt);
int* array = c_alloc_n (int, 100);
c_free(array);
-cstr a = cstr_new("Hello"), b = cstr_new("World");
+cstr a = cstr_lit("Hello"), b = cstr_lit("World");
c_drop(cstr, &a, &b);
```
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 315d2062..520d9046 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -316,13 +316,13 @@ int main()
// Use a HashMap to store the vikings' health points.
c_auto (Vikings, vikings) // uses Vikings_init(), Vikings_drop()
{
- Vikings_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Norway")}, 25);
- Vikings_insert(&vikings, (Viking){cstr_new("Olaf"), cstr_new("Denmark")}, 24);
- Vikings_insert(&vikings, (Viking){cstr_new("Harald"), cstr_new("Iceland")}, 12);
- Vikings_insert(&vikings, (Viking){cstr_new("Einar"), cstr_new("Denmark")}, 21);
+ Vikings_insert(&vikings, (Viking){cstr_lit("Einar"), cstr_lit("Norway")}, 25);
+ Vikings_insert(&vikings, (Viking){cstr_lit("Olaf"), cstr_lit("Denmark")}, 24);
+ Vikings_insert(&vikings, (Viking){cstr_lit("Harald"), cstr_lit("Iceland")}, 12);
+ Vikings_insert(&vikings, (Viking){cstr_lit("Einar"), cstr_lit("Denmark")}, 21);
c_auto (Viking, lookup) {
- lookup = (Viking){cstr_new("Einar"), cstr_new("Norway")};
+ lookup = (Viking){cstr_lit("Einar"), cstr_lit("Norway")};
printf("Lookup: Einar of Norway has %d hp\n\n", *Vikings_at(&vikings, lookup));
}
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index 1f80e8e4..0f9589d9 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -19,7 +19,7 @@ All cstr definitions and prototypes are available by including a single header f
## Methods
```c
cstr cstr_init(void); // constructor; same as cstr_NULL.
-cstr cstr_new(const char literal_only[]); // cstr from literal; no strlen() call.
+cstr cstr_lit(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 n first bytes of str
cstr cstr_from_sv(csview sv); // construct cstr from csview
@@ -160,10 +160,10 @@ char* cstrnstrn(const char* str, const char* search, size_t slen, size_t
#include <stc/cstr.h>
int main() {
- cstr s0 = cstr_new("Initialization without using strlen().");
+ cstr s0 = cstr_lit("Initialization without using strlen().");
printf("%s\nLength: %" c_ZU "\n\n", cstr_str(&s0), cstr_size(&s0));
- cstr s1 = cstr_new("one-nine-three-seven-five.");
+ cstr s1 = cstr_lit("one-nine-three-seven-five.");
printf("%s\n", cstr_str(&s1));
cstr_insert(&s1, 3, "-two");
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 8d288783..4851152a 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -27,13 +27,14 @@ All csview definitions and prototypes are available by including a single header
```c
csview c_SV(const char literal_only[]); // construct from literal, no strlen()
-csview c_SV(const char* str, size_t n); // shorthand for csview_from_n()
+csview c_SV(const char* str, size_t n); // construct from str and length n
+csview csview_lit(const char literal_only[]); // alias for c_SV(lit)
csview csview_from(const char* str); // construct from const char*
-csview csview_from_n(const char* str); // construct from const char* and len
-void csview_clear(csview* self);
+csview csview_from_n(const char* str, size_t n); // alias for c_SV(str, n)
size_t csview_size(csview sv);
bool csview_empty(csview sv);
+void csview_clear(csview* self);
bool csview_equals(csview sv, csview sv2);
size_t csview_find(csview sv, const char* str);
@@ -120,7 +121,7 @@ uint64_t csview_hash(const csview* x);
int main ()
{
- cstr str1 = cstr_new("We think in generalities, but we live in details.");
+ cstr str1 = cstr_lit("We think in generalities, but we live in details.");
// (quoting Alfred N. Whitehead)
csview sv1 = cstr_substr(&str1, 3, 5); // "think"
@@ -129,7 +130,7 @@ int main ()
csview sv3 = cstr_slice(&str1, -8, -1); // get "details"
printf("%.*s %.*s %.*s\n",
c_ARGSV(sv1), c_ARGSV(sv2), c_ARGSV(sv3));
- cstr s1 = cstr_new("Apples are red");
+ cstr s1 = cstr_lit("Apples are red");
cstr s2 = cstr_from_sv(cstr_substr(&s1, -3, 3)); // "red"
cstr s3 = cstr_from_sv(cstr_substr(&s1, 0, 6)); // "Apples"
printf("%s %s\n", cstr_str(&s2), cstr_str(&s3));
@@ -151,7 +152,7 @@ red Apples
int main()
{
c_auto (cstr, s1) {
- s1 = cstr_new("hell😀 w😀rld");
+ s1 = cstr_lit("hell😀 w😀rld");
cstr_u8_replace(&s1, cstr_find(&s1, "😀rld"), 1, c_SV("ø"));
printf("%s\n", cstr_str(&s1));
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index d19607c6..9b2614af 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -214,9 +214,9 @@ User User_clone(User user) {
int main(void) {
UVec vec = UVec_init();
- UVec_push(&vec, (User){cstr_new("mary"), 0});
- UVec_push(&vec, (User){cstr_new("joe"), 1});
- UVec_push(&vec, (User){cstr_new("admin"), 2});
+ UVec_push(&vec, (User){cstr_lit("mary"), 0});
+ UVec_push(&vec, (User){cstr_lit("joe"), 1});
+ UVec_push(&vec, (User){cstr_lit("admin"), 2});
UVec vec2 = UVec_clone(vec);