commit 1d3d30776a647d3b4d61c7de09c929580e47b081
parent 2fae87d9a5e7da7dae2de81f81ed658b9ff9103a
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 27 May 2016 21:31:55 +0200
tweaks: more consistently use * instead of [0] when checking for '\0'
Diffstat:
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git 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
@@ -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
@@ -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;
}