return NULL;
compnode->node = node;
- TAILQ_INIT(&compnode->matches);
+ TAILQ_INIT(&compnode->items);
return compnode;
}
static struct ec_completed_item *
-ec_completed_item(enum ec_completed_type type, struct ec_parsed *state,
- const struct ec_node *node, const char *add)
+ec_completed_item(struct ec_parsed *state, const struct ec_node *node)
{
struct ec_completed_item *item = NULL;
struct ec_parsed *p;
p = ec_parsed_get_parent(p), len++)
item->path[len] = p->node;
- item->type = type;
+ item->type = EC_NO_MATCH;
item->node = node;
- if (add != NULL) {
- item->add = ec_strdup(add);
- if (item->add == NULL)
- goto fail;
- }
return item;
fail:
if (item != NULL) {
ec_free(item->path);
- ec_free(item->add);
+ ec_free(item->str);
}
ec_completed_item_free(item);
__ec_completed_add_match(enum ec_completed_type type,
struct ec_completed *completed,
struct ec_parsed *parsed_state,
- const struct ec_node *node, const char *add)
+ const struct ec_node *node, const char *str)
{
struct ec_completed_node *compnode = NULL;
- struct ec_completed_item *match = NULL;
+ struct ec_completed_item *item = NULL;
int ret = -ENOMEM;
/* find the compnode entry corresponding to this node */
if (compnode == NULL)
return -ENOENT;
- match = ec_completed_item(type, parsed_state, node, add);
- if (match == NULL)
+ item = ec_completed_item(parsed_state, node);
+ if (item == NULL)
goto fail;
+ item->type = type;
+ if (str != NULL) {
+ item->str = ec_strdup(str);
+ if (item->str == NULL)
+ goto fail;
+ }
- if (match->add != NULL)
+ if (item->str != NULL)
completed->count_match++;
- TAILQ_INSERT_TAIL(&compnode->matches, match, next);
+ TAILQ_INSERT_TAIL(&compnode->items, item, next);
completed->count++;
return 0;
fail:
- ec_completed_item_free(match);
+ ec_completed_item_free(item);
return ret;
}
int
ec_completed_add_match(struct ec_completed *completed,
struct ec_parsed *parsed_state,
- const struct ec_node *node, const char *add)
+ const struct ec_node *node, const char *str)
{
- return __ec_completed_add_match(EC_MATCH, completed, parsed_state,
- node, add);
+ struct ec_completed_node *compnode = NULL;
+ struct ec_completed_item *item = NULL;
+ int ret = -ENOMEM;
+
+ /* find the compnode entry corresponding to this node */
+ TAILQ_FOREACH(compnode, &completed->nodes, next) {
+ if (compnode->node == node)
+ break;
+ }
+ if (compnode == NULL)
+ return -ENOENT;
+
+ item = ec_completed_item(parsed_state, node);
+ if (item == NULL)
+ goto fail;
+ item->type = EC_MATCH;
+ if (str != NULL) {
+ item->str = ec_strdup(str);
+ if (item->str == NULL)
+ goto fail;
+ }
+
+ if (item->str != NULL)
+ completed->count_match++;
+
+ TAILQ_INSERT_TAIL(&compnode->items, item, next);
+ completed->count++;
+
+ return 0;
+
+fail:
+ ec_completed_item_free(item);
+ return ret;
}
int
int
ec_completed_add_partial_match(struct ec_completed *completed,
struct ec_parsed *parsed_state,
- const struct ec_node *node, const char *add)
+ const struct ec_node *node, const char *str)
{
return __ec_completed_add_match(EC_PARTIAL_MATCH, completed, parsed_state,
- node, add);
+ node, str);
}
int
void ec_completed_item_free(struct ec_completed_item *match)
{
- ec_free(match->add);
+ ec_free(match->str);
ec_free(match->path);
ec_free(match);
}
compnode = TAILQ_FIRST(&completed->nodes);
TAILQ_REMOVE(&completed->nodes, compnode, next);
- while (!TAILQ_EMPTY(&compnode->matches)) {
- item = TAILQ_FIRST(&compnode->matches);
- TAILQ_REMOVE(&compnode->matches, item, next);
+ while (!TAILQ_EMPTY(&compnode->items)) {
+ item = TAILQ_FIRST(&compnode->items);
+ TAILQ_REMOVE(&compnode->items, item, next);
ec_completed_item_free(item);
}
ec_free(compnode);
TAILQ_FOREACH(compnode, &completed->nodes, next) {
fprintf(out, "node=%p, node_type=%s\n",
compnode->node, compnode->node->type->name);
- TAILQ_FOREACH(item, &compnode->matches, next) {
+ TAILQ_FOREACH(item, &compnode->items, next) {
const char *typestr;
switch (item->type) {
default: typestr = "unknown"; break;
}
- fprintf(out, " type=%s add=<%s>\n", typestr, item->add);
+ fprintf(out, " type=%s str=<%s>\n", typestr, item->str);
}
}
}
goto fail;
TAILQ_FOREACH(compnode, &completed->nodes, next) {
- TAILQ_FOREACH(item, &compnode->matches, next) {
- if (item->add == NULL)
+ TAILQ_FOREACH(item, &compnode->items, next) {
+ if (item->str == NULL)
continue;
if (smallest_start == NULL) {
- smallest_start = ec_strdup(item->add);
+ smallest_start = ec_strdup(item->str);
if (smallest_start == NULL)
goto fail;
} else {
- n = strcmp_count(item->add, smallest_start);
+ n = strcmp_count(item->str, smallest_start);
smallest_start[n] = '\0';
}
}
/* first call */
if (cur_node == NULL) {
TAILQ_FOREACH(cur_node, &completed->nodes, next) {
- TAILQ_FOREACH(cur_match, &cur_node->matches, next) {
+ TAILQ_FOREACH(cur_match, &cur_node->items, next) {
if (cur_match != NULL &&
cur_match->type & iter->type)
goto found;
goto found;
cur_node = TAILQ_NEXT(cur_node, next);
while (cur_node != NULL) {
- cur_match = TAILQ_FIRST(&cur_node->matches);
+ cur_match = TAILQ_FIRST(&cur_node->items);
if (cur_match != NULL &&
cur_match->type & iter->type)
goto found;
TAILQ_ENTRY(ec_completed_item) next;
enum ec_completed_type type;
const struct ec_node *node;
- char *add;
+ char *str;
/* reverse order: [0] = last, [len-1] = root */
const struct ec_node **path;
struct ec_completed_node {
TAILQ_ENTRY(ec_completed_node) next;
const struct ec_node *node;
- struct ec_completed_item_list matches;
+ struct ec_completed_item_list items;
};
TAILQ_HEAD(ec_completed_node_list, ec_completed_node);
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "good", EC_NODE_ENDLIST,
- "good");
+ "good", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"g", EC_NODE_ENDLIST,
- "ood", EC_NODE_ENDLIST,
- "ood");
+ "good", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"good", "morning", "", EC_NODE_ENDLIST,
- "bob", "bobby", "michael", EC_NODE_ENDLIST,
- "");
+ "bob", "bobby", "michael", EC_NODE_ENDLIST);
ec_node_free(node);
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
}
/*
- * Almost the same than dirname (3) and basename (3) except that
- * it always returns a substring of the given path, which can
- * be empty.
+ * Almost the same than dirname (3) and basename (3) except that:
+ * - it always returns a substring of the given path, which can
+ * be empty.
* - the behavior is different when the path finishes with a '/'
- * - the argument is not modified
- * - the output is allocated and must be freed with ec_free().
+ * - the path argument is not modified
+ * - the outputs are allocated and must be freed with ec_free().
*
* path dirname basename split_path
* /usr/lib /usr lib /usr/ lib
}
if (is_dir) {
- if (asprintf(&add, "%s/", &de->d_name[bname_len]) < 0) {
+ if (asprintf(&add, "%s%s/", path,
+ &de->d_name[bname_len]) < 0) {
ret = -errno;
goto out;
}
goto out;
}
} else {
- if (asprintf(&add, "%s", &de->d_name[bname_len]) < 0) {
+ if (asprintf(&add, "%s%s", path,
+ &de->d_name[bname_len]) < 0) {
ret = -errno;
goto out;
}
#if 0 // XXX how to properly test file completion?
ret |= EC_TEST_CHECK_COMPLETE(node,
EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"/", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"/tmp", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"/tmp/", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"/tmp/.", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
#endif
ec_node_free(node);
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"x", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"1", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", EC_NODE_ENDLIST,
- "", EC_NODE_ENDLIST,
- "");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "foo", "", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "foo", "foo", "", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "foo", "foo", "foo", "", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST,
- "");
+ "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ec_node_free(node);
#endif
return ret;
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"b", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST,
- "");
+ "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"b", EC_NODE_ENDLIST,
- "ar", "ar2", EC_NODE_ENDLIST,
- "ar");
+ "bar", "bar2", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"bar", EC_NODE_ENDLIST,
- "", "2", EC_NODE_ENDLIST,
- "");
+ "bar", "bar2", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"t", EC_NODE_ENDLIST,
- "oto", "iti", EC_NODE_ENDLIST,
- "");
+ "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"to", EC_NODE_ENDLIST,
- "to", EC_NODE_ENDLIST,
- "to");
+ "toto", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"x", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", EC_NODE_ENDLIST,
- "", EC_NODE_ENDLIST,
- "");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "", EC_NODE_ENDLIST,
- "bar", "toto", EC_NODE_ENDLIST,
- "");
+ "bar", "toto", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "t", EC_NODE_ENDLIST,
- "oto", EC_NODE_ENDLIST,
- "oto");
+ "toto", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "b", EC_NODE_ENDLIST,
- "ar", EC_NODE_ENDLIST,
- "ar");
+ "bar", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", "bar", EC_NODE_ENDLIST,
- "", EC_NODE_ENDLIST,
- "");
+ "bar", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"x", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foobarx", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
" ", EC_NODE_ENDLIST,
- "foo", EC_NODE_ENDLIST,
- "foo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", EC_NODE_ENDLIST,
- "", EC_NODE_ENDLIST,
- "");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo ", EC_NODE_ENDLIST,
- "bar", "toto", EC_NODE_ENDLIST,
- "");
+ "bar", "toto", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo t", EC_NODE_ENDLIST,
- "oto", EC_NODE_ENDLIST,
- "oto");
+ "toto", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo b", EC_NODE_ENDLIST,
- "ar", EC_NODE_ENDLIST,
- "ar");
+ "bar", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo bar", EC_NODE_ENDLIST,
- "", EC_NODE_ENDLIST,
- "");
+ "bar", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo bar ", EC_NODE_ENDLIST,
- "titi", EC_NODE_ENDLIST,
- "titi");
+ "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo toto bar ", EC_NODE_ENDLIST,
- "titi", EC_NODE_ENDLIST,
- "titi");
+ "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"x", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo barx", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
ec_log(EC_LOG_ERR, "cannot create node\n");
return -1;
}
+ /* never completes whatever the input */
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
" ", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
if (str[n] == '\0') {
if (ec_completed_add_match(completed, parsed, gen_node,
- node->string + n) < 0)
+ node->string) < 0)
return -1;
}
"foo");
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST,
+ "foo");
ret |= EC_TEST_CHECK_COMPLETE(node,
"foo", EC_NODE_ENDLIST,
- "", EC_NODE_ENDLIST,
- "");
+ "foo", EC_NODE_ENDLIST,
+ "foo");
ret |= EC_TEST_CHECK_COMPLETE(node,
"x", EC_NODE_ENDLIST,
EC_NODE_ENDLIST,
}
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST,
- "");
+ "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"", EC_NODE_ENDLIST,
- "bar2", "bar", "foo", "toto", "titi", EC_NODE_ENDLIST,
- "");
+ "bar2", "bar", "foo", "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"bar", "bar2", "", EC_NODE_ENDLIST,
- "foo", "toto", "titi", EC_NODE_ENDLIST,
- "");
+ "foo", "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"f", EC_NODE_ENDLIST,
- "oo", EC_NODE_ENDLIST,
- "oo");
+ "foo", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"b", EC_NODE_ENDLIST,
- "ar", "ar2", EC_NODE_ENDLIST,
- "ar");
+ "bar", "bar2", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"bar", EC_NODE_ENDLIST,
- "", "2", EC_NODE_ENDLIST,
- "");
+ "bar", "bar2", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"bar", "b", EC_NODE_ENDLIST,
- "ar2", EC_NODE_ENDLIST,
- "ar2");
+ "bar2", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"t", EC_NODE_ENDLIST,
- "oto", "iti", EC_NODE_ENDLIST,
- "");
+ "toto", "titi", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"to", EC_NODE_ENDLIST,
- "to", EC_NODE_ENDLIST,
- "to");
+ "toto", EC_NODE_ENDLIST);
ret |= EC_TEST_CHECK_COMPLETE(node,
"x", EC_NODE_ENDLIST,
- EC_NODE_ENDLIST,
- "");
+ EC_NODE_ENDLIST);
ec_node_free(node);
return ret;
{
struct ec_completed *c = NULL;
struct ec_strvec *vec = NULL;
- const char *expected, *s;
- char *smallest_start = NULL;
+ const char *s;
int ret = 0;
unsigned int count = 0;
va_list ap;
/* only check matching completions */
iter = ec_completed_iter(c, EC_MATCH);
while ((item = ec_completed_iter_next(iter)) != NULL) {
- if (item->add != NULL && strcmp(item->add, s) == 0)
+ if (item->str != NULL && strcmp(item->str, s) == 0)
break;
}
} else
ec_completed_dump(stdout, c); //XXX
- /* check the expected smallest start */
- expected = va_arg(ap, const char *);
- smallest_start = ec_completed_smallest_start(c);
- if (smallest_start == NULL)
- goto out;
- if (strcmp(smallest_start, expected)) {
- ret = -1;
- ec_log(EC_LOG_ERR,
- "should complete with <%s> but completes with <%s>\n",
- expected, s);
- }
-
out:
ec_strvec_free(vec);
ec_completed_free(c);
- ec_free(smallest_start);
va_end(ap);
return ret;
}
static struct ec_completed *c;
static struct ec_completed_iter *iter;
static const struct ec_completed_item *item;
- char *out_string;
+
+ (void)s;
/* don't append a quote */
rl_completion_suppress_quote = 1;
//XXX see printable_part() and rl_display_match_list()
//XXX or: if match count > 1, strip beginning (in node_file)
- if (asprintf(&out_string, "%s%s", s, item->add) < 0) // XXX ec_asprintf (check all in code)
- return NULL;
-
- return out_string;
+ return strdup(item->str);
}
static char **my_attempted_completion(const char *text, int start, int end)
#else
count = 0;
TAILQ_FOREACH(compnode, &c->nodes, next) {
- if (TAILQ_EMPTY(&compnode->matches))
+ if (TAILQ_EMPTY(&compnode->items))
continue;
count++;
}
if (match)
helps[1] = "<return>";
+ /* strangely, rl_display_match_list() expects first index at 1 */
i = match + 1;
TAILQ_FOREACH(compnode, &c->nodes, next) {
- if (TAILQ_EMPTY(&compnode->matches))
+ if (TAILQ_EMPTY(&compnode->items))
continue;
// we should pass compnode instead
- helps[i++] = get_node_help(TAILQ_FIRST(&compnode->matches)); //XXX
+ helps[i++] = get_node_help(TAILQ_FIRST(&compnode->items)); //XXX
}
#endif