Skip to content
Snippets Groups Projects
Commit af4d9074 authored by Kim Phillips's avatar Kim Phillips Committed by Wolfgang Denk
Browse files

env: fix env var autocompletion


commit 560d424b "env: re-add
support for auto-completion" fell short of its description -
the 'used' logic in hmatch_r was reversed - 'used' is 0 if
the hash table entry is not used, or -1 if deleted.  This
patch makes hmatch_r actually match on valid ('used') entries,
instead of skipping them and failing to match anything.

typing 'printenv tft' and hitting 'tab' now displays valid
choices for variable names.

Signed-off-by: default avatarKim Phillips <kim.phillips@freescale.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Tested-by: default avatarMike Frysinger <vapier@gentoo.org>
parent f3143134
No related branches found
No related tags found
No related merge requests found
...@@ -209,7 +209,7 @@ int hmatch_r(const char *match, int last_idx, ENTRY ** retval, ...@@ -209,7 +209,7 @@ int hmatch_r(const char *match, int last_idx, ENTRY ** retval,
size_t key_len = strlen(match); size_t key_len = strlen(match);
for (idx = last_idx + 1; idx < htab->size; ++idx) { for (idx = last_idx + 1; idx < htab->size; ++idx) {
if (htab->table[idx].used > 0) if (htab->table[idx].used <= 0)
continue; continue;
if (!strncmp(match, htab->table[idx].entry.key, key_len)) { if (!strncmp(match, htab->table[idx].entry.key, key_len)) {
*retval = &htab->table[idx].entry; *retval = &htab->table[idx].entry;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment