From 184526f3bf90e2948b1d09b9da58d66814181f4d Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 15 Oct 2025 19:46:13 +0200 Subject: Import sam and samterm sources --- sam/util.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sam/util.c (limited to 'sam/util.c') diff --git a/sam/util.c b/sam/util.c new file mode 100644 index 0000000..b259968 --- /dev/null +++ b/sam/util.c @@ -0,0 +1,54 @@ +#include "sam.h" + +void +cvttorunes(char *p, int n, Rune *r, int *nb, int *nr, int *nulls) +{ + uchar *q; + Rune *s; + int j, w; + + /* + * Always guaranteed that n bytes may be interpreted + * without worrying about partial runes. This may mean + * reading up to UTFmax-1 more bytes than n; the caller + * knows this. If n is a firm limit, the caller should + * set p[n] = 0. + */ + q = (uchar*)p; + s = r; + for(j=0; j