]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
env: fix env var autocompletion
authorKim Phillips <kim.phillips@freescale.com>
Mon, 4 Apr 2011 15:17:45 +0000 (15:17 +0000)
committerWolfgang Denk <wd@denx.de>
Wed, 27 Apr 2011 22:54:40 +0000 (00:54 +0200)
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>
lib/hashtable.c

index fcdb53cd469b8ba97c9030c8756ca788d4387be8..92eaa3881ca2e46a2743f59c5714695580b24b58 100644 (file)
@@ -209,7 +209,7 @@ int hmatch_r(const char *match, int last_idx, ENTRY ** retval,
        size_t key_len = strlen(match);
 
        for (idx = last_idx + 1; idx < htab->size; ++idx) {
-               if (htab->table[idx].used > 0)
+               if (htab->table[idx].used <= 0)
                        continue;
                if (!strncmp(match, htab->table[idx].entry.key, key_len)) {
                        *retval = &htab->table[idx].entry;