Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2014-05-16 19:40:16 +0400
committerBryan Drewery <bryan@shatow.net>2014-05-16 19:40:16 +0400
commit1973fe4cc3728b4199e55022b3b3f3a7916cfd9d (patch)
tree221921ab31ab955ba7c42baea853c161c059a674 /external
parente0f2113d0310cc9b04319a07d0ba3a5d5ed003eb (diff)
Update libucl to 0.4.0-12-g0375252
Diffstat (limited to 'external')
-rw-r--r--external/libucl/.gitignore29
-rw-r--r--external/libucl/.travis.yml8
-rw-r--r--external/libucl/configure.ac2
-rw-r--r--external/libucl/include/ucl.h26
-rw-r--r--external/libucl/m4/.gitignore4
-rw-r--r--external/libucl/src/ucl_util.c95
-rw-r--r--external/libucl/tests/.gitignore8
-rw-r--r--external/libucl/tests/test_generate.c18
8 files changed, 175 insertions, 15 deletions
diff --git a/external/libucl/.gitignore b/external/libucl/.gitignore
new file mode 100644
index 00000000..36864da1
--- /dev/null
+++ b/external/libucl/.gitignore
@@ -0,0 +1,29 @@
+.cproject
+.project
+.settings
+
+# Auto*/libtool
+Makefile
+Makefile.in
+/aclocal.m4
+/autom4te.cache/
+/config.*
+/configure
+/depcomp
+/install-sh
+/libtool
+/ltmain.sh
+/missing
+/stamp-h*
+/ar-lib
+/test-driver
+/compile
+.deps/
+.dirstamp
+.libs/
+*.l[ao]
+*~
+*.o
+
+# pkgconf
+libucl.pc
diff --git a/external/libucl/.travis.yml b/external/libucl/.travis.yml
new file mode 100644
index 00000000..138f2dbc
--- /dev/null
+++ b/external/libucl/.travis.yml
@@ -0,0 +1,8 @@
+language: c
+
+compiler:
+ - clang
+ - gcc
+
+script:
+ - ./autogen.sh && ./configure && make && make check
diff --git a/external/libucl/configure.ac b/external/libucl/configure.ac
index 1f6e87d4..caea3ce5 100644
--- a/external/libucl/configure.ac
+++ b/external/libucl/configure.ac
@@ -1,6 +1,6 @@
m4_define([maj_ver], [0])
m4_define([med_ver], [4])
-m4_define([min_ver], [0])
+m4_define([min_ver], [1])
m4_define([so_version], [maj_ver:med_ver])
m4_define([ucl_version], [maj_ver.med_ver.min_ver])
diff --git a/external/libucl/include/ucl.h b/external/libucl/include/ucl.h
index 08039b29..fc973f4d 100644
--- a/external/libucl/include/ucl.h
+++ b/external/libucl/include/ucl.h
@@ -236,7 +236,13 @@ UCL_EXTERN ucl_object_t* ucl_object_new (void) UCL_WARN_UNUSED_RESULT;
* @param type type of a new object
* @return new object
*/
-UCL_EXTERN ucl_object_t* ucl_object_typed_new (unsigned int type) UCL_WARN_UNUSED_RESULT;
+UCL_EXTERN ucl_object_t* ucl_object_typed_new (ucl_type_t type) UCL_WARN_UNUSED_RESULT;
+
+/**
+ * Return the type of an object
+ * @return the object type
+ */
+UCL_EXTERN ucl_type_t ucl_object_type (const ucl_object_t *obj);
/**
* Convert any string to an ucl object making the specified transformations
@@ -413,6 +419,15 @@ UCL_EXTERN const ucl_object_t* ucl_array_tail (const ucl_object_t *top);
UCL_EXTERN ucl_object_t* ucl_array_pop_last (ucl_object_t *top);
/**
+ * Return object identified by an index of the array `top`
+ * @param obj object to get a key from (must be of type UCL_ARRAY)
+ * @param index index to return
+ * @return object at the specified index or NULL if index is not found
+ */
+UCL_EXTERN const ucl_object_t* ucl_array_find_index (const ucl_object_t *top,
+ unsigned int index);
+
+/**
* Removes the first element from the array `top`. Caller must unref the returned object when it is not
* needed.
* @param top array ucl object
@@ -534,6 +549,15 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_keyl (const ucl_object_t *obj,
const char *key, size_t klen);
/**
+ * Return object identified by dot notation string
+ * @param obj object to search in
+ * @param path dot.notation.path to the path to lookup. May use numeric .index on arrays
+ * @return object matched the specified path or NULL if path is not found
+ */
+UCL_EXTERN const ucl_object_t *ucl_lookup_path (const ucl_object_t *obj,
+ const char *path);
+
+/**
* Returns a key of an object as a NULL terminated string
* @param obj CL object
* @return key or NULL if there is no key
diff --git a/external/libucl/m4/.gitignore b/external/libucl/m4/.gitignore
new file mode 100644
index 00000000..5e7d2734
--- /dev/null
+++ b/external/libucl/m4/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/external/libucl/src/ucl_util.c b/external/libucl/src/ucl_util.c
index 9178795d..63f5e629 100644
--- a/external/libucl/src/ucl_util.c
+++ b/external/libucl/src/ucl_util.c
@@ -1330,20 +1330,10 @@ ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen)
const ucl_object_t *
ucl_object_find_key (const ucl_object_t *obj, const char *key)
{
- size_t klen;
- const ucl_object_t *ret;
- ucl_object_t srch;
-
- if (obj == NULL || obj->type != UCL_OBJECT || key == NULL) {
+ if (key == NULL)
return NULL;
- }
-
- klen = strlen (key);
- srch.key = key;
- srch.keylen = klen;
- ret = ucl_hash_search_obj (obj->value.ov, &srch);
- return ret;
+ return ucl_object_find_keyl (obj, key, strlen(key));
}
const ucl_object_t*
@@ -1396,6 +1386,58 @@ ucl_iterate_object (const ucl_object_t *obj, ucl_object_iter_t *iter, bool expan
return NULL;
}
+const ucl_object_t *
+ucl_lookup_path (const ucl_object_t *top, const char *path_in) {
+ const ucl_object_t *o = NULL, *found;
+ const char *p, *c;
+ char *err_str;
+ unsigned index;
+
+ if (path_in == NULL || top == NULL) {
+ return NULL;
+ }
+
+ found = NULL;
+ p = path_in;
+
+ /* Skip leading dots */
+ while (*p == '.') {
+ p ++;
+ }
+
+ c = p;
+ while (*p != '\0') {
+ p ++;
+ if (*p == '.' || *p == '\0') {
+ if (p > c) {
+ switch (top->type) {
+ case UCL_ARRAY:
+ /* Key should be an int */
+ index = strtoul (c, &err_str, 10);
+ if (err_str != NULL && (*err_str != '.' && *err_str != '\0')) {
+ return NULL;
+ }
+ o = ucl_array_find_index (top, index);
+ break;
+ default:
+ o = ucl_object_find_keyl (top, c, p - c);
+ break;
+ }
+ if (o == NULL) {
+ return NULL;
+ }
+ top = o;
+ }
+ if (*p != '\0') {
+ c = p + 1;
+ }
+ }
+ }
+ found = o;
+
+ return found;
+}
+
ucl_object_t *
ucl_object_new (void)
@@ -1411,7 +1453,7 @@ ucl_object_new (void)
}
ucl_object_t *
-ucl_object_typed_new (unsigned int type)
+ucl_object_typed_new (ucl_type_t type)
{
ucl_object_t *new;
new = malloc (sizeof (ucl_object_t));
@@ -1423,6 +1465,12 @@ ucl_object_typed_new (unsigned int type)
return new;
}
+ucl_type_t
+ucl_object_type (const ucl_object_t *obj)
+{
+ return obj->type;
+}
+
ucl_object_t*
ucl_object_fromstring (const char *str)
{
@@ -1591,6 +1639,27 @@ ucl_array_pop_first (ucl_object_t *top)
return ucl_array_delete (top, __DECONST(ucl_object_t *, ucl_array_head (top)));
}
+const ucl_object_t *
+ucl_array_find_index (const ucl_object_t *top, unsigned int index)
+{
+ ucl_object_iter_t it = NULL;
+ const ucl_object_t *ret;
+
+ if (top == NULL || top->type != UCL_ARRAY || top->len == 0 ||
+ (index + 1) > top->len) {
+ return NULL;
+ }
+
+ while ((ret = ucl_iterate_object (top, &it, true)) != NULL) {
+ if (index == 0) {
+ return ret;
+ }
+ --index;
+ }
+
+ return NULL;
+}
+
ucl_object_t *
ucl_elt_append (ucl_object_t *head, ucl_object_t *elt)
{
diff --git a/external/libucl/tests/.gitignore b/external/libucl/tests/.gitignore
new file mode 100644
index 00000000..5a48681d
--- /dev/null
+++ b/external/libucl/tests/.gitignore
@@ -0,0 +1,8 @@
+*.log
+*.trs
+*.plist
+
+test_basic
+test_generate
+test_schema
+test_speed
diff --git a/external/libucl/tests/test_generate.c b/external/libucl/tests/test_generate.c
index 2b1bf8d7..5c130e67 100644
--- a/external/libucl/tests/test_generate.c
+++ b/external/libucl/tests/test_generate.c
@@ -30,6 +30,7 @@ int
main (int argc, char **argv)
{
ucl_object_t *obj, *cur, *ar, *ref;
+ const ucl_object_t *found;
FILE *out;
unsigned char *emitted;
const char *fname_out = NULL;
@@ -114,6 +115,23 @@ main (int argc, char **argv)
cur = ucl_object_frombool (true);
ucl_object_insert_key (obj, cur, "k=3", 0, false);
+ /* Try to find using path */
+ /* Should exist */
+ found = ucl_lookup_path (obj, "key4.1");
+ assert (found != NULL && ucl_object_toint (found) == 10);
+ /* . should be ignored */
+ found = ucl_lookup_path (obj, ".key4.1");
+ assert (found != NULL && ucl_object_toint (found) == 10);
+ /* moar dots... */
+ found = ucl_lookup_path (obj, ".key4........1...");
+ assert (found != NULL && ucl_object_toint (found) == 10);
+ /* No such index */
+ found = ucl_lookup_path (obj, ".key4.3");
+ assert (found == NULL);
+ /* No such key */
+ found = ucl_lookup_path (obj, "key9..key1");
+ assert (found == NULL);
+
emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG);
fprintf (out, "%s\n", emitted);