mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
8342b4486b
@ -855,7 +855,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
||||
return FAIL;
|
||||
for (extra = 0, l = line1; l <= line2; l++) {
|
||||
str = vim_strsave(ml_get(l + extra));
|
||||
ml_append(dest + l - line1, str, (colnr_T)0, FALSE);
|
||||
ml_append(dest + l - line1, str, (colnr_T)0, false);
|
||||
xfree(str);
|
||||
if (dest < line1)
|
||||
extra++;
|
||||
@ -914,9 +914,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
||||
if (u_save(line1 + extra - 1, line2 + extra + 1) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
for (l = line1; l <= line2; l++)
|
||||
ml_delete(line1 + extra, TRUE);
|
||||
|
||||
for (l = line1; l <= line2; l++) {
|
||||
ml_delete(line1 + extra, true);
|
||||
}
|
||||
if (!global_busy && num_lines > p_report) {
|
||||
if (num_lines == 1)
|
||||
MSG(_("1 line moved"));
|
||||
@ -982,7 +982,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
|
||||
/* need to use vim_strsave() because the line will be unlocked within
|
||||
* ml_append() */
|
||||
p = vim_strsave(ml_get(line1));
|
||||
ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE);
|
||||
ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, false);
|
||||
xfree(p);
|
||||
|
||||
/* situation 2: skip already copied lines */
|
||||
@ -2720,7 +2720,7 @@ static int append_indent = 0; /* autoindent for first line */
|
||||
void ex_append(exarg_T *eap)
|
||||
{
|
||||
char_u *theline;
|
||||
int did_undo = FALSE;
|
||||
bool did_undo = false;
|
||||
linenr_T lnum = eap->line2;
|
||||
int indent = 0;
|
||||
char_u *p;
|
||||
@ -2808,16 +2808,16 @@ void ex_append(exarg_T *eap)
|
||||
if (p[0] == NUL)
|
||||
theline[0] = NUL;
|
||||
|
||||
did_undo = TRUE;
|
||||
ml_append(lnum, theline, (colnr_T)0, FALSE);
|
||||
did_undo = true;
|
||||
ml_append(lnum, theline, (colnr_T)0, false);
|
||||
appended_lines_mark(lnum + (empty ? 1 : 0), 1L);
|
||||
|
||||
xfree(theline);
|
||||
++lnum;
|
||||
|
||||
if (empty) {
|
||||
ml_delete(2L, FALSE);
|
||||
empty = FALSE;
|
||||
ml_delete(2L, false);
|
||||
empty = 0;
|
||||
}
|
||||
}
|
||||
State = NORMAL;
|
||||
@ -2862,7 +2862,7 @@ void ex_change(exarg_T *eap)
|
||||
for (lnum = eap->line2; lnum >= eap->line1; --lnum) {
|
||||
if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
|
||||
break;
|
||||
ml_delete(eap->line1, FALSE);
|
||||
ml_delete(eap->line1, false);
|
||||
}
|
||||
|
||||
/* make sure the cursor is not beyond the end of the file now */
|
||||
@ -3989,8 +3989,9 @@ skip:
|
||||
++lnum;
|
||||
if (u_savedel(lnum, nmatch_tl) != OK)
|
||||
break;
|
||||
for (i = 0; i < nmatch_tl; ++i)
|
||||
ml_delete(lnum, (int)FALSE);
|
||||
for (i = 0; i < nmatch_tl; i++) {
|
||||
ml_delete(lnum, false);
|
||||
}
|
||||
mark_adjust(lnum, lnum + nmatch_tl - 1,
|
||||
(long)MAXLNUM, -nmatch_tl, false);
|
||||
if (subflags.do_ask) {
|
||||
@ -5154,10 +5155,11 @@ void fix_help_buffer(void)
|
||||
}
|
||||
convert_setup(&vc, NULL, NULL);
|
||||
|
||||
ml_append(lnum, cp, (colnr_T)0, FALSE);
|
||||
if (cp != IObuff)
|
||||
ml_append(lnum, cp, (colnr_T)0, false);
|
||||
if (cp != IObuff) {
|
||||
xfree(cp);
|
||||
++lnum;
|
||||
}
|
||||
lnum++;
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
|
@ -7213,10 +7213,11 @@ static void ex_read(exarg_T *eap)
|
||||
else
|
||||
lnum = 1;
|
||||
if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) {
|
||||
ml_delete(lnum, FALSE);
|
||||
ml_delete(lnum, false);
|
||||
if (curwin->w_cursor.lnum > 1
|
||||
&& curwin->w_cursor.lnum >= lnum)
|
||||
--curwin->w_cursor.lnum;
|
||||
&& curwin->w_cursor.lnum >= lnum) {
|
||||
curwin->w_cursor.lnum--;
|
||||
}
|
||||
deleted_lines_mark(lnum, 1L);
|
||||
}
|
||||
}
|
||||
|
@ -6110,9 +6110,9 @@ static int open_cmdwin(void)
|
||||
do {
|
||||
if (++i == hislen)
|
||||
i = 0;
|
||||
if (history[histtype][i].hisstr != NULL)
|
||||
ml_append(lnum++, history[histtype][i].hisstr,
|
||||
(colnr_T)0, FALSE);
|
||||
if (history[histtype][i].hisstr != NULL) {
|
||||
ml_append(lnum++, history[histtype][i].hisstr, (colnr_T)0, false);
|
||||
}
|
||||
} while (i != hisidx[histtype]);
|
||||
}
|
||||
}
|
||||
|
@ -308,29 +308,30 @@ readfile (
|
||||
#ifdef UNIX
|
||||
int swap_mode = -1; /* protection bits for swap file */
|
||||
#endif
|
||||
int fileformat = 0; /* end-of-line format */
|
||||
int keep_fileformat = FALSE;
|
||||
int fileformat = 0; // end-of-line format
|
||||
bool keep_fileformat = false;
|
||||
FileInfo file_info;
|
||||
int file_readonly;
|
||||
linenr_T skip_count = 0;
|
||||
linenr_T read_count = 0;
|
||||
int msg_save = msg_scroll;
|
||||
linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of
|
||||
// last read was missing the eol
|
||||
int file_rewind = false;
|
||||
bool file_rewind = false;
|
||||
int can_retry;
|
||||
linenr_T conv_error = 0; /* line nr with conversion error */
|
||||
linenr_T illegal_byte = 0; /* line nr with illegal byte */
|
||||
int keep_dest_enc = FALSE; /* don't retry when char doesn't fit
|
||||
in destination encoding */
|
||||
linenr_T conv_error = 0; // line nr with conversion error
|
||||
linenr_T illegal_byte = 0; // line nr with illegal byte
|
||||
bool keep_dest_enc = false; // don't retry when char doesn't fit
|
||||
// in destination encoding
|
||||
int bad_char_behavior = BAD_REPLACE;
|
||||
/* BAD_KEEP, BAD_DROP or character to
|
||||
* replace with */
|
||||
char_u *tmpname = NULL; /* name of 'charconvert' output file */
|
||||
int fio_flags = 0;
|
||||
char_u *fenc; /* fileencoding to use */
|
||||
int fenc_alloced; /* fenc_next is in allocated memory */
|
||||
char_u *fenc_next = NULL; /* next item in 'fencs' or NULL */
|
||||
int advance_fenc = FALSE;
|
||||
char_u *fenc; // fileencoding to use
|
||||
bool fenc_alloced; // fenc_next is in allocated memory
|
||||
char_u *fenc_next = NULL; // next item in 'fencs' or NULL
|
||||
bool advance_fenc = false;
|
||||
long real_size = 0;
|
||||
# ifdef USE_ICONV
|
||||
iconv_t iconv_fd = (iconv_t)-1; /* descriptor for iconv() or -1 */
|
||||
@ -481,7 +482,6 @@ readfile (
|
||||
|
||||
if (newfile && !read_stdin && !read_buffer && !read_fifo) {
|
||||
// Remember time of file.
|
||||
FileInfo file_info;
|
||||
if (os_fileinfo((char *)fname, &file_info)) {
|
||||
buf_store_file_info(curbuf, &file_info);
|
||||
curbuf->b_mtime_read = curbuf->b_mtime;
|
||||
@ -627,8 +627,25 @@ readfile (
|
||||
// Set swap file protection bits after creating it.
|
||||
if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
|
||||
&& curbuf->b_ml.ml_mfp->mf_fname != NULL) {
|
||||
(void)os_setperm((const char *)curbuf->b_ml.ml_mfp->mf_fname,
|
||||
(long)swap_mode);
|
||||
const char *swap_fname = (const char *)curbuf->b_ml.ml_mfp->mf_fname;
|
||||
|
||||
// If the group-read bit is set but not the world-read bit, then
|
||||
// the group must be equal to the group of the original file. If
|
||||
// we can't make that happen then reset the group-read bit. This
|
||||
// avoids making the swap file readable to more users when the
|
||||
// primary group of the user is too permissive.
|
||||
if ((swap_mode & 044) == 040) {
|
||||
FileInfo swap_info;
|
||||
|
||||
if (os_fileinfo(swap_fname, &swap_info)
|
||||
&& file_info.stat.st_gid != swap_info.stat.st_gid
|
||||
&& os_fchown(curbuf->b_ml.ml_mfp->mf_fd, -1, file_info.stat.st_gid)
|
||||
== -1) {
|
||||
swap_mode &= 0600;
|
||||
}
|
||||
}
|
||||
|
||||
(void)os_setperm(swap_fname, swap_mode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -747,11 +764,11 @@ readfile (
|
||||
*/
|
||||
if (eap != NULL && eap->force_enc != 0) {
|
||||
fenc = enc_canonize(eap->cmd + eap->force_enc);
|
||||
fenc_alloced = TRUE;
|
||||
keep_dest_enc = TRUE;
|
||||
fenc_alloced = true;
|
||||
keep_dest_enc = true;
|
||||
} else if (curbuf->b_p_bin) {
|
||||
fenc = (char_u *)""; /* binary: don't convert */
|
||||
fenc_alloced = FALSE;
|
||||
fenc = (char_u *)""; // binary: don't convert
|
||||
fenc_alloced = false;
|
||||
} else if (curbuf->b_help) {
|
||||
// Help files are either utf-8 or latin1. Try utf-8 first, if this
|
||||
// fails it must be latin1.
|
||||
@ -762,12 +779,12 @@ readfile (
|
||||
|
||||
fenc_alloced = false;
|
||||
} else if (*p_fencs == NUL) {
|
||||
fenc = curbuf->b_p_fenc; /* use format from buffer */
|
||||
fenc_alloced = FALSE;
|
||||
fenc = curbuf->b_p_fenc; // use format from buffer
|
||||
fenc_alloced = false;
|
||||
} else {
|
||||
fenc_next = p_fencs; /* try items in 'fileencodings' */
|
||||
fenc = next_fenc(&fenc_next);
|
||||
fenc_alloced = TRUE;
|
||||
fenc_alloced = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -800,10 +817,11 @@ retry:
|
||||
error = true;
|
||||
goto failed;
|
||||
}
|
||||
/* Delete the previously read lines. */
|
||||
while (lnum > from)
|
||||
ml_delete(lnum--, FALSE);
|
||||
file_rewind = FALSE;
|
||||
// Delete the previously read lines.
|
||||
while (lnum > from) {
|
||||
ml_delete(lnum--, false);
|
||||
}
|
||||
file_rewind = false;
|
||||
if (set_options) {
|
||||
curbuf->b_p_bomb = FALSE;
|
||||
curbuf->b_start_bomb = FALSE;
|
||||
@ -815,9 +833,9 @@ retry:
|
||||
* When retrying with another "fenc" and the first time "fileformat"
|
||||
* will be reset.
|
||||
*/
|
||||
if (keep_fileformat)
|
||||
keep_fileformat = FALSE;
|
||||
else {
|
||||
if (keep_fileformat) {
|
||||
keep_fileformat = false;
|
||||
} else {
|
||||
if (eap != NULL && eap->force_ff != 0) {
|
||||
fileformat = get_fileformat_force(curbuf, eap);
|
||||
try_unix = try_dos = try_mac = FALSE;
|
||||
@ -841,7 +859,7 @@ retry:
|
||||
/*
|
||||
* Try the next entry in 'fileencodings'.
|
||||
*/
|
||||
advance_fenc = FALSE;
|
||||
advance_fenc = false;
|
||||
|
||||
if (eap != NULL && eap->force_enc != 0) {
|
||||
/* Conversion given with "++cc=" wasn't possible, read
|
||||
@ -851,7 +869,7 @@ retry:
|
||||
if (fenc_alloced)
|
||||
xfree(fenc);
|
||||
fenc = (char_u *)"";
|
||||
fenc_alloced = FALSE;
|
||||
fenc_alloced = false;
|
||||
} else {
|
||||
if (fenc_alloced)
|
||||
xfree(fenc);
|
||||
@ -860,7 +878,7 @@ retry:
|
||||
fenc_alloced = (fenc_next != NULL);
|
||||
} else {
|
||||
fenc = (char_u *)"";
|
||||
fenc_alloced = FALSE;
|
||||
fenc_alloced = false;
|
||||
}
|
||||
}
|
||||
if (tmpname != NULL) {
|
||||
@ -926,8 +944,8 @@ retry:
|
||||
if (tmpname == NULL) {
|
||||
tmpname = readfile_charconvert(fname, fenc, &fd);
|
||||
if (tmpname == NULL) {
|
||||
/* Conversion failed. Try another one. */
|
||||
advance_fenc = TRUE;
|
||||
// Conversion failed. Try another one.
|
||||
advance_fenc = true;
|
||||
if (fd < 0) {
|
||||
/* Re-opening the original file failed! */
|
||||
EMSG(_("E202: Conversion made file unreadable!"));
|
||||
@ -945,7 +963,7 @@ retry:
|
||||
) {
|
||||
/* Conversion wanted but we can't.
|
||||
* Try the next conversion in 'fileencodings' */
|
||||
advance_fenc = TRUE;
|
||||
advance_fenc = true;
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
@ -1180,14 +1198,14 @@ retry:
|
||||
|
||||
if (fio_flags == FIO_UCSBOM) {
|
||||
if (ccname == NULL) {
|
||||
/* No BOM detected: retry with next encoding. */
|
||||
advance_fenc = TRUE;
|
||||
// No BOM detected: retry with next encoding.
|
||||
advance_fenc = true;
|
||||
} else {
|
||||
/* BOM detected: set "fenc" and jump back */
|
||||
if (fenc_alloced)
|
||||
xfree(fenc);
|
||||
fenc = ccname;
|
||||
fenc_alloced = FALSE;
|
||||
fenc_alloced = false;
|
||||
}
|
||||
/* retry reading without getting new bytes or rewinding */
|
||||
skip_read = TRUE;
|
||||
@ -1512,9 +1530,9 @@ rewind_retry:
|
||||
did_iconv = TRUE;
|
||||
else
|
||||
# endif
|
||||
/* use next item from 'fileencodings' */
|
||||
advance_fenc = TRUE;
|
||||
file_rewind = TRUE;
|
||||
// use next item from 'fileencodings'
|
||||
advance_fenc = true;
|
||||
file_rewind = true;
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
@ -1648,8 +1666,8 @@ rewind_retry:
|
||||
fileformat = EOL_UNIX;
|
||||
if (set_options)
|
||||
set_fileformat(EOL_UNIX, OPT_LOCAL);
|
||||
file_rewind = TRUE;
|
||||
keep_fileformat = TRUE;
|
||||
file_rewind = true;
|
||||
keep_fileformat = true;
|
||||
goto retry;
|
||||
}
|
||||
ff_error = EOL_DOS;
|
||||
@ -1760,8 +1778,8 @@ failed:
|
||||
if (!recoverymode) {
|
||||
/* need to delete the last line, which comes from the empty buffer */
|
||||
if (newfile && wasempty && !(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
||||
ml_delete(curbuf->b_ml.ml_line_count, FALSE);
|
||||
--linecnt;
|
||||
ml_delete(curbuf->b_ml.ml_line_count, false);
|
||||
linecnt--;
|
||||
}
|
||||
linecnt = curbuf->b_ml.ml_line_count - linecnt;
|
||||
if (filesize == 0)
|
||||
@ -4894,9 +4912,9 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
|
||||
|
||||
/* Copy the lines in "frombuf" to "tobuf". */
|
||||
curbuf = tobuf;
|
||||
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; ++lnum) {
|
||||
p = vim_strsave(ml_get_buf(frombuf, lnum, FALSE));
|
||||
if (ml_append(lnum - 1, p, 0, FALSE) == FAIL) {
|
||||
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; lnum++) {
|
||||
p = vim_strsave(ml_get_buf(frombuf, lnum, false));
|
||||
if (ml_append(lnum - 1, p, 0, false) == FAIL) {
|
||||
xfree(p);
|
||||
retval = FAIL;
|
||||
break;
|
||||
@ -4907,13 +4925,14 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
|
||||
/* Delete all the lines in "frombuf". */
|
||||
if (retval != FAIL) {
|
||||
curbuf = frombuf;
|
||||
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0; --lnum)
|
||||
if (ml_delete(lnum, FALSE) == FAIL) {
|
||||
/* Oops! We could try putting back the saved lines, but that
|
||||
* might fail again... */
|
||||
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0; lnum--) {
|
||||
if (ml_delete(lnum, false) == FAIL) {
|
||||
// Oops! We could try putting back the saved lines, but that
|
||||
// might fail again...
|
||||
retval = FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curbuf = tbuf;
|
||||
|
@ -349,7 +349,7 @@ int ml_open(buf_T *buf)
|
||||
/*
|
||||
* Allocate first data block and create an empty line 1.
|
||||
*/
|
||||
hp = ml_new_data(mfp, FALSE, 1);
|
||||
hp = ml_new_data(mfp, false, 1);
|
||||
if (hp->bh_bnum != 2) {
|
||||
IEMSG(_("E298: Didn't get block nr 2?"));
|
||||
goto error;
|
||||
@ -764,7 +764,7 @@ void ml_recover(void)
|
||||
long error;
|
||||
int cannot_open;
|
||||
linenr_T line_count;
|
||||
int has_error;
|
||||
bool has_error;
|
||||
int idx;
|
||||
int top;
|
||||
int txt_start;
|
||||
@ -984,8 +984,9 @@ void ml_recover(void)
|
||||
* Now that we are sure that the file is going to be recovered, clear the
|
||||
* contents of the current buffer.
|
||||
*/
|
||||
while (!(curbuf->b_ml.ml_flags & ML_EMPTY))
|
||||
ml_delete((linenr_T)1, FALSE);
|
||||
while (!(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
||||
ml_delete((linenr_T)1, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try reading the original file to obtain the values of 'fileformat',
|
||||
@ -1034,8 +1035,8 @@ void ml_recover(void)
|
||||
}
|
||||
++error;
|
||||
ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"),
|
||||
(colnr_T)0, TRUE);
|
||||
} else { /* there is a block */
|
||||
(colnr_T)0, true);
|
||||
} else { // there is a block
|
||||
pp = hp->bh_data;
|
||||
if (pp->pb_id == PTR_ID) { /* it is a pointer block */
|
||||
/* check line count when using pointer block first time */
|
||||
@ -1045,15 +1046,15 @@ void ml_recover(void)
|
||||
if (line_count != 0) {
|
||||
++error;
|
||||
ml_append(lnum++, (char_u *)_("???LINE COUNT WRONG"),
|
||||
(colnr_T)0, TRUE);
|
||||
(colnr_T)0, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (pp->pb_count == 0) {
|
||||
ml_append(lnum++, (char_u *)_("???EMPTY BLOCK"),
|
||||
(colnr_T)0, TRUE);
|
||||
++error;
|
||||
} else if (idx < (int)pp->pb_count) { /* go a block deeper */
|
||||
(colnr_T)0, true);
|
||||
error++;
|
||||
} else if (idx < (int)pp->pb_count) { // go a block deeper
|
||||
if (pp->pb_pointer[idx].pe_bnum < 0) {
|
||||
/*
|
||||
* Data block with negative block number.
|
||||
@ -1073,7 +1074,7 @@ void ml_recover(void)
|
||||
if (cannot_open) {
|
||||
++error;
|
||||
ml_append(lnum++, (char_u *)_("???LINES MISSING"),
|
||||
(colnr_T)0, TRUE);
|
||||
(colnr_T)0, true);
|
||||
}
|
||||
++idx; /* get same block again for next index */
|
||||
continue;
|
||||
@ -1103,23 +1104,21 @@ void ml_recover(void)
|
||||
}
|
||||
++error;
|
||||
ml_append(lnum++, (char_u *)_("???BLOCK MISSING"),
|
||||
(colnr_T)0, TRUE);
|
||||
(colnr_T)0, true);
|
||||
} else {
|
||||
/*
|
||||
* it is a data block
|
||||
* Append all the lines in this block
|
||||
*/
|
||||
has_error = FALSE;
|
||||
/*
|
||||
* check length of block
|
||||
* if wrong, use length in pointer block
|
||||
*/
|
||||
// it is a data block
|
||||
// Append all the lines in this block
|
||||
has_error = false;
|
||||
// check length of block
|
||||
// if wrong, use length in pointer block
|
||||
if (page_count * mfp->mf_page_size != dp->db_txt_end) {
|
||||
ml_append(lnum++,
|
||||
(char_u *)_("??? from here until ???END lines may be messed up"),
|
||||
(colnr_T)0, TRUE);
|
||||
++error;
|
||||
has_error = TRUE;
|
||||
ml_append(
|
||||
lnum++,
|
||||
(char_u *)_("??? from here until ???END lines"
|
||||
" may be messed up"),
|
||||
(colnr_T)0, true);
|
||||
error++;
|
||||
has_error = true;
|
||||
dp->db_txt_end = page_count * mfp->mf_page_size;
|
||||
}
|
||||
|
||||
@ -1131,12 +1130,13 @@ void ml_recover(void)
|
||||
* if wrong, use count in data block
|
||||
*/
|
||||
if (line_count != dp->db_line_count) {
|
||||
ml_append(lnum++,
|
||||
(char_u *)_(
|
||||
"??? from here until ???END lines may have been inserted/deleted"),
|
||||
(colnr_T)0, TRUE);
|
||||
++error;
|
||||
has_error = TRUE;
|
||||
ml_append(
|
||||
lnum++,
|
||||
(char_u *)_("??? from here until ???END lines"
|
||||
" may have been inserted/deleted"),
|
||||
(colnr_T)0, true);
|
||||
error++;
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
for (i = 0; i < dp->db_line_count; ++i) {
|
||||
@ -1147,11 +1147,11 @@ void ml_recover(void)
|
||||
++error;
|
||||
} else
|
||||
p = (char_u *)dp + txt_start;
|
||||
ml_append(lnum++, p, (colnr_T)0, TRUE);
|
||||
ml_append(lnum++, p, (colnr_T)0, true);
|
||||
}
|
||||
if (has_error) {
|
||||
ml_append(lnum++, (char_u *)_("???END"), (colnr_T)0, true);
|
||||
}
|
||||
if (has_error)
|
||||
ml_append(lnum++, (char_u *)_("???END"),
|
||||
(colnr_T)0, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1202,7 +1202,7 @@ void ml_recover(void)
|
||||
*/
|
||||
while (curbuf->b_ml.ml_line_count > lnum
|
||||
&& !(curbuf->b_ml.ml_flags & ML_EMPTY))
|
||||
ml_delete(curbuf->b_ml.ml_line_count, FALSE);
|
||||
ml_delete(curbuf->b_ml.ml_line_count, false);
|
||||
curbuf->b_flags |= BF_RECOVERED;
|
||||
|
||||
recoverymode = FALSE;
|
||||
@ -1814,7 +1814,7 @@ char_u *
|
||||
ml_get_buf (
|
||||
buf_T *buf,
|
||||
linenr_T lnum,
|
||||
int will_change /* line will be changed */
|
||||
bool will_change // line will be changed
|
||||
)
|
||||
{
|
||||
bhdr_T *hp;
|
||||
@ -1900,12 +1900,11 @@ int ml_line_alloced(void)
|
||||
*
|
||||
* return FAIL for failure, OK otherwise
|
||||
*/
|
||||
int
|
||||
ml_append (
|
||||
linenr_T lnum, /* append after this line (can be 0) */
|
||||
char_u *line, /* text of the new line */
|
||||
colnr_T len, /* length of new line, including NUL, or 0 */
|
||||
int newfile /* flag, see above */
|
||||
int ml_append(
|
||||
linenr_T lnum, // append after this line (can be 0)
|
||||
char_u *line, // text of the new line
|
||||
colnr_T len, // length of new line, including NUL, or 0
|
||||
bool newfile // flag, see above
|
||||
)
|
||||
{
|
||||
/* When starting up, we might still need to create the memfile */
|
||||
@ -1921,13 +1920,12 @@ ml_append (
|
||||
* Like ml_append() but for an arbitrary buffer. The buffer must already have
|
||||
* a memline.
|
||||
*/
|
||||
int
|
||||
ml_append_buf (
|
||||
int ml_append_buf(
|
||||
buf_T *buf,
|
||||
linenr_T lnum, /* append after this line (can be 0) */
|
||||
char_u *line, /* text of the new line */
|
||||
colnr_T len, /* length of new line, including NUL, or 0 */
|
||||
int newfile /* flag, see above */
|
||||
linenr_T lnum, // append after this line (can be 0)
|
||||
char_u *line, // text of the new line
|
||||
colnr_T len, // length of new line, including NUL, or 0
|
||||
bool newfile // flag, see above
|
||||
)
|
||||
{
|
||||
if (buf->b_ml.ml_mfp == NULL)
|
||||
@ -1938,14 +1936,13 @@ ml_append_buf (
|
||||
return ml_append_int(buf, lnum, line, len, newfile, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
ml_append_int (
|
||||
static int ml_append_int(
|
||||
buf_T *buf,
|
||||
linenr_T lnum, /* append after this line (can be 0) */
|
||||
char_u *line, /* text of the new line */
|
||||
colnr_T len, /* length of line, including NUL, or 0 */
|
||||
int newfile, /* flag, see above */
|
||||
int mark /* mark the new line */
|
||||
linenr_T lnum, // append after this line (can be 0)
|
||||
char_u *line, // text of the new line
|
||||
colnr_T len, // length of line, including NUL, or 0
|
||||
bool newfile, // flag, see above
|
||||
int mark // mark the new line
|
||||
)
|
||||
{
|
||||
int i;
|
||||
@ -2428,13 +2425,13 @@ int ml_replace(linenr_T lnum, char_u *line, bool copy)
|
||||
///
|
||||
/// @param message Show "--No lines in buffer--" message.
|
||||
/// @return FAIL for failure, OK otherwise
|
||||
int ml_delete(linenr_T lnum, int message)
|
||||
int ml_delete(linenr_T lnum, bool message)
|
||||
{
|
||||
ml_flush_line(curbuf);
|
||||
return ml_delete_int(curbuf, lnum, message);
|
||||
}
|
||||
|
||||
static int ml_delete_int(buf_T *buf, linenr_T lnum, int message)
|
||||
static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message)
|
||||
{
|
||||
bhdr_T *hp;
|
||||
memfile_T *mfp;
|
||||
@ -2754,17 +2751,15 @@ static void ml_flush_line(buf_T *buf)
|
||||
/* The else case is already covered by the insert and delete */
|
||||
ml_updatechunk(buf, lnum, (long)extra, ML_CHNK_UPDLINE);
|
||||
} else {
|
||||
/*
|
||||
* Cannot do it in one data block: Delete and append.
|
||||
* Append first, because ml_delete_int() cannot delete the
|
||||
* last line in a buffer, which causes trouble for a buffer
|
||||
* that has only one line.
|
||||
* Don't forget to copy the mark!
|
||||
*/
|
||||
/* How about handling errors??? */
|
||||
(void)ml_append_int(buf, lnum, new_line, new_len, FALSE,
|
||||
(dp->db_index[idx] & DB_MARKED));
|
||||
(void)ml_delete_int(buf, lnum, FALSE);
|
||||
// Cannot do it in one data block: Delete and append.
|
||||
// Append first, because ml_delete_int() cannot delete the
|
||||
// last line in a buffer, which causes trouble for a buffer
|
||||
// that has only one line.
|
||||
// Don't forget to copy the mark!
|
||||
// How about handling errors???
|
||||
(void)ml_append_int(buf, lnum, new_line, new_len, false,
|
||||
(dp->db_index[idx] & DB_MARKED));
|
||||
(void)ml_delete_int(buf, lnum, false);
|
||||
}
|
||||
}
|
||||
xfree(new_line);
|
||||
@ -2778,7 +2773,7 @@ static void ml_flush_line(buf_T *buf)
|
||||
/*
|
||||
* create a new, empty, data block
|
||||
*/
|
||||
static bhdr_T *ml_new_data(memfile_T *mfp, int negative, int page_count)
|
||||
static bhdr_T *ml_new_data(memfile_T *mfp, bool negative, int page_count)
|
||||
{
|
||||
assert(page_count >= 0);
|
||||
bhdr_T *hp = mf_new(mfp, negative, (unsigned)page_count);
|
||||
|
@ -745,9 +745,9 @@ open_line (
|
||||
if (dir == BACKWARD)
|
||||
--curwin->w_cursor.lnum;
|
||||
if (!(State & VREPLACE_FLAG) || old_cursor.lnum >= orig_line_count) {
|
||||
if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE)
|
||||
== FAIL)
|
||||
if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, false) == FAIL) {
|
||||
goto theend;
|
||||
}
|
||||
// Postpone calling changed_lines(), because it would mess up folding
|
||||
// with markers.
|
||||
// Skip mark_adjust when adding a line after the last one, there can't
|
||||
@ -1747,8 +1747,8 @@ del_lines (
|
||||
if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
|
||||
break;
|
||||
|
||||
ml_delete(first, TRUE);
|
||||
++n;
|
||||
ml_delete(first, true);
|
||||
n++;
|
||||
|
||||
/* If we delete the last line in the file, stop */
|
||||
if (first > curbuf->b_ml.ml_line_count)
|
||||
|
@ -3001,9 +3001,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||
/* add a new line */
|
||||
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
|
||||
if (ml_append(curbuf->b_ml.ml_line_count, (char_u *)"",
|
||||
(colnr_T)1, FALSE) == FAIL)
|
||||
(colnr_T)1, false) == FAIL) {
|
||||
break;
|
||||
++nr_lines;
|
||||
}
|
||||
nr_lines++;
|
||||
}
|
||||
/* get the old line and advance to the position to insert at */
|
||||
oldp = get_cursor_line_ptr();
|
||||
@ -3190,8 +3191,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||
newp = (char_u *) xmalloc((size_t)(STRLEN(ptr) + totlen + 1));
|
||||
STRCPY(newp, y_array[y_size - 1]);
|
||||
STRCAT(newp, ptr);
|
||||
/* insert second line */
|
||||
ml_append(lnum, newp, (colnr_T)0, FALSE);
|
||||
// insert second line
|
||||
ml_append(lnum, newp, (colnr_T)0, false);
|
||||
xfree(newp);
|
||||
|
||||
oldp = ml_get(lnum);
|
||||
|
@ -672,7 +672,7 @@ static int pum_set_selected(int n, int repeat)
|
||||
&& (curbuf->b_p_bh[0] == 'w')) {
|
||||
// Already a "wipeout" buffer, make it empty.
|
||||
while (!BUFEMPTY()) {
|
||||
ml_delete((linenr_T)1, FALSE);
|
||||
ml_delete((linenr_T)1, false);
|
||||
}
|
||||
} else {
|
||||
// Don't want to sync undo in the current buffer.
|
||||
@ -697,11 +697,11 @@ static int pum_set_selected(int n, int repeat)
|
||||
for (p = pum_array[pum_selected].pum_info; *p != NUL;) {
|
||||
e = vim_strchr(p, '\n');
|
||||
if (e == NULL) {
|
||||
ml_append(lnum++, p, 0, FALSE);
|
||||
ml_append(lnum++, p, 0, false);
|
||||
break;
|
||||
} else {
|
||||
*e = NUL;
|
||||
ml_append(lnum++, p, (int)(e - p + 1), FALSE);
|
||||
ml_append(lnum++, p, (int)(e - p + 1), false);
|
||||
*e = '\n';
|
||||
p = e + 1;
|
||||
}
|
||||
|
@ -7100,9 +7100,9 @@ void ex_spelldump(exarg_T *eap)
|
||||
spell_dump_compl(NULL, 0, NULL, eap->forceit ? DUMPFLAG_COUNT : 0);
|
||||
|
||||
// Delete the empty line that we started with.
|
||||
if (curbuf->b_ml.ml_line_count > 1)
|
||||
ml_delete(curbuf->b_ml.ml_line_count, FALSE);
|
||||
|
||||
if (curbuf->b_ml.ml_line_count > 1) {
|
||||
ml_delete(curbuf->b_ml.ml_line_count, false);
|
||||
}
|
||||
redraw_later(NOT_VALID);
|
||||
}
|
||||
|
||||
@ -7171,7 +7171,7 @@ spell_dump_compl (
|
||||
if (do_region && region_names != NULL) {
|
||||
if (pat == NULL) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, "/regions=%s", region_names);
|
||||
ml_append(lnum++, IObuff, (colnr_T)0, FALSE);
|
||||
ml_append(lnum++, IObuff, (colnr_T)0, false);
|
||||
}
|
||||
} else
|
||||
do_region = false;
|
||||
@ -7185,7 +7185,7 @@ spell_dump_compl (
|
||||
|
||||
if (pat == NULL) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE, "# file: %s", slang->sl_fname);
|
||||
ml_append(lnum++, IObuff, (colnr_T)0, FALSE);
|
||||
ml_append(lnum++, IObuff, (colnr_T)0, false);
|
||||
}
|
||||
|
||||
// When matching with a pattern and there are no prefixes only use
|
||||
@ -7347,14 +7347,15 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, int *dir, int d
|
||||
}
|
||||
}
|
||||
|
||||
ml_append(lnum, p, (colnr_T)0, FALSE);
|
||||
ml_append(lnum, p, (colnr_T)0, false);
|
||||
} else if (((dumpflags & DUMPFLAG_ICASE)
|
||||
? mb_strnicmp(p, pat, STRLEN(pat)) == 0
|
||||
: STRNCMP(p, pat, STRLEN(pat)) == 0)
|
||||
&& ins_compl_add_infercase(p, (int)STRLEN(p),
|
||||
p_ic, NULL, *dir, 0) == OK)
|
||||
p_ic, NULL, *dir, 0) == OK) {
|
||||
// if dir was BACKWARD then honor it just once
|
||||
*dir = FORWARD;
|
||||
}
|
||||
}
|
||||
|
||||
// For ":spelldump": Find matching prefixes for "word". Prepend each to
|
||||
|
@ -955,8 +955,9 @@ someerror:
|
||||
break;
|
||||
}
|
||||
if (ml_append_buf(slang->sl_sugbuf, (linenr_T)wordnr,
|
||||
ga.ga_data, ga.ga_len, TRUE) == FAIL)
|
||||
ga.ga_data, ga.ga_len, true) == FAIL) {
|
||||
goto someerror;
|
||||
}
|
||||
}
|
||||
ga_clear(&ga);
|
||||
|
||||
@ -4920,9 +4921,10 @@ sug_filltable (
|
||||
((char_u *)gap->ga_data)[gap->ga_len++] = NUL;
|
||||
|
||||
if (ml_append_buf(spin->si_spellbuf, (linenr_T)wordnr,
|
||||
gap->ga_data, gap->ga_len, TRUE) == FAIL)
|
||||
gap->ga_data, gap->ga_len, true) == FAIL) {
|
||||
return -1;
|
||||
++wordnr;
|
||||
}
|
||||
wordnr++;
|
||||
|
||||
// Remove extra NUL entries, we no longer need them. We don't
|
||||
// bother freeing the nodes, the won't be reused anyway.
|
||||
|
@ -51,6 +51,42 @@ func Test_swap_directory()
|
||||
call delete("Xtest.je", "rf")
|
||||
endfunc
|
||||
|
||||
func Test_swap_group()
|
||||
if !has("unix")
|
||||
return
|
||||
endif
|
||||
let groups = split(system('groups'))
|
||||
if len(groups) <= 1
|
||||
throw 'Skipped: need at least two groups, got ' . string(groups)
|
||||
endif
|
||||
|
||||
try
|
||||
call delete('Xtest')
|
||||
split Xtest
|
||||
call setline(1, 'just some text')
|
||||
wq
|
||||
if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d'
|
||||
throw 'Skipped: test file does not have the first group'
|
||||
else
|
||||
silent !chmod 640 Xtest
|
||||
call system('chgrp ' . groups[1] . ' Xtest')
|
||||
if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d'
|
||||
throw 'Skipped: cannot set second group on test file'
|
||||
else
|
||||
split Xtest
|
||||
let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g')
|
||||
call assert_match('Xtest', swapname)
|
||||
" Group of swapfile must now match original file.
|
||||
call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname))
|
||||
|
||||
bwipe!
|
||||
endif
|
||||
endif
|
||||
finally
|
||||
call delete('Xtest')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_missing_dir()
|
||||
call mkdir('Xswapdir')
|
||||
exe 'set directory=' . getcwd() . '/Xswapdir'
|
||||
|
@ -242,6 +242,7 @@ func Test_undojoin()
|
||||
endfunc
|
||||
|
||||
func Test_undo_write()
|
||||
call delete('Xtest')
|
||||
split Xtest
|
||||
call feedkeys("ione one one\<Esc>", 'xt')
|
||||
w!
|
||||
|
@ -2151,7 +2151,7 @@ static void u_undoredo(int undo, bool do_buf_event)
|
||||
int new_flags;
|
||||
fmark_T namedm[NMARKS];
|
||||
visualinfo_T visualinfo;
|
||||
int empty_buffer; /* buffer became empty */
|
||||
bool empty_buffer; // buffer became empty
|
||||
u_header_T *curhead = curbuf->b_u_curhead;
|
||||
|
||||
/* Don't want autocommands using the undo structures here, they are
|
||||
@ -2218,7 +2218,7 @@ static void u_undoredo(int undo, bool do_buf_event)
|
||||
}
|
||||
}
|
||||
|
||||
empty_buffer = FALSE;
|
||||
empty_buffer = false;
|
||||
|
||||
/* delete the lines between top and bot and save them in newarray */
|
||||
if (oldsize > 0) {
|
||||
@ -2229,9 +2229,10 @@ static void u_undoredo(int undo, bool do_buf_event)
|
||||
newarray[i] = u_save_line(lnum);
|
||||
/* remember we deleted the last line in the buffer, and a
|
||||
* dummy empty line will be inserted */
|
||||
if (curbuf->b_ml.ml_line_count == 1)
|
||||
empty_buffer = TRUE;
|
||||
ml_delete(lnum, FALSE);
|
||||
if (curbuf->b_ml.ml_line_count == 1) {
|
||||
empty_buffer = true;
|
||||
}
|
||||
ml_delete(lnum, false);
|
||||
}
|
||||
} else
|
||||
newarray = NULL;
|
||||
@ -2246,7 +2247,7 @@ static void u_undoredo(int undo, bool do_buf_event)
|
||||
if (empty_buffer && lnum == 0) {
|
||||
ml_replace((linenr_T)1, uep->ue_array[i], true);
|
||||
} else {
|
||||
ml_append(lnum, uep->ue_array[i], (colnr_T)0, FALSE);
|
||||
ml_append(lnum, uep->ue_array[i], (colnr_T)0, false);
|
||||
}
|
||||
xfree(uep->ue_array[i]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user