[libvirt] [PATCH] virBuffer: add way to trim back extra text
Eric Blake
eblake at redhat.com
Mon May 21 22:07:45 UTC 2012
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 one to write:
>>
>> while (...)
>> virBufferAsprintf(buf, "%s,", str);
>> virBufferTrim(buf, ",", -1);
>>
>> to trim any remaining comma.
>>
>
> ACK, interesting addition :-) Code looks fine,
Thanks; pushed.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120521/d5d1e420/attachment-0001.sig>
More information about the libvir-list
mailing list