struct graph_node *start = vector_slot (cmdgraph->nodes, 0);
if ((*argv = command_match_r (start, vvline, 0))) // successful match
{
+ struct listnode *head = listhead (*argv);
+ struct listnode *tail = listtail (*argv);
+
// delete dummy start node
- list_delete_node (*argv, listhead (*argv));
+ del_cmd_token ((struct cmd_token_t *) head->data);
+ list_delete_node (*argv, head);
+
// get cmd_element out of list tail
- struct listnode *tail = listtail (*argv);
*el = listgetdata (tail);
- // delete list tail
- tail->data = NULL;
list_delete_node (*argv, tail);
+
// now argv is an ordered list of cmd_token matching the user
// input, with each cmd_token->arg holding the corresponding input
assert (*el);
unsigned int idx;
for (idx = 0; idx < vector_active (vline) && next->count > 0; idx++)
{
- list_free (current);
+ list_delete (current);
current = next;
next = list_new();
for (ALL_LIST_ELEMENTS_RO (next,node,gn))
listnode_add (*completions, gn->data);
- list_free (current);
- list_free (next);
+ list_delete (current);
+ list_delete (next);
return matcher_rv;
}
vector command = cmd_make_strvec (cmdstr);
// generate completions of user input
- struct list *completions = list_new ();
+ struct list *completions;
enum matcher_rv result = command_complete (nodegraph, command, &completions);
// print completions or relevant error message
tkn = vector_slot (comps, i);
fprintf (stdout, " %-*s %s%s", width, tkn->text, tkn->desc, "\n");
}
+
+ for (i = 0; i < vector_active (comps); i++)
+ del_cmd_token ((struct cmd_token_t *) vector_slot (comps, i));
+ vector_free (comps);
}
else
fprintf (stdout, "%% No match%s", "\n");
fprintf (stdout, "func: %p%s", element->func, "\n");
list_delete (argvv);
+ del_cmd_element (element);
}
else {
assert(MATCHER_ERROR(result));
}
// free resources
- cmd_free_strvec(command);
- free(cmdstr);
+ cmd_free_strvec (command);
+ free (cmdstr);
return CMD_SUCCESS;
}
void
del_cmd_token (struct cmd_token_t *token)
{
+ fprintf (stdout, "deleting token\n");
if (!token) return;
if (token->text)