search: rename ‘newline’ -> ‘advance_pos’ macro, reverse return value

This commit is contained in:
Daniel Eklöf 2022-04-18 14:57:31 +02:00
parent 2898ec70b6
commit 006c75d2d3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -609,21 +609,21 @@ search_match_to_end_of_word(struct terminal *term, bool spaces_only)
struct coord new_end = old_end; struct coord new_end = old_end;
struct row *row = NULL; struct row *row = NULL;
#define newline(coord) __extension__ \ #define advance_pos(coord) __extension__ \
({ \ ({ \
bool wrapped_around = false; \ bool wrapped_around = false; \
if (++(coord).col >= term->cols) { \ if (++(coord).col >= term->cols) { \
(coord).row = ((coord).row + 1) & (grid->num_rows - 1); \ (coord).row = ((coord).row + 1) & (grid->num_rows - 1); \
(coord).col = 0; \ (coord).col = 0; \
row = grid->rows[(coord).row]; \ row = grid->rows[(coord).row]; \
if (has_wrapped_around(term, (coord.row))) \ if (has_wrapped_around(term, (coord.row))) \
wrapped_around = true; \ wrapped_around = true; \
} \ } \
wrapped_around; \ !wrapped_around; \
}) })
/* First character to consider is the *next* character */ /* First character to consider is the *next* character */
if (newline(new_end)) if (!advance_pos(new_end))
return; return;
xassert(grid->rows[new_end.row] != NULL); xassert(grid->rows[new_end.row] != NULL);
@ -641,7 +641,7 @@ search_match_to_end_of_word(struct terminal *term, bool spaces_only)
return; return;
do { do {
if (newline(pos)) if (!advance_pos(pos))
break; break;
if (!extract_one(term, row, &row->cells[pos.col], pos.col, ctx)) if (!extract_one(term, row, &row->cells[pos.col], pos.col, ctx))
break; break;
@ -676,7 +676,7 @@ search_match_to_end_of_word(struct terminal *term, bool spaces_only)
term->search.match_len = term->search.len; term->search.match_len = term->search.len;
#undef newline #undef advance_pos
} }
static size_t static size_t