Remove ml_ prefix from cursor.h functions

s/ml_get_curline/get_cursor_line_ptr
s/ml_get_cursor/get_cursor_pos_ptr
This commit is contained in:
Pavel Platto
2014-05-16 11:59:00 +03:00
committed by Justin M. Keyes
parent 2a154ef71d
commit baaa428785
21 changed files with 197 additions and 194 deletions

View File

@@ -70,7 +70,7 @@ int coladvance(colnr_T wcol)
if (wcol == MAXCOL || rc == FAIL) if (wcol == MAXCOL || rc == FAIL)
curwin->w_valid &= ~VALID_VIRTCOL; curwin->w_valid &= ~VALID_VIRTCOL;
else if (*ml_get_cursor() != TAB) { else if (*get_cursor_pos_ptr() != TAB) {
/* Virtcol is valid when not on a TAB */ /* Virtcol is valid when not on a TAB */
curwin->w_valid |= VALID_VIRTCOL; curwin->w_valid |= VALID_VIRTCOL;
curwin->w_virtcol = wcol; curwin->w_virtcol = wcol;
@@ -444,8 +444,8 @@ int leftcol_changed(void)
int gchar_cursor(void) int gchar_cursor(void)
{ {
if (has_mbyte) if (has_mbyte)
return (*mb_ptr2char)(ml_get_cursor()); return (*mb_ptr2char)(get_cursor_pos_ptr());
return (int)*ml_get_cursor(); return (int)*get_cursor_pos_ptr();
} }
/* /*
@@ -461,7 +461,7 @@ void pchar_cursor(char_u c)
/* /*
* Return pointer to cursor line. * Return pointer to cursor line.
*/ */
char_u *ml_get_curline(void) char_u *get_cursor_line_ptr(void)
{ {
return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE); return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE);
} }
@@ -469,7 +469,7 @@ char_u *ml_get_curline(void)
/* /*
* Return pointer to cursor position. * Return pointer to cursor position.
*/ */
char_u *ml_get_cursor(void) char_u *get_cursor_pos_ptr(void)
{ {
return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE) + return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE) +
curwin->w_cursor.col; curwin->w_cursor.col;

View File

@@ -20,8 +20,8 @@ void adjust_cursor_col(void);
int leftcol_changed(void); int leftcol_changed(void);
int gchar_cursor(void); int gchar_cursor(void);
void pchar_cursor(char_u c); void pchar_cursor(char_u c);
char_u *ml_get_curline(void); char_u *get_cursor_line_ptr(void);
char_u *ml_get_cursor(void); char_u *get_cursor_pos_ptr(void);
#endif // NVIM_CURSOR_H #endif // NVIM_CURSOR_H

View File

