From e198c850531b3a14d5a123b160103ef2f1f234e4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 1 Jun 2016 17:58:16 +0200 Subject: [PATCH] tweaks: rename two variables, and elide a third --- src/search.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/search.c b/src/search.c index 622f1588..407f27ec 100644 --- a/src/search.c +++ b/src/search.c @@ -1206,7 +1206,7 @@ filestruct *find_history(const filestruct *h_start, const filestruct * list. */ 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); @@ -1220,22 +1220,19 @@ void update_history(filestruct **h, const char *s) assert(hage != NULL && hbot != NULL); - /* If this string is already in the history, delete it. */ - p = find_history(*hbot, *hage, s, strlen(s)); + /* See if this string is already in the history. */ + thesame = find_history(*hbot, *hage, s, strlen(s)); - if (p != NULL) { - filestruct *foo, *bar; + /* If an identical string was found, delete that item. */ + if (thesame != NULL) { + filestruct *after = thesame->next; - /* If the string is at the beginning, move the beginning down to - * the next string. */ - if (p == *hage) - *hage = (*hage)->next; + /* If the string is at the head of the list, move the head. */ + if (thesame == *hage) + *hage = after; - /* Delete the string. */ - foo = p; - bar = p->next; - unlink_node(foo); - renumber(bar); + unlink_node(thesame); + renumber(after); } /* If the history is full, delete the beginning entry to make room