X-Git-Url: http://git.droids-corp.org/?p=protos%2Flibecoli.git;a=blobdiff_plain;f=examples%2Freadline%2Fmain.c;fp=examples%2Freadline%2Fmain.c;h=a64d068b0048296e5c3cb4ad47156dfb5ba97b87;hp=90a25f070ba477f72622333dab20e9d228477ecf;hb=331d87b8f34493ea7eb4db75fa9d90b2e3ed503b;hpb=67b4d8d2b2593e3e64a848ce548bc0fd76bc440a diff --git a/examples/readline/main.c b/examples/readline/main.c index 90a25f0..a64d068 100644 --- a/examples/readline/main.c +++ b/examples/readline/main.c @@ -106,16 +106,16 @@ static char **my_attempted_completion(const char *text, int start, int end) static char *get_node_help(const struct ec_comp_item *item) { const struct ec_comp_group *grp; - const struct ec_pnode *state; + const struct ec_pnode *pstate; const struct ec_node *node; char *help = NULL; const char *node_help = NULL; - const char *node_desc = NULL; + char *node_desc = NULL; grp = ec_comp_item_get_grp(item); - for (state = ec_comp_group_get_state(grp); state != NULL; - state = ec_pnode_get_parent(state)) { - node = ec_pnode_get_node(state); + for (pstate = ec_comp_group_get_pstate(grp); pstate != NULL; + pstate = ec_pnode_get_parent(pstate)) { + node = ec_pnode_get_node(pstate); if (node_help == NULL) node_help = ec_dict_get(ec_node_attrs(node), "help"); if (node_desc == NULL) @@ -130,6 +130,8 @@ static char *get_node_help(const struct ec_comp_item *item) if (asprintf(&help, "%-20s %s", node_desc, node_help) < 0) return NULL; + ec_free(node_desc); + return help; } @@ -141,7 +143,7 @@ static int show_help(int ignore, int invoking_key) struct ec_comp *c = NULL; struct ec_pnode *p = NULL; char *line = NULL; - unsigned int count; + size_t count; char **helps = NULL; int match = 0; int cols;