summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortylov <[email protected]>2023-08-13 17:38:10 +0200
committertylov <[email protected]>2023-08-13 17:38:10 +0200
commit972aa23a674f743c187e82444c2271aaa3e9cd06 (patch)
treeb39b5e9e36c0251a06d40090a26c8e8da5a2167e
parent1802558d41112e99d965000c97c45ebf7984d70c (diff)
downloadSTC-modified-972aa23a674f743c187e82444c2271aaa3e9cd06.tar.gz
STC-modified-972aa23a674f743c187e82444c2271aaa3e9cd06.zip
Removed csview_null - use csview_init().
-rw-r--r--docs/csview_api.md2
-rw-r--r--include/stc/csview.h8
-rw-r--r--misc/examples/coroutines/cotasks1.c2
-rw-r--r--misc/examples/coroutines/cotasks2.c2
-rw-r--r--misc/examples/coroutines/filetask.c2
-rw-r--r--src/cregex.c6
6 files changed, 9 insertions, 13 deletions
diff --git a/docs/csview_api.md b/docs/csview_api.md
index 79a5c07b..49e4f9d1 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -29,7 +29,6 @@ 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, intptr_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, intptr_t n); // alias for c_sv(str, n)
@@ -112,7 +111,6 @@ uint64_t csview_hash(const csview* x);
| Name | Value | Usage |
|:---------------|:---------------------|:---------------------------------------------|
-| `csview_null` | same as `c_sv("")` | `sview = csview_null;` |
| `c_SV(sv)` | printf argument | `printf("sv: %.*s\n", c_SV(sv));` |
## Example
diff --git a/include/stc/csview.h b/include/stc/csview.h
index 85965928..bbf7cd8e 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -27,11 +27,9 @@
#ifndef CSVIEW_H_INCLUDED
#define CSVIEW_H_INCLUDED
-#define csview_null c_sv_1("")
-#define csview_init() csview_null
+#define csview_init() c_sv_1("")
#define csview_drop(p) c_default_drop(p)
#define csview_clone(sv) c_default_clone(sv)
-#define csview_lit(literal) c_sv_1(literal)
#define csview_from_n(str, n) c_sv_2(str, n)
STC_API csview_iter csview_advance(csview_iter it, intptr_t pos);
@@ -43,7 +41,7 @@ STC_API csview csview_token(csview sv, const char* sep, intptr_t* start);
STC_INLINE csview csview_from(const char* str)
{ return c_LITERAL(csview){str, c_strlen(str)}; }
-STC_INLINE void csview_clear(csview* self) { *self = csview_null; }
+STC_INLINE void csview_clear(csview* self) { *self = csview_init(); }
STC_INLINE intptr_t csview_size(csview sv) { return sv.size; }
STC_INLINE bool csview_empty(csview sv) { return sv.size == 0; }
@@ -52,7 +50,7 @@ STC_INLINE bool csview_equals(csview sv, const char* str)
{ intptr_t n = c_strlen(str); return sv.size == n && !c_memcmp(sv.str, str, n); }
STC_INLINE intptr_t csview_find(csview sv, const char* str)
- { return csview_find_sv(sv, c_sv(str, c_strlen(str))); }
+ { return csview_find_sv(sv, c_sv_2(str, c_strlen(str))); }
STC_INLINE bool csview_contains(csview sv, const char* str)
{ return csview_find(sv, str) != c_NPOS; }
diff --git a/misc/examples/coroutines/cotasks1.c b/misc/examples/coroutines/cotasks1.c
index 7df4eb34..db9632e6 100644
--- a/misc/examples/coroutines/cotasks1.c
+++ b/misc/examples/coroutines/cotasks1.c
@@ -43,7 +43,7 @@ struct produce_items {
int produce_items(struct produce_items* p)
{
cco_routine (p) {
- p->str = cstr_null;
+ p->str = cstr_init();
while (true)
{
cco_await(next_value(&p->next) != CCO_AWAIT);
diff --git a/misc/examples/coroutines/cotasks2.c b/misc/examples/coroutines/cotasks2.c
index f6257a7e..12c2c4a3 100644
--- a/misc/examples/coroutines/cotasks2.c
+++ b/misc/examples/coroutines/cotasks2.c
@@ -41,7 +41,7 @@ cco_task_struct (produce_items,
int produce_items(struct produce_items* p, cco_runtime* rt)
{
cco_routine (p) {
- p->str = cstr_null;
+ p->str = cstr_init();
p->next.cco_func = next_value;
while (true)
{
diff --git a/misc/examples/coroutines/filetask.c b/misc/examples/coroutines/filetask.c
index 74388359..9650cb60 100644
--- a/misc/examples/coroutines/filetask.c
+++ b/misc/examples/coroutines/filetask.c
@@ -17,7 +17,7 @@ int file_read(struct file_read* co, cco_runtime* rt)
{
cco_routine (co) {
co->fp = fopen(co->path, "r");
- co->line = cstr_null;
+ co->line = cstr_init();
while (true) {
// emulate async io: await 10ms per line
diff --git a/src/cregex.c b/src/cregex.c
index ac94a5dd..975a5104 100644
--- a/src/cregex.c
+++ b/src/cregex.c
@@ -1220,7 +1220,7 @@ _build_subst(const char* replace, int nmatch, const csview match[],
cstr_buf buf = cstr_buffer(subst);
intptr_t len = 0, cap = buf.cap;
char* dst = buf.data;
- cstr mstr = cstr_null;
+ cstr mstr = cstr_init();
while (*replace != '\0') {
if (*replace == '$') {
@@ -1293,8 +1293,8 @@ cregex_find_pattern_4(const char* pattern, const char* input,
cstr
cregex_replace_sv_6(const cregex* re, csview input, const char* replace, int count,
bool (*mfun)(int, csview, cstr*), int rflags) {
- cstr out = cstr_null;
- cstr subst = cstr_null;
+ cstr out = cstr_init();
+ cstr subst = cstr_init();
csview match[CREG_MAX_CAPTURES];
int nmatch = cregex_captures(re) + 1;
if (!count) count = INT32_MAX;