| File src/hstr.c changed (mode: 100644) (index ebb657b..51b6058) |
| ... |
... |
unsigned make_selection(char *prefix, HistoryItems *history, int maxSelectionCou |
| 109 |
109 |
alloc_selection(sizeof(char*) * maxSelectionCount); // TODO realloc |
alloc_selection(sizeof(char*) * maxSelectionCount); // TODO realloc |
| 110 |
110 |
unsigned i, selectionCount=0; |
unsigned i, selectionCount=0; |
| 111 |
111 |
|
|
| 112 |
|
HashSet set; |
|
| 113 |
|
hashset_init(&set); |
|
| 114 |
|
|
|
| 115 |
112 |
for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) { |
for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) { |
| 116 |
|
if(history->items[i]!=NULL && !hashset_contains(&set, history->items[i])) { |
|
|
113 |
|
if(history->items[i]) { |
| 117 |
114 |
if(prefix==NULL) { |
if(prefix==NULL) { |
| 118 |
115 |
selection[selectionCount++]=history->items[i]; |
selection[selectionCount++]=history->items[i]; |
| 119 |
|
hashset_add(&set, history->items[i]); |
|
| 120 |
116 |
} else { |
} else { |
| 121 |
117 |
if(history->items[i]==strstr(history->items[i], prefix)) { |
if(history->items[i]==strstr(history->items[i], prefix)) { |
| 122 |
118 |
selection[selectionCount++]=history->items[i]; |
selection[selectionCount++]=history->items[i]; |
| 123 |
|
hashset_add(&set, history->items[i]); |
|
| 124 |
119 |
} |
} |
| 125 |
120 |
} |
} |
| 126 |
121 |
} |
} |
| 127 |
122 |
} |
} |
| 128 |
123 |
|
|
| 129 |
|
if(prefix!=NULL && selectionCount<maxSelectionCount) { |
|
|
124 |
|
if(prefix && selectionCount<maxSelectionCount) { |
| 130 |
125 |
for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) { |
for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) { |
| 131 |
|
if(!hashset_contains(&set, history->items[i])) { |
|
| 132 |
|
char *substring = strstr(history->items[i], prefix); |
|
| 133 |
|
if (substring != NULL && substring!=history->items[i]) { |
|
| 134 |
|
selection[selectionCount++]=history->items[i]; |
|
| 135 |
|
hashset_add(&set, history->items[i]); |
|
| 136 |
|
} |
|
|
126 |
|
char *substring = strstr(history->items[i], prefix); |
|
127 |
|
if (substring != NULL && substring!=history->items[i]) { |
|
128 |
|
selection[selectionCount++]=history->items[i]; |
| 137 |
129 |
} |
} |
| 138 |
130 |
} |
} |
| 139 |
131 |
} |
} |