Skip to content

Commit

Permalink
completion: Fix completion for devices with a dot in the name
Browse files Browse the repository at this point in the history
Devices can have a dot in the name, so do not expect the full
device name before the first dot.

Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
saschahauer committed Oct 7, 2016
1 parent f5d77d8 commit e4a45c0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions common/complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
struct env_context *c;
char *instr_param;
int len;
char end = '=';
char end = '=', *pos, *dot;
char *begin = "";

if (!instr)
Expand All @@ -290,7 +290,6 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
end = ' ';
}

instr_param = strchr(instr, '.');
len = strlen(instr);

c = get_current_context();
Expand All @@ -312,20 +311,21 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
c = c->parent;
}

if (instr_param) {
pos = instr;
while ((dot = strchr(pos, '.'))) {
char *devname;

len = (instr_param - instr);

devname = xstrndup(instr, len);
devname = xstrndup(instr, dot - instr);

instr_param++;

dev = get_device_by_name(devname);
free(devname);

if (dev)
device_param_complete(dev, sl, instr_param, eval);
return 0;
device_param_complete(dev, sl, dot + 1, eval);

pos = dot + 1;
}

len = strlen(instr);
Expand Down

0 comments on commit e4a45c0

Please sign in to comment.