lib: Fix various matching bugs

Missed a copy, disambigs forgot to walkback

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2016-09-13 01:16:22 +00:00
parent 97c45dae54
commit ee551f4827
2 changed files with 7 additions and 4 deletions

View File

@ -208,7 +208,8 @@ command_match_r (struct graph_node *start, vector vline, unsigned int n)
// that all nodes have the same data type, so when // that all nodes have the same data type, so when
// deleting this list the last node must be // deleting this list the last node must be
// manually deleted // manually deleted
listnode_add (currbest, leaf->data); struct cmd_element *el = leaf->data;
listnode_add (currbest, copy_cmd_element (el));
currbest->del = (void (*)(void *)) &del_cmd_token; currbest->del = (void (*)(void *)) &del_cmd_token;
break; break;
} }
@ -533,8 +534,10 @@ disambiguate (struct list *first,
char *token = vector_slot(vline, i); char *token = vector_slot(vline, i);
if ((best = disambiguate_tokens (ftok, stok, token))) if ((best = disambiguate_tokens (ftok, stok, token)))
return best == ftok ? first : second; return best == ftok ? first : second;
ftok = listgetdata (listnextnode (fnode)); fnode = listnextnode (fnode);
stok = listgetdata (listnextnode (snode)); snode = listnextnode (snode);
ftok = listgetdata (fnode);
stok = listgetdata (snode);
} }
return NULL; return NULL;

View File

@ -446,7 +446,7 @@ doc_next()
{ {
char *piece = NULL; char *piece = NULL;
if (!docstr || !(piece = strsep (&docstr, "\n"))) if (!docstr || !(piece = strsep (&docstr, "\n")))
return NULL; return XSTRDUP (MTYPE_CMD_TOKENS, "");
return XSTRDUP (MTYPE_CMD_TOKENS, piece); return XSTRDUP (MTYPE_CMD_TOKENS, piece);
} }