From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] completion: Fix completion for devices with a dot in the name
Date: Fri, 7 Oct 2016 09:09:08 +0200 [thread overview]
Message-ID: <20161007070908.14855-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20161007070908.14855-1-s.hauer@pengutronix.de>
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 <s.hauer@pengutronix.de>
---
common/complete.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/common/complete.c b/common/complete.c
index aee21ea..2dab7d1 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -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)
@@ -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();
@@ -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);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2016-10-07 7:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 7:09 [PATCH 1/2] Allow device parameters for devices with dots in name Sascha Hauer
2016-10-07 7:09 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161007070908.14855-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox