diff options
Diffstat (limited to 'src/nvim/textformat.c')
-rw-r--r-- | src/nvim/textformat.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index b2bfca08ed..25728ef0f1 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -97,7 +97,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on colnr_T len; colnr_T virtcol; int orig_col = 0; - char_u *saved_text = NULL; + char *saved_text = NULL; colnr_T col; colnr_T end_col; bool did_do_comment = false; @@ -117,11 +117,11 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on // Don't break until after the comment leader if (do_comments) { - char_u *line = get_cursor_line_ptr(); + char_u *line = (char_u *)get_cursor_line_ptr(); leader_len = get_leader_len((char *)line, NULL, false, true); if (leader_len == 0 && curbuf->b_p_cin) { // Check for a line comment after code. - int comment_start = check_linecomment(line); + int comment_start = check_linecomment((char *)line); if (comment_start != MAXCOL) { leader_len = get_leader_len((char *)line + comment_start, NULL, false, true); if (leader_len != 0) { @@ -353,7 +353,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on if (State & VREPLACE_FLAG) { // In MODE_VREPLACE state, we will backspace over the text to be // wrapped, so save a copy now to put on the next line. - saved_text = vim_strsave(get_cursor_pos_ptr()); + saved_text = xstrdup(get_cursor_pos_ptr()); curwin->w_cursor.col = orig_col; saved_text[startcol] = NUL; @@ -411,7 +411,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on // add the additional whitespace needed after the // comment leader for the numbered list. for (int i = 0; i < padding; i++) { - ins_str((char_u *)" "); + ins_str(" "); } changed_bytes(curwin->w_cursor.lnum, leader_len); } else { @@ -425,13 +425,13 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on if (State & VREPLACE_FLAG) { // In MODE_VREPLACE state we have backspaced over the text to be // moved, now we re-insert it into the new line. - ins_bytes((char *)saved_text); + ins_bytes(saved_text); xfree(saved_text); } else { // Check if cursor is not past the NUL off the line, cindent // may have added or removed indent. curwin->w_cursor.col += startcol; - len = (colnr_T)STRLEN(get_cursor_line_ptr()); + len = (colnr_T)strlen(get_cursor_line_ptr()); if (curwin->w_cursor.col > len) { curwin->w_cursor.col = len; } @@ -470,7 +470,7 @@ static int fmt_check_par(linenr_T lnum, int *leader_len, char_u **leader_flags, char_u *flags = NULL; // init for GCC char_u *ptr; - ptr = ml_get(lnum); + ptr = (char_u *)ml_get(lnum); if (do_comments) { *leader_len = get_leader_len((char *)ptr, (char **)leader_flags, false, true); } else { @@ -493,7 +493,7 @@ static int fmt_check_par(linenr_T lnum, int *leader_len, char_u **leader_flags, /// @return true if line "lnum" ends in a white character. static bool ends_in_white(linenr_T lnum) { - char_u *s = ml_get(lnum); + char_u *s = (char_u *)ml_get(lnum); size_t l; if (*s == NUL) { @@ -508,13 +508,13 @@ static bool ends_in_white(linenr_T lnum) /// @param lnum The first line. White-space is ignored. /// /// @note the whole of 'leader1' must match 'leader2_len' characters from 'leader2'. -static bool same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, int leader2_len, - char_u *leader2_flags) +static bool same_leader(linenr_T lnum, int leader1_len, char *leader1_flags, int leader2_len, + char *leader2_flags) { int idx1 = 0, idx2 = 0; - char_u *p; - char_u *line1; - char_u *line2; + char *p; + char *line1; + char *line2; if (leader1_len == 0) { return leader2_len == 0; @@ -552,7 +552,7 @@ static bool same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, i // Get current line and next line, compare the leaders. // The first line has to be saved, only one line can be locked at a time. - line1 = vim_strsave(ml_get(lnum)); + line1 = xstrdup(ml_get(lnum)); for (idx1 = 0; ascii_iswhite(line1[idx1]); idx1++) {} line2 = ml_get(lnum + 1); for (idx2 = 0; idx2 < leader2_len; idx2++) { @@ -586,7 +586,7 @@ static bool paragraph_start(linenr_T lnum) if (lnum <= 1) { return true; // start of the file } - p = ml_get(lnum - 1); + p = (char_u *)ml_get(lnum - 1); if (*p == NUL) { return true; // after empty line } @@ -605,8 +605,8 @@ static bool paragraph_start(linenr_T lnum) if (has_format_option(FO_Q_NUMBER) && (get_number_indent(lnum) > 0)) { return true; // numbered item starts in "lnum". } - if (!same_leader(lnum - 1, leader_len, leader_flags, - next_leader_len, next_leader_flags)) { + if (!same_leader(lnum - 1, leader_len, (char *)leader_flags, + next_leader_len, (char *)next_leader_flags)) { return true; // change of comment leader. } return false; @@ -624,8 +624,8 @@ void auto_format(bool trailblank, bool prev_line) { pos_T pos; colnr_T len; - char_u *old; - char_u *new, *pnew; + char *old; + char *new, *pnew; int wasatend; int cc; @@ -644,7 +644,7 @@ void auto_format(bool trailblank, bool prev_line) // in 'formatoptions' and there is a single character before the cursor. // Otherwise the line would be broken and when typing another non-white // next they are not joined back together. - wasatend = (pos.col == (colnr_T)STRLEN(old)); + wasatend = (pos.col == (colnr_T)strlen(old)); if (*old != NUL && !trailblank && wasatend) { dec_cursor(); cc = gchar_cursor(); @@ -663,7 +663,7 @@ void auto_format(bool trailblank, bool prev_line) // With the 'c' flag in 'formatoptions' and 't' missing: only format // comments. if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP) - && get_leader_len((char *)old, NULL, false, true) == 0) { + && get_leader_len(old, NULL, false, true) == 0) { return; } @@ -698,12 +698,12 @@ void auto_format(bool trailblank, bool prev_line) // formatted. if (!wasatend && has_format_option(FO_WHITE_PAR)) { new = get_cursor_line_ptr(); - len = (colnr_T)STRLEN(new); + len = (colnr_T)strlen(new); if (curwin->w_cursor.col == len) { - pnew = vim_strnsave(new, (size_t)len + 2); + pnew = xstrnsave(new, (size_t)len + 2); pnew[len] = ' '; pnew[len + 1] = NUL; - ml_replace(curwin->w_cursor.lnum, (char *)pnew, false); + ml_replace(curwin->w_cursor.lnum, pnew, false); // remove the space later did_add_space = true; } else { @@ -1018,9 +1018,9 @@ void format_lines(linenr_T line_count, bool avoid_fex) // When the comment leader changes, it's the end of the paragraph. if (curwin->w_cursor.lnum >= curbuf->b_ml.ml_line_count || !same_leader(curwin->w_cursor.lnum, - leader_len, leader_flags, + leader_len, (char *)leader_flags, next_leader_len, - next_leader_flags)) { + (char *)next_leader_flags)) { // Special case: If the next line starts with a line comment // and this line has a line comment after some text, the // paragraph doesn't really end. @@ -1115,7 +1115,7 @@ void format_lines(linenr_T line_count, bool avoid_fex) } first_par_line = false; // If the line is getting long, format it next time - if (STRLEN(get_cursor_line_ptr()) > (size_t)max_len) { + if (strlen(get_cursor_line_ptr()) > (size_t)max_len) { force_format = true; } else { force_format = false; |