summaryrefslogtreecommitdiff
path: root/xs_unicode.h
diff options
context:
space:
mode:
authorGravatar default2024-04-14 19:26:49 +0200
committerGravatar default2024-04-14 19:26:49 +0200
commit0275658a3602f74035ff776dac8d8f64b9a2794f (patch)
treed9489684e46d7cd0d5bd8347a880316abe22f48f /xs_unicode.h
parentBetter redirection URL building in oauth_post_handler(). (diff)
downloadsnac2-0275658a3602f74035ff776dac8d8f64b9a2794f.tar.gz
snac2-0275658a3602f74035ff776dac8d8f64b9a2794f.tar.xz
snac2-0275658a3602f74035ff776dac8d8f64b9a2794f.zip
Backport from xs.
Diffstat (limited to '')
-rw-r--r--xs_unicode.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/xs_unicode.h b/xs_unicode.h
index 47e1101..6654da4 100644
--- a/xs_unicode.h
+++ b/xs_unicode.h
@@ -27,8 +27,8 @@
27 27
28#ifdef XS_IMPLEMENTATION 28#ifdef XS_IMPLEMENTATION
29 29
30#ifndef countof 30#ifndef xs_countof
31#define countof(a) (sizeof((a)) / sizeof((*a))) 31#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
32#endif 32#endif
33 33
34int _xs_utf8_enc(char buf[4], unsigned int cpoint) 34int _xs_utf8_enc(char buf[4], unsigned int cpoint)
@@ -125,7 +125,7 @@ int xs_unicode_width(unsigned int cpoint)
125/* returns the width in columns of a Unicode codepoint (somewhat simplified) */ 125/* returns the width in columns of a Unicode codepoint (somewhat simplified) */
126{ 126{
127 int b = 0; 127 int b = 0;
128 int t = countof(xs_unicode_width_table) / 3 - 1; 128 int t = xs_countof(xs_unicode_width_table) / 3 - 1;
129 129
130 while (t >= b) { 130 while (t >= b) {
131 int n = (b + t) / 2; 131 int n = (b + t) / 2;
@@ -193,7 +193,7 @@ unsigned int *_xs_unicode_upper_search(unsigned int cpoint)
193/* searches for an uppercase codepoint in the case fold table */ 193/* searches for an uppercase codepoint in the case fold table */
194{ 194{
195 int b = 0; 195 int b = 0;
196 int t = countof(xs_unicode_case_fold_table) / 2 + 1; 196 int t = xs_countof(xs_unicode_case_fold_table) / 2 + 1;
197 197
198 while (t >= b) { 198 while (t >= b) {
199 int n = (b + t) / 2; 199 int n = (b + t) / 2;
@@ -216,7 +216,7 @@ unsigned int *_xs_unicode_lower_search(unsigned int cpoint)
216/* searches for a lowercase codepoint in the case fold table */ 216/* searches for a lowercase codepoint in the case fold table */
217{ 217{
218 unsigned int *p = xs_unicode_case_fold_table; 218 unsigned int *p = xs_unicode_case_fold_table;
219 unsigned int *e = p + countof(xs_unicode_case_fold_table); 219 unsigned int *e = p + xs_countof(xs_unicode_case_fold_table);
220 220
221 while (p < e) { 221 while (p < e) {
222 if (cpoint == p[1]) 222 if (cpoint == p[1])
@@ -251,7 +251,7 @@ int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac)
251/* applies unicode Normalization Form D */ 251/* applies unicode Normalization Form D */
252{ 252{
253 int b = 0; 253 int b = 0;
254 int t = countof(xs_unicode_nfd_table) / 3 - 1; 254 int t = xs_countof(xs_unicode_nfd_table) / 3 - 1;
255 255
256 while (t >= b) { 256 while (t >= b) {
257 int n = (b + t) / 2; 257 int n = (b + t) / 2;
@@ -279,7 +279,7 @@ int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint)
279/* applies unicode Normalization Form C */ 279/* applies unicode Normalization Form C */
280{ 280{
281 unsigned int *p = xs_unicode_nfd_table; 281 unsigned int *p = xs_unicode_nfd_table;
282 unsigned int *e = p + countof(xs_unicode_nfd_table); 282 unsigned int *e = p + xs_countof(xs_unicode_nfd_table);
283 283
284 while (p < e) { 284 while (p < e) {
285 if (p[1] == base && p[2] == diac) { 285 if (p[1] == base && p[2] == diac) {
@@ -298,7 +298,7 @@ int xs_unicode_is_alpha(unsigned int cpoint)
298/* checks if a codepoint is an alpha (i.e. a letter) */ 298/* checks if a codepoint is an alpha (i.e. a letter) */
299{ 299{
300 int b = 0; 300 int b = 0;
301 int t = countof(xs_unicode_alpha_table) / 2 - 1; 301 int t = xs_countof(xs_unicode_alpha_table) / 2 - 1;
302 302
303 while (t >= b) { 303 while (t >= b) {
304 int n = (b + t) / 2; 304 int n = (b + t) / 2;