commit b552a50: [Minor] Libucl: Do not expand empty objects on output

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Apr 20 10:07:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-04-20 11:06:39 +0100
URL: https://github.com/rspamd/rspamd/commit/b552a50d983ebf6eae97b28d21d089ef9d0637bc (HEAD -> master)

[Minor] Libucl: Do not expand empty objects on output

---
 contrib/libucl/ucl_emitter.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/contrib/libucl/ucl_emitter.c b/contrib/libucl/ucl_emitter.c
index 687e6cdae..777093aca 100644
--- a/contrib/libucl/ucl_emitter.c
+++ b/contrib/libucl/ucl_emitter.c
@@ -197,7 +197,7 @@ ucl_emitter_common_end_object (struct ucl_emitter_context *ctx,
 
 	if (UCL_EMIT_IDENT_TOP_OBJ(ctx, obj)) {
 		ctx->indent --;
-		if (compact) {
+		if (compact || obj->len == 0) {
 			func->ucl_emitter_append_character ('}', 1, func->ud);
 		}
 		else {
@@ -225,7 +225,7 @@ ucl_emitter_common_end_array (struct ucl_emitter_context *ctx,
 	const struct ucl_emitter_functions *func = ctx->func;
 
 	ctx->indent --;
-	if (compact) {
+	if (compact || obj->len == 0) {
 		func->ucl_emitter_append_character (']', 1, func->ud);
 	}
 	else {
@@ -257,7 +257,7 @@ ucl_emitter_common_start_array (struct ucl_emitter_context *ctx,
 
 	ucl_emitter_print_key (print_key, ctx, obj, compact);
 
-	if (compact) {
+	if (compact || obj->len == 0) {
 		func->ucl_emitter_append_character ('[', 1, func->ud);
 	}
 	else {
@@ -282,8 +282,6 @@ ucl_emitter_common_start_array (struct ucl_emitter_context *ctx,
 			cur = cur->next;
 		}
 	}
-
-
 }
 
 /**
@@ -307,7 +305,7 @@ ucl_emitter_common_start_object (struct ucl_emitter_context *ctx,
 	 * <ident_level + 1><object content>
 	 */
 	if (UCL_EMIT_IDENT_TOP_OBJ(ctx, obj)) {
-		if (compact) {
+		if (compact || obj->len == 0) {
 			func->ucl_emitter_append_character ('{', 1, func->ud);
 		}
 		else {


More information about the Commits mailing list