libutf

UTF-8 library
git clone git://git.suckless.org/libutf
Log | Files | Refs | README | LICENSE

runetype.c (475B)


      1 #include <stdlib.h>
      2 #include "utf.h"
      3 
      4 #define nelem(x)  (sizeof (x) / sizeof *(x))
      5 
      6 static int rune1cmp(const void *, const void *);
      7 static int rune2cmp(const void *, const void *);
      8 
      9 #include "runetypebody.h"
     10 
     11 int
     12 rune1cmp(const void *v1, const void *v2)
     13 {
     14 	Rune r1 = *(Rune *)v1, r2 = *(Rune *)v2;
     15 
     16 	return r1 - r2;
     17 }
     18 
     19 int
     20 rune2cmp(const void *v1, const void *v2)
     21 {
     22 	Rune r = *(Rune *)v1, *p = (Rune *)v2;
     23 
     24 	if(r >= p[0] && r <= p[1])
     25 		return 0;
     26 	else
     27 		return r - p[0];
     28 }