]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
provide default yaml indent
authorMark Andrews <marka@isc.org>
Mon, 25 Nov 2019 04:28:51 +0000 (15:28 +1100)
committerOndřej Surý <ondrej@isc.org>
Tue, 26 Nov 2019 12:52:30 +0000 (13:52 +0100)
lib/dns/masterdump.c

index 309beddf7b03ed09813f24abe918693bffe0a977..f8c3b122062af8a157f72af9e13d73288f298b23 100644 (file)
@@ -176,7 +176,7 @@ dns_master_style_debug = {
 };
 
 /*%
- * Similar, but indented (i.e., prepended with msg->indent.string).
+ * Similar, but indented (i.e., prepended with indentctx.string).
  */
 LIBDNS_EXTERNAL_DATA const dns_master_style_t
 dns_master_style_indent = {
@@ -247,6 +247,7 @@ struct dns_dumpctx {
 #define NXDOMAIN(x) (((x)->attributes & DNS_RDATASETATTR_NXDOMAIN) != 0)
 
 static const dns_indent_t default_indent = { "\t", 1 };
+static const dns_indent_t default_yamlindent = { "  ", 1 };
 
 /*%
  * Output tabs and spaces to go from column '*current' to
@@ -321,6 +322,14 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
 
        REQUIRE(style->tab_width != 0);
 
+       if (indentctx == NULL) {
+               if ((style->flags & DNS_STYLEFLAG_YAML) != 0) {
+                       indentctx = &default_yamlindent;
+               } else {
+                       indentctx = &default_indent;
+               }
+       }
+
        ctx->style = *style;
        ctx->class_printed = false;
 
@@ -346,9 +355,6 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
                if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
                    (ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
                {
-                       if (indentctx == NULL) {
-                               indentctx = &default_indent;
-                       }
                        unsigned int i, len = strlen(indentctx->string);
                        for (i = 0; i < indentctx->count; i++) {
                                if (isc_buffer_availablelength(&buf) < len)