summaryrefslogtreecommitdiff
path: root/xs_unicode.h
diff options
context:
space:
mode:
authorLouis Brauer <louis77@noreply.codeberg.org>2024-05-25 08:05:36 +0000
committerLouis Brauer <louis77@noreply.codeberg.org>2024-05-25 08:05:36 +0000
commit84a767dd0878013194ed7551b5ae6ef715e841a6 (patch)
tree9fb1b2b89e0bfbb4b8bf1e85d840c8653e646bb7 /xs_unicode.h
parentcf5718bf4dedb85d2e1a1495f05bfc7e66124022 (diff)
parenta2920800007c291bdf2b5264622cbc713d4961ee (diff)
Merge pull request 'master' (#1) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/louis77/snac2/pulls/1
Diffstat (limited to 'xs_unicode.h')
-rw-r--r--xs_unicode.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/xs_unicode.h b/xs_unicode.h
index 47e1101..1799d89 100644
--- a/xs_unicode.h
+++ b/xs_unicode.h
@@ -6,7 +6,7 @@
int _xs_utf8_enc(char buf[4], unsigned int cpoint);
int xs_is_utf8_cont_byte(char c);
- unsigned int xs_utf8_dec(char **str);
+ unsigned int xs_utf8_dec(const char **str);
int xs_unicode_width(unsigned int cpoint);
int xs_is_surrogate(unsigned int cpoint);
unsigned int xs_surrogate_dec(unsigned int p1, unsigned int p2);
@@ -27,8 +27,8 @@
#ifdef XS_IMPLEMENTATION
-#ifndef countof
-#define countof(a) (sizeof((a)) / sizeof((*a)))
+#ifndef xs_countof
+#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
#endif
int _xs_utf8_enc(char buf[4], unsigned int cpoint)
@@ -66,10 +66,10 @@ int xs_is_utf8_cont_byte(char c)
}
-unsigned int xs_utf8_dec(char **str)
+unsigned int xs_utf8_dec(const char **str)
/* decodes an utf-8 char inside str and updates the pointer */
{
- char *p = *str;
+ const char *p = *str;
unsigned int cpoint = 0;
unsigned char c = *p++;
int cb = 0;
@@ -125,7 +125,7 @@ int xs_unicode_width(unsigned int cpoint)
/* returns the width in columns of a Unicode codepoint (somewhat simplified) */
{
int b = 0;
- int t = countof(xs_unicode_width_table) / 3 - 1;
+ int t = xs_countof(xs_unicode_width_table) / 3 - 1;
while (t >= b) {
int n = (b + t) / 2;
@@ -193,7 +193,7 @@ unsigned int *_xs_unicode_upper_search(unsigned int cpoint)
/* searches for an uppercase codepoint in the case fold table */
{
int b = 0;
- int t = countof(xs_unicode_case_fold_table) / 2 + 1;
+ int t = xs_countof(xs_unicode_case_fold_table) / 2 + 1;
while (t >= b) {
int n = (b + t) / 2;
@@ -216,7 +216,7 @@ unsigned int *_xs_unicode_lower_search(unsigned int cpoint)
/* searches for a lowercase codepoint in the case fold table */
{
unsigned int *p = xs_unicode_case_fold_table;
- unsigned int *e = p + countof(xs_unicode_case_fold_table);
+ unsigned int *e = p + xs_countof(xs_unicode_case_fold_table);
while (p < e) {
if (cpoint == p[1])
@@ -251,7 +251,7 @@ int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac)
/* applies unicode Normalization Form D */
{
int b = 0;
- int t = countof(xs_unicode_nfd_table) / 3 - 1;
+ int t = xs_countof(xs_unicode_nfd_table) / 3 - 1;
while (t >= b) {
int n = (b + t) / 2;
@@ -279,7 +279,7 @@ int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint)
/* applies unicode Normalization Form C */
{
unsigned int *p = xs_unicode_nfd_table;
- unsigned int *e = p + countof(xs_unicode_nfd_table);
+ unsigned int *e = p + xs_countof(xs_unicode_nfd_table);
while (p < e) {
if (p[1] == base && p[2] == diac) {
@@ -298,7 +298,7 @@ int xs_unicode_is_alpha(unsigned int cpoint)
/* checks if a codepoint is an alpha (i.e. a letter) */
{
int b = 0;
- int t = countof(xs_unicode_alpha_table) / 2 - 1;
+ int t = xs_countof(xs_unicode_alpha_table) / 2 - 1;
while (t >= b) {
int n = (b + t) / 2;