@@ -428,7 +428,7 @@ edit (
if (startln) if (startln)
Insstart.col = 0; Insstart.col = 0;
} }
Insstart_textlen = (colnr_T)linetabsize(ml_get_curline()); Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
Insstart_blank_vcol = MAXCOL; Insstart_blank_vcol = MAXCOL;
if (!did_ai) if (!did_ai)
ai_col = 0; ai_col = 0;
@@ -521,7 +521,7 @@ edit (
update_curswant(); update_curswant();
if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum) if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)
|| curwin->w_curswant > curwin->w_virtcol) || curwin->w_curswant > curwin->w_virtcol)
&& *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL) { && *(ptr = get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) {
if (ptr[1] == NUL) if (ptr[1] == NUL)
++curwin->w_cursor.col; ++curwin->w_cursor.col;
else if (has_mbyte) { else if (has_mbyte) {
@@ -1501,7 +1501,7 @@ void display_dollar(colnr_T col)
char_u *p; char_u *p;
/* If on the last byte of a multi-byte move to the first byte. */ /* If on the last byte of a multi-byte move to the first byte. */
p = ml_get_curline(); p = get_cursor_line_ptr();
curwin->w_cursor.col -= (*mb_head_off)(p, p + col); curwin->w_cursor.col -= (*mb_head_off)(p, p + col);
} }
curs_columns(FALSE); /* recompute w_wrow and w_wcol */ curs_columns(FALSE); /* recompute w_wrow and w_wcol */
@@ -1555,7 +1555,7 @@ change_indent (
/* VREPLACE mode needs to know what the line was like before changing */ /* VREPLACE mode needs to know what the line was like before changing */
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
orig_line = vim_strsave(ml_get_curline()); /* Deal with NULL below */ orig_line = vim_strsave(get_cursor_line_ptr()); /* Deal with NULL below */
orig_col = curwin->w_cursor.col; orig_col = curwin->w_cursor.col;
} }
@@ -1636,7 +1636,7 @@ change_indent (
*/ */
vcol = last_vcol = 0; vcol = last_vcol = 0;
new_cursor_col = -1; new_cursor_col = -1;
ptr = ml_get_curline(); ptr = get_cursor_line_ptr();
while (vcol <= (int)curwin->w_virtcol) { while (vcol <= (int)curwin->w_virtcol) {
last_vcol = vcol; last_vcol = vcol;
if (has_mbyte && new_cursor_col >= 0) if (has_mbyte && new_cursor_col >= 0)
@@ -1727,7 +1727,7 @@ change_indent (
return; return;
/* Save new line */ /* Save new line */
new_line = vim_strsave(ml_get_curline()); new_line = vim_strsave(get_cursor_line_ptr());
/* We only put back the new line up to the cursor */ /* We only put back the new line up to the cursor */
new_line[curwin->w_cursor.col] = NUL; new_line[curwin->w_cursor.col] = NUL;
@@ -1798,13 +1798,13 @@ static int del_char_after_col(int limit_col)
* composing character. */ * composing character. */
mb_adjust_cursor(); mb_adjust_cursor();
while (curwin->w_cursor.col < (colnr_T)limit_col) { while (curwin->w_cursor.col < (colnr_T)limit_col) {
int l = utf_ptr2len(ml_get_cursor()); int l = utf_ptr2len(get_cursor_pos_ptr());
if (l == 0) /* end of line */ if (l == 0) /* end of line */
break; break;
curwin->w_cursor.col += l; curwin->w_cursor.col += l;
} }
if (*ml_get_cursor() == NUL || curwin->w_cursor.col == ecol) if (*get_cursor_pos_ptr() == NUL || curwin->w_cursor.col == ecol)
return FALSE; return FALSE;
del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE); del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE);
} else } else
@@ -2321,7 +2321,8 @@ void set_completion(colnr_T startcol, list_T *list)
compl_col = startcol; compl_col = startcol;
compl_length = (int)curwin->w_cursor.col - (int)startcol; compl_length = (int)curwin->w_cursor.col - (int)startcol;
/* compl_pattern doesn't need to be set */ /* compl_pattern doesn't need to be set */
compl_orig_text = vim_strnsave(ml_get_curline() + compl_col, compl_length); compl_orig_text = vim_strnsave(get_cursor_line_ptr() + compl_col,
compl_length);
if (ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0, if (ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0,
ORIGINAL_TEXT, FALSE) != OK) { ORIGINAL_TEXT, FALSE) != OK) {
return; return;
@@ -2849,7 +2850,7 @@ static int ins_compl_bs(void)
char_u *line; char_u *line;
char_u *p; char_u *p;
line = ml_get_curline(); line = get_cursor_line_ptr();
p = line + curwin->w_cursor.col; p = line + curwin->w_cursor.col;
mb_ptr_back(line, p); mb_ptr_back(line, p);
@@ -2971,7 +2972,7 @@ static void ins_compl_addleader(int c)
* break redo. */ * break redo. */
if (!compl_opt_refresh_always) { if (!compl_opt_refresh_always) {
free(compl_leader); free(compl_leader);
compl_leader = vim_strnsave(ml_get_curline() + compl_col, compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
(int)(curwin->w_cursor.col - compl_col)); (int)(curwin->w_cursor.col - compl_col));
ins_compl_new_leader(); ins_compl_new_leader();
} }
@@ -3220,7 +3221,7 @@ static int ins_compl_prep(int c)
if (stop_arrow() == OK) if (stop_arrow() == OK)
insertchar(NUL, 0, -1); insertchar(NUL, 0, -1);
if (prev_col > 0 if (prev_col > 0
&& ml_get_curline()[curwin->w_cursor.col] != NUL) && get_cursor_line_ptr()[curwin->w_cursor.col] != NUL)
inc_cursor(); inc_cursor();
} }
@@ -4921,7 +4922,8 @@ insert_special (
# define WHITECHAR(cc) (vim_iswhite(cc) && \ # define WHITECHAR(cc) (vim_iswhite(cc) && \
(!enc_utf8 || \ (!enc_utf8 || \
!utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1)))) !utf_iscomposing( \
utf_ptr2char(get_cursor_pos_ptr() + 1))))
/* /*
* "flags": INSCHAR_FORMAT - force formatting * "flags": INSCHAR_FORMAT - force formatting
@@ -4967,7 +4969,7 @@ insertchar (
|| (!vim_iswhite(c) || (!vim_iswhite(c)
&& !((State & REPLACE_FLAG) && !((State & REPLACE_FLAG)
&& !(State & VREPLACE_FLAG) && !(State & VREPLACE_FLAG)
&& *ml_get_cursor() != NUL) && *get_cursor_pos_ptr() != NUL)
&& (curwin->w_cursor.lnum != Insstart.lnum && (curwin->w_cursor.lnum != Insstart.lnum
|| ((!has_format_option(FO_INS_LONG) || ((!has_format_option(FO_INS_LONG)
|| Insstart_textlen <= (colnr_T)textwidth) || Insstart_textlen <= (colnr_T)textwidth)
@@ -5002,7 +5004,7 @@ insertchar (
* Need to remove existing (middle) comment leader and insert end * Need to remove existing (middle) comment leader and insert end
* comment leader. First, check what comment leader we can find. * comment leader. First, check what comment leader we can find.
*/ */
i = get_leader_len(line = ml_get_curline(), &p, FALSE, TRUE); i = get_leader_len(line = get_cursor_line_ptr(), &p, FALSE, TRUE);
if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { /* Just checking */ if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { /* Just checking */
/* Skip middle-comment string */ /* Skip middle-comment string */
while (*p && p[-1] != ':') /* find end of middle flags */ while (*p && p[-1] != ':') /* find end of middle flags */
@@ -5198,7 +5200,7 @@ internal_format (
/* Don't break until after the comment leader */ /* Don't break until after the comment leader */
if (do_comments) if (do_comments)
leader_len = get_leader_len(ml_get_curline(), NULL, FALSE, TRUE); leader_len = get_leader_len(get_cursor_line_ptr(), NULL, FALSE, TRUE);
else else
leader_len = 0; leader_len = 0;
@@ -5350,7 +5352,7 @@ internal_format (
* In VREPLACE mode, we will backspace over the text to be * In VREPLACE mode, we will backspace over the text to be
* wrapped, so save a copy now to put on the next line. * wrapped, so save a copy now to put on the next line.
*/ */
saved_text = vim_strsave(ml_get_cursor()); saved_text = vim_strsave(get_cursor_pos_ptr());
curwin->w_cursor.col = orig_col; curwin->w_cursor.col = orig_col;
if (saved_text == NULL) if (saved_text == NULL)
break; /* Can't do it, out of memory */ break; /* Can't do it, out of memory */
@@ -5428,7 +5430,7 @@ internal_format (
* may have added or removed indent. * may have added or removed indent.
*/ */
curwin->w_cursor.col += startcol; curwin->w_cursor.col += startcol;
len = (colnr_T)STRLEN(ml_get_curline()); len = (colnr_T)STRLEN(get_cursor_line_ptr());
if (curwin->w_cursor.col > len) if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len; curwin->w_cursor.col = len;
} }
@@ -5476,7 +5478,7 @@ auto_format (
return; return;
pos = curwin->w_cursor; pos = curwin->w_cursor;
old = ml_get_curline(); old = get_cursor_line_ptr();
/* may remove added space */ /* may remove added space */
check_auto_format(FALSE); check_auto_format(FALSE);
@@ -5539,7 +5541,7 @@ auto_format (
* need to add a space when 'w' is in 'formatoptions' to keep a paragraph * need to add a space when 'w' is in 'formatoptions' to keep a paragraph
* formatted. */ * formatted. */
if (!wasatend && has_format_option(FO_WHITE_PAR)) { if (!wasatend && has_format_option(FO_WHITE_PAR)) {
new = ml_get_curline(); new = get_cursor_line_ptr();
len = (colnr_T)STRLEN(new); len = (colnr_T)STRLEN(new);
if (curwin->w_cursor.col == len) { if (curwin->w_cursor.col == len) {
pnew = vim_strnsave(new, len + 2); pnew = vim_strnsave(new, len + 2);
@@ -5702,7 +5704,7 @@ int stop_arrow(void)
ins_need_undo = FALSE; ins_need_undo = FALSE;
} }
Insstart = curwin->w_cursor; /* new insertion starts here */ Insstart = curwin->w_cursor; /* new insertion starts here */
Insstart_textlen = (colnr_T)linetabsize(ml_get_curline()); Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
ai_col = 0; ai_col = 0;
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
orig_line_count = curbuf->b_ml.ml_line_count; orig_line_count = curbuf->b_ml.ml_line_count;
@@ -5820,7 +5822,7 @@ stop_insert (
/* <C-S-Right> may have started Visual mode, adjust the position for /* <C-S-Right> may have started Visual mode, adjust the position for
* deleted characters. */ * deleted characters. */
if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum) { if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum) {
int len = (int)STRLEN(ml_get_curline()); int len = (int)STRLEN(get_cursor_line_ptr());
if (VIsual.col > len) { if (VIsual.col > len) {
VIsual.col = len; VIsual.col = len;
@@ -5917,7 +5919,7 @@ void beginline(int flags)
if (flags & (BL_WHITE | BL_SOL)) { if (flags & (BL_WHITE | BL_SOL)) {
char_u *ptr; char_u *ptr;
for (ptr = ml_get_curline(); vim_iswhite(*ptr) for (ptr = get_cursor_line_ptr(); vim_iswhite(*ptr)
&& !((flags & BL_FIX) && ptr[1] == NUL); ++ptr) && !((flags & BL_FIX) && ptr[1] == NUL); ++ptr)
++curwin->w_cursor.col; ++curwin->w_cursor.col;
} }
@@ -5942,7 +5944,7 @@ int oneright(void)
pos_T prevpos = curwin->w_cursor; pos_T prevpos = curwin->w_cursor;
/* Adjust for multi-wide char (excluding TAB) */ /* Adjust for multi-wide char (excluding TAB) */
ptr = ml_get_cursor(); ptr = get_cursor_pos_ptr();
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc( coladvance(getviscol() + ((*ptr != TAB && vim_isprintc(
(*mb_ptr2char)(ptr) (*mb_ptr2char)(ptr)
)) ))
@@ -5953,7 +5955,7 @@ int oneright(void)
|| prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL; || prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL;
} }
ptr = ml_get_cursor(); ptr = get_cursor_pos_ptr();
if (*ptr == NUL) if (*ptr == NUL)
return FAIL; /* already at the very end */ return FAIL; /* already at the very end */
@@ -6000,7 +6002,7 @@ int oneleft(void)
char_u *ptr; char_u *ptr;
/* Adjust for multi-wide char (not a TAB) */ /* Adjust for multi-wide char (not a TAB) */
ptr = ml_get_cursor(); ptr = get_cursor_pos_ptr();
if (*ptr != TAB && vim_isprintc( if (*ptr != TAB && vim_isprintc(
(*mb_ptr2char)(ptr) (*mb_ptr2char)(ptr)
) && ptr2cells(ptr) > 1) ) && ptr2cells(ptr) > 1)
@@ -6226,7 +6228,7 @@ static int echeck_abbr(int c)
if (p_paste || no_abbr || arrow_used) if (p_paste || no_abbr || arrow_used)
return FALSE; return FALSE;
return check_abbr(c, ml_get_curline(), curwin->w_cursor.col, return check_abbr(c, get_cursor_line_ptr(), curwin->w_cursor.col,
curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0); curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0);
} }
@@ -6417,23 +6419,23 @@ static void replace_do_bs(int limit_col)
/* Get the number of screen cells used by the character we are /* Get the number of screen cells used by the character we are
* going to delete. */ * going to delete. */
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL); getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
orig_vcols = chartabsize(ml_get_cursor(), start_vcol); orig_vcols = chartabsize(get_cursor_pos_ptr(), start_vcol);
} }
if (has_mbyte) { if (has_mbyte) {
(void)del_char_after_col(limit_col); (void)del_char_after_col(limit_col);
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
orig_len = (int)STRLEN(ml_get_cursor()); orig_len = (int)STRLEN(get_cursor_pos_ptr());
replace_push(cc); replace_push(cc);
} else { } else {
pchar_cursor(cc); pchar_cursor(cc);
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
orig_len = (int)STRLEN(ml_get_cursor()) - 1; orig_len = (int)STRLEN(get_cursor_pos_ptr()) - 1;
} }
replace_pop_ins(); replace_pop_ins();
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
/* Get the number of screen cells used by the inserted characters */ /* Get the number of screen cells used by the inserted characters */
p = ml_get_cursor(); p = get_cursor_pos_ptr();
ins_len = (int)STRLEN(p) - orig_len; ins_len = (int)STRLEN(p) - orig_len;
vcol = start_vcol; vcol = start_vcol;
for (i = 0; i < ins_len; ++i) { for (i = 0; i < ins_len; ++i) {
@@ -6576,7 +6578,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
*/ */
else if (*look == 'e') { else if (*look == 'e') {
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
p = ml_get_curline(); p = get_cursor_line_ptr();
if (skipwhite(p) == p + curwin->w_cursor.col - 4 && if (skipwhite(p) == p + curwin->w_cursor.col - 4 &&
STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0)
return TRUE; return TRUE;
@@ -6590,18 +6592,18 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
*/ */
else if (*look == ':') { else if (*look == ':') {
if (try_match && keytyped == ':') { if (try_match && keytyped == ':') {
p = ml_get_curline(); p = get_cursor_line_ptr();
if (cin_iscase(p, FALSE) || cin_isscopedecl(p) || cin_islabel()) if (cin_iscase(p, FALSE) || cin_isscopedecl(p) || cin_islabel())
return TRUE; return TRUE;
/* Need to get the line again after cin_islabel(). */ /* Need to get the line again after cin_islabel(). */
p = ml_get_curline(); p = get_cursor_line_ptr();
if (curwin->w_cursor.col > 2 if (curwin->w_cursor.col > 2
&& p[curwin->w_cursor.col - 1] == ':' && p[curwin->w_cursor.col - 1] == ':'
&& p[curwin->w_cursor.col - 2] == ':') { && p[curwin->w_cursor.col - 2] == ':') {
p[curwin->w_cursor.col - 1] = ' '; p[curwin->w_cursor.col - 1] = ' ';
i = (cin_iscase(p, FALSE) || cin_isscopedecl(p) i = (cin_iscase(p, FALSE) || cin_isscopedecl(p)
|| cin_islabel()); || cin_islabel());
p = ml_get_curline(); p = get_cursor_line_ptr();
p[curwin->w_cursor.col - 1] = ':'; p[curwin->w_cursor.col - 1] = ':';
if (i) if (i)
return TRUE; return TRUE;
@@ -6653,7 +6655,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
/* Just completed a word, check if it starts with "look". /* Just completed a word, check if it starts with "look".
* search back for the start of a word. */ * search back for the start of a word. */
line = ml_get_curline(); line = get_cursor_line_ptr();
if (has_mbyte) { if (has_mbyte) {
char_u *n; char_u *n;
@@ -6676,7 +6678,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
if (keytyped == (int)p[-1] || (icase && keytyped < 256 if (keytyped == (int)p[-1] || (icase && keytyped < 256
&& TOLOWER_LOC(keytyped) == && TOLOWER_LOC(keytyped) ==
TOLOWER_LOC((int)p[-1]))) { TOLOWER_LOC((int)p[-1]))) {
line = ml_get_cursor(); line = get_cursor_pos_ptr();
if ((curwin->w_cursor.col == (colnr_T)(p - look) if ((curwin->w_cursor.col == (colnr_T)(p - look)
|| !vim_iswordc(line[-(p - look) - 1])) || !vim_iswordc(line[-(p - look) - 1]))
&& (icase && (icase
@@ -6688,7 +6690,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
if (match && try_match_word && !try_match) { if (match && try_match_word && !try_match) {
/* "0=word": Check if there are only blanks before the /* "0=word": Check if there are only blanks before the
* word. */ * word. */
line = ml_get_curline(); line = get_cursor_line_ptr();
if ((int)(skipwhite(line) - line) != if ((int)(skipwhite(line) - line) !=
(int)(curwin->w_cursor.col - (p - look))) (int)(curwin->w_cursor.col - (p - look)))
match = FALSE; match = FALSE;
@@ -7229,7 +7231,7 @@ static void ins_shift(int c, int lastc)
} else } else
change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE); change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE);
if (did_ai && *skipwhite(ml_get_curline()) != NUL) if (did_ai && *skipwhite(get_cursor_line_ptr()) != NUL)
did_ai = FALSE; did_ai = FALSE;
did_si = FALSE; did_si = FALSE;
can_si = FALSE; can_si = FALSE;
@@ -7452,8 +7454,8 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
&& ((p_sta && in_indent) && ((p_sta && in_indent)
|| (get_sts_value() != 0 || (get_sts_value() != 0
&& curwin->w_cursor.col > 0 && curwin->w_cursor.col > 0
&& (*(ml_get_cursor() - 1) == TAB && (*(get_cursor_pos_ptr() - 1) == TAB
|| (*(ml_get_cursor() - 1) == ' ' || (*(get_cursor_pos_ptr() - 1) == ' '
&& (!*inserted_space_p && (!*inserted_space_p
|| arrow_used)))))) { || arrow_used)))))) {
int ts; int ts;
@@ -7478,7 +7480,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
/* delete characters until we are at or before want_vcol */ /* delete characters until we are at or before want_vcol */
while (vcol > want_vcol while (vcol > want_vcol
&& (cc = *(ml_get_cursor() - 1), vim_iswhite(cc))) && (cc = *(get_cursor_pos_ptr() - 1), vim_iswhite(cc)))
ins_bs_one(&vcol); ins_bs_one(&vcol);
/* insert extra spaces until we are at want_vcol */ /* insert extra spaces until we are at want_vcol */
@@ -7530,7 +7532,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
replace_do_bs(-1); replace_do_bs(-1);
else { else {
if (enc_utf8 && p_deco) if (enc_utf8 && p_deco)
(void)utfc_ptr2char(ml_get_cursor(), cpc); (void)utfc_ptr2char(get_cursor_pos_ptr(), cpc);
(void)del_char(FALSE); (void)del_char(FALSE);
/* /*
* If there are combining characters and 'delcombine' is set * If there are combining characters and 'delcombine' is set
@@ -7767,7 +7769,7 @@ static void ins_right(void)
oneright(); oneright();
else { else {
if (has_mbyte) if (has_mbyte)
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr());
else else
++curwin->w_cursor.col; ++curwin->w_cursor.col;
} }
@@ -7976,10 +7978,10 @@ static int ins_tab(void)
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
pos = curwin->w_cursor; pos = curwin->w_cursor;
cursor = &pos; cursor = &pos;
saved_line = vim_strsave(ml_get_curline()); saved_line = vim_strsave(get_cursor_line_ptr());
ptr = saved_line + pos.col; ptr = saved_line + pos.col;
} else { } else {
ptr = ml_get_cursor(); ptr = get_cursor_pos_ptr();
cursor = &curwin->w_cursor; cursor = &curwin->w_cursor;
} }
@@ -8120,7 +8122,7 @@ static int ins_eol(int c)
/* NL in reverse insert will always start in the end of /* NL in reverse insert will always start in the end of
* current line. */ * current line. */
if (revins_on) if (revins_on)
curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor()); curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
AppendToRedobuff(NL_STR); AppendToRedobuff(NL_STR);
i = open_line(FORWARD, i = open_line(FORWARD,

View File

@@ -8036,7 +8036,7 @@ static void f_col(typval_T *argvars, typval_T *rettv)
/* col(".") when the cursor is on the NUL at the end of the line /* col(".") when the cursor is on the NUL at the end of the line
* because of "coladd" can be seen as an extra column. */ * because of "coladd" can be seen as an extra column. */
if (virtual_active() && fp == &curwin->w_cursor) { if (virtual_active() && fp == &curwin->w_cursor) {
char_u *p = ml_get_cursor(); char_u *p = get_cursor_pos_ptr();
if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p, if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p,
curwin->w_virtcol - curwin->w_cursor.coladd)) { curwin->w_virtcol - curwin->w_cursor.coladd)) {
@@ -13832,7 +13832,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv)
/* Find the start and length of the badly spelled word. */ /* Find the start and length of the badly spelled word. */
len = spell_move_to(curwin, FORWARD, TRUE, TRUE, &attr); len = spell_move_to(curwin, FORWARD, TRUE, TRUE, &attr);
if (len != 0) if (len != 0)
word = ml_get_cursor(); word = get_cursor_pos_ptr();
} else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL) { } else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL) {
char_u *str = get_tv_string_chk(&argvars[0]); char_u *str = get_tv_string_chk(&argvars[0]);
int capcol = -1; int capcol = -1;
@@ -15393,7 +15393,7 @@ var2fpos (
pos.col = 0; pos.col = 0;
} else { } else {
pos.lnum = curwin->w_cursor.lnum; pos.lnum = curwin->w_cursor.lnum;
pos.col = (colnr_T)STRLEN(ml_get_curline()); pos.col = (colnr_T)STRLEN(get_cursor_line_ptr());
} }
return &pos; return &pos;
} }

View File

@@ -91,7 +91,7 @@ void do_ascii(exarg_T *eap)
int len; int len;
if (enc_utf8) if (enc_utf8)
c = utfc_ptr2char(ml_get_cursor(), cc); c = utfc_ptr2char(get_cursor_pos_ptr(), cc);
else else
c = gchar_cursor(); c = gchar_cursor();
if (c == NUL) { if (c == NUL) {
@@ -258,7 +258,7 @@ static int linelen(int *has_tab)
int len; int len;
/* find the first non-blank character */ /* find the first non-blank character */
line = ml_get_curline(); line = get_cursor_line_ptr();
first = skipwhite(line); first = skipwhite(line);
/* find the character after the last non-blank character */ /* find the character after the last non-blank character */

View File

@@ -6120,7 +6120,7 @@ static void ex_open(exarg_T *eap)
regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog != NULL) { if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic; regmatch.rm_ic = p_ic;
p = ml_get_curline(); p = get_cursor_line_ptr();
if (vim_regexec(&regmatch, p, (colnr_T)0)) if (vim_regexec(&regmatch, p, (colnr_T)0))
curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
else else

View File

@@ -5306,7 +5306,7 @@ static int ex_window(void)
* and don't modify the cmd window. */ * and don't modify the cmd window. */
ccline.cmdbuff = NULL; ccline.cmdbuff = NULL;
} else } else
ccline.cmdbuff = vim_strsave(ml_get_curline()); ccline.cmdbuff = vim_strsave(get_cursor_line_ptr());
if (ccline.cmdbuff == NULL) if (ccline.cmdbuff == NULL)
cmdwin_result = Ctrl_C; cmdwin_result = Ctrl_C;
else { else {

View File

@@ -170,7 +170,7 @@ static int toF_Xor_X_(int c)
tempc = _HE; tempc = _HE;
if (p_ri && if (p_ri &&
(curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline()))) { (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(get_cursor_line_ptr()))) {
inc_cursor(); inc_cursor();
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
tempc = _HE_; tempc = _HE_;
@@ -178,7 +178,7 @@ static int toF_Xor_X_(int c)
dec_cursor(); dec_cursor();
} }
if (!p_ri && STRLEN(ml_get_curline())) { if (!p_ri && STRLEN(get_cursor_line_ptr())) {
dec_cursor(); dec_cursor();
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
tempc = _HE_; tempc = _HE_;
@@ -455,7 +455,7 @@ static void put_curr_and_l_to_X(int c)
return; return;
} }
if ((curwin->w_cursor.col < (colnr_T)STRLEN(ml_get_curline()))) { if ((curwin->w_cursor.col < (colnr_T)STRLEN(get_cursor_line_ptr()))) {
if ((p_ri && curwin->w_cursor.col) || !p_ri) { if ((p_ri && curwin->w_cursor.col) || !p_ri) {
if (p_ri) { if (p_ri) {
dec_cursor(); dec_cursor();
@@ -699,7 +699,7 @@ static void chg_c_to_X_or_X(void)
tempc = gchar_cursor(); tempc = gchar_cursor();
if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline())) { if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(get_cursor_line_ptr())) {
inc_cursor(); inc_cursor();
if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) { if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) {
tempc = _HE_; tempc = _HE_;
@@ -722,7 +722,7 @@ static void chg_l_to_X_orX_(void)
int tempc; int tempc;
if ((curwin->w_cursor.col != 0) if ((curwin->w_cursor.col != 0)
&& (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) { && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) {
return; return;
} }
@@ -802,7 +802,7 @@ static void chg_l_toXor_X(void)
int tempc; int tempc;
if ((curwin->w_cursor.col != 0) && if ((curwin->w_cursor.col != 0) &&
(curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) { (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) {
return; return;
} }
@@ -1564,7 +1564,7 @@ int fkmap(int c)
break; break;
case 'G': case 'G':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (gchar_cursor() == _LAM) { if (gchar_cursor() == _LAM) {
chg_c_toX_orX(); chg_c_toX_orX();
} else if (p_ri) { } else if (p_ri) {
@@ -1600,7 +1600,7 @@ int fkmap(int c)
return tempc; return tempc;
case 'h': case 'h':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (p_ri) { if (p_ri) {
chg_c_to_X_or_X(); chg_c_to_X_or_X();
} }
@@ -1643,7 +1643,7 @@ int fkmap(int c)
case 'i': case 'i':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) { if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_(); chg_c_to_X_orX_();
} }
@@ -1678,7 +1678,7 @@ int fkmap(int c)
case 'J': case 'J':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (p_ri) { if (p_ri) {
chg_c_to_X_or_X(); chg_c_to_X_or_X();
} }
@@ -1753,7 +1753,7 @@ int fkmap(int c)
break; break;
case 'u': case 'u':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) { if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_(); chg_c_to_X_orX_();
} }
@@ -1797,7 +1797,7 @@ int fkmap(int c)
break; break;
case 'y': case 'y':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) { if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_(); chg_c_to_X_orX_();
} }
@@ -1857,7 +1857,7 @@ int fkmap(int c)
} }
if ((F_isalpha(tempc) || F_isdigit(tempc))) { if ((F_isalpha(tempc) || F_isdigit(tempc))) {
if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) { if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_(); chg_c_to_X_orX_();
} }

View File

@@ -2172,7 +2172,7 @@ static int vgetorpeek(int advance)
* character -- webb * character -- webb
*/ */
col = vcol = curwin->w_wcol = 0; col = vcol = curwin->w_wcol = 0;
ptr = ml_get_curline(); ptr = get_cursor_line_ptr();
while (col < curwin->w_cursor.col) { while (col < curwin->w_cursor.col) {
if (!vim_iswhite(ptr[col])) if (!vim_iswhite(ptr[col]))
curwin->w_wcol = vcol; curwin->w_wcol = vcol;
@@ -2200,7 +2200,7 @@ static int vgetorpeek(int advance)
if (has_mbyte && col > 0 && curwin->w_wcol > 0) { if (has_mbyte && col > 0 && curwin->w_wcol > 0) {
/* Correct when the cursor is on the right halve /* Correct when the cursor is on the right halve
* of a double-wide character. */ * of a double-wide character. */
ptr = ml_get_curline(); ptr = get_cursor_line_ptr();
col -= (*mb_head_off)(ptr, ptr + col); col -= (*mb_head_off)(ptr, ptr + col);
if ((*mb_ptr2cells)(ptr + col) > 1) if ((*mb_ptr2cells)(ptr + col) > 1)
--curwin->w_wcol; --curwin->w_wcol;

View File

@@ -18,7 +18,7 @@ static int lisp_match(char_u *p);
// Count the size (in window cells) of the indent in the current line. // Count the size (in window cells) of the indent in the current line.
int get_indent(void) int get_indent(void)
{ {
return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts); return get_indent_str(get_cursor_line_ptr(), (int)curbuf->b_p_ts);
} }
@@ -88,7 +88,7 @@ int set_indent(int size, int flags)
// characters needed for the indent. // characters needed for the indent.
todo = size; todo = size;
ind_len = 0; ind_len = 0;
p = oldline = ml_get_curline(); p = oldline = get_cursor_line_ptr();
// Calculate the buffer size for the new indent, and check to see if it // Calculate the buffer size for the new indent, and check to see if it
// isn't already set. // isn't already set.
@@ -368,14 +368,14 @@ int copy_indent(int size, char_u *src)
if (p == NULL) { if (p == NULL) {
// Allocate memory for the result: the copied indent, new indent // Allocate memory for the result: the copied indent, new indent
// and the rest of the line. // and the rest of the line.
line_len = (int)STRLEN(ml_get_curline()) + 1; line_len = (int)STRLEN(get_cursor_line_ptr()) + 1;
line = xmalloc(ind_len + line_len); line = xmalloc(ind_len + line_len);
p = line; p = line;
} }
} }
// Append the original line // Append the original line
memmove(p, ml_get_curline(), (size_t)line_len); memmove(p, get_cursor_line_ptr(), (size_t)line_len);
// Replace the line // Replace the line
ml_replace(curwin->w_cursor.lnum, line, false); ml_replace(curwin->w_cursor.lnum, line, false);
@@ -437,7 +437,7 @@ int inindent(int extra)
char_u *ptr; char_u *ptr;
colnr_T col; colnr_T col;
for (col = 0, ptr = ml_get_curline(); vim_iswhite(*ptr); ++col) { for (col = 0, ptr = get_cursor_line_ptr(); vim_iswhite(*ptr); ++col) {
ptr++; ptr++;
} }
@@ -550,7 +550,7 @@ int get_lisp_indent(void)
continue; continue;
} }
for (that = ml_get_curline(); *that != NUL; ++that) { for (that = get_cursor_line_ptr(); *that != NUL; ++that) {
if (*that == ';') { if (*that == ';') {
while (*(that + 1) != NUL) { while (*(that + 1) != NUL) {
that++; that++;
@@ -597,7 +597,7 @@ int get_lisp_indent(void)
curwin->w_cursor.col = pos->col; curwin->w_cursor.col = pos->col;
col = pos->col; col = pos->col;
that = ml_get_curline(); that = get_cursor_line_ptr();
if (vi_lisp && (get_indent() == 0)) { if (vi_lisp && (get_indent() == 0)) {
amount = 2; amount = 2;

View File

@@ -267,7 +267,7 @@ int cin_islabel(void)
{ /* XXX */ { /* XXX */
char_u *s; char_u *s;
s = cin_skipcomment(ml_get_curline()); s = cin_skipcomment(get_cursor_line_ptr());
/* /*
* Exclude "default" from labels, since it should be indented * Exclude "default" from labels, since it should be indented
@@ -298,7 +298,7 @@ int cin_islabel(void)
if ((trypos = ind_find_start_comment()) != NULL) /* XXX */ if ((trypos = ind_find_start_comment()) != NULL) /* XXX */
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
line = ml_get_curline(); line = get_cursor_line_ptr();
if (cin_ispreproc(line)) /* ignore #defines, #if, etc. */ if (cin_ispreproc(line)) /* ignore #defines, #if, etc. */
continue; continue;
if (*(line = cin_skipcomment(line)) == NUL) if (*(line = cin_skipcomment(line)) == NUL)
@@ -328,7 +328,7 @@ static int cin_isinit(void)
char_u *s; char_u *s;
static char *skip[] = {"static", "public", "protected", "private"}; static char *skip[] = {"static", "public", "protected", "private"};
s = cin_skipcomment(ml_get_curline()); s = cin_skipcomment(get_cursor_line_ptr());
if (cin_starts_with(s, "typedef")) if (cin_starts_with(s, "typedef"))
s = cin_skipcomment(s + 7); s = cin_skipcomment(s + 7);
@@ -522,16 +522,16 @@ static int skip_label(linenr_T lnum, char_u **pp)
cursor_save = curwin->w_cursor; cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
l = ml_get_curline(); l = get_cursor_line_ptr();
/* XXX */ /* XXX */
if (cin_iscase(l, FALSE) || cin_isscopedecl(l) || cin_islabel()) { if (cin_iscase(l, FALSE) || cin_isscopedecl(l) || cin_islabel()) {
amount = get_indent_nolabel(lnum); amount = get_indent_nolabel(lnum);
l = after_label(ml_get_curline()); l = after_label(get_cursor_line_ptr());
if (l == NULL) /* just in case */ if (l == NULL) /* just in case */
l = ml_get_curline(); l = get_cursor_line_ptr();
} else { } else {
amount = get_indent(); amount = get_indent();
l = ml_get_curline(); l = get_cursor_line_ptr();
} }
*pp = l; *pp = l;
@@ -553,7 +553,7 @@ static int cin_first_id_amount(void)
pos_T fp; pos_T fp;
colnr_T col; colnr_T col;
line = ml_get_curline(); line = get_cursor_line_ptr();
p = skipwhite(line); p = skipwhite(line);
len = (int)(skiptowhite(p) - p); len = (int)(skiptowhite(p) - p);
if (len == 6 && STRNCMP(p, "static", 6) == 0) { if (len == 6 && STRNCMP(p, "static", 6) == 0) {
@@ -869,7 +869,7 @@ cin_iswhileofdo ( /* XXX */
cursor_save = curwin->w_cursor; cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
p = ml_get_curline(); p = get_cursor_line_ptr();
while (*p && *p != 'w') { /* skip any '}', until the 'w' of the "while" */ while (*p && *p != 'w') { /* skip any '}', until the 'w' of the "while" */
++p; ++p;
++curwin->w_cursor.col; ++curwin->w_cursor.col;
@@ -942,7 +942,7 @@ static int cin_iswhileofdo_end(int terminated)
if (terminated != ';') /* there must be a ';' at the end */ if (terminated != ';') /* there must be a ';' at the end */
return FALSE; return FALSE;
p = line = ml_get_curline(); p = line = get_cursor_line_ptr();
while (*p != NUL) { while (*p != NUL) {
p = cin_skipcomment(p); p = cin_skipcomment(p);
if (*p == ')') { if (*p == ')') {
@@ -964,7 +964,7 @@ static int cin_iswhileofdo_end(int terminated)
} }
/* Searching may have made "line" invalid, get it again. */ /* Searching may have made "line" invalid, get it again. */
line = ml_get_curline(); line = get_cursor_line_ptr();
p = line + i; p = line + i;
} }
} }
@@ -1000,7 +1000,7 @@ cin_is_cpp_baseclass (
char_u *s; char_u *s;
int class_or_struct, lookfor_ctor_init, cpp_base_class; int class_or_struct, lookfor_ctor_init, cpp_base_class;
linenr_T lnum = curwin->w_cursor.lnum; linenr_T lnum = curwin->w_cursor.lnum;
char_u *line = ml_get_curline(); char_u *line = get_cursor_line_ptr();
*col = 0; *col = 0;
@@ -1126,10 +1126,10 @@ static int get_baseclass_amount(int col)
if (col == 0) { if (col == 0) {
amount = get_indent(); amount = get_indent();
if (find_last_paren(ml_get_curline(), '(', ')') if (find_last_paren(get_cursor_line_ptr(), '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
amount = get_indent_lnum(trypos->lnum); /* XXX */ amount = get_indent_lnum(trypos->lnum); /* XXX */
if (!cin_ends_in(ml_get_curline(), (char_u *)",", NULL)) if (!cin_ends_in(get_cursor_line_ptr(), (char_u *)",", NULL))
amount += curbuf->b_ind_cpp_baseclass; amount += curbuf->b_ind_cpp_baseclass;
} else { } else {
curwin->w_cursor.col = col; curwin->w_cursor.col = col;
@@ -1866,7 +1866,7 @@ int get_c_indent(void)
/* Ignore a '(' in front of the line that has a match before /* Ignore a '(' in front of the line that has a match before
* our matching '('. */ * our matching '('. */
curwin->w_cursor.lnum = our_paren_pos.lnum; curwin->w_cursor.lnum = our_paren_pos.lnum;
line = ml_get_curline(); line = get_cursor_line_ptr();
look_col = (int)(look - line); look_col = (int)(look - line);
curwin->w_cursor.col = look_col + 1; curwin->w_cursor.col = look_col + 1;
if ((trypos = findmatchlimit(NULL, ')', 0, if ((trypos = findmatchlimit(NULL, ')', 0,
@@ -2042,7 +2042,7 @@ int get_c_indent(void)
* } * }
*/ */
if (curbuf->b_ind_js || (curbuf->b_ind_keep_case_label if (curbuf->b_ind_js || (curbuf->b_ind_keep_case_label
&& cin_iscase(skipwhite(ml_get_curline()), && cin_iscase(skipwhite(get_cursor_line_ptr()),
FALSE))) FALSE)))
amount = get_indent(); amount = get_indent();
else else
@@ -2106,7 +2106,7 @@ int get_c_indent(void)
if (start_brace == BRACE_AT_END) { /* '{' is at end of line */ if (start_brace == BRACE_AT_END) { /* '{' is at end of line */
amount += curbuf->b_ind_open_imag; amount += curbuf->b_ind_open_imag;
l = skipwhite(ml_get_curline()); l = skipwhite(get_cursor_line_ptr());
if (cin_is_cpp_namespace(l)) if (cin_is_cpp_namespace(l))
amount += curbuf->b_ind_cpp_namespace; amount += curbuf->b_ind_cpp_namespace;
} else { } else {
@@ -2178,7 +2178,7 @@ int get_c_indent(void)
break; break;
} }
l = ml_get_curline(); l = get_cursor_line_ptr();
/* /*
* If we're in a comment now, skip to the start of the * If we're in a comment now, skip to the start of the
@@ -2287,7 +2287,7 @@ int get_c_indent(void)
< ourscope - FIND_NAMESPACE_LIM) < ourscope - FIND_NAMESPACE_LIM)
break; break;
l = ml_get_curline(); l = get_cursor_line_ptr();
/* If we're in a comment now, skip to the start of /* If we're in a comment now, skip to the start of
* the comment. */ * the comment. */
@@ -2325,7 +2325,7 @@ int get_c_indent(void)
continue; continue;
} }
l = ml_get_curline(); l = get_cursor_line_ptr();
/* /*
* If this is a switch() label, may line up relative to that. * If this is a switch() label, may line up relative to that.
@@ -2406,7 +2406,7 @@ int get_c_indent(void)
*/ */
if (n) { if (n) {
amount = n; amount = n;
l = after_label(ml_get_curline()); l = after_label(get_cursor_line_ptr());
if (l != NULL && cin_is_cinword(l)) { if (l != NULL && cin_is_cinword(l)) {
if (theline[0] == '{') if (theline[0] == '{')
amount += curbuf->b_ind_open_extra; amount += curbuf->b_ind_open_extra;
@@ -2450,7 +2450,7 @@ int get_c_indent(void)
* Ignore jump labels with nothing after them. * Ignore jump labels with nothing after them.
*/ */
if (!curbuf->b_ind_js && cin_islabel()) { if (!curbuf->b_ind_js && cin_islabel()) {
l = after_label(ml_get_curline()); l = after_label(get_cursor_line_ptr());
if (l == NULL || cin_nocode(l)) if (l == NULL || cin_nocode(l))
continue; continue;
} }
@@ -2461,7 +2461,7 @@ int get_c_indent(void)
* (need to get the line again, cin_islabel() may have * (need to get the line again, cin_islabel() may have
* unlocked it) * unlocked it)
*/ */
l = ml_get_curline(); l = get_cursor_line_ptr();
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum) if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)
|| cin_nocode(l)) || cin_nocode(l))
continue; continue;
@@ -2473,7 +2473,7 @@ int get_c_indent(void)
n = FALSE; n = FALSE;
if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) { if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) {
n = cin_is_cpp_baseclass(&col); n = cin_is_cpp_baseclass(&col);
l = ml_get_curline(); l = get_cursor_line_ptr();
} }
if (n) { if (n) {
if (lookfor == LOOKFOR_UNTERM) { if (lookfor == LOOKFOR_UNTERM) {
@@ -2545,7 +2545,7 @@ int get_c_indent(void)
* asdf) * asdf)
*/ */
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
l = ml_get_curline(); l = get_cursor_line_ptr();
if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) { if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) {
++curwin->w_cursor.lnum; ++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -2657,7 +2657,7 @@ int get_c_indent(void)
* x = 1; * x = 1;
* -> here * -> here
*/ */
l = skipwhite(ml_get_curline()); l = skipwhite(get_cursor_line_ptr());
if (cin_isdo(l)) { if (cin_isdo(l)) {
if (whilelevel == 0) if (whilelevel == 0)
break; break;
@@ -2676,7 +2676,7 @@ int get_c_indent(void)
* not the one from "if () {". */ * not the one from "if () {". */
if (*l == '}') if (*l == '}')
curwin->w_cursor.col = curwin->w_cursor.col =
(colnr_T)(l - ml_get_curline()) + 1; (colnr_T)(l - get_cursor_line_ptr()) + 1;
if ((trypos = find_start_brace()) == NULL if ((trypos = find_start_brace()) == NULL
|| find_match(LOOKFOR_IF, trypos->lnum) || find_match(LOOKFOR_IF, trypos->lnum)
@@ -2802,7 +2802,7 @@ int get_c_indent(void)
* may be lined up with the case label. * may be lined up with the case label.
*/ */
if (lookfor == LOOKFOR_NOBREAK if (lookfor == LOOKFOR_NOBREAK
&& cin_isbreak(skipwhite(ml_get_curline()))) { && cin_isbreak(skipwhite(get_cursor_line_ptr()))) {
lookfor = LOOKFOR_ANY; lookfor = LOOKFOR_ANY;
continue; continue;
} }
@@ -2811,7 +2811,7 @@ int get_c_indent(void)
* Handle "do {" line. * Handle "do {" line.
*/ */
if (whilelevel > 0) { if (whilelevel > 0) {
l = cin_skipcomment(ml_get_curline()); l = cin_skipcomment(get_cursor_line_ptr());
if (cin_isdo(l)) { if (cin_isdo(l)) {
amount = get_indent(); /* XXX */ amount = get_indent(); /* XXX */
--whilelevel; --whilelevel;
@@ -2867,7 +2867,7 @@ int get_c_indent(void)
* here; * here;
*/ */
term_again: term_again:
l = ml_get_curline(); l = get_cursor_line_ptr();
if (find_last_paren(l, '(', ')') if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren( && (trypos = find_match_paren(
curbuf->b_ind_maxparen)) != NULL) { curbuf->b_ind_maxparen)) != NULL) {
@@ -2878,7 +2878,7 @@ term_again:
* asdf) * asdf)
*/ */
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
l = ml_get_curline(); l = get_cursor_line_ptr();
if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) { if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) {
++curwin->w_cursor.lnum; ++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -2935,13 +2935,13 @@ term_again:
* If we're at the end of a block, skip to the start of * If we're at the end of a block, skip to the start of
* that block. * that block.
*/ */
l = ml_get_curline(); l = get_cursor_line_ptr();
if (find_last_paren(l, '{', '}') /* XXX */ if (find_last_paren(l, '{', '}') /* XXX */
&& (trypos = find_start_brace()) != NULL) { && (trypos = find_start_brace()) != NULL) {
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
/* if not "else {" check for terminated again */ /* if not "else {" check for terminated again */
/* but skip block for "} else {" */ /* but skip block for "} else {" */
l = cin_skipcomment(ml_get_curline()); l = cin_skipcomment(get_cursor_line_ptr());
if (*l == '}' || !cin_iselse(l)) if (*l == '}' || !cin_iselse(l))
goto term_again; goto term_again;
++curwin->w_cursor.lnum; ++curwin->w_cursor.lnum;
@@ -3006,7 +3006,7 @@ term_again:
curwin->w_cursor.lnum--; curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
l = ml_get_curline(); l = get_cursor_line_ptr();
/* /*
* If we're in a comment now, skip to the start of the comment. * If we're in a comment now, skip to the start of the comment.
@@ -3024,7 +3024,7 @@ term_again:
n = FALSE; n = FALSE;
if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') { if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') {
n = cin_is_cpp_baseclass(&col); n = cin_is_cpp_baseclass(&col);
l = ml_get_curline(); l = get_cursor_line_ptr();
} }
if (n) { if (n) {
/* XXX */ /* XXX */
@@ -3091,7 +3091,7 @@ term_again:
*/ */
if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */ if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */
break; break;
l = ml_get_curline(); l = get_cursor_line_ptr();
/* /*
* Finding the closing '}' of a previous function. Put * Finding the closing '}' of a previous function. Put
@@ -3152,7 +3152,7 @@ term_again:
if (cin_ends_in(l, (char_u *)",", NULL) if (cin_ends_in(l, (char_u *)",", NULL)
|| (*l != NUL && l[STRLEN(l) - 1] == '\\')) || (*l != NUL && l[STRLEN(l) - 1] == '\\'))
break; break;
l = ml_get_curline(); l = get_cursor_line_ptr();
} }
/* /*
@@ -3226,7 +3226,7 @@ static int find_match(int lookfor, linenr_T ourscope)
curwin->w_cursor.lnum--; curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
look = cin_skipcomment(ml_get_curline()); look = cin_skipcomment(get_cursor_line_ptr());
if (cin_iselse(look) if (cin_iselse(look)
|| cin_isif(look) || cin_isif(look)
|| cin_isdo(look) /* XXX */ || cin_isdo(look) /* XXX */
@@ -3260,7 +3260,7 @@ static int find_match(int lookfor, linenr_T ourscope)
* then we need to go back to another if, so * then we need to go back to another if, so
* increment elselevel * increment elselevel
*/ */
look = cin_skipcomment(ml_get_curline()); look = cin_skipcomment(get_cursor_line_ptr());
if (cin_iselse(look)) { if (cin_iselse(look)) {
mightbeif = cin_skipcomment(look + 4); mightbeif = cin_skipcomment(look + 4);
if (!cin_isif(mightbeif)) if (!cin_isif(mightbeif))
@@ -3278,7 +3278,7 @@ static int find_match(int lookfor, linenr_T ourscope)
} }
/* If it's an "if" decrement elselevel */ /* If it's an "if" decrement elselevel */
look = cin_skipcomment(ml_get_curline()); look = cin_skipcomment(get_cursor_line_ptr());
if (cin_isif(look)) { if (cin_isif(look)) {
elselevel--; elselevel--;
/* /*

View File

@@ -2860,7 +2860,7 @@ void show_utf8()
/* Get the byte length of the char under the cursor, including composing /* Get the byte length of the char under the cursor, including composing
* characters. */ * characters. */
line = ml_get_cursor(); line = get_cursor_pos_ptr();
len = utfc_ptr2len(line); len = utfc_ptr2len(line);
if (len == 0) { if (len == 0) {
MSG("NUL"); MSG("NUL");
@@ -3097,7 +3097,7 @@ void utf_find_illegal()
curwin->w_cursor.coladd = 0; curwin->w_cursor.coladd = 0;
for (;; ) { for (;; ) {
p = ml_get_cursor(); p = get_cursor_pos_ptr();
if (vimconv.vc_type != CONV_NONE) { if (vimconv.vc_type != CONV_NONE) {
free(tofree); free(tofree);
tofree = string_convert(&vimconv, p, NULL); tofree = string_convert(&vimconv, p, NULL);
@@ -3113,12 +3113,12 @@ void utf_find_illegal()
if (*p >= 0x80 && (len == 1 if (*p >= 0x80 && (len == 1
|| utf_char2len(utf_ptr2char(p)) != len)) { || utf_char2len(utf_ptr2char(p)) != len)) {
if (vimconv.vc_type == CONV_NONE) if (vimconv.vc_type == CONV_NONE)
curwin->w_cursor.col += (colnr_T)(p - ml_get_cursor()); curwin->w_cursor.col += (colnr_T)(p - get_cursor_pos_ptr());
else { else {
int l; int l;
len = (int)(p - tofree); len = (int)(p - tofree);
for (p = ml_get_cursor(); *p != NUL && len-- > 0; p += l) { for (p = get_cursor_pos_ptr(); *p != NUL && len-- > 0; p += l) {
l = utf_ptr2len(p); l = utf_ptr2len(p);
curwin->w_cursor.col += l; curwin->w_cursor.col += l;
} }

View File

@@ -120,7 +120,7 @@ open_line (
/* /*
* make a copy of the current line so we can mess with it * make a copy of the current line so we can mess with it
*/ */
saved_line = vim_strsave(ml_get_curline()); saved_line = vim_strsave(get_cursor_line_ptr());
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
/* /*
@@ -286,7 +286,7 @@ open_line (
if ((pos = findmatch(NULL, '(')) != NULL) { if ((pos = findmatch(NULL, '(')) != NULL) {
curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.lnum = pos->lnum;
newindent = get_indent(); newindent = get_indent();
ptr = ml_get_curline(); ptr = get_cursor_line_ptr();
} }
} }
/* /*
@@ -887,7 +887,7 @@ open_line (
&& curbuf->b_p_lisp && curbuf->b_p_lisp
&& curbuf->b_p_ai) { && curbuf->b_p_ai) {
fixthisline(get_lisp_indent); fixthisline(get_lisp_indent);
p = ml_get_curline(); p = get_cursor_line_ptr();
ai_col = (colnr_T)(skipwhite(p) - p); ai_col = (colnr_T)(skipwhite(p) - p);
} }
/* /*
@@ -901,7 +901,7 @@ open_line (
? KEY_OPEN_FORW ? KEY_OPEN_FORW
: KEY_OPEN_BACK, ' ', linewhite(curwin->w_cursor.lnum))) { : KEY_OPEN_BACK, ' ', linewhite(curwin->w_cursor.lnum))) {
do_c_expr_indent(); do_c_expr_indent();
p = ml_get_curline(); p = get_cursor_line_ptr();
ai_col = (colnr_T)(skipwhite(p) - p); ai_col = (colnr_T)(skipwhite(p) - p);
} }
if (vreplace_mode != 0) if (vreplace_mode != 0)
@@ -914,7 +914,7 @@ open_line (
*/ */
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
/* Put new line in p_extra */ /* Put new line in p_extra */
p_extra = vim_strsave(ml_get_curline()); p_extra = vim_strsave(get_cursor_line_ptr());
/* Put back original line */ /* Put back original line */
ml_replace(curwin->w_cursor.lnum, next_line, FALSE); ml_replace(curwin->w_cursor.lnum, next_line, FALSE);
@@ -1595,7 +1595,7 @@ int del_char(int fixpos)
if (has_mbyte) { if (has_mbyte) {
/* Make sure the cursor is at the start of a character. */ /* Make sure the cursor is at the start of a character. */
mb_adjust_cursor(); mb_adjust_cursor();
if (*ml_get_cursor() == NUL) if (*get_cursor_pos_ptr() == NUL)
return FAIL; return FAIL;
return del_chars(1L, fixpos); return del_chars(1L, fixpos);
} }
@@ -1612,7 +1612,7 @@ int del_chars(long count, int fixpos)
char_u *p; char_u *p;
int l; int l;
p = ml_get_cursor(); p = get_cursor_pos_ptr();
for (i = 0; i < count && *p != NUL; ++i) { for (i = 0; i < count && *p != NUL; ++i) {
l = (*mb_ptr2len)(p); l = (*mb_ptr2len)(p);
bytes += l; bytes += l;

View File

@@ -798,7 +798,7 @@ curs_columns (
/* When cursor wraps to first char of next line in Insert /* When cursor wraps to first char of next line in Insert
* mode, the 'showbreak' string isn't shown, backup to first * mode, the 'showbreak' string isn't shown, backup to first
* column */ * column */
if (*p_sbr && *ml_get_cursor() == NUL if (*p_sbr && *get_cursor_pos_ptr() == NUL
&& curwin->w_wcol == (int)vim_strsize(p_sbr)) && curwin->w_wcol == (int)vim_strsize(p_sbr))
curwin->w_wcol = 0; curwin->w_wcol = 0;
} }

View File

@@ -1349,7 +1349,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
oap->start.col = 0; oap->start.col = 0;
if (hasFolding(curwin->w_cursor.lnum, NULL, if (hasFolding(curwin->w_cursor.lnum, NULL,
&curwin->w_cursor.lnum)) &curwin->w_cursor.lnum))
curwin->w_cursor.col = (colnr_T)STRLEN(ml_get_curline()); curwin->w_cursor.col = (colnr_T)STRLEN(get_cursor_line_ptr());
} }
oap->end = curwin->w_cursor; oap->end = curwin->w_cursor;
curwin->w_cursor = oap->start; curwin->w_cursor = oap->start;
@@ -2519,9 +2519,9 @@ do_mouse (
find_end_of_word(&VIsual); find_end_of_word(&VIsual);
} else { } else {
find_start_of_word(&VIsual); find_start_of_word(&VIsual);
if (*p_sel == 'e' && *ml_get_cursor() != NUL) if (*p_sel == 'e' && *get_cursor_pos_ptr() != NUL)
curwin->w_cursor.col += curwin->w_cursor.col +=
(*mb_ptr2len)(ml_get_cursor()); (*mb_ptr2len)(get_cursor_pos_ptr());
find_end_of_word(&curwin->w_cursor); find_end_of_word(&curwin->w_cursor);
} }
} }
@@ -2983,9 +2983,9 @@ void clear_showcmd(void)
if (cursor_bot) { if (cursor_bot) {
s = ml_get_pos(&VIsual); s = ml_get_pos(&VIsual);
e = ml_get_cursor(); e = get_cursor_pos_ptr();
} else { } else {
s = ml_get_cursor(); s = get_cursor_pos_ptr();
e = ml_get_pos(&VIsual); e = ml_get_pos(&VIsual);
} }
while ((*p_sel != 'e') ? s <= e : s < e) { while ((*p_sel != 'e') ? s <= e : s < e) {
@@ -3406,7 +3406,8 @@ find_decl (
par_pos = curwin->w_cursor; par_pos = curwin->w_cursor;
} else { } else {
par_pos = curwin->w_cursor; par_pos = curwin->w_cursor;
while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) while (curwin->w_cursor.lnum > 1
&& *skipwhite(get_cursor_line_ptr()) != NUL)
--curwin->w_cursor.lnum; --curwin->w_cursor.lnum;
} }
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -3438,7 +3439,7 @@ find_decl (
} }
break; break;
} }
if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) { if (get_leader_len(get_cursor_line_ptr(), NULL, FALSE, TRUE) > 0) {
/* Ignore this line, continue at start of next line. */ /* Ignore this line, continue at start of next line. */
++curwin->w_cursor.lnum; ++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -3484,7 +3485,7 @@ find_decl (
*/ */
static int nv_screengo(oparg_T *oap, int dir, long dist) static int nv_screengo(oparg_T *oap, int dir, long dist)
{ {
int linelen = linetabsize(ml_get_curline()); int linelen = linetabsize(get_cursor_line_ptr());
int retval = OK; int retval = OK;
int atend = FALSE; int atend = FALSE;
int n; int n;
@@ -3545,7 +3546,7 @@ static int nv_screengo(oparg_T *oap, int dir, long dist)
if (!(fdo_flags & FDO_ALL)) if (!(fdo_flags & FDO_ALL))
(void)hasFolding(curwin->w_cursor.lnum, (void)hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL); &curwin->w_cursor.lnum, NULL);
linelen = linetabsize(ml_get_curline()); linelen = linetabsize(get_cursor_line_ptr());
if (linelen > width1) if (linelen > width1)
curwin->w_curswant += (((linelen - width1 - 1) / width2) curwin->w_curswant += (((linelen - width1 - 1) / width2)
+ 1) * width2; + 1) * width2;
@@ -3569,7 +3570,7 @@ static int nv_screengo(oparg_T *oap, int dir, long dist)
} }
curwin->w_cursor.lnum++; curwin->w_cursor.lnum++;
curwin->w_curswant %= width2; curwin->w_curswant %= width2;
linelen = linetabsize(ml_get_curline()); linelen = linetabsize(get_cursor_line_ptr());
} }
} }
} }
@@ -4370,7 +4371,7 @@ static void nv_ident(cmdarg_T *cap)
* it was. * it was.
*/ */
setpcmark(); setpcmark();
curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline()); curwin->w_cursor.col = (colnr_T) (ptr - get_cursor_line_ptr());
if (!g_cmd && vim_iswordp(ptr)) if (!g_cmd && vim_iswordp(ptr))
STRCPY(buf, "\\<"); STRCPY(buf, "\\<");
@@ -4483,7 +4484,7 @@ static void nv_ident(cmdarg_T *cap)
*/ */
if (cmdchar == '*' || cmdchar == '#') { if (cmdchar == '*' || cmdchar == '#') {
if (!g_cmd && ( if (!g_cmd && (
has_mbyte ? vim_iswordp(mb_prevptr(ml_get_curline(), ptr)) : has_mbyte ? vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr)) :
vim_iswordc(ptr[-1]))) vim_iswordc(ptr[-1])))
STRCAT(buf, "\\>"); STRCAT(buf, "\\>");
/* put pattern in search history */ /* put pattern in search history */
@@ -4515,7 +4516,7 @@ get_visual_text (
return FAIL; return FAIL;
} }
if (VIsual_mode == 'V') { if (VIsual_mode == 'V') {
*pp = ml_get_curline(); *pp = get_cursor_line_ptr();
*lenp = (int)STRLEN(*pp); *lenp = (int)STRLEN(*pp);
} else { } else {
if (lt(curwin->w_cursor, VIsual)) { if (lt(curwin->w_cursor, VIsual)) {
@@ -4645,7 +4646,7 @@ static void nv_right(cmdarg_T *cap)
for (n = cap->count1; n > 0; --n) { for (n = cap->count1; n > 0; --n) {
if ((!PAST_LINE && oneright() == FAIL) if ((!PAST_LINE && oneright() == FAIL)
|| (PAST_LINE && *ml_get_cursor() == NUL) || (PAST_LINE && *get_cursor_pos_ptr() == NUL)
) { ) {
/* /*
* <Space> wraps to next line if 'whichwrap' has 's'. * <Space> wraps to next line if 'whichwrap' has 's'.
@@ -4691,7 +4692,7 @@ static void nv_right(cmdarg_T *cap)
else { else {
if (has_mbyte) if (has_mbyte)
curwin->w_cursor.col += curwin->w_cursor.col +=
(*mb_ptr2len)(ml_get_cursor()); (*mb_ptr2len)(get_cursor_pos_ptr());
else else
++curwin->w_cursor.col; ++curwin->w_cursor.col;
} }
@@ -4746,7 +4747,7 @@ static void nv_left(cmdarg_T *cap)
if ( (cap->oap->op_type == OP_DELETE if ( (cap->oap->op_type == OP_DELETE
|| cap->oap->op_type == OP_CHANGE) || cap->oap->op_type == OP_CHANGE)
&& !lineempty(curwin->w_cursor.lnum)) { && !lineempty(curwin->w_cursor.lnum)) {
char_u *cp = ml_get_cursor(); char_u *cp = get_cursor_pos_ptr();
if (*cp != NUL) { if (*cp != NUL) {
if (has_mbyte) { if (has_mbyte) {
@@ -5470,7 +5471,7 @@ static void nv_replace(cmdarg_T *cap)
} }
/* Abort if not enough characters to replace. */ /* Abort if not enough characters to replace. */
ptr = ml_get_cursor(); ptr = get_cursor_pos_ptr();
if (STRLEN(ptr) < (unsigned)cap->count1 if (STRLEN(ptr) < (unsigned)cap->count1
|| (has_mbyte && mb_charlen(ptr) < cap->count1) || (has_mbyte && mb_charlen(ptr) < cap->count1)
) { ) {
@@ -6309,7 +6310,7 @@ static void nv_g_cmd(cmdarg_T *cap)
cap->oap->op_type == OP_NOP) == FAIL) cap->oap->op_type == OP_NOP) == FAIL)
clearopbeep(cap->oap); clearopbeep(cap->oap);
else { else {
char_u *ptr = ml_get_curline(); char_u *ptr = get_cursor_line_ptr();
/* In Visual mode we may end up after the line. */ /* In Visual mode we may end up after the line. */
if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL)
@@ -6413,7 +6414,7 @@ static void nv_g_cmd(cmdarg_T *cap)
if (curbuf->b_last_insert.lnum != 0) { if (curbuf->b_last_insert.lnum != 0) {
curwin->w_cursor = curbuf->b_last_insert; curwin->w_cursor = curbuf->b_last_insert;
check_cursor_lnum(); check_cursor_lnum();
i = (int)STRLEN(ml_get_curline()); i = (int)STRLEN(get_cursor_line_ptr());
if (curwin->w_cursor.col > (colnr_T)i) { if (curwin->w_cursor.col > (colnr_T)i) {
if (virtual_active()) if (virtual_active())
curwin->w_cursor.coladd += curwin->w_cursor.col - i; curwin->w_cursor.coladd += curwin->w_cursor.col - i;
@@ -7117,7 +7118,7 @@ static void nv_edit(cmdarg_T *cap)
coladvance((colnr_T)MAXCOL); coladvance((colnr_T)MAXCOL);
State = save_State; State = save_State;
} else } else
curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor()); curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
break; break;
case 'I': /* "I"nsert before the first non-blank */ case 'I': /* "I"nsert before the first non-blank */
@@ -7132,10 +7133,10 @@ static void nv_edit(cmdarg_T *cap)
* column otherwise, also to append after an unprintable char */ * column otherwise, also to append after an unprintable char */
if (virtual_active() if (virtual_active()
&& (curwin->w_cursor.coladd > 0 && (curwin->w_cursor.coladd > 0
|| *ml_get_cursor() == NUL || *get_cursor_pos_ptr() == NUL
|| *ml_get_cursor() == TAB)) || *get_cursor_pos_ptr() == TAB))
curwin->w_cursor.coladd++; curwin->w_cursor.coladd++;
else if (*ml_get_cursor() != NUL) else if (*get_cursor_pos_ptr() != NUL)
inc_cursor(); inc_cursor();
break; break;
} }

View File

@@ -212,7 +212,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
block_col = curwin->w_cursor.col; block_col = curwin->w_cursor.col;
for (i = oap->line_count; --i >= 0; ) { for (i = oap->line_count; --i >= 0; ) {
first_char = *ml_get_curline(); first_char = *get_cursor_line_ptr();
if (first_char == NUL) /* empty line */ if (first_char == NUL) /* empty line */
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
else if (oap->block_mode) else if (oap->block_mode)
@@ -345,7 +345,7 @@ static void shift_block(oparg_T *oap, int amount)
/* total is number of screen columns to be inserted/removed */ /* total is number of screen columns to be inserted/removed */
total = amount * p_sw; total = amount * p_sw;
oldp = ml_get_curline(); oldp = get_cursor_line_ptr();
if (!left) { if (!left) {
/* /*
@@ -598,7 +598,7 @@ int (*how)(void);
*/ */
if (i != oap->line_count - 1 || oap->line_count == 1 if (i != oap->line_count - 1 || oap->line_count == 1
|| how != get_lisp_indent) { || how != get_lisp_indent) {
l = skipwhite(ml_get_curline()); l = skipwhite(get_cursor_line_ptr());
if (*l == NUL) /* empty or blank line */ if (*l == NUL) /* empty or blank line */
count = 0; count = 0;
else else
@@ -1563,7 +1563,7 @@ int op_delete(oparg_T *oap)
/* fix up things for virtualedit-delete: /* fix up things for virtualedit-delete:
* break the tabs which are going to get in our way * break the tabs which are going to get in our way
*/ */
char_u *curline = ml_get_curline(); char_u *curline = get_cursor_line_ptr();
int len = (int)STRLEN(curline); int len = (int)STRLEN(curline);
if (oap->end.coladd != 0 if (oap->end.coladd != 0
@@ -1744,7 +1744,7 @@ int op_replace(oparg_T *oap, int c)
/* oldlen includes textlen, so don't double count */ /* oldlen includes textlen, so don't double count */
n += numc - bd.textlen; n += numc - bd.textlen;
oldp = ml_get_curline(); oldp = get_cursor_line_ptr();
oldlen = STRLEN(oldp); oldlen = STRLEN(oldp);
newp = (char_u *) xmalloc((size_t)(oldlen + 1 + n)); newp = (char_u *) xmalloc((size_t)(oldlen + 1 + n));
memset(newp, NUL, (size_t)(oldlen + 1 + n)); memset(newp, NUL, (size_t)(oldlen + 1 + n));
@@ -2012,7 +2012,7 @@ int swapchar(int op_type, pos_T *pos)
curwin->w_cursor = *pos; curwin->w_cursor = *pos;
/* don't use del_char(), it also removes composing chars */ /* don't use del_char(), it also removes composing chars */
del_bytes(utf_ptr2len(ml_get_cursor()), FALSE, FALSE); del_bytes(utf_ptr2len(get_cursor_pos_ptr()), FALSE, FALSE);
ins_char(nc); ins_char(nc);
curwin->w_cursor = sp; curwin->w_cursor = sp;
} else } else
@@ -2070,7 +2070,7 @@ void op_insert(oparg_T *oap, long count1)
) { ) {
/* Move the cursor to the character right of the block. */ /* Move the cursor to the character right of the block. */
curwin->w_set_curswant = TRUE; curwin->w_set_curswant = TRUE;
while (*ml_get_cursor() != NUL while (*get_cursor_pos_ptr() != NUL
&& (curwin->w_cursor.col < bd.textcol + bd.textlen)) && (curwin->w_cursor.col < bd.textcol + bd.textlen))
++curwin->w_cursor.col; ++curwin->w_cursor.col;
if (bd.is_short && !bd.is_MAX) { if (bd.is_short && !bd.is_MAX) {
@@ -2687,11 +2687,11 @@ do_put (
* between. */ * between. */
if (u_save_cursor() == FAIL) if (u_save_cursor() == FAIL)
goto end; goto end;
ptr = vim_strsave(ml_get_cursor()); ptr = vim_strsave(get_cursor_pos_ptr());
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE); ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
free(ptr); free(ptr);
ptr = vim_strnsave(ml_get_curline(), curwin->w_cursor.col); ptr = vim_strnsave(get_cursor_line_ptr(), curwin->w_cursor.col);
ml_replace(curwin->w_cursor.lnum, ptr, FALSE); ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
++nr_lines; ++nr_lines;
dir = FORWARD; dir = FORWARD;
@@ -2776,7 +2776,7 @@ do_put (
if (has_mbyte) if (has_mbyte)
/* move to start of next multi-byte character */ /* move to start of next multi-byte character */
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr());
else if (c != TAB || ve_flags != VE_ALL) else if (c != TAB || ve_flags != VE_ALL)
++curwin->w_cursor.col; ++curwin->w_cursor.col;
++col; ++col;
@@ -2817,7 +2817,7 @@ do_put (
++nr_lines; ++nr_lines;
} }
/* get the old line and advance to the position to insert at */ /* get the old line and advance to the position to insert at */
oldp = ml_get_curline(); oldp = get_cursor_line_ptr();
oldlen = (int)STRLEN(oldp); oldlen = (int)STRLEN(oldp);
for (ptr = oldp; vcol < col && *ptr; ) { for (ptr = oldp; vcol < col && *ptr; ) {
/* Count a tab for what it's worth (if list mode not on) */ /* Count a tab for what it's worth (if list mode not on) */
@@ -2906,7 +2906,7 @@ do_put (
curwin->w_cursor.col++; curwin->w_cursor.col++;
/* in Insert mode we might be after the NUL, correct for that */ /* in Insert mode we might be after the NUL, correct for that */
len = (colnr_T)STRLEN(ml_get_curline()); len = (colnr_T)STRLEN(get_cursor_line_ptr());
if (curwin->w_cursor.col > len) if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len; curwin->w_cursor.col = len;
} else } else
@@ -2920,7 +2920,7 @@ do_put (
* char */ * char */
if (dir == FORWARD && gchar_cursor() != NUL) { if (dir == FORWARD && gchar_cursor() != NUL) {
if (has_mbyte) { if (has_mbyte) {
int bytelen = (*mb_ptr2len)(ml_get_cursor()); int bytelen = (*mb_ptr2len)(get_cursor_pos_ptr());
/* put it on the next of the multi-byte character. */ /* put it on the next of the multi-byte character. */
col += bytelen; col += bytelen;
@@ -3951,7 +3951,7 @@ format_lines (
mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L, mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
(long)-next_leader_len); (long)-next_leader_len);
} else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */ } else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */
char_u *p = ml_get_curline(); char_u *p = get_cursor_line_ptr();
int indent = (int)(skipwhite(p) - p); int indent = (int)(skipwhite(p) - p);
if (indent > 0) { if (indent > 0) {
@@ -3967,7 +3967,7 @@ format_lines (
} }
first_par_line = FALSE; first_par_line = FALSE;
/* If the line is getting long, format it next time */ /* If the line is getting long, format it next time */
if (STRLEN(ml_get_curline()) > (size_t)max_len) if (STRLEN(get_cursor_line_ptr()) > (size_t)max_len)
force_format = TRUE; force_format = TRUE;
else else
force_format = FALSE; force_format = FALSE;
@@ -4241,7 +4241,7 @@ int do_addsub(int command, linenr_T Prenum1)
dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */ dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */
doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); /* "alPha" */ doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); /* "alPha" */
ptr = ml_get_curline(); ptr = get_cursor_line_ptr();
RLADDSUBFIX(ptr); RLADDSUBFIX(ptr);
/* /*
@@ -4290,7 +4290,7 @@ int do_addsub(int command, linenr_T Prenum1)
} }
/* get ptr again, because u_save() may have changed it */ /* get ptr again, because u_save() may have changed it */
ptr = ml_get_curline(); ptr = get_cursor_line_ptr();
RLADDSUBFIX(ptr); RLADDSUBFIX(ptr);
if (doalp && ASCII_ISALPHA(firstdigit)) { if (doalp && ASCII_ISALPHA(firstdigit)) {
@@ -5119,7 +5119,7 @@ void cursor_pos_info(void)
(int64_t)char_count_cursor, (int64_t)char_count, (int64_t)char_count_cursor, (int64_t)char_count,
(int64_t)byte_count_cursor, (int64_t)byte_count); (int64_t)byte_count_cursor, (int64_t)byte_count);
} else { } else {
p = ml_get_curline(); p = get_cursor_line_ptr();
validate_virtcol(); validate_virtcol();
col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
(int)curwin->w_virtcol + 1); (int)curwin->w_virtcol + 1);

View File

@@ -1639,7 +1639,7 @@ win_found:
* found, reduce the error column value by the length of * found, reduce the error column value by the length of
* a tab character. * a tab character.
*/ */
line = ml_get_curline(); line = get_cursor_line_ptr();
screen_col = 0; screen_col = 0;
for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) { for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) {
if (*line == NUL) if (*line == NUL)

View File

@@ -6780,7 +6780,7 @@ void setcursor(void)
* character, position it on the leftmost column. */ * character, position it on the leftmost column. */
curwin->w_p_rl ? ((int)W_WIDTH(curwin) - curwin->w_wcol - ( curwin->w_p_rl ? ((int)W_WIDTH(curwin) - curwin->w_wcol - (
(has_mbyte (has_mbyte
&& (*mb_ptr2cells)(ml_get_cursor()) == 2 && (*mb_ptr2cells)(get_cursor_pos_ptr()) == 2
&& vim_isprintc(gchar_cursor())) ? 2 : && vim_isprintc(gchar_cursor())) ? 2 :
1)) : 1)) :
curwin->w_wcol)); curwin->w_wcol));

View File

@@ -1339,7 +1339,7 @@ int searchc(cmdarg_T *cap, int t_cmd)
else else
cap->oap->inclusive = TRUE; cap->oap->inclusive = TRUE;
p = ml_get_curline(); p = get_cursor_line_ptr();
col = curwin->w_cursor.col; col = curwin->w_cursor.col;
len = (int)STRLEN(p); len = (int)STRLEN(p);
@@ -2416,7 +2416,7 @@ fwd_word (
/* /*
* We'll stop if we land on a blank line * We'll stop if we land on a blank line
*/ */
if (curwin->w_cursor.col == 0 && *ml_get_curline() == NUL) if (curwin->w_cursor.col == 0 && *get_cursor_line_ptr() == NUL)
break; break;
i = inc_cursor(); i = inc_cursor();
@@ -3099,7 +3099,7 @@ static int in_html_tag(int);
*/ */
static int in_html_tag(int end_tag) static int in_html_tag(int end_tag)
{ {
char_u *line = ml_get_curline(); char_u *line = get_cursor_line_ptr();
char_u *p; char_u *p;
int c; int c;
int lc = NUL; int lc = NUL;
@@ -3202,12 +3202,12 @@ current_tagblock (
if (in_html_tag(FALSE)) { if (in_html_tag(FALSE)) {
/* cursor on start tag, move to its '>' */ /* cursor on start tag, move to its '>' */
while (*ml_get_cursor() != '>') while (*get_cursor_pos_ptr() != '>')
if (inc_cursor() < 0) if (inc_cursor() < 0)
break; break;
} else if (in_html_tag(TRUE)) { } else if (in_html_tag(TRUE)) {
/* cursor on end tag, move to just before it */ /* cursor on end tag, move to just before it */
while (*ml_get_cursor() != '<') while (*get_cursor_pos_ptr() != '<')
if (dec_cursor() < 0) if (dec_cursor() < 0)
break; break;
dec_cursor(); dec_cursor();
@@ -3240,7 +3240,7 @@ again:
* Search for matching "</aaa>". First isolate the "aaa". * Search for matching "</aaa>". First isolate the "aaa".
*/ */
inc_cursor(); inc_cursor();
p = ml_get_cursor(); p = get_cursor_pos_ptr();
for (cp = p; *cp != NUL && *cp != '>' && !vim_iswhite(*cp); mb_ptr_adv(cp)) for (cp = p; *cp != NUL && *cp != '>' && !vim_iswhite(*cp); mb_ptr_adv(cp))
; ;
len = (int)(cp - p); len = (int)(cp - p);
@@ -3270,12 +3270,12 @@ again:
if (do_include || r < 1) { if (do_include || r < 1) {
/* Include up to the '>'. */ /* Include up to the '>'. */
while (*ml_get_cursor() != '>') while (*get_cursor_pos_ptr() != '>')
if (inc_cursor() < 0) if (inc_cursor() < 0)
break; break;
} else { } else {
/* Exclude the '<' of the end tag. */ /* Exclude the '<' of the end tag. */
if (*ml_get_cursor() == '<') if (*get_cursor_pos_ptr() == '<')
dec_cursor(); dec_cursor();
} }
end_pos = curwin->w_cursor; end_pos = curwin->w_cursor;
@@ -3284,7 +3284,7 @@ again:
/* Exclude the start tag. */ /* Exclude the start tag. */
curwin->w_cursor = start_pos; curwin->w_cursor = start_pos;
while (inc_cursor() >= 0) while (inc_cursor() >= 0)
if (*ml_get_cursor() == '>') { if (*get_cursor_pos_ptr() == '>') {
inc_cursor(); inc_cursor();
start_pos = curwin->w_cursor; start_pos = curwin->w_cursor;
break; break;
@@ -3567,7 +3567,7 @@ current_quote (
int quotechar /* Quote character */ int quotechar /* Quote character */
) )
{ {
char_u *line = ml_get_curline(); char_u *line = get_cursor_line_ptr();
int col_end; int col_end;
int col_start = curwin->w_cursor.col; int col_start = curwin->w_cursor.col;
int inclusive = FALSE; int inclusive = FALSE;

View File

@@ -8648,7 +8648,7 @@ void spell_suggest(int count)
// No bad word or it starts after the cursor: use the word under the // No bad word or it starts after the cursor: use the word under the
// cursor. // cursor.
curwin->w_cursor = prev_cursor; curwin->w_cursor = prev_cursor;
line = ml_get_curline(); line = get_cursor_line_ptr();
p = line + curwin->w_cursor.col; p = line + curwin->w_cursor.col;
// Backup to before start of word. // Backup to before start of word.
while (p > line && spell_iswordp_nmw(p, curwin)) while (p > line && spell_iswordp_nmw(p, curwin))
@@ -8670,7 +8670,7 @@ void spell_suggest(int count)
need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col); need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);
// Make a copy of current line since autocommands may free the line. // Make a copy of current line since autocommands may free the line.
line = vim_strsave(ml_get_curline()); line = vim_strsave(get_cursor_line_ptr());
// Get the list of suggestions. Limit to 'lines' - 2 or the number in // Get the list of suggestions. Limit to 'lines' - 2 or the number in
// 'spellsuggest', whatever is smaller. // 'spellsuggest', whatever is smaller.
@@ -8824,7 +8824,7 @@ static int check_need_cap(linenr_T lnum, colnr_T col)
if (curwin->w_s->b_cap_prog == NULL) if (curwin->w_s->b_cap_prog == NULL)
return FALSE; return FALSE;
line = ml_get_curline(); line = get_cursor_line_ptr();
endcol = 0; endcol = 0;
if ((int)(skipwhite(line) - line) >= (int)col) { if ((int)(skipwhite(line) - line) >= (int)col) {
// At start of line, check if previous line is empty or sentence // At start of line, check if previous line is empty or sentence
@@ -8899,7 +8899,7 @@ void ex_spellrepall(exarg_T *eap)
// Only replace when the right word isn't there yet. This happens // Only replace when the right word isn't there yet. This happens
// when changing "etc" to "etc.". // when changing "etc" to "etc.".
line = ml_get_curline(); line = get_cursor_line_ptr();
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col, if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
repl_to, STRLEN(repl_to)) != 0) { repl_to, STRLEN(repl_to)) != 0) {
p = xmalloc(STRLEN(line) + addlen + 1); p = xmalloc(STRLEN(line) + addlen + 1);
@@ -13548,7 +13548,7 @@ int spell_word_start(int startcol)
return startcol; return startcol;
// Find a word character before "startcol". // Find a word character before "startcol".
line = ml_get_curline(); line = get_cursor_line_ptr();
for (p = line + startcol; p > line; ) { for (p = line + startcol; p > line; ) {
mb_ptr_back(line, p); mb_ptr_back(line, p);
if (spell_iswordp_nmw(p, curwin)) if (spell_iswordp_nmw(p, curwin))

View File

@@ -4773,7 +4773,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
*/ */
char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum) char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum)
{ {
return file_name_in_line(ml_get_curline(), return file_name_in_line(get_cursor_line_ptr(),
curwin->w_cursor.col, options, count, curbuf->b_ffname, curwin->w_cursor.col, options, count, curbuf->b_ffname,
file_lnum); file_lnum);
} }