vim-patch:8.1.2379: using old C style comments

Problem:    Using old C style comments.
Solution:   Use // comments where appropriate.
217e1b8359
This commit is contained in:
Dundar Göc
2021-10-20 16:38:54 +02:00
parent 122c0dfb5d
commit f677ba4dab
6 changed files with 304 additions and 319 deletions

View File

@@ -1082,8 +1082,8 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
curwin->w_cursor.lnum = n; curwin->w_cursor.lnum = n;
while (line1 <= line2) { while (line1 <= line2) {
/* need to use vim_strsave() because the line will be unlocked within // need to use vim_strsave() because the line will be unlocked within
* ml_append() */ // ml_append()
p = vim_strsave(ml_get(line1)); 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); xfree(p);
@@ -1206,9 +1206,9 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
prevcmd = newcmd; prevcmd = newcmd;
if (bangredo) { // put cmd in redo buffer for ! command if (bangredo) { // put cmd in redo buffer for ! command
/* If % or # appears in the command, it must have been escaped. // If % or # appears in the command, it must have been escaped.
* Reescape them, so that redoing them does not substitute them by the // Reescape them, so that redoing them does not substitute them by the
* buffername. */ // buffername.
char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#"); char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#");
AppendToRedobuffLit(cmd, -1); AppendToRedobuffLit(cmd, -1);
@@ -1237,8 +1237,8 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
do_shell(newcmd, 0); do_shell(newcmd, 0);
} else { // :range! } else { // :range!
/* Careful: This may recursively call do_bang() again! (because of // Careful: This may recursively call do_bang() again! (because of
* autocommands) */ // autocommands)
do_filter(line1, line2, eap, newcmd, do_in, do_out); do_filter(line1, line2, eap, newcmd, do_in, do_out);
apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, false, curbuf); apply_autocmds(EVENT_SHELLFILTERPOST, NULL, NULL, false, curbuf);
} }
@@ -1368,9 +1368,9 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
did_check_timestamps = FALSE; did_check_timestamps = FALSE;
need_check_timestamps = TRUE; need_check_timestamps = TRUE;
/* When interrupting the shell command, it may still have produced some // When interrupting the shell command, it may still have produced some
* useful output. Reset got_int here, so that readfile() won't cancel // useful output. Reset got_int here, so that readfile() won't cancel
* reading. */ // reading.
os_breakcheck(); os_breakcheck();
got_int = FALSE; got_int = FALSE;
@@ -1837,8 +1837,8 @@ int do_write(exarg_T *eap)
alt_buf = buflist_findname(ffname); alt_buf = buflist_findname(ffname);
} }
if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) { if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) {
/* Overwriting a file that is loaded in another buffer is not a // Overwriting a file that is loaded in another buffer is not a
* good idea. */ // good idea.
EMSG(_(e_bufloaded)); EMSG(_(e_bufloaded));
goto theend; goto theend;
} }
@@ -2143,8 +2143,8 @@ int not_writing(void)
*/ */
static int check_readonly(int *forceit, buf_T *buf) static int check_readonly(int *forceit, buf_T *buf)
{ {
/* Handle a file being readonly when the 'readonly' option is set or when // Handle a file being readonly when the 'readonly' option is set or when
* the file exists and permissions are read-only. */ // the file exists and permissions are read-only.
if (!*forceit && (buf->b_p_ro if (!*forceit && (buf->b_p_ro
|| (os_path_exists(buf->b_ffname) || (os_path_exists(buf->b_ffname)
&& !os_file_is_writable((char *)buf->b_ffname)))) { && !os_file_is_writable((char *)buf->b_ffname)))) {
@@ -2612,8 +2612,8 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
set_buflisted(TRUE); set_buflisted(TRUE);
} }
/* If autocommands change buffers under our fingers, forget about // If autocommands change buffers under our fingers, forget about
* editing the file. */ // editing the file.
if (buf != curbuf) { if (buf != curbuf) {
goto theend; goto theend;
} }
@@ -2677,9 +2677,9 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
} }
xfree(new_name); xfree(new_name);
/* If autocommands change buffers under our fingers, forget about // If autocommands change buffers under our fingers, forget about
* re-editing the file. Should do the buf_clear_file(), but perhaps // re-editing the file. Should do the buf_clear_file(), but perhaps
* the autocommands changed the buffer... */ // the autocommands changed the buffer...
if (buf != curbuf) { if (buf != curbuf) {
goto theend; goto theend;
} }
@@ -2711,8 +2711,8 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
*/ */
curwin_init(); curwin_init();
/* It's possible that all lines in the buffer changed. Need to update // It's possible that all lines in the buffer changed. Need to update
* automatic folding for all windows where it's used. */ // automatic folding for all windows where it's used.
FOR_ALL_TAB_WINDOWS(tp, win) { FOR_ALL_TAB_WINDOWS(tp, win) {
if (win->w_buffer == curbuf) { if (win->w_buffer == curbuf) {
foldUpdateAll(win); foldUpdateAll(win);
@@ -2744,9 +2744,9 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
} }
handle_swap_exists(&old_curbuf); handle_swap_exists(&old_curbuf);
} else { } else {
/* Read the modelines, but only to set window-local options. Any // Read the modelines, but only to set window-local options. Any
* buffer-local options have already been set and may have been // buffer-local options have already been set and may have been
* changed by the user. */ // changed by the user.
do_modelines(OPT_WINONLY); do_modelines(OPT_WINONLY);
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf, apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf,
@@ -2778,16 +2778,16 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
maketitle(); maketitle();
} }
/* Tell the diff stuff that this buffer is new and/or needs updating. // Tell the diff stuff that this buffer is new and/or needs updating.
* Also needed when re-editing the same buffer, because unloading will // Also needed when re-editing the same buffer, because unloading will
* have removed it as a diff buffer. */ // have removed it as a diff buffer.
if (curwin->w_p_diff) { if (curwin->w_p_diff) {
diff_buf_add(curbuf); diff_buf_add(curbuf);
diff_invalidate(curbuf); diff_invalidate(curbuf);
} }
/* If the window options were changed may need to set the spell language. // If the window options were changed may need to set the spell language.
* Can only do this after the buffer has been properly setup. */ // Can only do this after the buffer has been properly setup.
if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) { if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) {
(void)did_set_spelllang(curwin); (void)did_set_spelllang(curwin);
} }
@@ -3022,10 +3022,10 @@ void ex_append(exarg_T *eap)
curbuf->b_p_ai = !curbuf->b_p_ai; curbuf->b_p_ai = !curbuf->b_p_ai;
} }
/* "start" is set to eap->line2+1 unless that position is invalid (when // "start" is set to eap->line2+1 unless that position is invalid (when
* eap->line2 pointed to the end of the buffer and nothing was appended) // eap->line2 pointed to the end of the buffer and nothing was appended)
* "end" is set to lnum when something has been appended, otherwise // "end" is set to lnum when something has been appended, otherwise
* it is the same than "start" -- Acevedo */ // it is the same than "start" -- Acevedo
curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ? curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ?
eap->line2 + 1 : curbuf->b_ml.ml_line_count; eap->line2 + 1 : curbuf->b_ml.ml_line_count;
if (eap->cmdidx != CMD_append) { if (eap->cmdidx != CMD_append) {
@@ -3555,8 +3555,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
pat = NULL; // search_regcomp() will use previous pattern pat = NULL; // search_regcomp() will use previous pattern
sub = (char_u *)old_sub.sub; sub = (char_u *)old_sub.sub;
/* Vi compatibility quirk: repeating with ":s" keeps the cursor in the // Vi compatibility quirk: repeating with ":s" keeps the cursor in the
* last column after using "$". */ // last column after using "$".
endcolumn = (curwin->w_curswant == MAXCOL); endcolumn = (curwin->w_curswant == MAXCOL);
} }
@@ -3807,8 +3807,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
if (subflags.do_ask && !preview) { if (subflags.do_ask && !preview) {
int typed = 0; int typed = 0;
/* change State to CONFIRM, so that the mouse works // change State to CONFIRM, so that the mouse works
* properly */ // properly
int save_State = State; int save_State = State;
State = CONFIRM; State = CONFIRM;
setmouse(); // disable mouse in xterm setmouse(); // disable mouse in xterm
@@ -3864,9 +3864,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
const bool save_p_lz = p_lz; const bool save_p_lz = p_lz;
int save_p_fen = curwin->w_p_fen; int save_p_fen = curwin->w_p_fen;
curwin->w_p_fen = FALSE; curwin->w_p_fen = false;
/* Invert the matched string. // Invert the matched string.
* Remove the inversion afterwards. */ // Remove the inversion afterwards.
int temp = RedrawingDisabled; int temp = RedrawingDisabled;
RedrawingDisabled = 0; RedrawingDisabled = 0;
@@ -3874,11 +3874,11 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
p_lz = false; p_lz = false;
if (new_start != NULL) { if (new_start != NULL) {
/* There already was a substitution, we would // There already was a substitution, we would
* like to show this to the user. We cannot // like to show this to the user. We cannot
* really update the line, it would change // really update the line, it would change
* what matches. Temporarily replace the line // what matches. Temporarily replace the line
* and change it back afterwards. */ // and change it back afterwards.
orig_line = vim_strsave(ml_get(lnum)); orig_line = vim_strsave(ml_get(lnum));
char_u *new_line = concat_str(new_start, sub_firstline + copycol); char_u *new_line = concat_str(new_start, sub_firstline + copycol);
@@ -3908,8 +3908,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle
} }
msg_starthere(); msg_starthere();
i = msg_scroll; i = msg_scroll;
msg_scroll = 0; /* truncate msg when msg_scroll = 0; // truncate msg when
needed */ // needed
msg_no_more = true; msg_no_more = true;
msg_ext_set_kind("confirm_sub"); msg_ext_set_kind("confirm_sub");
smsg_attr(HL_ATTR(HLF_R), // Same highlight as wait_return(). smsg_attr(HL_ATTR(HLF_R), // Same highlight as wait_return().
@@ -4878,8 +4878,8 @@ void ex_help(exarg_T *eap)
if (!p_im) { if (!p_im) {
restart_edit = 0; // don't want insert mode in help file restart_edit = 0; // don't want insert mode in help file
} }
/* Restore KeyTyped, setting 'filetype=help' may reset it. // Restore KeyTyped, setting 'filetype=help' may reset it.
* It is needed for do_tag top open folds under the cursor. */ // It is needed for do_tag top open folds under the cursor.
KeyTyped = old_KeyTyped; KeyTyped = old_KeyTyped;
do_tag(tag, DT_HELP, 1, FALSE, TRUE); do_tag(tag, DT_HELP, 1, FALSE, TRUE);
@@ -5073,11 +5073,10 @@ int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches, bool
STRCPY(d + 4, "\\$"); STRCPY(d + 4, "\\$");
} }
} else { } else {
/* Replace: // Replace:
* "[:...:]" with "\[:...:]" // "[:...:]" with "\[:...:]"
* "[++...]" with "\[++...]" // "[++...]" with "\[++...]"
* "\{" with "\\{" -- matching "} \}" // "\{" with "\\{" -- matching "} \}"
*/
if ((arg[0] == '[' && (arg[1] == ':' if ((arg[0] == '[' && (arg[1] == ':'
|| (arg[1] == '+' && arg[2] == '+'))) || (arg[1] == '+' && arg[2] == '+')))
|| (arg[0] == '\\' && arg[1] == '{')) { || (arg[0] == '\\' && arg[1] == '{')) {
@@ -5327,8 +5326,8 @@ void fix_help_buffer(void)
continue; continue;
} }
/* Go through all directories in 'runtimepath', skipping // Go through all directories in 'runtimepath', skipping
* $VIMRUNTIME. */ // $VIMRUNTIME.
char_u *p = p_rtp; char_u *p = p_rtp;
while (*p != NUL) { while (*p != NUL) {
copy_option_part(&p, NameBuff, MAXPATHL, ","); copy_option_part(&p, NameBuff, MAXPATHL, ",");
@@ -5413,10 +5412,9 @@ void fix_help_buffer(void)
if (*s == '\r' || *s == '\n') { if (*s == '\r' || *s == '\n') {
*s = NUL; *s = NUL;
} }
/* The text is utf-8 when a byte // The text is utf-8 when a byte
* above 127 is found and no // above 127 is found and no
* illegal byte sequence is found. // illegal byte sequence is found.
*/
if (*s >= 0x80 && this_utf != kFalse) { if (*s >= 0x80 && this_utf != kFalse) {
this_utf = kTrue; this_utf = kTrue;
const int l = utf_ptr2len(s); const int l = utf_ptr2len(s);
@@ -5427,9 +5425,9 @@ void fix_help_buffer(void)
} }
++s; ++s;
} }
/* The help file is latin1 or utf-8; // The help file is latin1 or utf-8;
* conversion to the current // conversion to the current
* 'encoding' may be required. */ // 'encoding' may be required.
vc.vc_type = CONV_NONE; vc.vc_type = CONV_NONE;
convert_setup(&vc, convert_setup(&vc,
(char_u *)(this_utf == kTrue ? "utf-8" : "latin1"), (char_u *)(this_utf == kTrue ? "utf-8" : "latin1"),
@@ -5716,8 +5714,8 @@ static void do_helptags(char_u *dirname, bool add_help_tags, bool ignore_writeer
return; return;
} }
/* Go over all files in the directory to find out what languages are // Go over all files in the directory to find out what languages are
* present. */ // present.
int j; int j;
ga_init(&ga, 1, 10); ga_init(&ga, 1, 10);
for (int i = 0; i < filecount; i++) { for (int i = 0; i < filecount; i++) {

View File

@@ -340,12 +340,12 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
int getline_is_func; int getline_is_func;
static int call_depth = 0; // recursiveness static int call_depth = 0; // recursiveness
/* For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory // For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
* location for storing error messages to be converted to an exception. // location for storing error messages to be converted to an exception.
* This ensures that the do_errthrow() call in do_one_cmd() does not // This ensures that the do_errthrow() call in do_one_cmd() does not
* combine the messages stored by an earlier invocation of do_one_cmd() // combine the messages stored by an earlier invocation of do_one_cmd()
* with the command name of the later one. This would happen when // with the command name of the later one. This would happen when
* BufWritePost autocommands are executed after a write error. */ // BufWritePost autocommands are executed after a write error.
saved_msg_list = msg_list; saved_msg_list = msg_list;
msg_list = &private_msg_list; msg_list = &private_msg_list;
private_msg_list = NULL; private_msg_list = NULL;
@@ -445,12 +445,12 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// 1. If repeating, get a previous line from lines_ga. // 1. If repeating, get a previous line from lines_ga.
if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) { if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) {
/* Each '|' separated command is stored separately in lines_ga, to // Each '|' separated command is stored separately in lines_ga, to
* be able to jump to it. Don't use next_cmdline now. */ // be able to jump to it. Don't use next_cmdline now.
XFREE_CLEAR(cmdline_copy); XFREE_CLEAR(cmdline_copy);
/* Check if a function has returned or, unless it has an unclosed // Check if a function has returned or, unless it has an unclosed
* try conditional, aborted. */ // try conditional, aborted.
if (getline_is_func) { if (getline_is_func) {
if (do_profiling == PROF_YES) { if (do_profiling == PROF_YES) {
func_line_end(real_cookie); func_line_end(real_cookie);
@@ -630,8 +630,8 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
new_last_cmdline = NULL; new_last_cmdline = NULL;
} }
} else { } else {
/* need to copy the command after the '|' to cmdline_copy, for the // need to copy the command after the '|' to cmdline_copy, for the
* next do_one_cmd() */ // next do_one_cmd()
STRMOVE(cmdline_copy, next_cmdline); STRMOVE(cmdline_copy, next_cmdline);
next_cmdline = cmdline_copy; next_cmdline = cmdline_copy;
} }
@@ -656,10 +656,10 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) { if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) {
cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP);
/* Jump back to the matching ":while" or ":for". Be careful // Jump back to the matching ":while" or ":for". Be careful
* not to use a cs_line[] from an entry that isn't a ":while" // not to use a cs_line[] from an entry that isn't a ":while"
* or ":for": It would make "current_line" invalid and can // or ":for": It would make "current_line" invalid and can
* cause a crash. */ // cause a crash.
if (!did_emsg && !got_int && !current_exception if (!did_emsg && !got_int && !current_exception
&& cstack.cs_idx >= 0 && cstack.cs_idx >= 0
&& (cstack.cs_flags[cstack.cs_idx] && (cstack.cs_flags[cstack.cs_idx]
@@ -752,9 +752,9 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
while (!((got_int || (did_emsg && force_abort) || current_exception) while (!((got_int || (did_emsg && force_abort) || current_exception)
&& cstack.cs_trylevel == 0) && cstack.cs_trylevel == 0)
&& !(did_emsg && !(did_emsg
/* Keep going when inside try/catch, so that the error can be // Keep going when inside try/catch, so that the error can be
* deal with, except when it is a syntax error, it may cause // deal with, except when it is a syntax error, it may cause
* the :endtry to be missed. */ // the :endtry to be missed.
&& (cstack.cs_trylevel == 0 || did_emsg_syntax) && (cstack.cs_trylevel == 0 || did_emsg_syntax)
&& used_getline && used_getline
&& getline_equal(fgetline, cookie, getexline)) && getline_equal(fgetline, cookie, getexline))
@@ -2880,8 +2880,8 @@ int cmd_exists(const char *const name)
} }
} }
/* Check built-in commands and user defined commands. // Check built-in commands and user defined commands.
* For ":2match" and ":3match" we need to skip the number. */ // For ":2match" and ":3match" we need to skip the number.
ea.cmd = (char_u *)((*name == '2' || *name == '3') ? name + 1 : name); ea.cmd = (char_u *)((*name == '2' || *name == '3') ? name + 1 : name);
ea.cmdidx = (cmdidx_T)0; ea.cmdidx = (cmdidx_T)0;
int full = false; int full = false;
@@ -3963,8 +3963,8 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
if (skip) { if (skip) {
++cmd; ++cmd;
} else { } else {
/* Only accept a mark in another file when it is // Only accept a mark in another file when it is
* used by itself: ":'M". */ // used by itself: ":'M".
fp = getmark(*cmd, to_other_file && cmd[1] == NUL); fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
++cmd; ++cmd;
if (fp == (pos_T *)-1) { if (fp == (pos_T *)-1) {
@@ -4444,11 +4444,10 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
xfree(l); xfree(l);
} }
/* Need to escape white space et al. with a backslash. // Need to escape white space et al. with a backslash.
* Don't do this for: // Don't do this for:
* - replacement that already has been escaped: "##" // - replacement that already has been escaped: "##"
* - shell commands (may have to use quotes instead). // - shell commands (may have to use quotes instead).
*/
if (!eap->usefilter if (!eap->usefilter
&& !escaped && !escaped
&& eap->cmdidx != CMD_bang && eap->cmdidx != CMD_bang
@@ -4794,8 +4793,8 @@ static int getargopt(exarg_T *eap)
*p = TOLOWER_ASC(*p); *p = TOLOWER_ASC(*p);
} }
} else { } else {
/* Check ++bad= argument. Must be a single-byte character, "keep" or // Check ++bad= argument. Must be a single-byte character, "keep" or
* "drop". */ // "drop".
if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) { if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) {
return FAIL; return FAIL;
} }
@@ -6772,15 +6771,15 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
int h = tabline_height(); int h = tabline_height();
char_u prev_idx[NUMBUFLEN]; char_u prev_idx[NUMBUFLEN];
/* Limit to 1000 windows, autocommands may add a window while we close // Limit to 1000 windows, autocommands may add a window while we close
* one. OK, so I'm paranoid... */ // one. OK, so I'm paranoid...
while (++done < 1000) { while (++done < 1000) {
snprintf((char *)prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp)); snprintf((char *)prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp));
wp = tp->tp_lastwin; wp = tp->tp_lastwin;
ex_win_close(forceit, wp, tp); ex_win_close(forceit, wp, tp);
/* Autocommands may delete the tab page under our fingers and we may // Autocommands may delete the tab page under our fingers and we may
* fail to close a window with a modified buffer. */ // fail to close a window with a modified buffer.
if (!valid_tabpage(tp) || tp->tp_firstwin == wp) { if (!valid_tabpage(tp) || tp->tp_firstwin == wp) {
break; break;
} }
@@ -7166,8 +7165,8 @@ void ex_splitview(exarg_T *eap)
|| eap->cmdidx == CMD_tabfind || eap->cmdidx == CMD_tabfind
|| eap->cmdidx == CMD_tabnew; || eap->cmdidx == CMD_tabnew;
/* A ":split" in the quickfix window works like ":new". Don't want two // A ":split" in the quickfix window works like ":new". Don't want two
* quickfix windows. But it's OK when doing ":tab split". */ // quickfix windows. But it's OK when doing ":tab split".
if (bt_quickfix(curbuf) && cmdmod.tab == 0) { if (bt_quickfix(curbuf) && cmdmod.tab == 0) {
if (eap->cmdidx == CMD_split) { if (eap->cmdidx == CMD_split) {
eap->cmdidx = CMD_new; eap->cmdidx = CMD_new;
@@ -7514,18 +7513,18 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
enter_cleanup(&cs); enter_cleanup(&cs);
win_close(curwin, !need_hide && !buf_hide(curbuf)); win_close(curwin, !need_hide && !buf_hide(curbuf));
/* Restore the error/interrupt/exception state if not // Restore the error/interrupt/exception state if not
* discarded by a new aborting error, interrupt, or // discarded by a new aborting error, interrupt, or
* uncaught exception. */ // uncaught exception.
leave_cleanup(&cs); leave_cleanup(&cs);
} }
} }
} else if (readonlymode && curbuf->b_nwindows == 1) { } else if (readonlymode && curbuf->b_nwindows == 1) {
/* When editing an already visited buffer, 'readonly' won't be set // When editing an already visited buffer, 'readonly' won't be set
* but the previous value is kept. With ":view" and ":sview" we // but the previous value is kept. With ":view" and ":sview" we
* want the file to be readonly, except when another window is // want the file to be readonly, except when another window is
* editing the same buffer. */ // editing the same buffer.
curbuf->b_p_ro = TRUE; curbuf->b_p_ro = true;
} }
readonlymode = n; readonlymode = n;
} else { } else {

View File

@@ -406,9 +406,9 @@ char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname, i
val = ret + 4; val = ret + 4;
} }
/* msg_add_fname may have been used to prefix the message with a file // msg_add_fname may have been used to prefix the message with a file
* name in quotes. In the exception value, put the file name in // name in quotes. In the exception value, put the file name in
* parentheses and move it to the end. */ // parentheses and move it to the end.
for (p = mesg;; p++) { for (p = mesg;; p++) {
if (*p == NUL if (*p == NUL
|| (*p == 'E' || (*p == 'E'
@@ -922,16 +922,14 @@ void ex_else(exarg_T *eap)
cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE; cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE;
} }
/* // When debugging or a breakpoint was encountered, display the debug prompt
* When debugging or a breakpoint was encountered, display the debug prompt // (if not already done). This shows the user that an ":else" or ":elseif"
* (if not already done). This shows the user that an ":else" or ":elseif" // is executed when the ":if" or previous ":elseif" was not TRUE. Handle
* is executed when the ":if" or previous ":elseif" was not TRUE. Handle // a ">quit" debug command as if an interrupt had occurred before the
* a ">quit" debug command as if an interrupt had occurred before the // ":else" or ":elseif". That is, set "skip" and throw an interrupt
* ":else" or ":elseif". That is, set "skip" and throw an interrupt // exception if appropriate. Doing this here prevents that an exception
* exception if appropriate. Doing this here prevents that an exception // for a parsing errors is discarded when throwing the interrupt exception
* for a parsing errors is discarded when throwing the interrupt exception // later on.
* later on.
*/
if (!skip && dbg_check_skipped(eap) && got_int) { if (!skip && dbg_check_skipped(eap) && got_int) {
(void)do_intthrow(cstack); (void)do_intthrow(cstack);
skip = TRUE; skip = TRUE;
@@ -1055,11 +1053,11 @@ void ex_continue(exarg_T *eap)
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = (char_u *)N_("E586: :continue without :while or :for"); eap->errmsg = (char_u *)N_("E586: :continue without :while or :for");
} else { } else {
/* Try to find the matching ":while". This might stop at a try // Try to find the matching ":while". This might stop at a try
* conditional not in its finally clause (which is then to be executed // conditional not in its finally clause (which is then to be executed
* next). Therefore, deactivate all conditionals except the ":while" // next). Therefore, deactivate all conditionals except the ":while"
* itself (if reached). */ // itself (if reached).
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE); idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, false);
assert(idx >= 0); assert(idx >= 0);
if (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)) { if (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)) {
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel); rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
@@ -1070,8 +1068,8 @@ void ex_continue(exarg_T *eap)
*/ */
cstack->cs_lflags |= CSL_HAD_CONT; // let do_cmdline() handle it cstack->cs_lflags |= CSL_HAD_CONT; // let do_cmdline() handle it
} else { } else {
/* If a try conditional not in its finally clause is reached first, // If a try conditional not in its finally clause is reached first,
* make the ":continue" pending for execution at the ":endtry". */ // make the ":continue" pending for execution at the ":endtry".
cstack->cs_pending[idx] = CSTP_CONTINUE; cstack->cs_pending[idx] = CSTP_CONTINUE;
report_make_pending(CSTP_CONTINUE, NULL); report_make_pending(CSTP_CONTINUE, NULL);
} }
@@ -1092,7 +1090,7 @@ void ex_break(exarg_T *eap)
// Deactivate conditionals until the matching ":while" or a try // Deactivate conditionals until the matching ":while" or a try
// conditional not in its finally clause (which is then to be // conditional not in its finally clause (which is then to be
// executed next) is found. In the latter case, make the ":break" // executed next) is found. In the latter case, make the ":break"
// pending for execution at the ":endtry". */ // pending for execution at the ":endtry".
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, true); idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, true);
if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR))) { if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR))) {
cstack->cs_pending[idx] = CSTP_BREAK; cstack->cs_pending[idx] = CSTP_BREAK;
@@ -1155,20 +1153,17 @@ void ex_endwhile(exarg_T *eap)
// Cleanup and rewind all contained (and unclosed) conditionals. // Cleanup and rewind all contained (and unclosed) conditionals.
(void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE); (void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel); rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
} } else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE
/* && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)
* When debugging or a breakpoint was encountered, display the debug && dbg_check_skipped(eap)) {
* prompt (if not already done). This shows the user that an // When debugging or a breakpoint was encountered, display the debug
* ":endwhile"/":endfor" is executed when the ":while" was not TRUE or // prompt (if not already done). This shows the user that an
* after a ":break". Handle a ">quit" debug command as if an // ":endwhile"/":endfor" is executed when the ":while" was not TRUE or
* interrupt had occurred before the ":endwhile"/":endfor". That is, // after a ":break". Handle a ">quit" debug command as if an
* throw an interrupt exception if appropriate. Doing this here // interrupt had occurred before the ":endwhile"/":endfor". That is,
* prevents that an exception for a parsing error is discarded when // throw an interrupt exception if appropriate. Doing this here
* throwing the interrupt exception later on. // prevents that an exception for a parsing error is discarded when
*/ // throwing the interrupt exception later on.
else if (cstack->cs_flags[cstack->cs_idx] & CSF_TRUE
&& !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)
&& dbg_check_skipped(eap)) {
(void)do_intthrow(cstack); (void)do_intthrow(cstack);
} }
@@ -1354,8 +1349,8 @@ void ex_catch(exarg_T *eap)
} }
} }
if (cstack->cs_flags[idx] & CSF_FINALLY) { if (cstack->cs_flags[idx] & CSF_FINALLY) {
/* Give up for a ":catch" after ":finally" and ignore it. // Give up for a ":catch" after ":finally" and ignore it.
* Just parse. */ // Just parse.
eap->errmsg = (char_u *)N_("E604: :catch after :finally"); eap->errmsg = (char_u *)N_("E604: :catch after :finally");
give_up = TRUE; give_up = TRUE;
} else { } else {
@@ -1395,16 +1390,16 @@ void ex_catch(exarg_T *eap)
return; return;
} }
/* When debugging or a breakpoint was encountered, display the // When debugging or a breakpoint was encountered, display the
* debug prompt (if not already done) before checking for a match. // debug prompt (if not already done) before checking for a match.
* This is a helpful hint for the user when the regular expression // This is a helpful hint for the user when the regular expression
* matching fails. Handle a ">quit" debug command as if an // matching fails. Handle a ">quit" debug command as if an
* interrupt had occurred before the ":catch". That is, discard // interrupt had occurred before the ":catch". That is, discard
* the original exception, replace it by an interrupt exception, // the original exception, replace it by an interrupt exception,
* and don't catch it in this try block. */ // and don't catch it in this try block.
if (!dbg_check_skipped(eap) || !do_intthrow(cstack)) { if (!dbg_check_skipped(eap) || !do_intthrow(cstack)) {
/* Terminate the pattern and avoid the 'l' flag in 'cpoptions' // Terminate the pattern and avoid the 'l' flag in 'cpoptions'
* while compiling it. */ // while compiling it.
if (end != NULL) { if (end != NULL) {
save_char = *end; save_char = *end;
*end = NUL; *end = NUL;
@@ -1440,16 +1435,16 @@ void ex_catch(exarg_T *eap)
} }
if (caught) { if (caught) {
/* Make this ":catch" clause active and reset did_emsg and got_int. // Make this ":catch" clause active and reset did_emsg and got_int.
* Put the exception on the caught stack. */ // Put the exception on the caught stack.
cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT; cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT;
did_emsg = got_int = false; did_emsg = got_int = false;
catch_exception((except_T *)cstack->cs_exception[idx]); catch_exception((except_T *)cstack->cs_exception[idx]);
/* It's mandatory that the current exception is stored in the cstack // It's mandatory that the current exception is stored in the cstack
* so that it can be discarded at the next ":catch", ":finally", or // so that it can be discarded at the next ":catch", ":finally", or
* ":endtry" or when the catch clause is left by a ":continue", // ":endtry" or when the catch clause is left by a ":continue",
* ":break", ":return", ":finish", error, interrupt, or another // ":break", ":return", ":finish", error, interrupt, or another
* exception. */ // exception.
if (cstack->cs_exception[cstack->cs_idx] != current_exception) { if (cstack->cs_exception[cstack->cs_idx] != current_exception) {
internal_error("ex_catch()"); internal_error("ex_catch()");
} }
@@ -1576,13 +1571,13 @@ void ex_finally(exarg_T *eap)
assert(pending >= CHAR_MIN && pending <= CHAR_MAX); assert(pending >= CHAR_MIN && pending <= CHAR_MAX);
cstack->cs_pending[cstack->cs_idx] = (char)pending; cstack->cs_pending[cstack->cs_idx] = (char)pending;
/* It's mandatory that the current exception is stored in the // It's mandatory that the current exception is stored in the
* cstack so that it can be rethrown at the ":endtry" or be // cstack so that it can be rethrown at the ":endtry" or be
* discarded if the finally clause is left by a ":continue", // discarded if the finally clause is left by a ":continue",
* ":break", ":return", ":finish", error, interrupt, or another // ":break", ":return", ":finish", error, interrupt, or another
* exception. When emsg() is called for a missing ":endif" or // exception. When emsg() is called for a missing ":endif" or
* a missing ":endwhile"/":endfor" detected here, the // a missing ":endwhile"/":endfor" detected here, the
* exception will be discarded. */ // exception will be discarded.
if (current_exception if (current_exception
&& cstack->cs_exception[cstack->cs_idx] != current_exception) { && cstack->cs_exception[cstack->cs_idx] != current_exception) {
internal_error("ex_finally()"); internal_error("ex_finally()");
@@ -1666,21 +1661,20 @@ void ex_endtry(exarg_T *eap)
} }
} }
/* If there was no finally clause, show the user when debugging or // If there was no finally clause, show the user when debugging or
* a breakpoint was encountered that the end of the try conditional has // a breakpoint was encountered that the end of the try conditional has
* been reached: display the debug prompt (if not already done). Do // been reached: display the debug prompt (if not already done). Do
* this on normal control flow or when an exception was thrown, but not // this on normal control flow or when an exception was thrown, but not
* on an interrupt or error not converted to an exception or when // on an interrupt or error not converted to an exception or when
* a ":break", ":continue", ":return", or ":finish" is pending. These // a ":break", ":continue", ":return", or ":finish" is pending. These
* actions are carried out immediately. // actions are carried out immediately.
*/
if ((rethrow || (!skip if ((rethrow || (!skip
&& !(cstack->cs_flags[idx] & CSF_FINALLY) && !(cstack->cs_flags[idx] & CSF_FINALLY)
&& !cstack->cs_pending[idx])) && !cstack->cs_pending[idx]))
&& dbg_check_skipped(eap)) { && dbg_check_skipped(eap)) {
/* Handle a ">quit" debug command as if an interrupt had occurred // Handle a ">quit" debug command as if an interrupt had occurred
* before the ":endtry". That is, throw an interrupt exception and // before the ":endtry". That is, throw an interrupt exception and
* set "skip" and "rethrow". */ // set "skip" and "rethrow".
if (got_int) { if (got_int) {
skip = TRUE; skip = TRUE;
(void)do_intthrow(cstack); (void)do_intthrow(cstack);
@@ -1815,13 +1809,12 @@ void enter_cleanup(cleanup_T *csp)
| (current_exception ? CSTP_THROW : 0) | (current_exception ? CSTP_THROW : 0)
| (need_rethrow ? CSTP_THROW : 0); | (need_rethrow ? CSTP_THROW : 0);
/* If we are currently throwing an exception, save it as well. On an error // If we are currently throwing an exception, save it as well. On an error
* not yet converted to an exception, update "force_abort" and reset // not yet converted to an exception, update "force_abort" and reset
* "cause_abort" (as do_errthrow() would do). This is needed for the // "cause_abort" (as do_errthrow() would do). This is needed for the
* do_cmdline() call that is going to be made for autocommand execution. We // do_cmdline() call that is going to be made for autocommand execution. We
* need not save *msg_list because there is an extra instance for every call // need not save *msg_list because there is an extra instance for every call
* of do_cmdline(), anyway. // of do_cmdline(), anyway.
*/
if (current_exception || need_rethrow) { if (current_exception || need_rethrow) {
csp->exception = current_exception; csp->exception = current_exception;
current_exception = NULL; current_exception = NULL;
@@ -1897,13 +1890,10 @@ void leave_cleanup(cleanup_T *csp)
*/ */
if (pending & CSTP_THROW) { if (pending & CSTP_THROW) {
current_exception = csp->exception; current_exception = csp->exception;
} } else if (pending & CSTP_ERROR) {
/* // If an error was about to be converted to an exception when
* If an error was about to be converted to an exception when // enter_cleanup() was called, let "cause_abort" take the part of
* enter_cleanup() was called, let "cause_abort" take the part of // "force_abort" (as done by cause_errthrow()).
* "force_abort" (as done by cause_errthrow()).
*/
else if (pending & CSTP_ERROR) {
cause_abort = force_abort; cause_abort = force_abort;
force_abort = FALSE; force_abort = FALSE;
} }

View File

@@ -2625,8 +2625,8 @@ static void realloc_cmdbuff(int len)
char_u *p = ccline.cmdbuff; char_u *p = ccline.cmdbuff;
alloc_cmdbuff(len); // will get some more alloc_cmdbuff(len); // will get some more
/* There isn't always a NUL after the command, but it may need to be // There isn't always a NUL after the command, but it may need to be
* there, thus copy up to the NUL and add a NUL. */ // there, thus copy up to the NUL and add a NUL.
memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen); memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen);
ccline.cmdbuff[ccline.cmdlen] = NUL; ccline.cmdbuff[ccline.cmdlen] = NUL;
xfree(p); xfree(p);
@@ -3427,24 +3427,24 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
bool allocated; bool allocated;
struct cmdline_info save_ccline; struct cmdline_info save_ccline;
/* check for valid regname; also accept special characters for CTRL-R in // check for valid regname; also accept special characters for CTRL-R in
* the command line */ // the command line
if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W
&& regname != Ctrl_A && regname != Ctrl_L && regname != Ctrl_A && regname != Ctrl_L
&& !valid_yank_reg(regname, false)) { && !valid_yank_reg(regname, false)) {
return FAIL; return FAIL;
} }
/* A register containing CTRL-R can cause an endless loop. Allow using // A register containing CTRL-R can cause an endless loop. Allow using
* CTRL-C to break the loop. */ // CTRL-C to break the loop.
line_breakcheck(); line_breakcheck();
if (got_int) { if (got_int) {
return FAIL; return FAIL;
} }
/* Need to save and restore ccline. And set "textlock" to avoid nasty // Need to save and restore ccline. And set "textlock" to avoid nasty
* things like going to another buffer when evaluating an expression. */ // things like going to another buffer when evaluating an expression.
save_cmdline(&save_ccline); save_cmdline(&save_ccline);
textlock++; textlock++;
const bool i = get_spec_reg(regname, &arg, &allocated, true); const bool i = get_spec_reg(regname, &arg, &allocated, true);
@@ -6411,8 +6411,8 @@ static int open_cmdwin(void)
} }
} }
/* Replace the empty last line with the current command-line and put the // Replace the empty last line with the current command-line and put the
* cursor there. */ // cursor there.
ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, true); ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, true);
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
curwin->w_cursor.col = ccline.cmdpos; curwin->w_cursor.col = ccline.cmdpos;

