summaryrefslogtreecommitdiff
path: root/tests/model.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 12:31:21 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 12:31:21 +0300
commit212f1cc9109aa0deb9e5d990bb2dba2b167618fb (patch)
tree0044818d9e12d602b4da3b6823d9997557e5cfae /tests/model.c
parent5f03033b0e211f9ed13e7a1351f9a8f9011ab665 (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 'tests/model.c')
-rw-r--r--tests/model.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/model.c b/tests/model.c
index 8dead6c..7934d4f 100644
--- a/tests/model.c
+++ b/tests/model.c
@@ -31,7 +31,7 @@
#define STR_KEEP 1024
struct cell {
- uint32_t cp[GRAPHEME_MAX_LEN];
+ uint32_t cp[TERM_GRAPHEME_MAX_LEN];
uint8_t n, width;
uint16_t attrs;
term_color fg, bg;
@@ -98,7 +98,7 @@ struct model {
bool tabs[MAX_TABS];
struct keyboard keyboard[2];
/* The last printed glyph, for REP and cluster joins. */
- uint32_t last[GRAPHEME_MAX_LEN];
+ uint32_t last[TERM_GRAPHEME_MAX_LEN];
int last_n;
int prompt; /* screen row of the last OSC 133;A, or -1 */
unsigned flags;
@@ -158,7 +158,7 @@ static bool pristine(const struct model *m)
static bool is_ri(uint32_t cp)
{
- return cp - 0x1F1E6u <= 0x19u && grapheme_regional_indicator(cp);
+ return cp - 0x1F1E6u <= 0x19u && term_grapheme_regional_indicator(cp);
}
/* ---- replies ---- */
@@ -417,13 +417,13 @@ static void fill_gap(struct row *r, int x)
static uint16_t presentation(const uint32_t *cps, int n)
{
- bool pictographic = unicode_extended_pictographic(cps[0]);
+ bool pictographic = term_unicode_extended_pictographic(cps[0]);
bool emoji = false;
for (int i = 1; i < n; i++) {
if (cps[i] == 0xFE0F) return TERM_ATTR_EMOJI;
if (cps[i] == 0xFE0E) return TERM_ATTR_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;
}
@@ -443,7 +443,7 @@ static void put_glyph(struct model *m, const uint32_t *cps, int n, uint16_t attr
{
if (n > 1)
attrs = (uint16_t)((attrs & ~(TERM_ATTR_EMOJI | TERM_ATTR_TEXT)) | presentation(cps, n));
- int width = unicode_width(cps[0]) == 2 ? 2 : 1;
+ int width = term_unicode_width(cps[0]) == 2 ? 2 : 1;
if (attrs & TERM_ATTR_EMOJI) width = 2;
if (attrs & TERM_ATTR_TEXT) width = 1;
if (m->pending) wrap_to_next_row(m);
@@ -495,14 +495,14 @@ static void put_glyph(struct model *m, const uint32_t *cps, int n, uint16_t attr
static bool joins(uint32_t cp, int width)
{
if (cp < 0x300) return false;
- return width == 0 || grapheme_emoji_modifier(cp) ||
- (width == 1 && unicode_spacing_mark(cp));
+ return width == 0 || term_grapheme_emoji_modifier(cp) ||
+ (width == 1 && term_unicode_spacing_mark(cp));
}
static bool cluster_joins(const uint32_t *cps, int n, uint32_t cp, int width)
{
if (joins(cp, width)) return true;
- if (cps[n - 1] == 0x200D) return unicode_extended_pictographic(cp);
+ if (cps[n - 1] == 0x200D) return term_unicode_extended_pictographic(cp);
return n == 1 && is_ri(cp) && is_ri(cps[0]);
}
@@ -527,10 +527,10 @@ static bool extend_cluster(struct model *m, uint32_t cp, int width)
return joins(cp, width);
if (!cluster_joins(prev->cp, prev->n, cp, width))
return false;
- if (prev->n >= GRAPHEME_MAX_LEN)
+ if (prev->n >= TERM_GRAPHEME_MAX_LEN)
return true;
struct cell old = *prev;
- uint32_t cps[GRAPHEME_MAX_LEN];
+ uint32_t cps[TERM_GRAPHEME_MAX_LEN];
memcpy(cps, old.cp, (size_t)old.n * sizeof(*cps));
cps[old.n] = cp;
int n = old.n + 1;
@@ -590,7 +590,7 @@ static void print_cp(struct model *m, uint32_t cp)
emit(m, cp);
return;
}
- int width = unicode_width(cp);
+ int width = term_unicode_width(cp);
if (!extend_cluster(m, cp, width))
emit(m, cp);
}