summaryrefslogtreecommitdiff
path: root/include/al/wstr.h
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-04-09 09:49:33 -0400
committerAndrew Opalach <andrew@akon.city> 2026-04-09 09:49:33 -0400
commitabe21ac46759ffef041e52310a17552f36ee9297 (patch)
tree30abd744c7e0faea126a7b6fdf330eddc0e4280c /include/al/wstr.h
parentb5b765781482a7b3ff6026ea71b4eb35a0a155d0 (diff)
downloadlibalabaster-abe21ac46759ffef041e52310a17552f36ee9297.tar.gz
libalabaster-abe21ac46759ffef041e52310a17552f36ee9297.tar.bz2
libalabaster-abe21ac46759ffef041e52310a17552f36ee9297.zip
lib: Add strscmp() for static char arrays
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'include/al/wstr.h')
-rw-r--r--include/al/wstr.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/al/wstr.h b/include/al/wstr.h
index 8af16be..e5610a2 100644
--- a/include/al/wstr.h
+++ b/include/al/wstr.h
@@ -12,6 +12,8 @@ typedef struct {
wchar_t *__sized_by(alloc) data;
} wstr;
+#define AL_WIDE_CHARS_IF_LITERAL(wc) ((wchar_t *)(L"" wc L"")) // Use al_wstr_cs/r for non-static char arrays.
+
#define AL_WSTR_NO_POS ((u32)-1)
#define al_wstr_null() ((wstr){ 0, 0, NULL })
@@ -19,8 +21,7 @@ typedef struct {
#define al_wstr_at(w, index) (w)->data[index]
#define al_wstr_atr(w, index) (w)->data[(w)->length - (index)]
-#define al_wide_chars_if_literal(wc) ((wchar_t *)(L"" wc L"")) // use al_wstr_cs/r for non-static arrays.
-#define al_wstr_c(wc) ((wstr){ (u32)((sizeof(wc) / sizeof(wchar_t)) - 1), 0, al_wide_chars_if_literal(wc) })
+#define al_wstr_c(wc) ((wstr){ (u32)((sizeof(wc) / sizeof(wchar_t)) - 1), 0, AL_WIDE_CHARS_IF_LITERAL(wc) })
#define al_wstr_cs(wc) ((wstr){ (u32)al_wcsnlen(wc, sizeof(wc) / sizeof(wchar_t)), 0, ((wchar_t *)(wc)) }) // (s)ized
#define al_wstr_cr(wc) ((wstr){ (u32)al_wcsnlen(wc, MAX_ALLOC_32 / sizeof(wchar_t)), 0, ((wchar_t *)(wc)) }) // (r)untime