refactor: pre-incr to post-incr

This commit is contained in:
Lewis Russell
2022-08-24 22:49:25 +01:00
parent 1b29288709
commit 93f24403f8
35 changed files with 278 additions and 286 deletions

View File

@@ -513,7 +513,7 @@ void last_pat_prog(regmmatch_T *regmatch)
regmatch->regprog = NULL;
return;
}
++emsg_off; // So it doesn't beep if bad expr
emsg_off++; // So it doesn't beep if bad expr
(void)search_regcomp((char_u *)"", 0, last_idx, SEARCH_KEEP, regmatch);
emsg_off--;
}
@@ -632,7 +632,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir,
lnum = pos->lnum;
}
for (loop = 0; loop <= 1; ++loop) { // loop twice if 'wrapscan' set
for (loop = 0; loop <= 1; loop++) { // loop twice if 'wrapscan' set
for (; lnum > 0 && lnum <= buf->b_ml.ml_line_count;
lnum += dir, at_first_line = FALSE) {
// Stop after checking "stop_lnum", if it's set.
@@ -991,7 +991,7 @@ static int first_submatch(regmmatch_T *rp)
{
int submatch;
for (submatch = 1;; ++submatch) {
for (submatch = 1;; submatch++) {
if (rp->startpos[submatch].lnum >= 0) {
break;
}
@@ -1298,7 +1298,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
*/
if (!spats[0].off.line && spats[0].off.off && pos.col < MAXCOL - 2) {
if (spats[0].off.off > 0) {
for (c = spats[0].off.off; c; --c) {
for (c = spats[0].off.off; c; c--) {
if (decl(&pos) == -1) {
break;
}
@@ -1308,7 +1308,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
pos.col = MAXCOL;
}
} else {
for (c = spats[0].off.off; c; ++c) {
for (c = spats[0].off.off; c; c++) {
if (incl(&pos) == -1) {
break;
}
@@ -1867,7 +1867,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
* the line.
*/
if (linep[pos.col] == NUL && pos.col) {
--pos.col;
pos.col--;
}
for (;;) {
initc = utf_ptr2char((char *)linep + pos.col);
@@ -2001,7 +2001,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
if (pos.lnum == 1) { // start of file
break;
}
--pos.lnum;
pos.lnum--;
if (maxtravel > 0 && ++traveled > maxtravel) {
break;
@@ -2036,7 +2036,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|| lispcomm) {
break;
}
++pos.lnum;
pos.lnum++;
if (maxtravel && traveled++ > maxtravel) {
break;
@@ -2131,7 +2131,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
* Watch out for "\\".
*/
at_start = do_quotes;
for (ptr = linep; *ptr; ++ptr) {
for (ptr = linep; *ptr; ptr++) {
if (ptr == linep + pos.col + backwards) {
at_start = (do_quotes & 1);
}
@@ -2211,7 +2211,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
if (do_quotes) {
int col;
for (col = pos.col - 1; col >= 0; --col) {
for (col = pos.col - 1; col >= 0; col--) {
if (linep[col] != '\\') {
break;
}
@@ -2522,7 +2522,7 @@ int findsent(Direction dir, long count)
c = gchar_pos(&pos);
if (c == NUL || (pos.col == 0 && startPS(pos.lnum, NUL, FALSE))) {
if (dir == BACKWARD && pos.lnum != startlnum) {
++pos.lnum;
pos.lnum++;
}
break;
}
@@ -3298,7 +3298,7 @@ extend:
}
findsent_forward(count, at_start_sent);
if (*p_sel == 'e') {
++curwin->w_cursor.col;
curwin->w_cursor.col++;
}
}
return OK;
@@ -3356,7 +3356,7 @@ extend:
goto extend;
}
if (*p_sel == 'e') {
++curwin->w_cursor.col;
curwin->w_cursor.col++;
}
VIsual = start_pos;
VIsual_mode = 'v';
@@ -3409,7 +3409,7 @@ int current_block(oparg_T *oap, long count, int include, int what, int other)
}
if (gchar_cursor() == what) {
// cursor on '(' or '{', move cursor just after it
++curwin->w_cursor.col;
curwin->w_cursor.col++;
}
} else if (lt(VIsual, curwin->w_cursor)) {
old_start = VIsual;
@@ -3803,7 +3803,7 @@ extend:
}
prev_start_is_white = -1;
for (t = 0; t < 2; ++t) {
for (t = 0; t < 2; t++) {
start_lnum += dir;
start_is_white = linewhite(start_lnum);
if (prev_start_is_white == start_is_white) {
@@ -5638,7 +5638,7 @@ search_line:
p = (char_u *)skipwhite((char *)line);
if (matched
|| (p[0] == '/' && p[1] == '*') || p[0] == '*') {
for (p = line; *p && p < startp; ++p) {
for (p = line; *p && p < startp; p++) {
if (matched
&& p[0] == '/'
&& (p[1] == '*' || p[1] == '/')) {