On 2.9.2022 23.38, NRK wrote:
`ssize_t` is bit of an exotic type. by POSIX, it's only guaranteed to be
able to hold {-1, SSIZE_MAX} [0], meaning that negative values less than
-1 isn't guaranteed to representable in `ssize_t` (though it works out
in practice).
by default `ctrl+u` will call `insert()` with `-cursor` which can be
lesser than `-1`. so just use `long` instead which doesn't have such
issues.
Could also use ptrdiff_t[0], although very likely long and ptrdiff_t are
the same type.
> @@ -540,7 +540,7 @@ paste(void)
> if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1,
False,
> utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
> == Success && p) {
> - insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
> + insert(p, (q = strchr(p, '\n')) ? q - p : (long)strlen(p));
The true-branch of this ternary would already have type ptrdiff_t, as it
is a substraction of pointers.
> XFree(p);
> }
> drawmenu();
[0]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html
--
Santtu