From: Christophe CURIS <[email protected]>

The previous code limited the number of entries that were read into
the history array, but the user is expecting a maximum on the
number of entries displayed. This can make a little difference in
two cases:
 - if there are duplicate entries (dups are checked for and removed)
 - if some entries are not strings (unlikely, but not impossible)

The new code just stops adding history entries when the user
specified count is reached.
---
 src/dialog.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/dialog.c b/src/dialog.c
index a3e7e7e..0508747 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -199,14 +199,15 @@ static WMArray *LoadHistory(const char *filename, int max)
 
        if (plhistory && WMIsPLArray(plhistory)) {
                num = WMGetPropListItemCount(plhistory);
-               if (num > max)
-                       num = max;
 
                for (i = 0; i < num; ++i) {
                        plitem = WMGetFromPLArray(plhistory, i);
                        if (WMIsPLString(plitem) && WMFindInArray(history, 
strmatch,
-                                                                 
WMGetFromPLString(plitem)) == WANotFound)
+                                                                 
WMGetFromPLString(plitem)) == WANotFound) {
                                WMAddToArray(history, 
WMGetFromPLString(plitem));
+                               if (--max <= 0)
+                                       break;
+                       }
                }
        }
 
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to