git.droids-corp.org
/
protos
/
libecoli.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rework completion iterators
[protos/libecoli.git]
/
src
/
ecoli_parse.c
diff --git
a/src/ecoli_parse.c
b/src/ecoli_parse.c
index
3b27070
..
e1b6018
100644
(file)
--- a/
src/ecoli_parse.c
+++ b/
src/ecoli_parse.c
@@
-12,7
+12,7
@@
#include <ecoli_assert.h>
#include <ecoli_malloc.h>
#include <ecoli_strvec.h>
#include <ecoli_assert.h>
#include <ecoli_malloc.h>
#include <ecoli_strvec.h>
-#include <ecoli_
keyval
.h>
+#include <ecoli_
dict
.h>
#include <ecoli_log.h>
#include <ecoli_test.h>
#include <ecoli_node.h>
#include <ecoli_log.h>
#include <ecoli_test.h>
#include <ecoli_node.h>
@@
-23,23
+23,23
@@
EC_LOG_TYPE_REGISTER(parse);
EC_LOG_TYPE_REGISTER(parse);
-TAILQ_HEAD(ec_p
arse_list, ec_pars
e);
+TAILQ_HEAD(ec_p
node_list, ec_pnod
e);
-struct ec_p
ars
e {
- TAILQ_ENTRY(ec_p
ars
e) next;
- struct ec_p
ars
e_list children;
- struct ec_p
ars
e *parent;
+struct ec_p
nod
e {
+ TAILQ_ENTRY(ec_p
nod
e) next;
+ struct ec_p
nod
e_list children;
+ struct ec_p
nod
e *parent;
const struct ec_node *node;
struct ec_strvec *strvec;
const struct ec_node *node;
struct ec_strvec *strvec;
- struct ec_
keyval
*attrs;
+ struct ec_
dict
*attrs;
};
};
-static int __ec_
node_
parse_child(const struct ec_node *node,
- struct ec_p
ars
e *state,
+static int __ec_parse_child(const struct ec_node *node,
+ struct ec_p
nod
e *state,
bool is_root, const struct ec_strvec *strvec)
{
struct ec_strvec *match_strvec;
bool is_root, const struct ec_strvec *strvec)
{
struct ec_strvec *match_strvec;
- struct ec_p
ars
e *child = NULL;
+ struct ec_p
nod
e *child = NULL;
int ret;
// XXX limit max number of recursions to avoid segfault
int ret;
// XXX limit max number of recursions to avoid segfault
@@
-50,11
+50,11
@@
static int __ec_node_parse_child(const struct ec_node *node,
}
if (!is_root) {
}
if (!is_root) {
- child = ec_p
ars
e(node);
+ child = ec_p
nod
e(node);
if (child == NULL)
return -1;
if (child == NULL)
return -1;
- ec_p
ars
e_link_child(state, child);
+ ec_p
nod
e_link_child(state, child);
} else {
child = state;
}
} else {
child = state;
}
@@
-64,8
+64,8
@@
static int __ec_node_parse_child(const struct ec_node *node,
if (ret == EC_PARSE_NOMATCH) {
if (!is_root) {
if (ret == EC_PARSE_NOMATCH) {
if (!is_root) {
- ec_p
ars
e_unlink_child(state, child);
- ec_p
ars
e_free(child);
+ ec_p
nod
e_unlink_child(state, child);
+ ec_p
nod
e_free(child);
}
return ret;
}
}
return ret;
}
@@
-80,42
+80,42
@@
static int __ec_node_parse_child(const struct ec_node *node,
fail:
if (!is_root) {
fail:
if (!is_root) {
- ec_p
ars
e_unlink_child(state, child);
- ec_p
ars
e_free(child);
+ ec_p
nod
e_unlink_child(state, child);
+ ec_p
nod
e_free(child);
}
return -1;
}
}
return -1;
}
-int ec_
node_parse_child(const struct ec_node *node, struct ec_pars
e *state,
+int ec_
parse_child(const struct ec_node *node, struct ec_pnod
e *state,
const struct ec_strvec *strvec)
{
assert(state != NULL);
const struct ec_strvec *strvec)
{
assert(state != NULL);
- return __ec_
node_
parse_child(node, state, false, strvec);
+ return __ec_parse_child(node, state, false, strvec);
}
// XXX what is returned if no match ??
}
// XXX what is returned if no match ??
-struct ec_p
arse *ec_node
_parse_strvec(const struct ec_node *node,
+struct ec_p
node *ec
_parse_strvec(const struct ec_node *node,
const struct ec_strvec *strvec)
{
const struct ec_strvec *strvec)
{
- struct ec_p
arse *parse = ec_pars
e(node);
+ struct ec_p
node *parse = ec_pnod
e(node);
int ret;
if (parse == NULL)
return NULL;
int ret;
if (parse == NULL)
return NULL;
- ret = __ec_
node_
parse_child(node, parse, true, strvec);
+ ret = __ec_parse_child(node, parse, true, strvec);
if (ret < 0) {
if (ret < 0) {
- ec_p
ars
e_free(parse);
+ ec_p
nod
e_free(parse);
return NULL;
}
return parse;
}
return NULL;
}
return parse;
}
-struct ec_p
arse *ec_node
_parse(const struct ec_node *node, const char *str)
+struct ec_p
node *ec
_parse(const struct ec_node *node, const char *str)
{
struct ec_strvec *strvec = NULL;
{
struct ec_strvec *strvec = NULL;
- struct ec_p
ars
e *parse = NULL;
+ struct ec_p
nod
e *parse = NULL;
errno = ENOMEM;
strvec = ec_strvec();
errno = ENOMEM;
strvec = ec_strvec();
@@
-125,7
+125,7
@@
struct ec_parse *ec_node_parse(const struct ec_node *node, const char *str)
if (ec_strvec_add(strvec, str) < 0)
goto fail;
if (ec_strvec_add(strvec, str) < 0)
goto fail;
- parse = ec_
node_
parse_strvec(node, strvec);
+ parse = ec_parse_strvec(node, strvec);
if (parse == NULL)
goto fail;
if (parse == NULL)
goto fail;
@@
-134,13
+134,13
@@
struct ec_parse *ec_node_parse(const struct ec_node *node, const char *str)
fail:
ec_strvec_free(strvec);
fail:
ec_strvec_free(strvec);
- ec_p
ars
e_free(parse);
+ ec_p
nod
e_free(parse);
return NULL;
}
return NULL;
}
-struct ec_p
arse *ec_pars
e(const struct ec_node *node)
+struct ec_p
node *ec_pnod
e(const struct ec_node *node)
{
{
- struct ec_p
ars
e *parse = NULL;
+ struct ec_p
nod
e *parse = NULL;
parse = ec_calloc(1, sizeof(*parse));
if (parse == NULL)
parse = ec_calloc(1, sizeof(*parse));
if (parse == NULL)
@@
-149,7
+149,7
@@
struct ec_parse *ec_parse(const struct ec_node *node)
TAILQ_INIT(&parse->children);
parse->node = node;
TAILQ_INIT(&parse->children);
parse->node = node;
- parse->attrs = ec_
keyval
();
+ parse->attrs = ec_
dict
();
if (parse->attrs == NULL)
goto fail;
if (parse->attrs == NULL)
goto fail;
@@
-157,34
+157,34
@@
struct ec_parse *ec_parse(const struct ec_node *node)
fail:
if (parse != NULL)
fail:
if (parse != NULL)
- ec_
keyval
_free(parse->attrs);
+ ec_
dict
_free(parse->attrs);
ec_free(parse);
return NULL;
}
ec_free(parse);
return NULL;
}
-static struct ec_p
ars
e *
-__ec_p
arse_dup(const struct ec_parse *root, const struct ec_pars
e *ref,
- struct ec_p
ars
e **new_ref)
+static struct ec_p
nod
e *
+__ec_p
node_dup(const struct ec_pnode *root, const struct ec_pnod
e *ref,
+ struct ec_p
nod
e **new_ref)
{
{
- struct ec_p
ars
e *dup = NULL;
- struct ec_p
ars
e *child, *dup_child;
- struct ec_
keyval
*attrs = NULL;
+ struct ec_p
nod
e *dup = NULL;
+ struct ec_p
nod
e *child, *dup_child;
+ struct ec_
dict
*attrs = NULL;
if (root == NULL)
return NULL;
if (root == NULL)
return NULL;
- dup = ec_p
ars
e(root->node);
+ dup = ec_p
nod
e(root->node);
if (dup == NULL)
return NULL;
if (root == ref)
*new_ref = dup;
if (dup == NULL)
return NULL;
if (root == ref)
*new_ref = dup;
- attrs = ec_
keyval
_dup(root->attrs);
+ attrs = ec_
dict
_dup(root->attrs);
if (attrs == NULL)
goto fail;
if (attrs == NULL)
goto fail;
- ec_
keyval
_free(dup->attrs);
+ ec_
dict
_free(dup->attrs);
dup->attrs = attrs;
if (root->strvec != NULL) {
dup->attrs = attrs;
if (root->strvec != NULL) {
@@
-194,26
+194,26
@@
__ec_parse_dup(const struct ec_parse *root, const struct ec_parse *ref,
}
TAILQ_FOREACH(child, &root->children, next) {
}
TAILQ_FOREACH(child, &root->children, next) {
- dup_child = __ec_p
ars
e_dup(child, ref, new_ref);
+ dup_child = __ec_p
nod
e_dup(child, ref, new_ref);
if (dup_child == NULL)
goto fail;
if (dup_child == NULL)
goto fail;
- ec_p
ars
e_link_child(dup, dup_child);
+ ec_p
nod
e_link_child(dup, dup_child);
}
return dup;
fail:
}
return dup;
fail:
- ec_p
ars
e_free(dup);
+ ec_p
nod
e_free(dup);
return NULL;
}
return NULL;
}
-struct ec_p
arse *ec_parse_dup(const struct ec_pars
e *parse)
+struct ec_p
node *ec_pnode_dup(const struct ec_pnod
e *parse)
{
{
- const struct ec_p
ars
e *root;
- struct ec_p
ars
e *dup_root, *dup = NULL;
+ const struct ec_p
nod
e *root;
+ struct ec_p
nod
e *dup_root, *dup = NULL;
- root = ec_p
ars
e_get_root(parse);
- dup_root = __ec_p
ars
e_dup(root, parse, &dup);
+ root = ec_p
nod
e_get_root(parse);
+ dup_root = __ec_p
nod
e_dup(root, parse, &dup);
if (dup_root == NULL)
return NULL;
assert(dup != NULL);
if (dup_root == NULL)
return NULL;
assert(dup != NULL);
@@
-221,9
+221,9
@@
struct ec_parse *ec_parse_dup(const struct ec_parse *parse)
return dup;
}
return dup;
}
-void ec_p
arse_free_children(struct ec_pars
e *parse)
+void ec_p
node_free_children(struct ec_pnod
e *parse)
{
{
- struct ec_p
ars
e *child;
+ struct ec_p
nod
e *child;
if (parse == NULL)
return;
if (parse == NULL)
return;
@@
-232,47
+232,47
@@
void ec_parse_free_children(struct ec_parse *parse)
child = TAILQ_FIRST(&parse->children);
TAILQ_REMOVE(&parse->children, child, next);
child->parent = NULL;
child = TAILQ_FIRST(&parse->children);
TAILQ_REMOVE(&parse->children, child, next);
child->parent = NULL;
- ec_p
ars
e_free(child);
+ ec_p
nod
e_free(child);
}
}
}
}
-void ec_p
arse_free(struct ec_pars
e *parse)
+void ec_p
node_free(struct ec_pnod
e *parse)
{
if (parse == NULL)
return;
ec_assert_print(parse->parent == NULL,
{
if (parse == NULL)
return;
ec_assert_print(parse->parent == NULL,
- "parent not NULL in ec_p
ars
e_free()");
+ "parent not NULL in ec_p
nod
e_free()");
- ec_p
ars
e_free_children(parse);
+ ec_p
nod
e_free_children(parse);
ec_strvec_free(parse->strvec);
ec_strvec_free(parse->strvec);
- ec_
keyval
_free(parse->attrs);
+ ec_
dict
_free(parse->attrs);
ec_free(parse);
}
ec_free(parse);
}
-static void __ec_p
ars
e_dump(FILE *out,
- const struct ec_p
ars
e *parse, size_t indent)
+static void __ec_p
nod
e_dump(FILE *out,
+ const struct ec_p
nod
e *parse, size_t indent)
{
{
- struct ec_p
ars
e *child;
+ struct ec_p
nod
e *child;
const struct ec_strvec *vec;
const char *id = "none", *typename = "none";
/* node can be null when parsing is incomplete */
if (parse->node != NULL) {
const struct ec_strvec *vec;
const char *id = "none", *typename = "none";
/* node can be null when parsing is incomplete */
if (parse->node != NULL) {
- id =
parse->node->id
;
+ id =
ec_node_id(parse->node)
;
typename = ec_node_type(parse->node)->name;
}
fprintf(out, "%*s" "type=%s id=%s vec=",
(int)indent * 4, "", typename, id);
typename = ec_node_type(parse->node)->name;
}
fprintf(out, "%*s" "type=%s id=%s vec=",
(int)indent * 4, "", typename, id);
- vec = ec_p
ars
e_strvec(parse);
+ vec = ec_p
nod
e_strvec(parse);
ec_strvec_dump(out, vec);
TAILQ_FOREACH(child, &parse->children, next)
ec_strvec_dump(out, vec);
TAILQ_FOREACH(child, &parse->children, next)
- __ec_p
ars
e_dump(out, child, indent + 1);
+ __ec_p
nod
e_dump(out, child, indent + 1);
}
}
-void ec_p
arse_dump(FILE *out, const struct ec_pars
e *parse)
+void ec_p
node_dump(FILE *out, const struct ec_pnod
e *parse)
{
fprintf(out, "------------------- parse dump:\n");
{
fprintf(out, "------------------- parse dump:\n");
@@
-285,51
+285,51
@@
void ec_parse_dump(FILE *out, const struct ec_parse *parse)
* does not have children: an incomplete parse, like those
* generated by complete() don't match but have children that
* may match. */
* does not have children: an incomplete parse, like those
* generated by complete() don't match but have children that
* may match. */
- if (!ec_p
ars
e_matches(parse) && TAILQ_EMPTY(&parse->children)) {
+ if (!ec_p
nod
e_matches(parse) && TAILQ_EMPTY(&parse->children)) {
fprintf(out, "no match\n");
return;
}
fprintf(out, "no match\n");
return;
}
- __ec_p
ars
e_dump(out, parse, 0);
+ __ec_p
nod
e_dump(out, parse, 0);
}
}
-void ec_p
arse_link_child(struct ec_pars
e *parse,
- struct ec_p
ars
e *child)
+void ec_p
node_link_child(struct ec_pnod
e *parse,
+ struct ec_p
nod
e *child)
{
TAILQ_INSERT_TAIL(&parse->children, child, next);
child->parent = parse;
}
{
TAILQ_INSERT_TAIL(&parse->children, child, next);
child->parent = parse;
}
-void ec_p
arse_unlink_child(struct ec_pars
e *parse,
- struct ec_p
ars
e *child)
+void ec_p
node_unlink_child(struct ec_pnod
e *parse,
+ struct ec_p
nod
e *child)
{
TAILQ_REMOVE(&parse->children, child, next);
child->parent = NULL;
}
{
TAILQ_REMOVE(&parse->children, child, next);
child->parent = NULL;
}
-struct ec_p
ars
e *
-ec_p
arse_get_first_child(const struct ec_pars
e *parse)
+struct ec_p
nod
e *
+ec_p
node_get_first_child(const struct ec_pnod
e *parse)
{
return TAILQ_FIRST(&parse->children);
}
{
return TAILQ_FIRST(&parse->children);
}
-struct ec_p
ars
e *
-ec_p
arse_get_last_child(const struct ec_pars
e *parse)
+struct ec_p
nod
e *
+ec_p
node_get_last_child(const struct ec_pnod
e *parse)
{
{
- return TAILQ_LAST(&parse->children, ec_p
ars
e_list);
+ return TAILQ_LAST(&parse->children, ec_p
nod
e_list);
}
}
-struct ec_p
arse *ec_parse_get_next(const struct ec_pars
e *parse)
+struct ec_p
node *ec_pnode_next(const struct ec_pnod
e *parse)
{
return TAILQ_NEXT(parse, next);
}
{
return TAILQ_NEXT(parse, next);
}
-bool ec_p
arse_has_child(const struct ec_pars
e *parse)
+bool ec_p
node_has_child(const struct ec_pnod
e *parse)
{
return !TAILQ_EMPTY(&parse->children);
}
{
return !TAILQ_EMPTY(&parse->children);
}
-const struct ec_node *ec_p
arse_get_node(const struct ec_pars
e *parse)
+const struct ec_node *ec_p
node_get_node(const struct ec_pnod
e *parse)
{
if (parse == NULL)
return NULL;
{
if (parse == NULL)
return NULL;
@@
-337,16
+337,16
@@
const struct ec_node *ec_parse_get_node(const struct ec_parse *parse)
return parse->node;
}
return parse->node;
}
-void ec_p
arse_del_last_child(struct ec_pars
e *parse)
+void ec_p
node_del_last_child(struct ec_pnod
e *parse)
{
{
- struct ec_p
ars
e *child;
+ struct ec_p
nod
e *child;
- child = ec_p
ars
e_get_last_child(parse);
- ec_p
ars
e_unlink_child(parse, child);
- ec_p
ars
e_free(child);
+ child = ec_p
nod
e_get_last_child(parse);
+ ec_p
nod
e_unlink_child(parse, child);
+ ec_p
nod
e_free(child);
}
}
-struct ec_p
arse *__ec_parse_get_root(struct ec_pars
e *parse)
+struct ec_p
node *__ec_pnode_get_root(struct ec_pnod
e *parse)
{
if (parse == NULL)
return NULL;
{
if (parse == NULL)
return NULL;
@@
-357,7
+357,7
@@
struct ec_parse *__ec_parse_get_root(struct ec_parse *parse)
return parse;
}
return parse;
}
-struct ec_p
arse *ec_parse_get_parent(const struct ec_pars
e *parse)
+struct ec_p
node *ec_pnode_get_parent(const struct ec_pnod
e *parse)
{
if (parse == NULL)
return NULL;
{
if (parse == NULL)
return NULL;
@@
-365,15
+365,18
@@
struct ec_parse *ec_parse_get_parent(const struct ec_parse *parse)
return parse->parent;
}
return parse->parent;
}
-struct ec_parse *ec_parse_iter_next(struct ec_parse *parse)
+struct ec_pnode *__ec_pnode_iter_next(const struct ec_pnode *root,
+ struct ec_pnode *parse, bool iter_children)
{
{
- struct ec_p
ars
e *child, *parent, *next;
+ struct ec_p
nod
e *child, *parent, *next;
- child = TAILQ_FIRST(&parse->children);
- if (child != NULL)
- return child;
+ if (iter_children) {
+ child = TAILQ_FIRST(&parse->children);
+ if (child != NULL)
+ return child;
+ }
parent = parse->parent;
parent = parse->parent;
- while (parent != NULL) {
+ while (parent != NULL
&& parse != root
) {
next = TAILQ_NEXT(parse, next);
if (next != NULL)
return next;
next = TAILQ_NEXT(parse, next);
if (next != NULL)
return next;
@@
-383,26
+386,37
@@
struct ec_parse *ec_parse_iter_next(struct ec_parse *parse)
return NULL;
}
return NULL;
}
-struct ec_parse *ec_parse_find_first(struct ec_parse *parse,
- const char *id)
+struct ec_pnode *
+ec_pnode_find_next(struct ec_pnode *root, struct ec_pnode *start,
+ const char *id, bool iter_children)
{
{
- struct ec_p
ars
e *iter;
+ struct ec_p
nod
e *iter;
- if (
parse
== NULL)
+ if (
root
== NULL)
return NULL;
return NULL;
+ if (start == NULL)
+ start = root;
+ else
+ start = EC_PNODE_ITER_NEXT(root, start, iter_children);
- for (iter = parse; iter != NULL; iter = ec_parse_iter_next(iter)) {
+ for (iter = start; iter != NULL;
+ iter = EC_PNODE_ITER_NEXT(root, iter, 1)) {
if (iter->node != NULL &&
if (iter->node != NULL &&
- iter->node->id != NULL &&
- !strcmp(iter->node->id, id))
+ !strcmp(ec_node_id(iter->node), id))
return iter;
}
return NULL;
}
return iter;
}
return NULL;
}
-struct ec_keyval *
-ec_parse_get_attrs(struct ec_parse *parse)
+struct ec_pnode *ec_pnode_find(struct ec_pnode *parse,
+ const char *id)
+{
+ return ec_pnode_find_next(parse, NULL, id, 1);
+}
+
+struct ec_dict *
+ec_pnode_get_attrs(struct ec_pnode *parse)
{
if (parse == NULL)
return NULL;
{
if (parse == NULL)
return NULL;
@@
-410,7
+424,7
@@
ec_parse_get_attrs(struct ec_parse *parse)
return parse->attrs;
}
return parse->attrs;
}
-const struct ec_strvec *ec_p
arse_strvec(const struct ec_pars
e *parse)
+const struct ec_strvec *ec_p
node_strvec(const struct ec_pnod
e *parse)
{
if (parse == NULL || parse->strvec == NULL)
return NULL;
{
if (parse == NULL || parse->strvec == NULL)
return NULL;
@@
-419,7
+433,7
@@
const struct ec_strvec *ec_parse_strvec(const struct ec_parse *parse)
}
/* number of strings in the parse vector */
}
/* number of strings in the parse vector */
-size_t ec_p
arse_len(const struct ec_pars
e *parse)
+size_t ec_p
node_len(const struct ec_pnod
e *parse)
{
if (parse == NULL || parse->strvec == NULL)
return 0;
{
if (parse == NULL || parse->strvec == NULL)
return 0;
@@
-427,7
+441,7
@@
size_t ec_parse_len(const struct ec_parse *parse)
return ec_strvec_len(parse->strvec);
}
return ec_strvec_len(parse->strvec);
}
-size_t ec_p
arse_matches(const struct ec_pars
e *parse)
+size_t ec_p
node_matches(const struct ec_pnod
e *parse)
{
if (parse == NULL)
return 0;
{
if (parse == NULL)
return 0;
@@
-439,11
+453,11
@@
size_t ec_parse_matches(const struct ec_parse *parse)
}
/* LCOV_EXCL_START */
}
/* LCOV_EXCL_START */
-static int ec_p
ars
e_testcase(void)
+static int ec_p
nod
e_testcase(void)
{
struct ec_node *node = NULL;
{
struct ec_node *node = NULL;
- struct ec_p
ars
e *p = NULL, *p2 = NULL;
- const struct ec_p
ars
e *pc;
+ struct ec_p
nod
e *p = NULL, *p2 = NULL;
+ const struct ec_p
nod
e *pc;
FILE *f = NULL;
char *buf = NULL;
size_t buflen = 0;
FILE *f = NULL;
char *buf = NULL;
size_t buflen = 0;
@@
-457,15
+471,15
@@
static int ec_parse_testcase(void)
if (node == NULL)
goto fail;
if (node == NULL)
goto fail;
- p = ec_
node_
parse(node, "xcdscds");
+ p = ec_parse(node, "xcdscds");
testres |= EC_TEST_CHECK(
testres |= EC_TEST_CHECK(
- p != NULL && !ec_p
ars
e_matches(p),
+ p != NULL && !ec_p
nod
e_matches(p),
"parse should not match\n");
f = open_memstream(&buf, &buflen);
if (f == NULL)
goto fail;
"parse should not match\n");
f = open_memstream(&buf, &buflen);
if (f == NULL)
goto fail;
- ec_p
ars
e_dump(f, p);
+ ec_p
nod
e_dump(f, p);
fclose(f);
f = NULL;
fclose(f);
f = NULL;
@@
-473,43
+487,43
@@
static int ec_parse_testcase(void)
strstr(buf, "no match"), "bad dump\n");
free(buf);
buf = NULL;
strstr(buf, "no match"), "bad dump\n");
free(buf);
buf = NULL;
- ec_p
ars
e_free(p);
+ ec_p
nod
e_free(p);
- p = ec_
node_
parse(node, "x y");
+ p = ec_parse(node, "x y");
testres |= EC_TEST_CHECK(
testres |= EC_TEST_CHECK(
- p != NULL && ec_p
ars
e_matches(p),
+ p != NULL && ec_p
nod
e_matches(p),
"parse should match\n");
testres |= EC_TEST_CHECK(
"parse should match\n");
testres |= EC_TEST_CHECK(
- ec_p
ars
e_len(p) == 1, "bad parse len\n");
+ ec_p
nod
e_len(p) == 1, "bad parse len\n");
- ret = ec_
keyval_set(ec_pars
e_get_attrs(p), "key", "val", NULL);
+ ret = ec_
dict_set(ec_pnod
e_get_attrs(p), "key", "val", NULL);
testres |= EC_TEST_CHECK(ret == 0,
"cannot set parse attribute\n");
testres |= EC_TEST_CHECK(ret == 0,
"cannot set parse attribute\n");
- p2 = ec_p
ars
e_dup(p);
+ p2 = ec_p
nod
e_dup(p);
testres |= EC_TEST_CHECK(
testres |= EC_TEST_CHECK(
- p2 != NULL && ec_p
ars
e_matches(p2),
+ p2 != NULL && ec_p
nod
e_matches(p2),
"parse should match\n");
"parse should match\n");
- ec_p
ars
e_free(p2);
+ ec_p
nod
e_free(p2);
p2 = NULL;
p2 = NULL;
- pc = ec_p
arse_find_first
(p, "id_x");
+ pc = ec_p
node_find
(p, "id_x");
testres |= EC_TEST_CHECK(pc != NULL, "cannot find id_x");
testres |= EC_TEST_CHECK(pc != NULL &&
testres |= EC_TEST_CHECK(pc != NULL, "cannot find id_x");
testres |= EC_TEST_CHECK(pc != NULL &&
- ec_p
ars
e_get_parent(pc) != NULL &&
- ec_p
arse_get_parent(ec_pars
e_get_parent(pc)) == p,
+ ec_p
nod
e_get_parent(pc) != NULL &&
+ ec_p
node_get_parent(ec_pnod
e_get_parent(pc)) == p,
"invalid parent\n");
"invalid parent\n");
- pc = ec_p
arse_find_first
(p, "id_y");
+ pc = ec_p
node_find
(p, "id_y");
testres |= EC_TEST_CHECK(pc != NULL, "cannot find id_y");
testres |= EC_TEST_CHECK(pc != NULL, "cannot find id_y");
- pc = ec_p
arse_find_first
(p, "id_dezdezdez");
+ pc = ec_p
node_find
(p, "id_dezdezdez");
testres |= EC_TEST_CHECK(pc == NULL, "should not find bad id");
f = open_memstream(&buf, &buflen);
if (f == NULL)
goto fail;
testres |= EC_TEST_CHECK(pc == NULL, "should not find bad id");
f = open_memstream(&buf, &buflen);
if (f == NULL)
goto fail;
- ec_p
ars
e_dump(f, p);
+ ec_p
nod
e_dump(f, p);
fclose(f);
f = NULL;
fclose(f);
f = NULL;
@@
-522,13
+536,13
@@
static int ec_parse_testcase(void)
free(buf);
buf = NULL;
free(buf);
buf = NULL;
- ec_p
ars
e_free(p);
+ ec_p
nod
e_free(p);
ec_node_free(node);
return testres;
fail:
ec_node_free(node);
return testres;
fail:
- ec_p
ars
e_free(p2);
- ec_p
ars
e_free(p);
+ ec_p
nod
e_free(p2);
+ ec_p
nod
e_free(p);
ec_node_free(node);
if (f != NULL)
fclose(f);
ec_node_free(node);
if (f != NULL)
fclose(f);
@@
-538,9
+552,9
@@
fail:
}
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
-static struct ec_test ec_p
ars
e_test = {
+static struct ec_test ec_p
nod
e_test = {
.name = "parse",
.name = "parse",
- .test = ec_p
ars
e_testcase,
+ .test = ec_p
nod
e_testcase,
};
};
-EC_TEST_REGISTER(ec_p
ars
e_test);
+EC_TEST_REGISTER(ec_p
nod
e_test);