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/core.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/core.c')
| -rw-r--r-- | src/core.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -16,13 +16,13 @@ static uint16_t cluster_presentation(const uint32_t *cps, int len) { if (len <= 1) return 0; - bool pictographic = unicode_extended_pictographic(cps[0]); + bool pictographic = term_unicode_extended_pictographic(cps[0]); if (len == 2) { uint32_t c1 = cps[1]; if (c1 == 0xFE0F) return CELL_EMOJI; if (c1 == 0xFE0E) return CELL_TEXT; - if (c1 == 0x20E3 || grapheme_regional_indicator(c1) || - (pictographic && (c1 == 0x200D || grapheme_emoji_modifier(c1) || + if (c1 == 0x20E3 || term_grapheme_regional_indicator(c1) || + (pictographic && (c1 == 0x200D || term_grapheme_emoji_modifier(c1) || (c1 >= 0xE0020 && c1 <= 0xE007F)))) return CELL_EMOJI; return 0; @@ -33,8 +33,8 @@ static uint16_t cluster_presentation(const uint32_t *cps, int len) return CELL_EMOJI; if (cps[i] == 0xFE0E) return CELL_TEXT; - if (cps[i] == 0x20E3 || grapheme_regional_indicator(cps[i]) || - (pictographic && (cps[i] == 0x200D || grapheme_emoji_modifier(cps[i]) || + if (cps[i] == 0x20E3 || term_grapheme_regional_indicator(cps[i]) || + (pictographic && (cps[i] == 0x200D || term_grapheme_emoji_modifier(cps[i]) || (cps[i] >= 0xE0020 && cps[i] <= 0xE007F)))) emoji = true; } @@ -44,9 +44,9 @@ static uint16_t cluster_presentation(const uint32_t *cps, int len) void term_sc_print_glyph(struct term *t, uint32_t cp, int width, uint16_t flags) { uint32_t base = cp; - if (TERM_EXPECT(grapheme_is_handle(cp), 0)) { - uint32_t cps[GRAPHEME_MAX_LEN]; - int len = term_gstore_expand(t->gstore, cp, cps, GRAPHEME_MAX_LEN); + if (TERM_EXPECT(term_grapheme_is_handle(cp), 0)) { + uint32_t cps[TERM_GRAPHEME_MAX_LEN]; + int len = term_gstore_expand(t->gstore, cp, cps, TERM_GRAPHEME_MAX_LEN); base = cps[0]; flags = (flags & ~(CELL_EMOJI | CELL_TEXT)) | cluster_presentation(cps, len); } @@ -179,13 +179,13 @@ bool term_sc_extend_cluster(struct term *t, uint32_t cp, int klass) return false; struct cell *prev = last_written_cell(t); - uint32_t cps[GRAPHEME_MAX_LEN]; - int len = prev && prev->c > ' ' ? term_gstore_expand(t->gstore, prev->c, cps, GRAPHEME_MAX_LEN) : 0; + uint32_t cps[TERM_GRAPHEME_MAX_LEN]; + int len = prev && prev->c > ' ' ? term_gstore_expand(t->gstore, prev->c, cps, TERM_GRAPHEME_MAX_LEN) : 0; if (!len) return joins_cluster(cp, klass); if (!cluster_joins(cps, len, cp, klass)) return false; - if (len >= GRAPHEME_MAX_LEN) + if (len >= TERM_GRAPHEME_MAX_LEN) return true; cps[len++] = cp; @@ -517,7 +517,7 @@ static inline bool next_byte_wraps(const char *buf, size_t len, size_t pos, uint { if (pos >= len) return false; uint32_t cp; - if (!utf8_decode_one(buf + pos, len - pos, &cp)) return false; + if (!term_utf8_decode_one(buf + pos, len - pos, &cp)) return false; int w = term_text_class(cp); return w > 0 && !can_extend_cluster(last, cp, w); } |
