tweaks: rename a variable, to better indicate it contains two characters

Also rename a function, to differentiate it more from do_find_bracket().
master
Benno Schulenberg 2019-04-27 17:01:02 +02:00
parent 20d9070aa1
commit e84a790b5d
1 changed files with 10 additions and 10 deletions

View File

@ -863,9 +863,9 @@ void do_gotolinecolumn_void(void)
#ifndef NANO_TINY #ifndef NANO_TINY
/* Search, starting from the current position, for any of the two characters /* Search, starting from the current position, for any of the two characters
* in bracket_set. If reverse is TRUE, search backwards, otherwise forwards. * in bracket_pair. If reverse is TRUE, search backwards, otherwise forwards.
* Return TRUE when one of the brackets was found, and FALSE otherwise. */ * Return TRUE when one of the brackets was found, and FALSE otherwise. */
bool find_bracket_match(bool reverse, const char *bracket_set) bool find_a_bracket(bool reverse, const char *bracket_pair)
{ {
linestruct *line = openfile->current; linestruct *line = openfile->current;
const char *pointer, *found; const char *pointer, *found;
@ -885,9 +885,9 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
/* Now seek for any of the two brackets, either backwards or forwards. */ /* Now seek for any of the two brackets, either backwards or forwards. */
while (TRUE) { while (TRUE) {
if (reverse) if (reverse)
found = mbrevstrpbrk(line->data, bracket_set, pointer); found = mbrevstrpbrk(line->data, bracket_pair, pointer);
else else
found = mbstrpbrk(pointer, bracket_set); found = mbstrpbrk(pointer, bracket_pair);
if (found) if (found)
break; break;
@ -928,7 +928,7 @@ void do_find_bracket(void)
/* The location in matchbrackets of the complementing bracket. */ /* The location in matchbrackets of the complementing bracket. */
int wanted_ch_len; int wanted_ch_len;
/* The length of wanted_ch in bytes. */ /* The length of wanted_ch in bytes. */
char bracket_set[MAXCHARLEN * 2 + 1]; char bracket_pair[MAXCHARLEN * 2 + 1];
/* The pair of characters in ch and wanted_ch. */ /* The pair of characters in ch and wanted_ch. */
size_t halfway = 0; size_t halfway = 0;
/* The index in matchbrackets where the closing brackets start. */ /* The index in matchbrackets where the closing brackets start. */
@ -968,13 +968,13 @@ void do_find_bracket(void)
ch_len = parse_mbchar(ch, NULL, NULL); ch_len = parse_mbchar(ch, NULL, NULL);
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL); wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
/* Fill bracket_set in with the values of ch and wanted_ch. */ /* Copy the two complementary brackets into a single string. */
strncpy(bracket_set, ch, ch_len); strncpy(bracket_pair, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len); strncpy(bracket_pair + ch_len, wanted_ch, wanted_ch_len);
bracket_set[ch_len + wanted_ch_len] = '\0'; bracket_pair[ch_len + wanted_ch_len] = '\0';
while (TRUE) { while (TRUE) {
if (find_bracket_match(reverse, bracket_set)) { if (find_a_bracket(reverse, bracket_pair)) {
/* If we found an identical bracket, increment balance. If we /* If we found an identical bracket, increment balance. If we
* found a complementary bracket, decrement it. */ * found a complementary bracket, decrement it. */
balance += (strncmp(openfile->current->data + openfile->current_x, balance += (strncmp(openfile->current->data + openfile->current_x,