mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04:00
xsnprintf: various improvements related to xvsnprintf() and xsnprintf()
Summary of changes:
* Make xvsnprintf() static
* restrict-qualify pointer arguments (as done by the libc equivalents)
* Make comments and spec references more thorough
* Remove pointless `n <= INT_MAX` assertion (see comment)
* Use FATAL_ERROR() instead of xassert() (since the assertion is inside
a shared util function but the caller is responsible for ensuring the
condition holds true)
* Change some callers to use size_t instead of int for the return value
(negative returns are impossible and all subsequent uses are size_t)
The updated comments and code were taken (and adapted) from:
49260bb154/src/util/xsnprintf.c (L6-50)
This work was entirely authored by me and I hereby license this
contribution under the MIT license (stated explicitly, so that
there's no ambiguity w.r.t. the original license).
This commit is contained in:
parent
31f88e636c
commit
d4a1283797
8 changed files with 54 additions and 35 deletions
|
|
@ -4302,7 +4302,7 @@ term_send_size_notification(struct terminal *term)
|
|||
const int width = term->width - term->margins.left - term->margins.right;
|
||||
|
||||
char buf[128];
|
||||
const int n = xsnprintf(
|
||||
const size_t n = xsnprintf(
|
||||
buf, sizeof(buf), "\033[48;%d;%d;%d;%dt",
|
||||
term->rows, term->cols, height, width);
|
||||
term_to_slave(term, buf, n);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue