summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-06-11 07:36:31 +0200
committerTyge Løvset <[email protected]>2023-06-11 07:36:31 +0200
commitf3529a2600141dc7f84c734ea3bf5db8f7090e56 (patch)
tree18f690c53c86c929da251e467446389ef8352938 /include
parent5f935739d2ce280beda36c7a7ddb0e0ee34c8fb3 (diff)
downloadSTC-modified-f3529a2600141dc7f84c734ea3bf5db8f7090e56.tar.gz
STC-modified-f3529a2600141dc7f84c734ea3bf5db8f7090e56.zip
More internal structuring
Diffstat (limited to 'include')
-rw-r--r--include/stc/cstr.h3
-rw-r--r--include/stc/csview.h39
-rw-r--r--include/stc/utf8.h3
3 files changed, 26 insertions, 19 deletions
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index f47889b4..0c5b67d8 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -655,8 +655,11 @@ intptr_t cstr_printf(cstr* self, const char* fmt, ...) {
#if defined __GNUC__ && !defined __clang__
# pragma GCC diagnostic pop
#endif
+#ifndef _i_no_undef
#undef i_opt
#undef i_header
#undef i_static
#undef i_implement
#undef i_import
+#endif
+#undef _i_no_undef
diff --git a/include/stc/csview.h b/include/stc/csview.h
index ee217e98..a1893063 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -114,6 +114,22 @@ STC_INLINE bool csview_valid_utf8(csview sv) // depends on src/utf8code.c
#define c_fortoken(it, input, sep) \
c_fortoken_sv(it, csview_from(input), sep)
+/* ---- Container helper functions ---- */
+
+STC_INLINE int csview_cmp(const csview* x, const csview* y) {
+ intptr_t n = x->size < y->size ? x->size : y->size;
+ int c = c_memcmp(x->str, y->str, n);
+ return c ? c : (int)(x->size - y->size);
+}
+
+STC_INLINE int csview_icmp(const csview* x, const csview* y)
+ { return utf8_icmp_sv(*x, *y); }
+
+STC_INLINE bool csview_eq(const csview* x, const csview* y)
+ { return x->size == y->size && !c_memcmp(x->str, y->str, x->size); }
+
+#endif // CSVIEW_H_INCLUDED
+
/* csview interaction with cstr: */
#ifdef CSTR_H_INCLUDED
@@ -131,23 +147,7 @@ STC_INLINE csview cstr_slice_ex(const cstr* self, intptr_t p1, intptr_t p2)
STC_INLINE csview cstr_u8_substr(const cstr* self , intptr_t bytepos, intptr_t u8len)
{ return csview_u8_substr(cstr_sv(self), bytepos, u8len); }
-
#endif
-/* ---- Container helper functions ---- */
-
-STC_INLINE int csview_cmp(const csview* x, const csview* y) {
- intptr_t n = x->size < y->size ? x->size : y->size;
- int c = c_memcmp(x->str, y->str, n);
- return c ? c : (int)(x->size - y->size);
-}
-
-STC_INLINE int csview_icmp(const csview* x, const csview* y)
- { return utf8_icmp_sv(*x, *y); }
-
-STC_INLINE bool csview_eq(const csview* x, const csview* y)
- { return x->size == y->size && !c_memcmp(x->str, y->str, x->size); }
-
-#endif // CSVIEW_H_INCLUDED
/* -------------------------- IMPLEMENTATION ------------------------- */
#ifndef CSVIEW_C_INCLUDED
@@ -203,8 +203,11 @@ csview csview_token(csview sv, const char* sep, intptr_t* start) {
}
#endif
#endif
-#undef i_opt
+#ifndef _i_no_undef
+#undef i_static
#undef i_header
#undef i_implement
-#undef i_static
#undef i_import
+#undef i_opt
+#endif
+#undef _i_no_undef
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index e853263b..d6c759eb 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -1,10 +1,11 @@
+#include "ccommon.h"
+
#ifndef UTF8_H_INCLUDED
#define UTF8_H_INCLUDED
#include <ctype.h>
#include "forward.h"
-#include "ccommon.h"
enum {
U8G_Cc, U8G_Lt, U8G_Nd, U8G_Nl,