aboutsummaryrefslogtreecommitdiff
path: root/include/mbstring.h
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-04-27 20:56:32 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-04-27 20:56:32 +0200
commit88a5a75f7620ec29143e73493143bca4b8800225 (patch)
treef0a2e91ca290ce1d78b9732850c9525b1c8f6dd0 /include/mbstring.h
parent95c062edfa87cda142cc617bb0b4e21a644f4a15 (diff)
Rename U8V() to U8(), and handle U8(nullptr)
Diffstat (limited to 'include/mbstring.h')
-rw-r--r--include/mbstring.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/mbstring.h b/include/mbstring.h
index b6a769c..e487da5 100644
--- a/include/mbstring.h
+++ b/include/mbstring.h
@@ -8,7 +8,10 @@
#include "_rune.h"
#include "_u8view.h"
-#define U8V(s) ((struct u8view){.p = (s), .len = sizeof(s) - 1})
+#define U8(s) \
+ _Generic((s), \
+ nullptr_t: ((struct u8view){}), \
+ default: ((struct u8view){.p = (s), .len = sizeof(s) - 1}))
#define U8_ARGS(s) ((s).p), ((s).len)
#define U8_ARGSP(s) (&(s).p), (&(s).len)