xmlIndentTreeOutput = 1;
xmlbuf = xmlBufferCreate();
if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata,
- virBufferGetIndent(buf, false) / 2, 1) < 0) {
+ virBufferGetIndent(buf) / 2, 1) < 0) {
xmlBufferFree(xmlbuf);
xmlIndentTreeOutput = oldIndentTreeOutput;
goto error;
xmlIndentTreeOutput = 1;
xmlbuf = xmlBufferCreate();
if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata,
- virBufferGetIndent(buf, false) / 2, 1) < 0) {
+ virBufferGetIndent(buf) / 2, 1) < 0) {
xmlBufferFree(xmlbuf);
xmlIndentTreeOutput = oldIndentTreeOutput;
goto error;
/**
* virBufferGetIndent:
* @buf: the buffer
- * @dynamic: if false, return set value; if true, return 0 unless next
- * append would be affected by auto-indent
*
- * Return the current auto-indent value, or -1 if there has been an error.
+ * Return the current auto-indent setting of @buf.
*/
-int
-virBufferGetIndent(const virBuffer *buf, bool dynamic)
+size_t
+virBufferGetIndent(const virBuffer *buf)
{
- if (!buf || buf->error)
- return -1;
- if (dynamic && buf->use && buf->content[buf->use - 1] != '\n')
- return 0;
return buf->indent;
}
* child buffer.
*/
#define virBufferSetChildIndent(childBuf_, parentBuf_) \
- virBufferSetIndent(childBuf_, virBufferGetIndent(parentBuf_, false) + 2)
+ virBufferSetIndent(childBuf_, virBufferGetIndent(parentBuf_) + 2)
-int virBufferGetIndent(const virBuffer *buf, bool dynamic);
+size_t virBufferGetIndent(const virBuffer *buf);
size_t virBufferGetEffectiveIndent(const virBuffer *buf);
void virBufferTrim(virBufferPtr buf, const char *trim, int len);
virBufferAddLit(debug, "(\n");
virBufferAdjustIndent(debug, 3);
- indent = virBufferGetIndent(debug, false);
+ indent = virBufferGetIndent(debug);
n = virJSONValueArraySize(members);
for (i = 0; i < n; i++) {
char *result = NULL;
int ret = 0;
- if (virBufferGetIndent(buf, false) != 0 ||
+ if (virBufferGetIndent(buf) != 0 ||
virBufferGetEffectiveIndent(buf) != 0) {
VIR_TEST_DEBUG("Wrong indentation");
ret = -1;
VIR_TEST_DEBUG("Wrong content");
ret = -1;
}
- if (virBufferGetIndent(buf, false) != 3 ||
+ if (virBufferGetIndent(buf) != 3 ||
virBufferGetEffectiveIndent(buf) != 3 ||
virBufferError(buf)) {
VIR_TEST_DEBUG("Wrong indentation");
ret = -1;
}
virBufferAdjustIndent(buf, -2);
- if (virBufferGetIndent(buf, false) != 1 ||
+ if (virBufferGetIndent(buf) != 1 ||
virBufferGetEffectiveIndent(buf) != 1 ||
virBufferError(buf)) {
VIR_TEST_DEBUG("Wrong indentation");
ret = -1;
}
virBufferAdjustIndent(buf, -3);
- if (virBufferGetIndent(buf, false) != 0 ||
+ if (virBufferGetIndent(buf) != 0 ||
virBufferGetEffectiveIndent(buf) != 0) {
VIR_TEST_DEBUG("Indentation level not truncated");
ret = -1;
}
virBufferAdjustIndent(buf, 3);
virBufferFreeAndReset(buf);
- if (virBufferGetIndent(buf, false) != 0 ||
+ if (virBufferGetIndent(buf) != 0 ||
virBufferGetEffectiveIndent(buf) != 0 ||
virBufferError(buf)) {
VIR_TEST_DEBUG("Reset didn't clear indentation");
VIR_TEST_DEBUG("Wrong content");
ret = -1;
}
- if (virBufferGetIndent(buf, false) != 2 ||
+ if (virBufferGetIndent(buf) != 2 ||
virBufferGetEffectiveIndent(buf) != 0) {
VIR_TEST_DEBUG("Wrong indentation");
ret = -1;