Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix exporting yaml in pkg info -R in case multiple deps has the same name
Baptiste Daroussin committed 12 years ago
commit 9770b5608aeb43942ed0328715caf84bd13b3799
parent 3bc309b
1 file changed +20 -11
modified external/libucl/src/ucl_emitter.c
@@ -38,6 +38,7 @@ static void ucl_elt_write_rcl (ucl_object_t *obj, UT_string *buf, unsigned int t
		bool start_tabs, bool is_top, bool expand_array);
static void ucl_elt_write_yaml (ucl_object_t *obj, UT_string *buf, unsigned int tabs,
		bool start_tabs, bool compact, bool expand_array);
+
static void ucl_elt_array_write_yaml (ucl_object_t *obj, UT_string *buf, unsigned int tabs, bool start_tabs, bool is_top);

/**
 * Add tabulation to the output buffer
@@ -471,6 +472,19 @@ ucl_object_emit_rcl (ucl_object_t *obj)
}


+
static void
+
ucl_obj_write_yaml (ucl_object_t *obj, UT_string *buf, unsigned int tabs, bool start_tabs)
+
{
+
	ucl_object_t *cur;
+
	bool is_array = (obj->next != NULL);
+

+
	if (is_array) {
+
		ucl_elt_array_write_yaml (obj, buf, tabs, start_tabs, false);
+
	}
+
	else {
+
		ucl_elt_write_yaml(obj, buf, tabs, start_tabs, false, true);
+
	}
+
}
/**
 * Write a single object to the buffer
 * @param obj object to write
@@ -486,25 +500,20 @@ ucl_elt_obj_write_yaml (ucl_object_t *obj, UT_string *buf, unsigned int tabs, bo
		ucl_add_tabs (buf, tabs, is_top);
	}
	if (!is_top) {
-
		utstring_append_len (buf, ": {\n", 4);
+
		utstring_append_len (buf, "{\n", 2);
	}

	while ((cur = ucl_hash_iterate (obj->value.ov, &it))) {
		ucl_add_tabs (buf, tabs + 1, is_top);
-
		if (cur->flags & UCL_OBJECT_NEED_KEY_ESCAPE) {
+
		if (cur->keylen > 0) {
			ucl_elt_string_write_json (cur->key, cur->keylen, buf);
		}
		else {
-
			utstring_append_len (buf, cur->key, cur->keylen);
-
		}
-
		if (cur->type != UCL_OBJECT && cur->type != UCL_ARRAY) {
-
			utstring_append_len (buf, " : ", 3);
-
		}
-
		else {
-
			utstring_append_c (buf, ' ');
+
			utstring_append_len (buf, "null", 4);
		}
-
		ucl_elt_write_yaml (cur, buf, is_top ? tabs : tabs + 1, false, false, true);
-
		if (cur->type != UCL_OBJECT && cur->type != UCL_ARRAY) {
+
		utstring_append_len(buf, ": ", 2);
+
		ucl_obj_write_yaml (cur, buf, is_top ? tabs : tabs + 1, false);
+
		if (ucl_hash_iter_has_next(it)) {
			if (!is_top) {
				utstring_append_len (buf, ",\n", 2);
			}