From 212f1cc9109aa0deb9e5d990bb2dba2b167618fb Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 12:31:21 +0300 Subject: Keep installed headers from shadowing or polluting host names The pkg-config file put include/term on the host's include path, so ncurses' term.h could be picked up in place of ours. Hosts now write and the package adds only its include directory. The installed Unicode API had unprefixed names that collide with host symbols and macros. Rename them: term_ for functions, types, and static tables, TERM_ for macros and include guards. unicode_data.inc and tools/generate_unicode.py are renamed to match. The generator's inputs here are Unicode 15.1 and the checked-in table is 18.0.0, so the table data was not regenerated. Only the declarations were checked against the generator. utf8.h casts the malloc result so it compiles as C++. header_test.sh now includes with only include/ on the path. It also checks that a host which defines unicode_width, UTF8_ACCEPT, GRAPHEME_MAX_LEN, in_ranges, and similar names compiles with the Unicode headers as C11 and C++, in both declaration orders. Co-Authored-By: Claude Haiku 5.5 --- tests/gstore_test.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/gstore_test.c') diff --git a/tests/gstore_test.c b/tests/gstore_test.c index 637b136..ea582f3 100644 --- a/tests/gstore_test.c +++ b/tests/gstore_test.c @@ -32,7 +32,7 @@ static void test_direct_unit(void) /* Cluster returns a handle. */ uint32_t c1[2] = { 'e', 0x0301 }; uint32_t h1 = term_gstore_intern(g, c1, 2); - assert(grapheme_is_handle(h1)); + assert(term_grapheme_is_handle(h1)); assert(term_gstore_count(g) == 1); /* Identical cluster deduplicates to the same handle. */ @@ -43,17 +43,17 @@ static void test_direct_unit(void) /* Different cluster gets a distinct handle. */ uint32_t c2[2] = { 'a', 0x0300 }; uint32_t h2 = term_gstore_intern(g, c2, 2); - assert(grapheme_is_handle(h2)); + assert(term_grapheme_is_handle(h2)); assert(h2 != h1); assert(term_gstore_count(g) == 2); /* Expand both handles. */ - uint32_t out[GRAPHEME_MAX_LEN] = {0}; - int n = term_gstore_expand(g, h1, out, GRAPHEME_MAX_LEN); + uint32_t out[TERM_GRAPHEME_MAX_LEN] = {0}; + int n = term_gstore_expand(g, h1, out, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(out[0] == 'e' && out[1] == 0x0301); - n = term_gstore_expand(g, h2, out, GRAPHEME_MAX_LEN); + n = term_gstore_expand(g, h2, out, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(out[0] == 'a' && out[1] == 0x0300); @@ -63,20 +63,20 @@ static void test_direct_unit(void) assert(term_gstore_count(g) == 1); /* h1 is still valid. */ - n = term_gstore_expand(g, h1, out, GRAPHEME_MAX_LEN); + n = term_gstore_expand(g, h1, out, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(out[0] == 'e' && out[1] == 0x0301); /* h2 was reclaimed. */ - n = term_gstore_expand(g, h2, out, GRAPHEME_MAX_LEN); + n = term_gstore_expand(g, h2, out, TERM_GRAPHEME_MAX_LEN); assert(n == 1 && out[0] == 0xFFFD); /* New cluster can reuse the reclaimed slot. */ uint32_t c3[3] = { 'o', 0x0308, 0x0301 }; uint32_t h3 = term_gstore_intern(g, c3, 3); - assert(grapheme_is_handle(h3)); + assert(term_grapheme_is_handle(h3)); assert(term_gstore_count(g) == 2); - n = term_gstore_expand(g, h3, out, GRAPHEME_MAX_LEN); + n = term_gstore_expand(g, h3, out, TERM_GRAPHEME_MAX_LEN); assert(n == 3); assert(out[0] == 'o' && out[1] == 0x0308 && out[2] == 0x0301); @@ -105,8 +105,8 @@ static void test_two_terminals_isolation(void) const struct term_cell *row = term_snapshot_row(snap, 0); assert(row[0].text & TERM_TEXT_CLUSTER); - uint32_t cps[GRAPHEME_MAX_LEN] = {0}; - int n = term_snapshot_cluster(snap, row[0].text, cps, GRAPHEME_MAX_LEN); + uint32_t cps[TERM_GRAPHEME_MAX_LEN] = {0}; + int n = term_snapshot_cluster(snap, row[0].text, cps, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(cps[0] == 'e' && cps[1] == 0x0301); @@ -143,16 +143,16 @@ static void test_screen_clusters_survive_sweep(void) const struct term_cell *row = term_snapshot_row(snap, 0); assert(row[0].text & TERM_TEXT_CLUSTER); - uint32_t cps[GRAPHEME_MAX_LEN] = {0}; - int n = term_snapshot_cluster(snap, row[0].text, cps, GRAPHEME_MAX_LEN); + uint32_t cps[TERM_GRAPHEME_MAX_LEN] = {0}; + int n = term_snapshot_cluster(snap, row[0].text, cps, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(cps[0] == 'a' && cps[1] == 0x0300); - n = term_snapshot_cluster(snap, row[1].text, cps, GRAPHEME_MAX_LEN); + n = term_snapshot_cluster(snap, row[1].text, cps, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(cps[0] == 'b' && cps[1] == 0x0301); - n = term_snapshot_cluster(snap, row[2].text, cps, GRAPHEME_MAX_LEN); + n = term_snapshot_cluster(snap, row[2].text, cps, TERM_GRAPHEME_MAX_LEN); assert(n == 2); assert(cps[0] == 'c' && cps[1] == 0x0302); @@ -183,8 +183,8 @@ static void test_more_than_65536_clusters(void) size_t len = 0; buf[len++] = base; - len += (size_t)utf8_encode(cp1, buf + len); - len += (size_t)utf8_encode(cp2, buf + len); + len += (size_t)term_utf8_encode(cp1, buf + len); + len += (size_t)term_utf8_encode(cp2, buf + len); buf[len++] = '\r'; buf[len++] = '\n'; @@ -204,8 +204,8 @@ static void test_more_than_65536_clusters(void) const struct term_cell *row = term_snapshot_row(snap, y); assert(row[0].text & TERM_TEXT_CLUSTER); - uint32_t cps[GRAPHEME_MAX_LEN] = {0}; - int n = term_snapshot_cluster(snap, row[0].text, cps, GRAPHEME_MAX_LEN); + uint32_t cps[TERM_GRAPHEME_MAX_LEN] = {0}; + int n = term_snapshot_cluster(snap, row[0].text, cps, TERM_GRAPHEME_MAX_LEN); assert(n == 3); /* Live cluster count must be small (only bounded screen and history). */ -- cgit v1.2.3