Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163992711
D58333.id182436.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D58333.id182436.diff
View Options
diff --git a/contrib/libucl/FREEBSD-Xlist b/contrib/libucl/FREEBSD-Xlist
--- a/contrib/libucl/FREEBSD-Xlist
+++ b/contrib/libucl/FREEBSD-Xlist
@@ -1,5 +1,6 @@
.github
.gitignore
+CLAUDE.md
CMakeLists.txt
ChangeLog.md
Makefile.am
diff --git a/contrib/libucl/FREEBSD-upgrade b/contrib/libucl/FREEBSD-upgrade
--- a/contrib/libucl/FREEBSD-upgrade
+++ b/contrib/libucl/FREEBSD-upgrade
@@ -33,7 +33,7 @@
# 3. Merge vendor tree
#
# $ git subtree merge -P contrib/libucl vendor/libucl/<REF_BRANCH_TO_BE_IMPORTED>
-# $ sh -c 'for F in `cat FREEBSD-Xlist | grep -v FreeBSD`; do rm -rf ./$F ; done'
+# $ sh -c 'for F in `cat FREEBSD-Xlist | grep -v FreeBSD`; do git rm -rf ./$F ; done'
#
# Recheck if there were any new files were added which are not necessary in the
# contrib tree. If so, remove them and also add them to the FREEBSD-Xlist file.
diff --git a/contrib/libucl/include/ucl.h b/contrib/libucl/include/ucl.h
--- a/contrib/libucl/include/ucl.h
+++ b/contrib/libucl/include/ucl.h
@@ -861,6 +861,29 @@
#define ucl_iterate_object ucl_object_iterate
#define ucl_object_iterate(ob, it, ev) ucl_object_iterate_with_error((ob), (it), (ev), NULL)
+/**
+ * Free resources associated with an inline iterator when iteration is
+ * abandoned before completion. Only needed for UCL_OBJECT iteration where
+ * internal heap state is allocated. Safe to call with a NULL iterator or
+ * on non-object types.
+ *
+ * Example usage:
+ * ucl_object_iter_t it = NULL;
+ * while ((cur = ucl_iterate_object(obj, &it, true))) {
+ * if (error) {
+ * ucl_object_iterate_end(obj, &it);
+ * return;
+ * }
+ * }
+ *
+ * @param obj the object being iterated
+ * @param iter pointer to the iterator to free
+ */
+UCL_EXTERN void ucl_object_iterate_end(const ucl_object_t *obj,
+ ucl_object_iter_t *iter);
+
+#define ucl_iterate_object_end ucl_object_iterate_end
+
/**
* Create new safe iterator for the specified object
* @param obj object to iterate
diff --git a/contrib/libucl/src/ucl_emitter.c b/contrib/libucl/src/ucl_emitter.c
--- a/contrib/libucl/src/ucl_emitter.c
+++ b/contrib/libucl/src/ucl_emitter.c
@@ -353,10 +353,16 @@
else {
/* Expand implicit arrays */
if (cur->next != NULL) {
- if (first_key) {
- ucl_add_tabs(func, ctx->indent, compact);
+ if (!first_key) {
+ if (compact) {
+ func->ucl_emitter_append_character(',', 1, func->ud);
+ }
+ else {
+ func->ucl_emitter_append_len(",\n", 2, func->ud);
+ }
}
- ucl_emitter_common_start_array(ctx, cur, first_key, true, compact);
+ ucl_add_tabs(func, ctx->indent, compact);
+ ucl_emitter_common_start_array(ctx, cur, true, true, compact);
ucl_emitter_common_end_array(ctx, cur, compact);
}
else {
diff --git a/contrib/libucl/src/ucl_hash.h b/contrib/libucl/src/ucl_hash.h
--- a/contrib/libucl/src/ucl_hash.h
+++ b/contrib/libucl/src/ucl_hash.h
@@ -97,6 +97,12 @@
*/
bool ucl_hash_iter_has_next(ucl_hash_t *hashlin, ucl_hash_iter_t iter);
+/**
+ * Free a hash iterator (used when iteration is abandoned early)
+ * @param iter iterator to free, may be NULL
+ */
+void ucl_hash_iterate_free(ucl_hash_iter_t iter);
+
/**
* Reserves space in hash
* @return true on sucess, false on failure (e.g. ENOMEM)
diff --git a/contrib/libucl/src/ucl_hash.c b/contrib/libucl/src/ucl_hash.c
--- a/contrib/libucl/src/ucl_hash.c
+++ b/contrib/libucl/src/ucl_hash.c
@@ -443,6 +443,14 @@
return it->cur != NULL;
}
+void ucl_hash_iterate_free(ucl_hash_iter_t iter)
+{
+ struct ucl_hash_real_iter *it = (struct ucl_hash_real_iter *) (iter);
+
+ if (it != NULL) {
+ UCL_FREE(sizeof(*it), it);
+ }
+}
const ucl_object_t *
ucl_hash_search(ucl_hash_t *hashlin, const char *key, unsigned keylen)
@@ -610,6 +618,9 @@
void ucl_hash_sort(ucl_hash_t *hashlin, enum ucl_object_keys_sort_flags fl)
{
+ if (hashlin == NULL) {
+ return;
+ }
if (fl & UCL_SORT_KEYS_ICASE) {
DL_SORT(hashlin->head, ucl_hash_cmp_icase);
diff --git a/contrib/libucl/src/ucl_util.c b/contrib/libucl/src/ucl_util.c
--- a/contrib/libucl/src/ucl_util.c
+++ b/contrib/libucl/src/ucl_util.c
@@ -2435,9 +2435,7 @@
if (found == NULL) {
top->value.ov = ucl_hash_insert_object(top->value.ov, elt, false);
top->len++;
- if (replace) {
- ret = false;
- }
+ /* Key was inserted - return true regardless of replace flag */
}
else {
if (replace) {
@@ -2767,6 +2765,20 @@
return NULL;
}
+void
+ucl_object_iterate_end(const ucl_object_t *obj, ucl_object_iter_t *iter)
+{
+ if (iter == NULL || *iter == NULL) {
+ return;
+ }
+
+ if (obj != NULL && obj->type == UCL_OBJECT) {
+ ucl_hash_iterate_free(*iter);
+ }
+
+ *iter = NULL;
+}
+
enum ucl_safe_iter_flags {
UCL_ITERATE_FLAG_UNDEFINED = 0,
UCL_ITERATE_FLAG_INSIDE_ARRAY,
@@ -3028,6 +3040,16 @@
if (obj->type == UCL_ARRAY) {
UCL_ARRAY_GET(vec, obj);
+ if (vec == NULL) {
+ /* Allocate array storage if not present (e.g., copied empty array) */
+ vec = UCL_ALLOC(sizeof(*vec));
+ if (vec == NULL) {
+ return false;
+ }
+ kv_init(*vec);
+ obj->value.av = (void *)vec;
+ }
+
if (vec->m < reserved) {
/* Preallocate some space for arrays */
kv_resize_safe(ucl_object_t *, *vec, reserved, e0);
@@ -3657,8 +3679,9 @@
}
if (other->type == UCL_ARRAY || other->type == UCL_OBJECT) {
- /* reset old value */
+ /* reset old value and length since we will re-add elements below */
memset(&new->value, 0, sizeof(new->value));
+ new->len = 0;
while ((cur = ucl_object_iterate(other, &it, true)) != NULL) {
if (other->type == UCL_ARRAY) {
diff --git a/contrib/libucl/tests/CMakeLists.txt b/contrib/libucl/tests/CMakeLists.txt
--- a/contrib/libucl/tests/CMakeLists.txt
+++ b/contrib/libucl/tests/CMakeLists.txt
@@ -22,10 +22,14 @@
ENDIF()
endmacro()
-# Build test binaries always (not just for testing)
-add_ucl_test(test_basic test_basic.c basic.test)
-add_ucl_test(test_speed test_speed.c speed.test)
-add_ucl_test(test_schema test_schema.c schema.test)
+# Tests using POSIX APIs (mmap, STDIN_FILENO, etc.) - skip on Windows
+IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ add_ucl_test(test_basic test_basic.c basic.test)
+ add_ucl_test(test_speed test_speed.c speed.test)
+ add_ucl_test(test_schema test_schema.c schema.test)
+ENDIF()
+
+# Portable tests
add_ucl_test(test_msgpack test_msgpack.c msgpack.test)
add_ucl_test(test_generate test_generate.c generate.test)
diff --git a/contrib/libucl/tests/basic/issue312.in b/contrib/libucl/tests/basic/issue312.in
new file mode 100644
--- /dev/null
+++ b/contrib/libucl/tests/basic/issue312.in
@@ -0,0 +1,4 @@
+section_a { key_1 = "value_1"; }
+section_a { key_2 = "value_2"; }
+section_b { key_3 = "value_3"; }
+section_b { key_4 = "value_4"; }
diff --git a/contrib/libucl/tests/basic/issue312.res b/contrib/libucl/tests/basic/issue312.res
new file mode 100644
--- /dev/null
+++ b/contrib/libucl/tests/basic/issue312.res
@@ -0,0 +1,13 @@
+section_a {
+ key_1 = "value_1";
+}
+section_a {
+ key_2 = "value_2";
+}
+section_b {
+ key_3 = "value_3";
+}
+section_b {
+ key_4 = "value_4";
+}
+
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 28, 5:11 PM (14 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35666666
Default Alt Text
D58333.id182436.diff (6 KB)
Attached To
Mode
D58333: libucl: Import libucl 0.9.4
Attached
Detach File
Event Timeline
Log In to Comment