tweaks: rename two variables, and elide a third
parent
05e2a6d259
commit
e198c85053
25
src/search.c
25
src/search.c
|
@ -1206,7 +1206,7 @@ filestruct *find_history(const filestruct *h_start, const filestruct
|
||||||
* list. */
|
* list. */
|
||||||
void update_history(filestruct **h, const char *s)
|
void update_history(filestruct **h, const char *s)
|
||||||
{
|
{
|
||||||
filestruct **hage = NULL, **hbot = NULL, *p;
|
filestruct **hage = NULL, **hbot = NULL, *thesame;
|
||||||
|
|
||||||
assert(h != NULL && s != NULL);
|
assert(h != NULL && s != NULL);
|
||||||
|
|
||||||
|
@ -1220,22 +1220,19 @@ void update_history(filestruct **h, const char *s)
|
||||||
|
|
||||||
assert(hage != NULL && hbot != NULL);
|
assert(hage != NULL && hbot != NULL);
|
||||||
|
|
||||||
/* If this string is already in the history, delete it. */
|
/* See if this string is already in the history. */
|
||||||
p = find_history(*hbot, *hage, s, strlen(s));
|
thesame = find_history(*hbot, *hage, s, strlen(s));
|
||||||
|
|
||||||
if (p != NULL) {
|
/* If an identical string was found, delete that item. */
|
||||||
filestruct *foo, *bar;
|
if (thesame != NULL) {
|
||||||
|
filestruct *after = thesame->next;
|
||||||
|
|
||||||
/* If the string is at the beginning, move the beginning down to
|
/* If the string is at the head of the list, move the head. */
|
||||||
* the next string. */
|
if (thesame == *hage)
|
||||||
if (p == *hage)
|
*hage = after;
|
||||||
*hage = (*hage)->next;
|
|
||||||
|
|
||||||
/* Delete the string. */
|
unlink_node(thesame);
|
||||||
foo = p;
|
renumber(after);
|
||||||
bar = p->next;
|
|
||||||
unlink_node(foo);
|
|
||||||
renumber(bar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the history is full, delete the beginning entry to make room
|
/* If the history is full, delete the beginning entry to make room
|
||||||
|
|
Loading…
Reference in New Issue