1 ed7c8e8d 2003-09-30 devnull #include "sam.h"
4 ed7c8e8d 2003-09-30 devnull cvttorunes(char *p, int n, Rune *r, int *nb, int *nr, int *nulls)
11 ed7c8e8d 2003-09-30 devnull * Always guaranteed that n bytes may be interpreted
12 ed7c8e8d 2003-09-30 devnull * without worrying about partial runes. This may mean
13 ed7c8e8d 2003-09-30 devnull * reading up to UTFmax-1 more bytes than n; the caller
14 ed7c8e8d 2003-09-30 devnull * knows this. If n is a firm limit, the caller should
15 ed7c8e8d 2003-09-30 devnull * set p[n] = 0.
17 ed7c8e8d 2003-09-30 devnull q = (uchar*)p;
19 ed7c8e8d 2003-09-30 devnull for(j=0; j<n; j+=w){
20 ed7c8e8d 2003-09-30 devnull if(*q < Runeself){
22 ed7c8e8d 2003-09-30 devnull *s = *q++;
24 ed7c8e8d 2003-09-30 devnull w = chartorune(s, (char*)q);
29 ed7c8e8d 2003-09-30 devnull else if(nulls)
30 ed7c8e8d 2003-09-30 devnull *nulls = TRUE;
32 ed7c8e8d 2003-09-30 devnull *nb = (char*)q-p;
33 ed7c8e8d 2003-09-30 devnull *nr = s-r;
37 ed7c8e8d 2003-09-30 devnull fbufalloc(void)
39 ed7c8e8d 2003-09-30 devnull return emalloc(BUFSIZE);
43 ed7c8e8d 2003-09-30 devnull fbuffree(void *f)
49 ed7c8e8d 2003-09-30 devnull min(uint a, uint b)
51 ed7c8e8d 2003-09-30 devnull if(a < b)
52 ed7c8e8d 2003-09-30 devnull return a;
53 ed7c8e8d 2003-09-30 devnull return b;