From 4f93f935dc7a981ca073a322425c3f5929ffb644 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 21 Jan 2024 03:03:58 +0100 Subject: Support line- & column-based match locations --- vendor/librune/lib/utf8/u8set.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 vendor/librune/lib/utf8/u8set.c (limited to 'vendor/librune/lib/utf8/u8set.c') diff --git a/vendor/librune/lib/utf8/u8set.c b/vendor/librune/lib/utf8/u8set.c new file mode 100644 index 0000000..0dfba2c --- /dev/null +++ b/vendor/librune/lib/utf8/u8set.c @@ -0,0 +1,24 @@ +#include + +#include "utf8.h" + +#include "internal/common.h" + +size_t +u8set(const char8_t *s, rune ch, size_t n) +{ + int m; + char8_t buf[U8_LEN_MAX]; + + if (n == 0) + return 0; + if (ch <= _1B_MAX) { + memset((char *)s, ch, n); + return n; + } + m = rtou8(buf, ch, sizeof(buf)); + for (size_t i = 0; i < n; i += m) + memcpy((char *)s + i, buf, m); + + return n - n % m; +} -- cgit v1.2.3