summaryrefslogtreecommitdiff
path: root/common/cmd_nvedit.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2013-03-23 23:50:29 +0000
committerTom Rini <trini@ti.com>2013-05-01 16:24:00 -0400
commit5a31ea04c9ee5544fbb70ad7597ea4b294840eab (patch)
treea6a8c141675e4a4f712aa05b9d2aa5792a0309dd /common/cmd_nvedit.c
parentea009d4743ab4b801703982086e053e74266ff4c (diff)
downloadu-boot-imx-5a31ea04c9ee5544fbb70ad7597ea4b294840eab.zip
u-boot-imx-5a31ea04c9ee5544fbb70ad7597ea4b294840eab.tar.gz
u-boot-imx-5a31ea04c9ee5544fbb70ad7597ea4b294840eab.tar.bz2
"env grep" - reimplement command using hexport_r()
Also drop hstrstr_r() which is not needed any more. The new code is way more flexible. Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'common/cmd_nvedit.c')
-rw-r--r--common/cmd_nvedit.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 49b9d74..a4b71f8 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -164,31 +164,25 @@ static int do_env_print(cmd_tbl_t *cmdtp, int flag, int argc,
static int do_env_grep(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
- ENTRY *match;
- unsigned char matched[env_htab.size / 8];
- int rcode = 1, arg = 1, idx;
+ char *res = NULL;
+ int len;
if (argc < 2)
return CMD_RET_USAGE;
- memset(matched, 0, env_htab.size / 8);
+ len = hexport_r(&env_htab, '\n',
+ flag | H_MATCH_BOTH | H_MATCH_SUBSTR,
+ &res, 0, argc, argv);
- while (arg <= argc) {
- idx = 0;
- while ((idx = hstrstr_r(argv[arg], idx, &match, &env_htab))) {
- if (!(matched[idx / 8] & (1 << (idx & 7)))) {
- puts(match->key);
- puts("=");
- puts(match->data);
- puts("\n");
- }
- matched[idx / 8] |= 1 << (idx & 7);
- rcode = 0;
- }
- arg++;
+ if (len > 0) {
+ puts(res);
+ free(res);
}
- return rcode;
+ if (len < 2)
+ return 1;
+
+ return 0;
}
#endif
#endif /* CONFIG_SPL_BUILD */