summaryrefslogtreecommitdiffstats
path: root/utf8.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-07-21 08:01:19 +0100
committerThomas Adam <thomas@xteddy.org>2020-07-21 08:01:19 +0100
commit90de0c1a9b044d1c180f3a10399f5372e7a434ab (patch)
tree1cd183948da7a6b68eb972037979d7b9d9a46711 /utf8.c
parent70a674dde1346ec9317a71afb8751aead355e40e (diff)
parent743ab5728da1ce950a3782d5bc08831f61c5d744 (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 5ba41e9a..e640d845 100644
--- a/utf8.c
+++ b/utf8.c
@@ -353,6 +353,20 @@ utf8_stravis(char **dst, const char *src, int flag)
return (len);
}
+/* Same as utf8_strvis but allocate the buffer. */
+int
+utf8_stravisx(char **dst, const char *src, size_t srclen, int flag)
+{
+ char *buf;
+ int len;
+
+ buf = xreallocarray(NULL, 4, srclen + 1);
+ len = utf8_strvis(buf, src, srclen, flag);
+
+ *dst = xrealloc(buf, len + 1);
+ return (len);
+}
+
/* Does this string contain anything that isn't valid UTF-8? */
int
utf8_isvalid(const char *s)