View File

@@ -224,8 +224,8 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
bool keep_dest_enc = false; // don't retry when char doesn't fit bool keep_dest_enc = false; // don't retry when char doesn't fit
// in destination encoding // in destination encoding
int bad_char_behavior = BAD_REPLACE; int bad_char_behavior = BAD_REPLACE;
/* BAD_KEEP, BAD_DROP or character to // BAD_KEEP, BAD_DROP or character to
* replace with */ // replace with
char_u *tmpname = NULL; // name of 'charconvert' output file char_u *tmpname = NULL; // name of 'charconvert' output file
int fio_flags = 0; int fio_flags = 0;
char_u *fenc; // fileencoding to use char_u *fenc; // fileencoding to use
@@ -280,8 +280,8 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
|| (sfname == curbuf->b_ffname); || (sfname == curbuf->b_ffname);
using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname); using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname);
/* After reading a file the cursor line changes but we don't want to // After reading a file the cursor line changes but we don't want to
* display the line. */ // display the line.
ex_no_reprint = true; ex_no_reprint = true;
// don't display the file info for another buffer now // don't display the file info for another buffer now
@@ -454,9 +454,9 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
// been created by someone else, a ":w" will complain. // been created by someone else, a ":w" will complain.
curbuf->b_flags |= BF_NEW; curbuf->b_flags |= BF_NEW;
/* Create a swap file now, so that other Vims are warned // Create a swap file now, so that other Vims are warned
* that we are editing this file. Don't do this for a // that we are editing this file. Don't do this for a
* "nofile" or "nowrite" buffer type. */ // "nofile" or "nowrite" buffer type.
if (!bt_dontwrite(curbuf)) { if (!bt_dontwrite(curbuf)) {
check_need_swap(newfile); check_need_swap(newfile);
// SwapExists autocommand may mess things up // SwapExists autocommand may mess things up
@@ -524,9 +524,9 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
curbuf->b_start_bomb = FALSE; curbuf->b_start_bomb = FALSE;
} }
/* Create a swap file now, so that other Vims are warned that we are // Create a swap file now, so that other Vims are warned that we are
* editing this file. // editing this file.
* Don't do this for a "nofile" or "nowrite" buffer type. */ // Don't do this for a "nofile" or "nowrite" buffer type.
if (!bt_dontwrite(curbuf)) { if (!bt_dontwrite(curbuf)) {
check_need_swap(newfile); check_need_swap(newfile);
if (!read_stdin if (!read_stdin
@@ -854,8 +854,8 @@ retry:
#ifdef HAVE_ICONV #ifdef HAVE_ICONV
did_iconv = false; did_iconv = false;
#endif #endif
/* Skip conversion when it's already done (retry for wrong // Skip conversion when it's already done (retry for wrong
* "fileformat"). */ // "fileformat").
if (tmpname == NULL) { if (tmpname == NULL) {
tmpname = readfile_charconvert(fname, fenc, &fd); tmpname = readfile_charconvert(fname, fenc, &fd);
if (tmpname == NULL) { if (tmpname == NULL) {
@@ -876,17 +876,17 @@ retry:
&& iconv_fd == (iconv_t)-1 && iconv_fd == (iconv_t)-1
#endif #endif
) { ) {
/* Conversion wanted but we can't. // Conversion wanted but we can't.
* Try the next conversion in 'fileencodings' */ // Try the next conversion in 'fileencodings'
advance_fenc = true; advance_fenc = true;
goto retry; goto retry;
} }
} }
} }
/* Set "can_retry" when it's possible to rewind the file and try with // Set "can_retry" when it's possible to rewind the file and try with
* another "fenc" value. It's FALSE when no other "fenc" to try, reading // another "fenc" value. It's FALSE when no other "fenc" to try, reading
* stdin or fixed at a specific encoding. */ // stdin or fixed at a specific encoding.
can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo); can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo);
if (!skip_read) { if (!skip_read) {
@@ -1014,9 +1014,9 @@ retry:
read_buf_col += n; read_buf_col += n;
break; break;
} else { } else {
/* Append whole line and new-line. Change NL // Append whole line and new-line. Change NL
* to NUL to reverse the effect done below. */ // to NUL to reverse the effect done below.
for (ni = 0; ni < n; ++ni) { for (ni = 0; ni < n; ni++) {
if (p[ni] == NL) { if (p[ni] == NL) {
ptr[tlen++] = NUL; ptr[tlen++] = NUL;
} else { } else {
@@ -1076,10 +1076,10 @@ retry:
*(ptr - conv_restlen) = NUL; *(ptr - conv_restlen) = NUL;
conv_restlen = 0; conv_restlen = 0;
} else { } else {
/* Replace the trailing bytes with the replacement // Replace the trailing bytes with the replacement
* character if we were converting; if we weren't, // character if we were converting; if we weren't,
* leave the UTF8 checking code to do it, as it // leave the UTF8 checking code to do it, as it
* works slightly differently. */ // works slightly differently.
if (bad_char_behavior != BAD_KEEP && (fio_flags != 0 if (bad_char_behavior != BAD_KEEP && (fio_flags != 0
#ifdef HAVE_ICONV #ifdef HAVE_ICONV
|| iconv_fd != (iconv_t)-1 || iconv_fd != (iconv_t)-1
@@ -1212,8 +1212,8 @@ retry:
} }
if (from_size > 0) { if (from_size > 0) {
/* Some remaining characters, keep them for the next // Some remaining characters, keep them for the next
* round. */ // round.
memmove(conv_rest, (char_u *)fromp, from_size); memmove(conv_rest, (char_u *)fromp, from_size);
conv_restlen = (int)from_size; conv_restlen = (int)from_size;
} }
@@ -1752,11 +1752,11 @@ failed:
} }
if (newfile || read_buffer) { if (newfile || read_buffer) {
redraw_curbuf_later(NOT_VALID); redraw_curbuf_later(NOT_VALID);
/* After reading the text into the buffer the diff info needs to // After reading the text into the buffer the diff info needs to
* be updated. */ // be updated.
diff_invalidate(curbuf); diff_invalidate(curbuf);
/* All folds in the window are invalid now. Mark them for update // All folds in the window are invalid now. Mark them for update
* before triggering autocommands. */ // before triggering autocommands.
foldUpdateAll(curwin); foldUpdateAll(curwin);
} else if (linecnt) { // appended at least one line } else if (linecnt) { // appended at least one line
appended_lines_mark(from, linecnt); appended_lines_mark(from, linecnt);
@@ -2129,8 +2129,8 @@ static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp)
} }
if (errmsg != NULL) { if (errmsg != NULL) {
/* Don't use emsg(), it breaks mappings, the retry with // Don't use emsg(), it breaks mappings, the retry with
* another type of conversion might still work. */ // another type of conversion might still work.
MSG(errmsg); MSG(errmsg);
if (tmpname != NULL) { if (tmpname != NULL) {
os_remove((char *)tmpname); // delete converted file os_remove((char *)tmpname); // delete converted file
@@ -3908,9 +3908,9 @@ static int check_mtime(buf_T *buf, FileInfo *file_info)
static bool time_differs(long t1, long t2) FUNC_ATTR_CONST static bool time_differs(long t1, long t2) FUNC_ATTR_CONST
{ {
#if defined(__linux__) || defined(MSWIN) #if defined(__linux__) || defined(MSWIN)
/* On a FAT filesystem, esp. under Linux, there are only 5 bits to store // On a FAT filesystem, esp. under Linux, there are only 5 bits to store
* the seconds. Since the roundoff is done when flushing the inode, the // the seconds. Since the roundoff is done when flushing the inode, the
* time may change unexpectedly by one second!!! */ // time may change unexpectedly by one second!!!
return t1 - t2 > 1 || t2 - t1 > 1; return t1 - t2 > 1 || t2 - t1 > 1;
#else #else
return t1 != t2; return t1 != t2;
@@ -4192,8 +4192,8 @@ static bool need_conversion(const char_u *fenc)
same_encoding = TRUE; same_encoding = TRUE;
fenc_flags = 0; fenc_flags = 0;
} else { } else {
/* Ignore difference between "ansi" and "latin1", "ucs-4" and // Ignore difference between "ansi" and "latin1", "ucs-4" and
* "ucs-4be", etc. */ // "ucs-4be", etc.
enc_flags = get_fio_flags(p_enc); enc_flags = get_fio_flags(p_enc);
fenc_flags = get_fio_flags(fenc); fenc_flags = get_fio_flags(fenc);
same_encoding = (enc_flags != 0 && fenc_flags == enc_flags); same_encoding = (enc_flags != 0 && fenc_flags == enc_flags);
@@ -4203,8 +4203,8 @@ static bool need_conversion(const char_u *fenc)
return false; return false;
} }
/* Encodings differ. However, conversion is not needed when 'enc' is any // Encodings differ. However, conversion is not needed when 'enc' is any
* Unicode encoding and the file is UTF-8. */ // Unicode encoding and the file is UTF-8.
return !(fenc_flags == FIO_UTF8); return !(fenc_flags == FIO_UTF8);
} }
@@ -4697,8 +4697,8 @@ int vim_rename(const char_u *from, const char_u *to)
(void)os_rename(tempname, from); (void)os_rename(tempname, from);
return -1; return -1;
} }
/* If it fails for one temp name it will most likely fail // If it fails for one temp name it will most likely fail
* for any temp name, give up. */ // for any temp name, give up.
return -1; return -1;
} }
} }
@@ -4954,8 +4954,8 @@ int buf_check_timestamp(buf_T *buf)
buf_store_file_info(buf, &file_info); buf_store_file_info(buf, &file_info);
} }
/* Don't do anything for a directory. Might contain the file // Don't do anything for a directory. Might contain the file
* explorer. */ // explorer.
if (os_isdir(buf->b_fname)) { if (os_isdir(buf->b_fname)) {
} else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar) } else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
&& !bufIsChanged(buf) && file_info_ok) { && !bufIsChanged(buf) && file_info_ok) {
@@ -5217,8 +5217,8 @@ void buf_reload(buf_T *buf, int orig_mode)
// Invalidate diff info if necessary. // Invalidate diff info if necessary.
diff_invalidate(curbuf); diff_invalidate(curbuf);
/* Restore the topline and cursor position and check it (lines may // Restore the topline and cursor position and check it (lines may
* have been removed). */ // have been removed).
if (old_topline > curbuf->b_ml.ml_line_count) { if (old_topline > curbuf->b_ml.ml_line_count) {
curwin->w_topline = curbuf->b_ml.ml_line_count; curwin->w_topline = curbuf->b_ml.ml_line_count;
} else { } else {
@@ -5237,9 +5237,9 @@ void buf_reload(buf_T *buf, int orig_mode)
} }
} }
/* If the mode didn't change and 'readonly' was set, keep the old // If the mode didn't change and 'readonly' was set, keep the old
* value; the user probably used the ":view" command. But don't // value; the user probably used the ":view" command. But don't
* reset it, might have had a read error. */ // reset it, might have had a read error.
if (orig_mode == curbuf->b_orig_mode) { if (orig_mode == curbuf->b_orig_mode) {
curbuf->b_p_ro |= old_ro; curbuf->b_p_ro |= old_ro;
} }
@@ -5754,8 +5754,8 @@ long write_eintr(int fd, void *buf, size_t bufsize)
long ret = 0; long ret = 0;
long wlen; long wlen;
/* Repeat the write() so long it didn't fail, other than being interrupted // Repeat the write() so long it didn't fail, other than being interrupted
* by a signal. */ // by a signal.
while (ret < (long)bufsize) { while (ret < (long)bufsize) {
wlen = write(fd, (char *)buf + ret, bufsize - ret); wlen = write(fd, (char *)buf + ret, bufsize - ret);
if (wlen < 0) { if (wlen < 0) {

View File

@@ -72,12 +72,12 @@ typedef struct {
linenr_T lnum_save; // line nr used by foldUpdateIEMSRecurse() linenr_T lnum_save; // line nr used by foldUpdateIEMSRecurse()
int lvl; // current level (-1 for undefined) int lvl; // current level (-1 for undefined)
int lvl_next; // level used for next line int lvl_next; // level used for next line
int start; /* number of folds that are forced to start at int start; // number of folds that are forced to start at
this line. */ // this line.
int end; /* level of fold that is forced to end below int end; // level of fold that is forced to end below
this line */ // this line
int had_end; /* level of fold that is forced to end above int had_end; // level of fold that is forced to end above
this line (copy of "end" of prev. line) */ // this line (copy of "end" of prev. line)
} fline_T; } fline_T;
// Flag is set when redrawing is needed. // Flag is set when redrawing is needed.
@@ -405,8 +405,8 @@ void opFoldRange(pos_T firstpos, pos_T lastpos, int opening, int recurse, int ha
for (lnum = first; lnum <= last; lnum = lnum_next + 1) { for (lnum = first; lnum <= last; lnum = lnum_next + 1) {
pos_T temp = { lnum, 0, 0 }; pos_T temp = { lnum, 0, 0 };
lnum_next = lnum; lnum_next = lnum;
/* Opening one level only: next fold to open is after the one going to // Opening one level only: next fold to open is after the one going to
* be opened. */ // be opened.
if (opening && !recurse) { if (opening && !recurse) {
(void)hasFolding(lnum, NULL, &lnum_next); (void)hasFolding(lnum, NULL, &lnum_next);
} }
@@ -639,8 +639,8 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
} }
if (cont > 0) { if (cont > 0) {
ga_grow(&fold_ga, cont); ga_grow(&fold_ga, cont);
/* If the first fold starts before the new fold, let the new fold // If the first fold starts before the new fold, let the new fold
* start there. Otherwise the existing fold would change. */ // start there. Otherwise the existing fold would change.
if (start_rel.lnum > fp->fd_top) { if (start_rel.lnum > fp->fd_top) {
start_rel.lnum = fp->fd_top; start_rel.lnum = fp->fd_top;
} }
@@ -655,8 +655,8 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
fold_ga.ga_len += cont; fold_ga.ga_len += cont;
i += cont; i += cont;
/* Adjust line numbers in contained folds to be relative to the // Adjust line numbers in contained folds to be relative to the
* new fold. */ // new fold.
for (int j = 0; j < cont; j++) { for (int j = 0; j < cont; j++) {
((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel.lnum; ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel.lnum;
} }
@@ -673,9 +673,8 @@ void foldCreate(win_T *wp, pos_T start, pos_T end)
fp->fd_top = start_rel.lnum; fp->fd_top = start_rel.lnum;
fp->fd_len = end_rel.lnum - start_rel.lnum + 1; fp->fd_len = end_rel.lnum - start_rel.lnum + 1;
/* We want the new fold to be closed. If it would remain open because // We want the new fold to be closed. If it would remain open because
* of using 'foldlevel', need to adjust fd_flags of containing folds. // of using 'foldlevel', need to adjust fd_flags of containing folds.
*/
if (use_level && !closed && level < wp->w_p_fdl) { if (use_level && !closed && level < wp->w_p_fdl) {
closeFold(start, 1L); closeFold(start, 1L);
} }
@@ -916,8 +915,8 @@ int foldMoveTo(const bool updown, const int dir, const long count)
break; break;
} }
} }
/* don't look for contained folds, they will always move // don't look for contained folds, they will always move
* the cursor too far. */ // the cursor too far.
last = true; last = true;
} }
@@ -953,8 +952,8 @@ int foldMoveTo(const bool updown, const int dir, const long count)
} }
} }
} else { } else {
/* Open fold found, set cursor to its start/end and then check // Open fold found, set cursor to its start/end and then check
* nested folds. */ // nested folds.
if (dir == FORWARD) { if (dir == FORWARD) {
lnum = fp->fd_top + lnum_off + fp->fd_len - 1; lnum = fp->fd_top + lnum_off + fp->fd_len - 1;
if (lnum > curwin->w_cursor.lnum) { if (lnum > curwin->w_cursor.lnum) {
@@ -1375,8 +1374,8 @@ static void deleteFoldEntry(win_T *const wp, garray_T *const gap, const int idx,
memmove(fp, fp + 1, sizeof(*fp) * (size_t)(gap->ga_len - idx)); memmove(fp, fp + 1, sizeof(*fp) * (size_t)(gap->ga_len - idx));
} }
} else { } else {
/* Move nested folds one level up, to overwrite the fold that is // Move nested folds one level up, to overwrite the fold that is
* deleted. */ // deleted.
int moved = fp->fd_nested.ga_len; int moved = fp->fd_nested.ga_len;
ga_grow(gap, moved - 1); ga_grow(gap, moved - 1);
{ {
@@ -1517,8 +1516,8 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line
fp->fd_len += amount_after; fp->fd_len += amount_after;
} }
} else { } else {
/* 5. fold is below line1 and contains line2; need to // 5. fold is below line1 and contains line2; need to
* correct nested folds too */ // correct nested folds too
if (amount == MAXLNUM) { if (amount == MAXLNUM) {
foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top, foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top,
line2 - fp->fd_top, amount, line2 - fp->fd_top, amount,
@@ -1660,8 +1659,8 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
foldAddMarker(buf, start, wp->w_p_fmr, foldstartmarkerlen); foldAddMarker(buf, start, wp->w_p_fmr, foldstartmarkerlen);
foldAddMarker(buf, end, foldendmarker, foldendmarkerlen); foldAddMarker(buf, end, foldendmarker, foldendmarkerlen);
/* Update both changes here, to avoid all folds after the start are // Update both changes here, to avoid all folds after the start are
* changed when the start marker is inserted and the end isn't. */ // changed when the start marker is inserted and the end isn't.
// TODO(teto): pass the buffer // TODO(teto): pass the buffer
changed_lines(start.lnum, (colnr_T)0, end.lnum, 0L, false); changed_lines(start.lnum, (colnr_T)0, end.lnum, 0L, false);
@@ -1857,8 +1856,8 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
} }
if (text != NULL) { if (text != NULL) {
/* Replace unprintable characters, if there are any. But // Replace unprintable characters, if there are any. But
* replace a TAB with a space. */ // replace a TAB with a space.
for (p = text; *p != NUL; p++) { for (p = text; *p != NUL; p++) {
int len = utfc_ptr2len(p); int len = utfc_ptr2len(p);
@@ -1941,10 +1940,9 @@ void foldtext_cleanup(char_u *str)
++len; ++len;
} }
/* May remove 'commentstring' start. Useful when it's a double // May remove 'commentstring' start. Useful when it's a double
* quote and we already removed a double quote. */ // quote and we already removed a double quote.
for (p = s; p > str && ascii_iswhite(p[-1]); --p) { for (p = s; p > str && ascii_iswhite(p[-1]); p--) {
;
} }
if (p >= str + cms_slen if (p >= str + cms_slen
&& STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) { && STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) {
@@ -2074,12 +2072,12 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
getlevel = foldlevelIndent; getlevel = foldlevelIndent;
} }
/* Backup to a line for which the fold level is defined. Since it's // Backup to a line for which the fold level is defined. Since it's
* always defined for line one, we will stop there. */ // always defined for line one, we will stop there.
fline.lvl = -1; fline.lvl = -1;
for (; !got_int; --fline.lnum) { for (; !got_int; fline.lnum--) {
/* Reset lvl_next each time, because it will be set to a value for // Reset lvl_next each time, because it will be set to a value for
* the next line, but we search backwards here. */ // the next line, but we search backwards here.
fline.lvl_next = -1; fline.lvl_next = -1;
getlevel(&fline); getlevel(&fline);
if (fline.lvl >= 0) { if (fline.lvl >= 0) {
@@ -2128,15 +2126,15 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
end = start; end = start;
} }
while (!got_int) { while (!got_int) {
/* Always stop at the end of the file ("end" can be past the end of // Always stop at the end of the file ("end" can be past the end of
* the file). */ // the file).
if (fline.lnum > wp->w_buffer->b_ml.ml_line_count) { if (fline.lnum > wp->w_buffer->b_ml.ml_line_count) {
break; break;
} }
if (fline.lnum > end) { if (fline.lnum > end) {
/* For "marker", "expr" and "syntax" methods: If a change caused // For "marker", "expr" and "syntax" methods: If a change caused
* a fold to be removed, we need to continue at least until where // a fold to be removed, we need to continue at least until where
* it ended. */ // it ended.
if (getlevel != foldlevelMarker if (getlevel != foldlevelMarker
&& getlevel != foldlevelSyntax && getlevel != foldlevelSyntax
&& getlevel != foldlevelExpr) { && getlevel != foldlevelExpr) {
@@ -2334,17 +2332,17 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
* firstlnum. * firstlnum.
*/ */
while (!got_int) { while (!got_int) {
/* set concat to 1 if it's allowed to concatenated this fold // set concat to 1 if it's allowed to concatenated this fold
* with a previous one that touches it. */ // with a previous one that touches it.
if (flp->start != 0 || flp->had_end <= MAX_LEVEL) { if (flp->start != 0 || flp->had_end <= MAX_LEVEL) {
concat = 0; concat = 0;
} else { } else {
concat = 1; concat = 1;
} }
/* Find an existing fold to re-use. Preferably one that // Find an existing fold to re-use. Preferably one that
* includes startlnum, otherwise one that ends just before // includes startlnum, otherwise one that ends just before
* startlnum or starts after it. */ // startlnum or starts after it.
if (gap->ga_len > 0 if (gap->ga_len > 0
&& (foldFind(gap, startlnum, &fp) && (foldFind(gap, startlnum, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len || (fp < ((fold_T *)gap->ga_data) + gap->ga_len
@@ -2405,9 +2403,9 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
i = (int)(fp - (fold_T *)gap->ga_data); i = (int)(fp - (fold_T *)gap->ga_data);
foldSplit(flp->wp->w_buffer, gap, i, breakstart, breakend - 1); foldSplit(flp->wp->w_buffer, gap, i, breakstart, breakend - 1);
fp = (fold_T *)gap->ga_data + i + 1; fp = (fold_T *)gap->ga_data + i + 1;
/* If using the "marker" or "syntax" method, we // If using the "marker" or "syntax" method, we
* need to continue until the end of the fold is // need to continue until the end of the fold is
* found. */ // found.
if (getlevel == foldlevelMarker if (getlevel == foldlevelMarker
|| getlevel == foldlevelExpr || getlevel == foldlevelExpr
|| getlevel == foldlevelSyntax) { || getlevel == foldlevelSyntax) {
@@ -2433,8 +2431,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
deleteFoldEntry(flp->wp, gap, deleteFoldEntry(flp->wp, gap,
(int)(fp - (fold_T *)gap->ga_data), true); (int)(fp - (fold_T *)gap->ga_data), true);
} else { } else {
/* A fold has some lines above startlnum, truncate it // A fold has some lines above startlnum, truncate it
* to stop just above startlnum. */ // to stop just above startlnum.
fp->fd_len = startlnum - fp->fd_top; fp->fd_len = startlnum - fp->fd_top;
foldMarkAdjustRecurse(flp->wp, &fp->fd_nested, foldMarkAdjustRecurse(flp->wp, &fp->fd_nested,
fp->fd_len, (linenr_T)MAXLNUM, fp->fd_len, (linenr_T)MAXLNUM,
@@ -2442,8 +2440,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
fold_changed = true; fold_changed = true;
} }
} else { } else {
/* Insert new fold. Careful: ga_data may be NULL and it // Insert new fold. Careful: ga_data may be NULL and it
* may change! */ // may change!
if (gap->ga_len == 0) { if (gap->ga_len == 0) {
i = 0; i = 0;
} else { } else {
@@ -2451,13 +2449,13 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *const gap, const int level,
} }
foldInsert(gap, i); foldInsert(gap, i);
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
/* The new fold continues until bot, unless we find the // The new fold continues until bot, unless we find the
* end earlier. */ // end earlier.
fp->fd_top = firstlnum; fp->fd_top = firstlnum;
fp->fd_len = bot - firstlnum + 1; fp->fd_len = bot - firstlnum + 1;
/* When the containing fold is open, the new fold is open. // When the containing fold is open, the new fold is open.
* The new fold is closed if the fold above it is closed. // The new fold is closed if the fold above it is closed.
* The first fold depends on the containing fold. */ // The first fold depends on the containing fold.
if (topflags == FD_OPEN) { if (topflags == FD_OPEN) {
flp->wp->w_fold_manual = true; flp->wp->w_fold_manual = true;
fp->fd_flags = FD_OPEN; fp->fd_flags = FD_OPEN;
@@ -2684,8 +2682,8 @@ static void foldSplit(buf_T *buf, garray_T *const gap, const int i, const linenr
fp[1].fd_small = kNone; fp[1].fd_small = kNone;
fp->fd_small = kNone; fp->fd_small = kNone;
/* Move nested folds below bot to new fold. There can't be // Move nested folds below bot to new fold. There can't be
* any between top and bot, they have been removed by the caller. */ // any between top and bot, they have been removed by the caller.
garray_T *const gap1 = &fp->fd_nested; garray_T *const gap1 = &fp->fd_nested;
garray_T *const gap2 = &fp[1].fd_nested; garray_T *const gap2 = &fp[1].fd_nested;
if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) { if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) {
@@ -3039,8 +3037,8 @@ static void foldlevelExpr(fline_T *flp)
flp->lvl = 0; flp->lvl = 0;
} }
/* KeyTyped may be reset to 0 when calling a function which invokes // KeyTyped may be reset to 0 when calling a function which invokes
* do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. */ // do_cmdline(). To make 'foldopen' work correctly restore KeyTyped.
const bool save_keytyped = KeyTyped; const bool save_keytyped = KeyTyped;
const int n = eval_foldexpr(flp->wp->w_p_fde, &c); const int n = eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped; KeyTyped = save_keytyped;
@@ -3308,9 +3306,9 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
} }
} }
} else { } else {
/* Open or close the leaf according to the window foldlevel. // Open or close the leaf according to the window foldlevel.
* Do not close a leaf that is already closed, as it will close // Do not close a leaf that is already closed, as it will close
* the parent. */ // the parent.
level = foldLevelWin(wp, off + fp->fd_top); level = foldLevelWin(wp, off + fp->fd_top);
if ((fp->fd_flags == FD_CLOSED && wp->w_p_fdl >= level) if ((fp->fd_flags == FD_CLOSED && wp->w_p_fdl >= level)
|| (fp->fd_flags != FD_CLOSED && wp->w_p_fdl < level)) { || (fp->fd_flags != FD_CLOSED && wp->w_p_fdl < level)) {