MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_bisearch

Function xo_bisearch

tools/libxo/libxo/xo_wcwidth.h:70–89  ·  view source on GitHub ↗

auxiliary function for binary search in interval table */

Source from the content-addressed store, hash-verified

68
69/* auxiliary function for binary search in interval table */
70static int
71xo_bisearch (wchar_t ucs, const struct interval *table, int max)
72{
73 int min = 0;
74 int mid;
75
76 if (ucs < table[0].first || ucs > table[max].last)
77 return 0;
78 while (max >= min) {
79 mid = (min + max) / 2;
80 if (ucs > table[mid].last)
81 min = mid + 1;
82 else if (ucs < table[mid].first)
83 max = mid - 1;
84 else
85 return 1;
86 }
87
88 return 0;
89}
90
91
92/* The following two functions define the column width of an ISO 10646

Callers 2

xo_wcwidthFunction · 0.85
mk_wcwidth_cjkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected