Commit af4d9074aa0ed7c0d62084af02a6967d69915de6

Authored by Kim Phillips
Committed by Wolfgang Denk
1 parent f314313494

env: fix env var autocompletion

commit 560d424b6d7cd4205b062ad95f1b104bd4f8bcc3 "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: Kim Phillips <kim.phillips@freescale.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Tested-by: Mike Frysinger <vapier@gentoo.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -209,7 +209,7 @@
209 209 size_t key_len = strlen(match);
210 210  
211 211 for (idx = last_idx + 1; idx < htab->size; ++idx) {
212   - if (htab->table[idx].used > 0)
  212 + if (htab->table[idx].used <= 0)
213 213 continue;
214 214 if (!strncmp(match, htab->table[idx].entry.key, key_len)) {
215 215 *retval = &htab->table[idx].entry;