struct ec_keyval_elt *vec;
};
-struct ec_keyval *ec_keyval_new(void)
+struct ec_keyval *ec_keyval(void)
{
struct ec_keyval *keyval;
struct ec_keyval *keyval;
char *val;
- keyval = ec_keyval_new();
+ keyval = ec_keyval();
if (keyval == NULL) {
ec_log(EC_LOG_ERR, "cannot create keyval\n");
return -1;
struct ec_keyval;
-struct ec_keyval *ec_keyval_new(void);
+struct ec_keyval *ec_keyval(void);
void *ec_keyval_get(const struct ec_keyval *keyval, const char *key);
int ec_keyval_del(struct ec_keyval *keyval, const char *key);
fprintf(out, "%s\n", type->name);
}
-struct ec_node *__ec_node_new(const struct ec_node_type *type, const char *id)
+struct ec_node *__ec_node(const struct ec_node_type *type, const char *id)
{
struct ec_node *node = NULL;
char buf[256]; // XXX
if (node->desc == NULL)
goto fail;
- node->attrs = ec_keyval_new();
+ node->attrs = ec_keyval();
if (node->attrs == NULL)
goto fail;
return NULL;
}
-struct ec_node *ec_node_new(const char *typename, const char *id)
+struct ec_node *ec_node(const char *typename, const char *id)
{
struct ec_node_type *type;
return NULL;
}
- return __ec_node_new(type, id);
+ return __ec_node(type, id);
}
void ec_node_free(struct ec_node *node)
struct ec_parsed *parsed;
errno = ENOMEM;
- strvec = ec_strvec_new();
+ strvec = ec_strvec();
if (strvec == NULL)
goto fail;
}
-struct ec_parsed *ec_parsed_new(void)
+struct ec_parsed *ec_parsed(void)
{
struct ec_parsed *parsed = NULL;
return 1;
}
-struct ec_completed *ec_completed_new(void)
+struct ec_completed *ec_completed(void)
{
struct ec_completed *completed = NULL;
return completed;
}
-struct ec_completed_elt *ec_completed_elt_new(const struct ec_node *node,
+struct ec_completed_elt *ec_completed_elt(const struct ec_node *node,
const char *add)
{
struct ec_completed_elt *elt = NULL;
struct ec_completed *completed;
errno = ENOMEM;
- strvec = ec_strvec_new();
+ strvec = ec_strvec();
if (strvec == NULL)
goto fail;
(void)strvec;
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
return NULL;
- completed_elt = ec_completed_elt_new(gen_node, NULL);
+ completed_elt = ec_completed_elt(gen_node, NULL);
if (completed_elt == NULL) {
ec_completed_free(completed);
return NULL;
}
struct ec_completed_iter *
-ec_completed_iter_new(struct ec_completed *completed,
+ec_completed_iter(struct ec_completed *completed,
enum ec_completed_filter_flags flags)
{
struct ec_completed_iter *iter;
/* create a new node when the type is known, typically called from the node
* code */
-struct ec_node *__ec_node_new(const struct ec_node_type *type, const char *id);
+struct ec_node *__ec_node(const struct ec_node_type *type, const char *id);
/* create a_new node node */
-struct ec_node *ec_node_new(const char *typename, const char *id);
+struct ec_node *ec_node(const char *typename, const char *id);
void ec_node_free(struct ec_node *node);
struct ec_strvec *strvec;
};
-struct ec_parsed *ec_parsed_new(void);
+struct ec_parsed *ec_parsed(void);
void ec_parsed_free(struct ec_parsed *parsed);
struct ec_node *ec_node_clone(struct ec_node *node);
void ec_parsed_free_children(struct ec_parsed *parsed);
const char *str);
struct ec_completed *ec_node_complete_strvec(struct ec_node *node,
const struct ec_strvec *strvec);
-struct ec_completed *ec_completed_new(void);
-struct ec_completed_elt *ec_completed_elt_new(const struct ec_node *node,
+struct ec_completed *ec_completed(void);
+struct ec_completed_elt *ec_completed_elt(const struct ec_node *node,
const char *add);
void ec_completed_add_elt(struct ec_completed *completed,
struct ec_completed_elt *elt);
};
struct ec_completed_iter *
-ec_completed_iter_new(struct ec_completed *completed,
+ec_completed_iter(struct ec_completed *completed,
enum ec_completed_filter_flags flags);
const struct ec_completed_elt *ec_completed_iter_next(
/* build the expression parser */
ret = -ENOMEM;
- expr = ec_node_new("expr", "expr");
+ expr = ec_node("expr", "expr");
if (expr == NULL)
goto fail;
ret = ec_node_expr_set_val_node(expr, ec_node_re(NULL, "[a-zA-Z0-9]+"));
goto fail;
ret = -ENOMEM;
- cmd = ec_node_new("seq", NULL);
+ cmd = ec_node("seq", NULL);
if (cmd == NULL)
goto fail;
struct ec_node *gen_node = NULL;
struct ec_node_cmd *node = NULL;
- gen_node = __ec_node_new(&ec_node_cmd_type, id);
+ gen_node = __ec_node(&ec_node_cmd_type, id);
if (gen_node == NULL)
goto fail;
(void)strvec;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
- match_strvec = ec_strvec_new();
+ match_strvec = ec_strvec();
if (match_strvec == NULL)
goto fail;
struct ec_node *node;
int ret = 0;
- node = ec_node_new("empty", NULL);
+ node = ec_node("empty", NULL);
if (node == NULL) {
ec_log(EC_LOG_ERR, "cannot create node\n");
return -1;
ec_node_free(node);
/* never completes */
- node = ec_node_new("empty", NULL);
+ node = ec_node("empty", NULL);
if (node == NULL) {
ec_log(EC_LOG_ERR, "cannot create node\n");
return -1;
/* create the object, we will initialize it later: this is
* needed because we have a circular dependency */
ret = -ENOMEM;
- weak = ec_node_new("weakref", "weak");
+ weak = ec_node("weakref", "weak");
if (weak == NULL)
return -1;
/* prefix unary operators */
- pre_op = ec_node_new("or", "pre-op");
+ pre_op = ec_node("or", "pre-op");
if (pre_op == NULL)
goto fail;
for (i = 0; i < node->pre_ops_len; i++) {
}
/* suffix unary operators */
- post_op = ec_node_new("or", "post-op");
+ post_op = ec_node("or", "post-op");
if (post_op == NULL)
goto fail;
for (i = 0; i < node->post_ops_len; i++) {
goto fail;
}
- post = ec_node_new("or", "post");
+ post = ec_node("or", "post");
if (post == NULL)
goto fail;
if (ec_node_or_add(post, ec_node_clone(node->val_node)) < 0)
struct ec_node *node = NULL, *lex_node = NULL;
int ret = 0;
- node = ec_node_new("expr", "my_expr");
+ node = ec_node("expr", "my_expr");
if (node == NULL)
return -1;
const char *str;
long long val;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
struct ec_node *gen_node = NULL;
struct ec_node_int *node = NULL;
- gen_node = __ec_node_new(&ec_node_int_type, id);
+ gen_node = __ec_node(&ec_node_int_type, id);
if (gen_node == NULL)
return NULL;
node = (struct ec_node_int *)gen_node;
struct ec_strvec *childvec = NULL;
size_t off = 0, len, count;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
size_t len = 0;
unsigned int i;
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
return NULL;
if (child == NULL)
return NULL;
- node = (struct ec_node_many *)__ec_node_new(&ec_node_many_type, id);
+ node = (struct ec_node_many *)__ec_node(&ec_node_many_type, id);
if (node == NULL) {
ec_node_free(child);
return NULL;
struct ec_parsed *parsed = NULL, *child_parsed;
struct ec_strvec *match_strvec;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
match_strvec = ec_strvec_dup(child_parsed->strvec);
} else {
ec_parsed_free(child_parsed);
- match_strvec = ec_strvec_new();
+ match_strvec = ec_strvec();
}
if (match_strvec == NULL)
if (child == NULL)
return NULL;
- gen_node = __ec_node_new(&ec_node_option_type, id);
+ gen_node = __ec_node(&ec_node_option_type, id);
if (gen_node == NULL) {
ec_node_free(child);
return NULL;
struct ec_strvec *match_strvec;
unsigned int i;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
struct ec_completed *completed, *child_completed;
size_t n;
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
return NULL;
va_start(ap, id);
- gen_node = __ec_node_new(&ec_node_or_type, id);
+ gen_node = __ec_node(&ec_node_or_type, id);
node = (struct ec_node_or *)gen_node;
if (node == NULL)
fail = 1;;
const char *str;
regmatch_t pos;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
{
struct ec_node *gen_node = NULL;
- gen_node = __ec_node_new(&ec_node_re_type, id);
+ gen_node = __ec_node(&ec_node_re_type, id);
if (gen_node == NULL)
goto fail;
if (dup == NULL)
goto fail;
- strvec = ec_strvec_new();
+ strvec = ec_strvec();
if (strvec == NULL)
goto fail;
struct ec_parsed *parsed = NULL, *child_parsed;
const char *str;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
return NULL;
if (child == NULL)
return NULL;
- node = (struct ec_node_re_lex *)__ec_node_new(&ec_node_re_lex_type, id);
+ node = (struct ec_node_re_lex *)__ec_node(&ec_node_re_lex_type, id);
if (node == NULL) {
ec_node_free(child);
return NULL;
size_t len = 0;
unsigned int i;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
size_t len = 0;
unsigned int i;
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
return NULL;
va_start(ap, id);
- gen_node = __ec_node_new(&ec_node_seq_type, id);
+ gen_node = __ec_node(&ec_node_seq_type, id);
node = (struct ec_node_seq *)gen_node;
if (node == NULL)
fail = 1;;
// printf("str=%s\n", str);
- strvec = ec_strvec_new();
+ strvec = ec_strvec();
if (strvec == NULL)
goto fail;
struct ec_parsed *parsed = NULL, *child_parsed;
const char *str;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
return NULL;
char missing_quote;
// printf("==================\n");
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
return NULL;
if (child == NULL)
return NULL;
- node = (struct ec_node_sh_lex *)__ec_node_new(&ec_node_sh_lex_type, id);
+ node = (struct ec_node_sh_lex *)__ec_node(&ec_node_sh_lex_type, id);
if (node == NULL) {
ec_node_free(child);
return NULL;
const char *str;
size_t len = 0;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
struct ec_node *node;
int ret = 0;
- node = ec_node_new("space", NULL);
+ node = ec_node("space", NULL);
if (node == NULL) {
ec_log(EC_LOG_ERR, "cannot create node\n");
return -1;
ec_node_free(node);
/* test completion */
- node = ec_node_new("space", NULL);
+ node = ec_node("space", NULL);
if (node == NULL) {
ec_log(EC_LOG_ERR, "cannot create node\n");
return -1;
struct ec_parsed *parsed = NULL;
const char *str;
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
const char *str, *add;
size_t n = 0;
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
return NULL;
else
add = node->string + n;
- completed_elt = ec_completed_elt_new(gen_node, add);
+ completed_elt = ec_completed_elt(gen_node, add);
if (completed_elt == NULL) {
ec_completed_free(completed);
return NULL;
{
struct ec_node *gen_node = NULL;
- gen_node = __ec_node_new(&ec_node_str_type, id);
+ gen_node = __ec_node(&ec_node_str_type, id);
if (gen_node == NULL)
goto fail;
struct ec_node *ec_node_str(const char *id, const char *str);
-struct ec_node *ec_node_str_new(const char *id);
-
/* str is duplicated */
int ec_node_str_set_str(struct ec_node *node, const char *str);
memset(&result, 0, sizeof(result));
- parsed = ec_parsed_new();
+ parsed = ec_parsed();
if (parsed == NULL)
goto fail;
/* if no child node matches, return a matching empty strvec */
if (result.parsed_table_len == 0) {
ec_free(result.parsed_table);
- match_strvec = ec_strvec_new();
+ match_strvec = ec_strvec();
if (match_strvec == NULL)
goto fail;
ec_parsed_set_match(parsed, gen_node, match_strvec);
* + __subset_complete([a, b], childvec) if c matches
*/
- completed = ec_completed_new();
+ completed = ec_completed();
if (completed == NULL)
goto fail;
va_start(ap, id);
- gen_node = __ec_node_new(&ec_node_subset_type, id);
+ gen_node = __ec_node(&ec_node_subset_type, id);
node = (struct ec_node_subset *)gen_node;
if (node == NULL)
fail = 1;;
if (child == NULL)
return NULL;
- gen_node = __ec_node_new(&ec_node_weakref_type, id);
+ gen_node = __ec_node(&ec_node_weakref_type, id);
if (gen_node == NULL)
return NULL;
struct ec_strvec_elt **vec;
};
-struct ec_strvec *ec_strvec_new(void)
+struct ec_strvec *ec_strvec(void)
{
struct ec_strvec *strvec;
struct ec_strvec *copy = NULL;
size_t i, veclen;
- copy = ec_strvec_new();
+ copy = ec_strvec();
if (copy == NULL)
goto fail;
#include <sys/types.h>
#include <stdio.h>
-struct ec_strvec *ec_strvec_new(void);
+struct ec_strvec *ec_strvec(void);
int ec_strvec_add(struct ec_strvec *strvec, const char *s);
struct ec_strvec *ec_strvec_dup(const struct ec_strvec *strvec);
struct ec_strvec *ec_strvec_ndup(const struct ec_strvec *strvec,
va_start(ap, expected);
/* build a string vector */
- vec = ec_strvec_new();
+ vec = ec_strvec();
if (vec == NULL)
goto out;
va_start(ap, tk);
/* build a string vector */
- vec = ec_strvec_new();
+ vec = ec_strvec();
if (vec == NULL)
goto out;
return NULL;
ec_completed_iter_free(iter);
- iter = ec_completed_iter_new(c, EC_MATCH);
+ iter = ec_completed_iter(c, EC_MATCH);
if (iter == NULL)
return NULL;
}
if (helps == NULL)
return 1;
- iter = ec_completed_iter_new(c, EC_MATCH | EC_NO_MATCH);
+ iter = ec_completed_iter(c, EC_MATCH | EC_NO_MATCH);
if (iter == NULL)
goto fail;
{
struct ec_node *cmdlist = NULL, *cmd = NULL;
- cmdlist = ec_node_new("or", NULL);
+ cmdlist = ec_node("or", NULL);
if (cmdlist == NULL)
goto fail;