Adjusting some indentation.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5741 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2016-03-17 19:30:29 +00:00
parent 7098dd0cd0
commit e753cd1c38
2 changed files with 43 additions and 47 deletions

View File

@ -3,6 +3,7 @@
a Re-search, to enable cancelling. This fixes Savannah bug #47159. a Re-search, to enable cancelling. This fixes Savannah bug #47159.
* src/search.c (do_replace): Remove two redundant returns. * src/search.c (do_replace): Remove two redundant returns.
* src/search.c (findnextstr): Prune two #ifdefs. * src/search.c (findnextstr): Prune two #ifdefs.
* src/search.c: Adjust some indentation.
2016-03-14 Benno Schulenberg <bensberg@justemail.net> 2016-03-14 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (color_update): Don't dereference a possible NULL. * src/color.c (color_update): Don't dereference a possible NULL.

View File

@ -94,7 +94,7 @@ void not_found_msg(const char *str)
numchars = actual_x(disp, mbstrnlen(disp, COLS / 2)); numchars = actual_x(disp, mbstrnlen(disp, COLS / 2));
statusbar(_("\"%.*s%s\" not found"), numchars, disp, statusbar(_("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "..."); (disp[numchars] == '\0') ? "" : "...");
free(disp); free(disp);
} }
@ -197,8 +197,8 @@ int search_init(bool replacing, bool use_answer)
backupstring = NULL; backupstring = NULL;
/* Cancel any search, or just return with no previous search. */ /* Cancel any search, or just return with no previous search. */
if (i == -1 || (i < 0 && *last_search == '\0') || (!replacing && if (i == -1 || (i < 0 && *last_search == '\0') ||
i == 0 && *answer == '\0')) { (!replacing && i == 0 && *answer == '\0')) {
statusbar(_("Cancelled")); statusbar(_("Cancelled"));
return -1; return -1;
} else { } else {
@ -206,41 +206,39 @@ int search_init(bool replacing, bool use_answer)
if (i == -2 || i == 0 ) { if (i == -2 || i == 0 ) {
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
/* Use last_search if answer is an empty string, or /* Use last_search if answer is an empty string, or
* answer if it isn't. */ * answer if it isn't. */
if (ISSET(USE_REGEXP) && !regexp_init((i == -2) ? if (ISSET(USE_REGEXP) && !regexp_init((i == -2) ?
last_search : answer)) last_search : answer))
return -1; return -1;
#endif #endif
; ;
#ifndef NANO_TINY #ifndef NANO_TINY
} else if (func == case_sens_void) { } else if (func == case_sens_void) {
TOGGLE(CASE_SENSITIVE); TOGGLE(CASE_SENSITIVE);
backupstring = mallocstrcpy(backupstring, answer); backupstring = mallocstrcpy(backupstring, answer);
return 1; return 1;
} else if (func == backwards_void) { } else if (func == backwards_void) {
TOGGLE(BACKWARDS_SEARCH); TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer); backupstring = mallocstrcpy(backupstring, answer);
return 1; return 1;
#endif #endif
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
} else if (func == regexp_void) { } else if (func == regexp_void) {
TOGGLE(USE_REGEXP); TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer); backupstring = mallocstrcpy(backupstring, answer);
return 1; return 1;
#endif #endif
} else if (func == do_replace || func == flip_replace_void) { } else if (func == do_replace || func == flip_replace_void) {
backupstring = mallocstrcpy(backupstring, answer); backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */ return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) { } else if (func == do_gotolinecolumn_void) {
do_gotolinecolumn(openfile->current->lineno, do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE); openfile->placewewant + 1, TRUE, TRUE);
/* Put answer up on the statusbar and /* Put answer up on the statusbar and fall through. */
* fall through. */ return 3;
return 3; } else
} else { return -1;
return -1;
}
} }
return 0; return 0;
@ -379,12 +377,11 @@ bool findnextstr(
/* Ensure we haven't wrapped around again! */ /* Ensure we haven't wrapped around again! */
if (search_last_line && if (search_last_line &&
#ifndef NANO_TINY #ifndef NANO_TINY
((!ISSET(BACKWARDS_SEARCH) && current_x_find > begin_x) || ((!ISSET(BACKWARDS_SEARCH) && current_x_find > begin_x) ||
(ISSET(BACKWARDS_SEARCH) && current_x_find < begin_x)) (ISSET(BACKWARDS_SEARCH) && current_x_find < begin_x))) {
#else #else
current_x_find > begin_x current_x_find > begin_x) {
#endif #endif
) {
not_found_msg(needle); not_found_msg(needle);
disable_nodelay(); disable_nodelay();
return FALSE; return FALSE;
@ -554,8 +551,7 @@ int replace_regexp(char *string, bool create)
while (*c != '\0') { while (*c != '\0') {
int num = (*(c + 1) - '0'); int num = (*(c + 1) - '0');
if (*c != '\\' || num < 1 || num > 9 || num > if (*c != '\\' || num < 1 || num > 9 || num > search_regexp.re_nsub) {
search_regexp.re_nsub) {
if (create) if (create)
*string++ = *c; *string++ = *c;
c++; c++;
@ -657,7 +653,7 @@ ssize_t do_replace_loop(
if (old_mark_set) { if (old_mark_set) {
/* If the mark is on, frame the region, and turn the mark off. */ /* If the mark is on, frame the region, and turn the mark off. */
mark_order((const filestruct **)&top, &top_x, mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up); (const filestruct **)&bot, &bot_x, &right_side_up);
openfile->mark_set = FALSE; openfile->mark_set = FALSE;
/* Start either at the top or the bottom of the marked region. */ /* Start either at the top or the bottom of the marked region. */
@ -687,9 +683,9 @@ ssize_t do_replace_loop(
/* When we've found an occurrence outside of the marked region, /* When we've found an occurrence outside of the marked region,
* stop the fanfare. */ * stop the fanfare. */
if (openfile->current->lineno > bot->lineno || if (openfile->current->lineno > bot->lineno ||
openfile->current->lineno < top->lineno || openfile->current->lineno < top->lineno ||
(openfile->current == bot && openfile->current_x > bot_x) || (openfile->current == bot && openfile->current_x > bot_x) ||
(openfile->current == top && openfile->current_x < top_x)) (openfile->current == top && openfile->current_x < top_x))
break; break;
} }
#endif #endif
@ -701,8 +697,8 @@ ssize_t do_replace_loop(
if (!replaceall) { if (!replaceall) {
size_t xpt = xplustabs(); size_t xpt = xplustabs();
char *exp_word = display_string(openfile->current->data, char *exp_word = display_string(openfile->current->data,
xpt, strnlenpt(openfile->current->data, xpt, strnlenpt(openfile->current->data,
openfile->current_x + match_len) - xpt, FALSE); openfile->current_x + match_len) - xpt, FALSE);
/* Refresh the edit window, scrolling it if necessary. */ /* Refresh the edit window, scrolling it if necessary. */
edit_refresh(); edit_refresh();
@ -902,9 +898,9 @@ void do_replace(void)
numreplaced = do_replace_loop( numreplaced = do_replace_loop(
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
FALSE, FALSE,
#endif #endif
NULL, begin, &begin_x, last_search); NULL, begin, &begin_x, last_search);
/* Restore where we were. */ /* Restore where we were. */
openfile->edittop = edittop_save; openfile->edittop = edittop_save;
@ -979,8 +975,8 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* Do a bounds check. Display a warning on an out-of-bounds /* Do a bounds check. Display a warning on an out-of-bounds
* line or column number only if we hit Enter at the statusbar * line or column number only if we hit Enter at the statusbar
* prompt. */ * prompt. */
if (!parse_line_column(answer, &line, &column) || line < 1 || if (!parse_line_column(answer, &line, &column) ||
column < 1) { line < 1 || column < 1) {
if (i == 0) if (i == 0)
statusbar(_("Invalid line or column number")); statusbar(_("Invalid line or column number"));
display_main_list(); display_main_list();
@ -1036,7 +1032,7 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
* it below in that case, and rev_start will be properly set when * it below in that case, and rev_start will be properly set when
* the search continues on the previous or next line. */ * the search continues on the previous or next line. */
rev_start = reverse ? fileptr->data + (openfile->current_x - 1) : rev_start = reverse ? fileptr->data + (openfile->current_x - 1) :
fileptr->data + (openfile->current_x + 1); fileptr->data + (openfile->current_x + 1);
/* Look for either of the two characters in bracket_set. rev_start /* Look for either of the two characters in bracket_set. rev_start
* can be 1 character before the start or after the end of the line. * can be 1 character before the start or after the end of the line.
@ -1133,8 +1129,7 @@ void do_find_bracket(void)
mbmatchhalf = mbstrlen(matchbrackets) / 2; mbmatchhalf = mbstrlen(matchbrackets) / 2;
for (i = 0; i < mbmatchhalf; i++) for (i = 0; i < mbmatchhalf; i++)
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL, matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL, NULL);
NULL);
reverse = ((ch - matchbrackets) >= matchhalf); reverse = ((ch - matchbrackets) >= matchhalf);
@ -1147,7 +1142,7 @@ void do_find_bracket(void)
while (mbmatchhalf > 0) { while (mbmatchhalf > 0) {
if (reverse) if (reverse)
wanted_ch = matchbrackets + move_mbleft(matchbrackets, wanted_ch = matchbrackets + move_mbleft(matchbrackets,
wanted_ch - matchbrackets); wanted_ch - matchbrackets);
else else
wanted_ch += move_mbright(wanted_ch, 0); wanted_ch += move_mbright(wanted_ch, 0);
@ -1170,7 +1165,7 @@ void do_find_bracket(void)
/* If we found an identical bracket, increment count. If we /* If we found an identical bracket, increment count. If we
* found a complementary bracket, decrement it. */ * found a complementary bracket, decrement it. */
parse_mbchar(openfile->current->data + openfile->current_x, parse_mbchar(openfile->current->data + openfile->current_x,
found_ch, NULL); found_ch, NULL);
count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1; count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1;
/* If count is zero, we've found a matching bracket. Update /* If count is zero, we've found a matching bracket. Update