diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 12:31:21 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 12:31:21 +0300 |
| commit | 212f1cc9109aa0deb9e5d990bb2dba2b167618fb (patch) | |
| tree | 0044818d9e12d602b4da3b6823d9997557e5cfae /src/gstore.c | |
| parent | 5f03033b0e211f9ed13e7a1351f9a8f9011ab665 (diff) | |
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
<term/term.h> 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 <term/term.h> 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 <noreply@anthropic.com>
Diffstat (limited to 'src/gstore.c')
| -rw-r--r-- | src/gstore.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/gstore.c b/src/gstore.c index d2bc57f..813ea7d 100644 --- a/src/gstore.c +++ b/src/gstore.c @@ -72,11 +72,11 @@ int term_gstore_expand(const struct gstore *g, uint32_t handle, uint32_t *cps, i { if (cap <= 0) return 0; - if (!g || !grapheme_is_handle(handle)) { + if (!g || !term_grapheme_is_handle(handle)) { cps[0] = handle; return 1; } - uint32_t idx = handle - GRAPHEME_HANDLE_BASE; + uint32_t idx = handle - TERM_GRAPHEME_HANDLE_BASE; if (idx >= g->entries_count || !g->entries[idx].allocated) { cps[0] = 0xFFFD; return 1; @@ -124,8 +124,8 @@ static bool grow_slots(struct gstore *g) struct gentry *e = &g->entries[i]; if (!e->allocated) continue; - uint32_t cps_buf[GRAPHEME_MAX_LEN]; - int n = term_gstore_expand(g, GRAPHEME_HANDLE_BASE + i, cps_buf, GRAPHEME_MAX_LEN); + uint32_t cps_buf[TERM_GRAPHEME_MAX_LEN]; + int n = term_gstore_expand(g, TERM_GRAPHEME_HANDLE_BASE + i, cps_buf, TERM_GRAPHEME_MAX_LEN); uint64_t h = hash_cps(cps_buf, n); uint32_t h32 = (uint32_t)h ? (uint32_t)h : 1; gstore_insert_slot(g, h32, i); @@ -147,7 +147,7 @@ static uint32_t gstore_find(const struct gstore *g, const uint32_t *cps, int n, uint32_t e_idx = slot->entry_idx - 1; const struct gentry *e = &g->entries[e_idx]; if (e->allocated && gentry_matches(g, e, cps, n)) - return GRAPHEME_HANDLE_BASE + e_idx; + return TERM_GRAPHEME_HANDLE_BASE + e_idx; } idx = (idx + 1) & mask; } @@ -193,9 +193,9 @@ void term_gstore_unpin(struct gstore *g) void term_gstore_mark(struct gstore *g, uint32_t handle) { - if (!g || !grapheme_is_handle(handle)) + if (!g || !term_grapheme_is_handle(handle)) return; - uint32_t idx = handle - GRAPHEME_HANDLE_BASE; + uint32_t idx = handle - TERM_GRAPHEME_HANDLE_BASE; if (idx < g->entries_count && g->entries[idx].allocated) g->entries[idx].mark = true; } @@ -204,7 +204,7 @@ static void sweep_mark_row(struct gstore *g, const struct cell *cells, int len) { for (int x = 0; x < len; x++) { uint32_t c = cells[x].c; - if (grapheme_is_handle(c)) + if (term_grapheme_is_handle(c)) term_gstore_mark(g, c); } } @@ -215,7 +215,7 @@ void term_gstore_sweep(struct gstore *g, struct term *t) return; if (t) { - if (grapheme_is_handle(t->last_char)) + if (term_grapheme_is_handle(t->last_char)) term_gstore_mark(g, t->last_char); struct screen *s = &t->scr; @@ -266,8 +266,8 @@ void term_gstore_sweep(struct gstore *g, struct term *t) live++; e->mark = false; if (g->slots) { - uint32_t cps_buf[GRAPHEME_MAX_LEN]; - int n = term_gstore_expand(g, GRAPHEME_HANDLE_BASE + i, cps_buf, GRAPHEME_MAX_LEN); + uint32_t cps_buf[TERM_GRAPHEME_MAX_LEN]; + int n = term_gstore_expand(g, TERM_GRAPHEME_HANDLE_BASE + i, cps_buf, TERM_GRAPHEME_MAX_LEN); uint64_t h = hash_cps(cps_buf, n); uint32_t h32 = (uint32_t)h ? (uint32_t)h : 1; gstore_insert_slot(g, h32, i); @@ -300,8 +300,8 @@ uint32_t term_gstore_intern(struct gstore *g, const uint32_t *cps, int n) return 0; if (n == 1) return cps[0]; - if (n > GRAPHEME_MAX_LEN) - n = GRAPHEME_MAX_LEN; + if (n > TERM_GRAPHEME_MAX_LEN) + n = TERM_GRAPHEME_MAX_LEN; uint64_t h = hash_cps(cps, n); uint32_t h32 = (uint32_t)h ? (uint32_t)h : 1; @@ -375,5 +375,5 @@ uint32_t term_gstore_intern(struct gstore *g, const uint32_t *cps, int n) gstore_insert_slot(g, h32, entry_idx); g->live_count++; - return GRAPHEME_HANDLE_BASE + entry_idx; + return TERM_GRAPHEME_HANDLE_BASE + entry_idx; } |
