aboutsummaryrefslogtreecommitdiff
path: root/lib/bob/u8strpushr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bob/u8strpushr.c')
-rw-r--r--lib/bob/u8strpushr.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bob/u8strpushr.c b/lib/bob/u8strpushr.c
new file mode 100644
index 0000000..6fe5fd9
--- /dev/null
+++ b/lib/bob/u8strpushr.c
@@ -0,0 +1,11 @@
+#include "bob.h"
+#include "mbstring.h"
+
+struct u8str *
+u8strpushr(struct u8str *b, rune ch)
+{
+ if (!u8strgrow(b, b->len + rtou8(nullptr, ch, 0)))
+ return nullptr;
+ b->len += rtou8(b->p + b->len, ch, b->cap - b->len);
+ return b;
+}