[Bug 236935] libxo =text and XOF_FLUSH does not print the first value

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Apr 2 05:55:47 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236935

--- Comment #5 from Phil Shafer <phil at freebsd.org> ---
The fix is:

+++ b/libxo/xo_buf.h
@@ -114,7 +114,12 @@ static inline int
 xo_buf_has_room (xo_buffer_t *xbp, ssize_t len)
 {
     if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
-       ssize_t sz = xbp->xb_size + XO_BUFSIZ;
+       /*
+        * Find out how much new space we need, round it up to XO_BUFSIZ
+        */
+       ssize_t sz = (xbp->xb_curp + len) - xbp->xb_bufp;
+       sz = (sz + XO_BUFSIZ - 1) & ~(XO_BUFSIZ - 1);
+

Instead of rounding up to XO_BUFSIZ, I was just adding XO_BUFSIZ.  For large
strings, this obviously fails.

Thanks,
 Phil

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list