summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-11-27 19:55:09 +0100
committerTyge Løvset <[email protected]>2022-11-27 19:55:09 +0100
commitd540332f52fbd9b2c50a402525a5cfca4919ec32 (patch)
tree7f4b8048f01badbfc03203508ab4539af9cb042d
parentbd6fdd79ee0aa91796ce88048ee15f7ae0f3e874 (diff)
downloadSTC-modified-d540332f52fbd9b2c50a402525a5cfca4919ec32.tar.gz
STC-modified-d540332f52fbd9b2c50a402525a5cfca4919ec32.zip
Removed dependence to STC_CSTR_V1.
-rw-r--r--examples/sso_substr.c2
-rw-r--r--include/stc/alt/cstr.h3
-rw-r--r--include/stc/cstr.h4
-rw-r--r--include/stc/forward.h12
4 files changed, 6 insertions, 15 deletions
diff --git a/examples/sso_substr.c b/examples/sso_substr.c
index 098d9b4b..0c8e9b22 100644
--- a/examples/sso_substr.c
+++ b/examples/sso_substr.c
@@ -14,9 +14,7 @@ int main ()
cstr_assign(&str, "apples are green or red");
cstr s2 = cstr_from_sv(cstr_substr_ex(&str, -3, 3)); // "red"
cstr s3 = cstr_from_sv(cstr_substr_ex(&str, 0, 6)); // "apples"
- #ifndef STC_CSTR_V1
printf("%s %s: %d, %d\n", cstr_str(&s2), cstr_str(&s3),
cstr_is_long(&str), cstr_is_long(&s2));
- #endif
c_drop (cstr, &str, &s2, &s3);
}
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h
index 728ce77f..ba0eb0bb 100644
--- a/include/stc/alt/cstr.h
+++ b/include/stc/alt/cstr.h
@@ -22,7 +22,6 @@
*/
#ifndef CSTR_H_INCLUDED
#define CSTR_H_INCLUDED
-#define STC_CSTR_V1 1
#include <stc/ccommon.h>
#include <stc/forward.h>
@@ -32,6 +31,8 @@
#include <stdio.h> /* vsnprintf */
#include <ctype.h>
+typedef char cstr_value;
+typedef struct { cstr_value* str; } cstr;
#define cstr_npos (SIZE_MAX >> 1)
typedef struct { size_t size, cap; char chr[1]; } cstr_priv;
#define _cstr_p(self) c_unchecked_container_of((self)->str, cstr_priv, chr)
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index ec5cd3c9..bf58444c 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -24,9 +24,6 @@
/* A string type with short string optimization in C99 with good small-string
* optimization (22 characters with 24 bytes string).
*/
-#ifdef STC_CSTR_V1
-#include "alt/cstr.h"
-#else
#ifndef CSTR_H_INCLUDED
#define CSTR_H_INCLUDED
@@ -631,4 +628,3 @@ STC_DEF size_t cstr_printf(cstr* self, const char* fmt, ...) {
#undef i_static
#undef i_implement
#undef i_extern
-#endif // !STC_CSTR_V1
diff --git a/include/stc/forward.h b/include/stc/forward.h
index a45efc3c..45a68e3a 100644
--- a/include/stc/forward.h
+++ b/include/stc/forward.h
@@ -51,14 +51,10 @@ typedef union {
typedef char cstr_value;
typedef struct { cstr_value* data; size_t size, cap; } cstr_buf;
-#if defined STC_CSTR_V1
- typedef struct { cstr_value* str; } cstr;
-#else
- typedef union {
- struct { cstr_value data[sizeof(cstr_buf) - 1]; unsigned char size; } sml;
- struct { cstr_value* data; size_t size, ncap; } lon;
- } cstr;
-#endif
+typedef union {
+ struct { cstr_value data[sizeof(cstr_buf) - 1]; unsigned char size; } sml;
+ struct { cstr_value* data; size_t size, ncap; } lon;
+} cstr;
typedef union {
cstr_value* ref;
struct { csview chr; } u8;