From 1ceb5917fd1b73c42d2ad535a0a65e645d6b4dbe Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Thu, 8 Mar 2018 22:30:04 +0100 Subject: [PATCH] remove max parse len --- lib/ecoli_node.c | 13 ------------- lib/ecoli_node.h | 9 --------- lib/ecoli_node_int.c | 8 -------- lib/ecoli_node_or.c | 15 --------------- lib/ecoli_node_re.c | 7 ------- lib/ecoli_node_seq.c | 17 ----------------- lib/ecoli_node_str.c | 7 ------- 7 files changed, 76 deletions(-) diff --git a/lib/ecoli_node.c b/lib/ecoli_node.c index ff52440..f8c6c02 100644 --- a/lib/ecoli_node.c +++ b/lib/ecoli_node.c @@ -156,13 +156,6 @@ void ec_node_free(struct ec_node *node) ec_free(node); } -size_t ec_node_get_max_parse_len(const struct ec_node *node) -{ - if (node->type->get_max_parse_len == NULL) - return SIZE_MAX; - return node->type->get_max_parse_len(node); -} - struct ec_node *ec_node_clone(struct ec_node *node) { if (node != NULL) @@ -268,10 +261,8 @@ static void __ec_node_dump(FILE *out, { const char *id, *typename, *desc; struct ec_node *child; - size_t maxlen; size_t i, n; - maxlen = ec_node_get_max_parse_len(node); id = ec_node_id(node); typename = node->type->name; desc = ec_node_desc(node); @@ -286,10 +277,6 @@ static void __ec_node_dump(FILE *out, fprintf(out, "node %p type=%s id=%s desc=%s ", node, typename, id, desc); - if (maxlen == SIZE_MAX) - fprintf(out, "maxlen=no\n"); - else - fprintf(out, "maxlen=%zu\n", maxlen); n = node->n_children; for (i = 0; i < n; i++) { child = node->children[i]; diff --git a/lib/ecoli_node.h b/lib/ecoli_node.h index 6520d23..f0b0281 100644 --- a/lib/ecoli_node.h +++ b/lib/ecoli_node.h @@ -99,7 +99,6 @@ typedef int (*ec_node_parse_t)(const struct ec_node *node, typedef int (*ec_node_complete_t)(const struct ec_node *node, struct ec_completed *completed_state, const struct ec_strvec *strvec); -typedef size_t (*ec_node_get_max_parse_len_t)(const struct ec_node *node); typedef const char * (*ec_node_desc_t)(const struct ec_node *); typedef int (*ec_node_init_priv_t)(struct ec_node *); typedef void (*ec_node_free_priv_t)(struct ec_node *); @@ -113,7 +112,6 @@ struct ec_node_type { ec_node_build_t build; /**< (Re)build the node */ ec_node_parse_t parse; ec_node_complete_t complete; - ec_node_get_max_parse_len_t get_max_parse_len; ec_node_desc_t desc; size_t size; ec_node_init_priv_t init_priv; @@ -172,13 +170,6 @@ ec_node_get_child(const struct ec_node *node, size_t i); int ec_node_add_child(struct ec_node *node, struct ec_node *child); int ec_node_del_child(struct ec_node *node, struct ec_node *child); -/** - * Get the max len of strvec that can be parsed by this node - * - * If there is no maximum, return SIZE_MAX. - */ -size_t ec_node_get_max_parse_len(const struct ec_node *node); - /* XXX add more accessors */ struct ec_keyval *ec_node_attrs(const struct ec_node *node); const char *ec_node_id(const struct ec_node *node); diff --git a/lib/ecoli_node_int.c b/lib/ecoli_node_int.c index b086c56..f8ba567 100644 --- a/lib/ecoli_node_int.c +++ b/lib/ecoli_node_int.c @@ -139,12 +139,6 @@ static int ec_node_int_uint_parse(const struct ec_node *gen_node, return 1; } -static size_t ec_node_int_uint_get_max_parse_len(const struct ec_node *gen_node) -{ - (void)gen_node; - return 1; -} - static int ec_node_uint_init_priv(struct ec_node *gen_node) { @@ -159,7 +153,6 @@ static struct ec_node_type ec_node_int_type = { .name = "int", .parse = ec_node_int_uint_parse, .complete = ec_node_default_complete, - .get_max_parse_len = ec_node_int_uint_get_max_parse_len, .size = sizeof(struct ec_node_int_uint), .init_priv = ec_node_uint_init_priv, }; @@ -191,7 +184,6 @@ static struct ec_node_type ec_node_uint_type = { .name = "uint", .parse = ec_node_int_uint_parse, .complete = ec_node_default_complete, - .get_max_parse_len = ec_node_int_uint_get_max_parse_len, .size = sizeof(struct ec_node_int_uint), }; diff --git a/lib/ecoli_node_or.c b/lib/ecoli_node_or.c index 03aa5fe..76ee271 100644 --- a/lib/ecoli_node_or.c +++ b/lib/ecoli_node_or.c @@ -88,20 +88,6 @@ ec_node_or_complete(const struct ec_node *gen_node, return 0; } -static size_t ec_node_or_get_max_parse_len(const struct ec_node *gen_node) -{ - struct ec_node_or *node = (struct ec_node_or *)gen_node; - size_t i, ret = 0, len; - - for (i = 0; i < node->len; i++) { - len = ec_node_get_max_parse_len(node->table[i]); - if (len > ret) - ret = len; - } - - return ret; -} - static void ec_node_or_free_priv(struct ec_node *gen_node) { struct ec_node_or *node = (struct ec_node_or *)gen_node; @@ -116,7 +102,6 @@ static struct ec_node_type ec_node_or_type = { .name = "or", .parse = ec_node_or_parse, .complete = ec_node_or_complete, - .get_max_parse_len = ec_node_or_get_max_parse_len, .size = sizeof(struct ec_node_or), .free_priv = ec_node_or_free_priv, }; diff --git a/lib/ecoli_node_re.c b/lib/ecoli_node_re.c index 85ac921..a83bf8a 100644 --- a/lib/ecoli_node_re.c +++ b/lib/ecoli_node_re.c @@ -71,12 +71,6 @@ ec_node_re_parse(const struct ec_node *gen_node, return 1; } -static size_t ec_node_re_get_max_parse_len(const struct ec_node *gen_node) -{ - (void)gen_node; - return 1; -} - static void ec_node_re_free_priv(struct ec_node *gen_node) { struct ec_node_re *node = (struct ec_node_re *)gen_node; @@ -89,7 +83,6 @@ static struct ec_node_type ec_node_re_type = { .name = "re", .parse = ec_node_re_parse, .complete = ec_node_default_complete, - .get_max_parse_len = ec_node_re_get_max_parse_len, .size = sizeof(struct ec_node_re), .free_priv = ec_node_re_free_priv, }; diff --git a/lib/ecoli_node_seq.c b/lib/ecoli_node_seq.c index 68aa287..e1bc40d 100644 --- a/lib/ecoli_node_seq.c +++ b/lib/ecoli_node_seq.c @@ -179,22 +179,6 @@ ec_node_seq_complete(const struct ec_node *gen_node, strvec); } -static size_t ec_node_seq_get_max_parse_len(const struct ec_node *gen_node) -{ - struct ec_node_seq *node = (struct ec_node_seq *)gen_node; - size_t i, len, ret = 0; - - for (i = 0; i < node->len; i++) { - len = ec_node_get_max_parse_len(node->table[i]); - if (len <= SIZE_MAX - ret) - ret += len; - else - ret = SIZE_MAX; - } - - return ret; -} - static void ec_node_seq_free_priv(struct ec_node *gen_node) { struct ec_node_seq *node = (struct ec_node_seq *)gen_node; @@ -209,7 +193,6 @@ static struct ec_node_type ec_node_seq_type = { .name = "seq", .parse = ec_node_seq_parse, .complete = ec_node_seq_complete, - .get_max_parse_len = ec_node_seq_get_max_parse_len, .size = sizeof(struct ec_node_seq), .free_priv = ec_node_seq_free_priv, }; diff --git a/lib/ecoli_node_str.c b/lib/ecoli_node_str.c index af4f607..716d20f 100644 --- a/lib/ecoli_node_str.c +++ b/lib/ecoli_node_str.c @@ -110,17 +110,10 @@ static void ec_node_str_free_priv(struct ec_node *gen_node) ec_free(node->string); } -static size_t ec_node_str_get_max_parse_len(const struct ec_node *gen_node) -{ - (void)gen_node; - return 1; -} - static struct ec_node_type ec_node_str_type = { .name = "str", .parse = ec_node_str_parse, .complete = ec_node_str_complete, - .get_max_parse_len = ec_node_str_get_max_parse_len, .desc = ec_node_str_desc, .size = sizeof(struct ec_node_str), .free_priv = ec_node_str_free_priv, -- 2.39.5