Re: [libvirt] [PATCH] virBuffer: add way to trim back extra text

2012-05-21 Thread Daniel Veillard
On Fri, May 18, 2012 at 04:42:36PM -0600, Eric Blake wrote: I'm tired of writing: bool sep = false; while (...) { if (sep) virBufferAddChar(buf, ','); sep = true; virBufferAdd(buf, str); } This makes it easier, allowing one to write: while (...)

Re: [libvirt] [PATCH] virBuffer: add way to trim back extra text

2012-05-21 Thread Eric Blake
On 05/21/2012 02:26 AM, Daniel Veillard wrote: On Fri, May 18, 2012 at 04:42:36PM -0600, Eric Blake wrote: I'm tired of writing: bool sep = false; while (...) { if (sep) virBufferAddChar(buf, ','); sep = true; virBufferAdd(buf, str); } This makes it easier, allowing

[libvirt] [PATCH] virBuffer: add way to trim back extra text

2012-05-18 Thread Eric Blake
I'm tired of writing: bool sep = false; while (...) { if (sep) virBufferAddChar(buf, ','); sep = true; virBufferAdd(buf, str); } This makes it easier, allowing one to write: while (...) virBufferAsprintf(buf, %s,, str); virBufferTrim(buf, ,, -1); to trim any remaining