From 1d3d30776a647d3b4d61c7de09c929580e47b081 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Fri, 27 May 2016 21:31:55 +0200 Subject: [PATCH] tweaks: more consistently use * instead of [0] when checking for '\0' --- src/browser.c | 11 +++++------ src/prompt.c | 2 +- src/search.c | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/browser.c b/src/browser.c index 99ec5072..10f0cad8 100644 --- a/src/browser.c +++ b/src/browser.c @@ -681,7 +681,7 @@ int filesearch_init(void) int input; char *buf; - if (last_search[0] != '\0') { + if (*last_search != '\0') { char *disp = display_string(last_search, 0, COLS / 3, FALSE); buf = charalloc(strlen(disp) + 7); @@ -787,9 +787,8 @@ void do_filesearch(void) last_search = mallocstrcpy(last_search, answer); #ifndef DISABLE_HISTORIES - /* If answer is not "", add this search string to the search history - * list. */ - if (answer[0] != '\0') + /* If answer is not empty, add the string to the search history list. */ + if (*answer != '\0') update_history(&search_history, answer); #endif @@ -798,10 +797,10 @@ void do_filesearch(void) bottombars(MBROWSER); } -/* Search for the last given filename again without prompting. */ +/* Search again for the last given filename, without prompting. */ void do_fileresearch(void) { - if (last_search[0] == '\0') + if (*last_search == '\0') statusbar(_("No current search pattern")); else findnextfile(last_search); diff --git a/src/prompt.c b/src/prompt.c index eacae87a..27e777f6 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -629,7 +629,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, if (history_list != NULL) { /* If we're scrolling up at the bottom of the history list * and answer isn't blank, save answer in magichistory. */ - if ((*history_list)->next == NULL && answer[0] != '\0') + if ((*history_list)->next == NULL && *answer != '\0') magichistory = mallocstrcpy(magichistory, answer); /* Get the older search from the history list and save it in diff --git a/src/search.c b/src/search.c index 56ad96d9..dd75f6ce 100644 --- a/src/search.c +++ b/src/search.c @@ -142,7 +142,7 @@ int search_init(bool replacing, bool use_answer) * do_search() or do_replace() and be called again. In that case, * we should put the same search string back up. */ - if (last_search[0] != '\0') { + if (*last_search != '\0') { char *disp = display_string(last_search, 0, COLS / 3, FALSE); buf = charalloc(strlen(disp) + 7); @@ -465,11 +465,11 @@ void do_research(void) #ifndef DISABLE_HISTORIES /* If nothing was searched for yet during this run of nano, but * there is a search history, take the most recent item. */ - if (last_search[0] == '\0' && searchbot->prev != NULL) + if (*last_search == '\0' && searchbot->prev != NULL) last_search = mallocstrcpy(last_search, searchbot->prev->data); #endif - if (last_search[0] == '\0') { + if (*last_search == '\0') { statusbar(_("No current search pattern")); return; } -- GitLab