diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/meson.build | 6 | ||||
| -rw-r--r-- | src/screen.c | 3 | ||||
| -rw-r--r-- | src/snapshot.c | 14 | ||||
| -rw-r--r-- | src/term.c | 5 |
4 files changed, 22 insertions, 6 deletions
diff --git a/src/meson.build b/src/meson.build index 694ee0e..7223caa 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,9 @@ subdir('osc') +# The SONAME carries the major version. An ABI break bumps it, so an old +# binary keeps the old library. +term_soversion = meson.project_version().split('.')[0] + # The x86-64 SIMD kernels pick their level at run time (see simd.h), so the # library needs no ISA flags. -march in c_args sets the lowest level. term_lib = both_libraries('term', @@ -23,6 +27,8 @@ term_lib = both_libraries('term', include_directories: term_private_inc, dependencies: [m_dep], gnu_symbol_visibility: 'hidden', + version: meson.project_version(), + soversion: term_soversion, install: true ) diff --git a/src/screen.c b/src/screen.c index 697e08a..ab912a1 100644 --- a/src/screen.c +++ b/src/screen.c @@ -846,6 +846,9 @@ struct term *term_new(const struct term_options *opt) static const struct term_options defaults; if (!opt) opt = &defaults; + for (size_t i = 0; i < sizeof(opt->reserved) / sizeof(opt->reserved[0]); i++) + if (opt->reserved[i]) + return NULL; if (opt->size.x < 0 || opt->size.y < 0 || opt->size.x > TERM_MAX_COLS) return NULL; if (opt->scrollback < 0 || (unsigned)opt->cursor_style > TERM_CURSOR_BAR) diff --git a/src/snapshot.c b/src/snapshot.c index 8dbb498..c578f18 100644 --- a/src/snapshot.c +++ b/src/snapshot.c @@ -314,34 +314,36 @@ bool term_snapshot_update(struct term_snapshot *s, struct term *t) const struct term_view *term_snapshot_view(const struct term_snapshot *s) { - return &s->view; + return s ? &s->view : NULL; } const struct term_cell *term_snapshot_row(const struct term_snapshot *s, int y) { - if (y < 0 || y >= s->view.size.y) + if (!s || y < 0 || y >= s->view.size.y) return NULL; return s->cells + (size_t)y * s->view.size.x; } uint64_t term_snapshot_row_key(const struct term_snapshot *s, int y) { - if (y < 0 || y >= s->view.size.y) + if (!s || y < 0 || y >= s->view.size.y) return 0; return s->keys[y]; } struct term_span term_snapshot_row_selection(const struct term_snapshot *s, int y) { - if (y < 0 || y >= s->view.size.y) + if (!s || y < 0 || y >= s->view.size.y) return (struct term_span){ 0 }; return s->selection[y]; } int term_snapshot_cluster(const struct term_snapshot *s, uint32_t text, uint32_t *cps, int cap) { + if (!s) + return 0; if (!(text & TERM_TEXT_CLUSTER)) { - if (cap > 0) + if (cps && cap > 0) cps[0] = text; return 1; } @@ -350,7 +352,7 @@ int term_snapshot_cluster(const struct term_snapshot *s, uint32_t text, uint32_t return 0; int n = (int)s->arena[off]; int copy = n < cap ? n : cap; - if (copy > 0) + if (cps && copy > 0) memcpy(cps, &s->arena[off + 1], (size_t)copy * sizeof(*cps)); return n; } @@ -8,6 +8,11 @@ const char *term_unicode_version(void) return UNICODE_DATA_VERSION; } +unsigned term_version(void) +{ + return TERM_VERSION_CODE; +} + void term_lock(struct term *t) { term_write_begin(t); |
