From 2bddc4ca54e31a14b7e9799beda134217ae867e7 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Wed, 15 Aug 2018 22:02:33 +0300 Subject: Remove occurences of mb_head_off --- src/nvim/search.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nvim/search.c') diff --git a/src/nvim/search.c b/src/nvim/search.c index 95929f0eb4..10d7d3320d 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -821,7 +821,7 @@ int searchit( if (has_mbyte && pos->lnum <= buf->b_ml.ml_line_count) { ptr = ml_get_buf(buf, pos->lnum, FALSE); - pos->col -= (*mb_head_off)(ptr, ptr + pos->col); + pos->col -= utf_head_off(ptr, ptr + pos->col); } } } else { @@ -1419,7 +1419,7 @@ int searchc(cmdarg_T *cap, int t_cmd) } else { if (col == 0) return FAIL; - col -= (*mb_head_off)(p, p + col - 1) + 1; + col -= utf_head_off(p, p + col - 1) + 1; } if (lastc_bytelen == 1) { if (p[col] == c && stop) { @@ -1450,7 +1450,7 @@ int searchc(cmdarg_T *cap, int t_cmd) col += lastc_bytelen - 1; else /* To previous char, which may be multi-byte. */ - col -= (*mb_head_off)(p, p + col); + col -= utf_head_off(p, p + col); } } curwin->w_cursor.col = col; @@ -1483,7 +1483,7 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) { --col; if (col > 0 && has_mbyte) - col -= (*mb_head_off)(linep, linep + col); + col -= utf_head_off(linep, linep + col); if (prevcol) *prevcol = col; return (col >= 0 && linep[col] == ch) ? TRUE : FALSE; @@ -1795,7 +1795,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } else { --pos.col; if (has_mbyte) - pos.col -= (*mb_head_off)(linep, linep + pos.col); + pos.col -= utf_head_off(linep, linep + pos.col); } } else { /* forward search */ if (linep[pos.col] == NUL @@ -2386,7 +2386,7 @@ findpar ( if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { curwin->w_cursor.col--; curwin->w_cursor.col -= - (*mb_head_off)(line, line + curwin->w_cursor.col); + utf_head_off(line, line + curwin->w_cursor.col); *pincl = true; } } else @@ -3692,7 +3692,7 @@ find_prev_quote( while (col_start > 0) { --col_start; - col_start -= (*mb_head_off)(line, line + col_start); + col_start -= utf_head_off(line, line + col_start); n = 0; if (escape != NULL) while (col_start - n > 0 && vim_strchr(escape, -- cgit From 30392b635689a5f25421c17ead79e521863c8b57 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Wed, 15 Aug 2018 22:46:48 +0300 Subject: Remove has_mbyte from lines near changes in parent commit --- src/nvim/search.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/nvim/search.c') diff --git a/src/nvim/search.c b/src/nvim/search.c index 10d7d3320d..8e2c23b006 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -818,8 +818,7 @@ int searchit( } } else { --pos->col; - if (has_mbyte - && pos->lnum <= buf->b_ml.ml_line_count) { + if (pos->lnum <= buf->b_ml.ml_line_count) { ptr = ml_get_buf(buf, pos->lnum, FALSE); pos->col -= utf_head_off(ptr, ptr + pos->col); } @@ -1444,14 +1443,12 @@ int searchc(cmdarg_T *cap, int t_cmd) if (t_cmd) { /* backup to before the character (possibly double-byte) */ col -= dir; - if (has_mbyte) { - if (dir < 0) - /* Landed on the search char which is lastc_bytelen long */ - col += lastc_bytelen - 1; - else - /* To previous char, which may be multi-byte. */ - col -= utf_head_off(p, p + col); - } + if (dir < 0) + /* Landed on the search char which is lastc_bytelen long */ + col += lastc_bytelen - 1; + else + /* To previous char, which may be multi-byte. */ + col -= utf_head_off(p, p + col); } curwin->w_cursor.col = col; @@ -1482,7 +1479,7 @@ pos_T *findmatch(oparg_T *oap, int initc) static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) { --col; - if (col > 0 && has_mbyte) + if (col > 0) col -= utf_head_off(linep, linep + col); if (prevcol) *prevcol = col; @@ -1794,8 +1791,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) pos.col = comment_col; } else { --pos.col; - if (has_mbyte) - pos.col -= utf_head_off(linep, linep + pos.col); + pos.col -= utf_head_off(linep, linep + pos.col); } } else { /* forward search */ if (linep[pos.col] == NUL -- cgit From d110c6d7907d6f27f32b1d2bd91ffee7ef6097f4 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Thu, 16 Aug 2018 05:09:21 +0300 Subject: lint: cleanup after parent commits --- src/nvim/search.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/nvim/search.c') diff --git a/src/nvim/search.c b/src/nvim/search.c index 8e2c23b006..97975c037b 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -817,9 +817,9 @@ int searchit( pos->lnum, FALSE)); } } else { - --pos->col; + pos->col--; if (pos->lnum <= buf->b_ml.ml_line_count) { - ptr = ml_get_buf(buf, pos->lnum, FALSE); + ptr = ml_get_buf(buf, pos->lnum, false); pos->col -= utf_head_off(ptr, ptr + pos->col); } } @@ -1441,14 +1441,15 @@ int searchc(cmdarg_T *cap, int t_cmd) } if (t_cmd) { - /* backup to before the character (possibly double-byte) */ + // Backup to before the character (possibly double-byte). col -= dir; - if (dir < 0) - /* Landed on the search char which is lastc_bytelen long */ + if (dir < 0) { + // Landed on the search char which is lastc_bytelen long. col += lastc_bytelen - 1; - else - /* To previous char, which may be multi-byte. */ + } else { + // To previous char, which may be multi-byte. col -= utf_head_off(p, p + col); + } } curwin->w_cursor.col = col; @@ -1469,21 +1470,21 @@ pos_T *findmatch(oparg_T *oap, int initc) return findmatchlimit(oap, initc, 0, 0); } -/* - * Return TRUE if the character before "linep[col]" equals "ch". - * Return FALSE if "col" is zero. - * Update "*prevcol" to the column of the previous character, unless "prevcol" - * is NULL. - * Handles multibyte string correctly. - */ -static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) +// Return true if the character before "linep[col]" equals "ch". +// Return false if "col" is zero. +// Update "*prevcol" to the column of the previous character, unless "prevcol" +// is NULL. +// Handles multibyte string correctly. +static bool check_prevcol(char_u *linep, int col, int ch, int *prevcol) { - --col; - if (col > 0) + col--; + if (col > 0) { col -= utf_head_off(linep, linep + col); - if (prevcol) + } + if (prevcol) { *prevcol = col; - return (col >= 0 && linep[col] == ch) ? TRUE : FALSE; + } + return (col >= 0 && linep[col] == ch) ? true : false; } /* @@ -1790,7 +1791,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) if (lisp && comment_col != MAXCOL) pos.col = comment_col; } else { - --pos.col; + pos.col--; pos.col -= utf_head_off(linep, linep + pos.col); } } else { /* forward search */ @@ -2381,8 +2382,7 @@ findpar ( // motion inclusive. if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { curwin->w_cursor.col--; - curwin->w_cursor.col -= - utf_head_off(line, line + curwin->w_cursor.col); + curwin->w_cursor.col -= utf_head_off(line, line + curwin->w_cursor.col); *pincl = true; } } else @@ -3687,7 +3687,7 @@ find_prev_quote( int n; while (col_start > 0) { - --col_start; + col_start--; col_start -= utf_head_off(line, line + col_start); n = 0; if (escape != NULL) -- cgit