File: iswspace.c

package info (click to toggle)
dictd 1.13.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 3,920 kB
  • sloc: ansic: 12,523; sh: 4,406; yacc: 512; makefile: 442; cpp: 277; lex: 256; perl: 175; awk: 12
file content (42 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "dictP.h"

static const wint_t start [] = {
     0,
     9,    32,  5760,  8192,  8200,  8232, 12288,
};

static int count [] = {
     0,
     5,     1,     1,     7,     4,     2,     1,
};

#define ARRAY_SIZE (sizeof (start) / sizeof (start [0]))

extern int iswspace__ (wint_t wc);

int iswspace__ (wint_t wc)
{
   const wint_t *l = start;
   const wint_t *r = start + ARRAY_SIZE;
   const wint_t *s = NULL;

   if (wc == WEOF)
      return 0;

   while (l < r) {
      s = l + ((r - l) >> 1);

      if (*s <= wc){
	 l = s + 1;
      }else{
	 r = s;
      }
   }

   --l;

   if (wc < l [0] + count [l - start])
      return 1;
   else
      return 0;
}