From 3280656d497dd487ff7571954baeeb1608e5a40e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 2 Mar 2026 07:06:48 +0200 Subject: inf: take window size into account foundation before truncating of pwd. --- lib/str.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/str.h b/lib/str.h index d9451a9..7e90bb0 100644 --- a/lib/str.h +++ b/lib/str.h @@ -113,7 +113,7 @@ str_memset(str *s, int c, usize n) s->l += n; } -static inline void +static inline usize str_push_u32_b(str *s, u32 v, u32 b, int c, usize l) { static const char d[] = "0123456789abcdef"; @@ -125,20 +125,22 @@ str_push_u32_b(str *s, u32 v, u32 b, int c, usize l) v /= b; } while (v); usize n = (usize)(&o[sizeof(o)] - p); - if (n < l) str_memset(s, c, l - n); + usize g = (n < l) ? l - n : 0; + if (g) str_memset(s, c, g); str_push(s, p, n); + return g + n; } -static inline void +static inline usize str_push_u32_p(str *s, u32 v, int c, usize l) { - str_push_u32_b(s, v, 10, c, l); + return str_push_u32_b(s, v, 10, c, l); } -static inline void +static inline usize str_push_u32(str *s, u32 v) { - str_push_u32_p(s, v, 0, 0); + return str_push_u32_p(s, v, 0, 0); } static inline void -- cgit v1.2.3