summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/autocmd.c17
-rw-r--r--src/beval.c17
-rw-r--r--src/blob.c2
-rw-r--r--src/blowfish.c46
-rw-r--r--src/buffer.c915
-rw-r--r--src/change.c12
-rw-r--r--src/channel.c545
-rw-r--r--src/charset.c277
-rw-r--r--src/cindent.c6
-rw-r--r--src/crypt.c73
-rw-r--r--src/crypt_zip.c8
-rw-r--r--src/version.c2
12 files changed, 959 insertions, 961 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index 7e8a6925f..de24dd219 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -232,14 +232,14 @@ typedef struct AutoPatCmd
struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
} AutoPatCmd;
-static AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */
+static AutoPatCmd *active_apc_list = NULL; // stack of active autocommands
/*
* augroups stores a list of autocmd group names.
*/
static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
#define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
-/* use get_deleted_augroup() to get this */
+// use get_deleted_augroup() to get this
static char_u *deleted_augroup = NULL;
/*
@@ -247,7 +247,7 @@ static char_u *deleted_augroup = NULL;
*/
static int current_augroup = AUGROUP_DEFAULT;
-static int au_need_clean = FALSE; /* need to delete marked patterns */
+static int au_need_clean = FALSE; // need to delete marked patterns
static char_u *event_nr2name(event_T event);
static int au_get_grouparg(char_u **argp);
@@ -258,7 +258,7 @@ static int au_find_group(char_u *name);
static event_T last_event;
static int last_group;
-static int autocmd_blocked = 0; /* block all autocmds */
+static int autocmd_blocked = 0; // block all autocmds
static char_u *
get_deleted_augroup(void)
@@ -783,7 +783,7 @@ au_event_restore(char_u *old_ei)
vim_free(old_ei);
}
}
-# endif /* FEAT_SYN_HL */
+# endif // FEAT_SYN_HL
/*
* do_autocmd() -- implements the :autocmd command. Can be used in the
@@ -1027,7 +1027,7 @@ do_autocmd_event(
int patlen;
int is_buflocal;
int buflocal_nr;
- char_u buflocal_pat[25]; /* for "<buffer=X>" */
+ char_u buflocal_pat[25]; // for "<buffer=X>"
if (group == AUGROUP_ALL)
findgroup = current_augroup;
@@ -1120,7 +1120,8 @@ do_autocmd_event(
{
if (ap->pat != NULL)
{
- /* Accept a pattern when:
+ /*
+ * Accept a pattern when:
* - a group was specified and it's that group, or a group was
* not specified and it's the current group, or a group was
* not specified and we are listing
@@ -1177,7 +1178,7 @@ do_autocmd_event(
*/
if (ap == NULL)
{
- /* refuse to add buffer-local ap if buffer number is invalid */
+ // refuse to add buffer-local ap if buffer number is invalid
if (is_buflocal && (buflocal_nr == 0
|| buflist_findnr(buflocal_nr) == NULL))
{
diff --git a/src/beval.c b/src/beval.c
index 8ef8e8e1d..1bc31a17a 100644
--- a/src/beval.c
+++ b/src/beval.c
@@ -239,13 +239,13 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
#endif
static int recursive = FALSE;
- /* Don't do anything when 'ballooneval' is off, messages scrolled the
- * windows up or we have no beval area. */
+ // Don't do anything when 'ballooneval' is off, messages scrolled the
+ // windows up or we have no beval area.
if (!can_use_beval() || beval == NULL)
return;
- /* Don't do this recursively. Happens when the expression evaluation
- * takes a long time and invokes something that checks for CTRL-C typed. */
+ // Don't do this recursively. Happens when the expression evaluation
+ // takes a long time and invokes something that checks for CTRL-C typed.
if (recursive)
return;
recursive = TRUE;
@@ -257,7 +257,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
: wp->w_buffer->b_p_bexpr;
if (*bexpr != NUL)
{
- /* Convert window pointer to number. */
+ // Convert window pointer to number.
for (cw = firstwin; cw != wp; cw = cw->w_next)
++winnr;
@@ -285,9 +285,9 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
vim_free(result);
result = eval_to_string(bexpr, NULL, TRUE);
- /* Remove one trailing newline, it is added when the result was a
- * list and it's hardly ever useful. If the user really wants a
- * trailing newline he can add two and one remains. */
+ // Remove one trailing newline, it is added when the result was a
+ // list and it's hardly ever useful. If the user really wants a
+ // trailing newline he can add two and one remains.
if (result != NULL)
{
len = STRLEN(result);
@@ -322,4 +322,3 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
}
#endif
-
diff --git a/src/blob.c b/src/blob.c
index 278ced62c..2a7ec3a73 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -328,4 +328,4 @@ blob_remove(typval_T *argvars, typval_T *rettv)
}
}
-#endif /* defined(FEAT_EVAL) */
+#endif // defined(FEAT_EVAL)
diff --git a/src/blowfish.c b/src/blowfish.c
index 65f89327e..a73b3b6c5 100644
--- a/src/blowfish.c
+++ b/src/blowfish.c
@@ -35,28 +35,28 @@ typedef union {
} block8;
#if defined(MSWIN)
- /* MS-Windows is always little endian */
+ // MS-Windows is always little endian
#else
# ifdef HAVE_CONFIG_H
- /* in configure.ac AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed */
+ // in configure.ac AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed
# else
error!
Please change this code to define WORDS_BIGENDIAN for big-endian machines.
# endif
#endif
-/* The state of encryption, referenced by cryptstate_T. */
+// The state of encryption, referenced by cryptstate_T.
typedef struct {
- UINT32_T pax[18]; /* P-array */
- UINT32_T sbx[4][256]; /* S-boxes */
+ UINT32_T pax[18]; // P-array
+ UINT32_T sbx[4][256]; // S-boxes
int randbyte_offset;
int update_offset;
- char_u cfb_buffer[BF_MAX_CFB_LEN]; /* up to 64 bytes used */
- int cfb_len; /* size of cfb_buffer actually used */
+ char_u cfb_buffer[BF_MAX_CFB_LEN]; // up to 64 bytes used
+ int cfb_len; // size of cfb_buffer actually used
} bf_state_T;
-/* Blowfish code */
+// Blowfish code
static UINT32_T pax_init[18] = {
0x243f6a88u, 0x85a308d3u, 0x13198a2eu,
0x03707344u, 0xa4093822u, 0x299f31d0u,
@@ -409,13 +409,13 @@ bf_key_init(
char_u *key;
int keylen;
- /* Process the key 1001 times.
- * See http://en.wikipedia.org/wiki/Key_strengthening. */
+ // Process the key 1001 times.
+ // See http://en.wikipedia.org/wiki/Key_strengthening.
key = sha256_key(password, salt, salt_len);
for (i = 0; i < 1000; i++)
key = sha256_key(key, salt, salt_len);
- /* Convert the key from 64 hex chars to 32 binary chars. */
+ // Convert the key from 64 hex chars to 32 binary chars.
keylen = (int)STRLEN(key) / 2;
if (keylen == 0)
{
@@ -428,8 +428,8 @@ bf_key_init(
key[i] = u;
}
- /* Use "key" to initialize the P-array ("pax") and S-boxes ("sbx") of
- * Blowfish. */
+ // Use "key" to initialize the P-array ("pax") and S-boxes ("sbx") of
+ // Blowfish.
mch_memmove(bfs->sbx, sbx_init, 4 * 4 * 256);
for (i = 0; i < 18; ++i)
@@ -484,7 +484,7 @@ typedef struct {
char_u salt[9];
char_u plaintxt[9];
char_u cryptxt[9];
- char_u badcryptxt[9]; /* cryptxt when big/little endian is wrong */
+ char_u badcryptxt[9]; // cryptxt when big/little endian is wrong
UINT32_T keysum;
} struct_bf_test_data;
@@ -497,9 +497,9 @@ static struct_bf_test_data bf_test_data[] = {
"password",
"salt",
"plaintxt",
- "\xad\x3d\xfa\x7f\xe8\xea\x40\xf6", /* cryptxt */
- "\x72\x50\x3b\x38\x10\x60\x22\xa7", /* badcryptxt */
- 0x56701b5du /* keysum */
+ "\xad\x3d\xfa\x7f\xe8\xea\x40\xf6", // cryptxt
+ "\x72\x50\x3b\x38\x10\x60\x22\xa7", // badcryptxt
+ 0x56701b5du // keysum
},
};
@@ -518,8 +518,8 @@ bf_self_test(void)
vim_memset(&state, 0, sizeof(bf_state_T));
state.cfb_len = BF_MAX_CFB_LEN;
- /* We can't simply use sizeof(UINT32_T), it would generate a compiler
- * warning. */
+ // We can't simply use sizeof(UINT32_T), it would generate a compiler
+ // warning.
if (ui != 0xffffffffUL || ui + 1 != 0) {
err++;
emsg(_("E820: sizeof(uint32_t) != 4"));
@@ -537,7 +537,7 @@ bf_self_test(void)
if (!bf_check_tables(state.pax, state.sbx, bf_test_data[i].keysum))
err++;
- /* Don't modify bf_test_data[i].plaintxt, self test is idempotent. */
+ // Don't modify bf_test_data[i].plaintxt, self test is idempotent.
memcpy(bk.uc, bf_test_data[i].plaintxt, 8);
bf_e_cblock(&state, bk.uc);
if (memcmp(bk.uc, bf_test_data[i].cryptxt, 8) != 0)
@@ -651,8 +651,8 @@ crypt_blowfish_init(
return FAIL;
state->method_state = bfs;
- /* "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8
- * times. "blowfish2" uses a 8 byte buffer to avoid repeating. */
+ // "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8
+ // times. "blowfish2" uses a 8 byte buffer to avoid repeating.
bfs->cfb_len = state->method_nr == CRYPT_M_BF ? BF_MAX_CFB_LEN : BF_BLOCK;
if (blowfish_self_test() == FAIL)
@@ -684,4 +684,4 @@ blowfish_self_test(void)
return OK;
}
-#endif /* FEAT_CRYPT */
+#endif // FEAT_CRYPT
diff --git a/src/buffer.c b/src/buffer.c
index 3b50c8937..4868428f5 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -78,9 +78,9 @@ get_highest_fnum(void)
*/
static int
read_buffer(
- int read_stdin, /* read file from stdin, otherwise fifo */
- exarg_T *eap, /* for forced 'ff' and 'fenc' or NULL */
- int flags) /* extra flags for readfile() */
+ int read_stdin, // read file from stdin, otherwise fifo
+ exarg_T *eap, // for forced 'ff' and 'fenc' or NULL
+ int flags) // extra flags for readfile()
{
int retval = OK;
linenr_T line_count;
@@ -98,24 +98,24 @@ read_buffer(
flags | READ_BUFFER);
if (retval == OK)
{
- /* Delete the binary lines. */
+ // Delete the binary lines.
while (--line_count >= 0)
ml_delete((linenr_T)1, FALSE);
}
else
{
- /* Delete the converted lines. */
+ // Delete the converted lines.
while (curbuf->b_ml.ml_line_count > line_count)
ml_delete(line_count, FALSE);
}
- /* Put the cursor on the first line. */
+ // Put the cursor on the first line.
curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
if (read_stdin)
{
- /* Set or reset 'modified' before executing autocommands, so that
- * it can be changed there. */
+ // Set or reset 'modified' before executing autocommands, so that
+ // it can be changed there.
if (!readonlymode && !BUFEMPTY())
changed();
else if (retval == OK)
@@ -158,9 +158,9 @@ buffer_ensure_loaded(buf_T *buf)
*/
int
open_buffer(
- int read_stdin, /* read file from stdin */
- exarg_T *eap, /* for forced 'ff' and 'fenc' or NULL */
- int flags) /* extra flags for readfile() */
+ int read_stdin, // read file from stdin
+ exarg_T *eap, // for forced 'ff' and 'fenc' or NULL
+ int flags) // extra flags for readfile()
{
int retval = OK;
bufref_T old_curbuf;
@@ -211,12 +211,12 @@ open_buffer(
return FAIL;
}
- /* The autocommands in readfile() may change the buffer, but only AFTER
- * reading the file. */
+ // The autocommands in readfile() may change the buffer, but only AFTER
+ // reading the file.
set_bufref(&old_curbuf, curbuf);
modified_was_set = FALSE;
- /* mark cursor position as being invalid */
+ // mark cursor position as being invalid
curwin->w_valid = 0;
if (curbuf->b_ffname != NULL
@@ -264,7 +264,7 @@ open_buffer(
#ifdef FEAT_NETBEANS_INTG
netbeansFireChanges = oldFire;
#endif
- /* Help buffer is filtered. */
+ // Help buffer is filtered.
if (bt_help(curbuf))
fix_help_buffer();
}
@@ -287,7 +287,7 @@ open_buffer(
retval = read_buffer(TRUE, eap, flags);
}
- /* if first time loading this buffer, init b_chartab[] */
+ // if first time loading this buffer, init b_chartab[]
if (curbuf->b_flags & BF_NEVERLOADED)
{
(void)buf_init_chartab(curbuf, FALSE);
@@ -301,11 +301,11 @@ open_buffer(
* Apply the automatic commands, before processing the modelines.
* So the modelines have priority over autocommands.
*/
- /* When reading stdin, the buffer contents always needs writing, so set
- * the changed flag. Unless in readonly mode: "ls | gview -".
- * When interrupted and 'cpoptions' contains 'i' set changed flag. */
+ // When reading stdin, the buffer contents always needs writing, so set
+ // the changed flag. Unless in readonly mode: "ls | gview -".
+ // When interrupted and 'cpoptions' contains 'i' set changed flag.
if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
- || modified_was_set /* ":set modified" used in autocmd */
+ || modified_was_set // ":set modified" used in autocmd
#ifdef FEAT_EVAL
|| (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
#endif
@@ -313,14 +313,14 @@ open_buffer(
changed();
else if (retval == OK && !read_stdin && !read_fifo)
unchanged(curbuf, FALSE, TRUE);
- save_file_ff(curbuf); /* keep this fileformat */
+ save_file_ff(curbuf); // keep this fileformat
- /* Set last_changedtick to avoid triggering a TextChanged autocommand right
- * after it was added. */
+ // Set last_changedtick to avoid triggering a TextChanged autocommand right
+ // after it was added.
curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf);
- /* require "!" to overwrite the file, because it wasn't read completely */
+ // require "!" to overwrite the file, because it wasn't read completely
#ifdef FEAT_EVAL
if (aborting())
#else
@@ -329,12 +329,12 @@ open_buffer(
curbuf->b_flags |= BF_READERR;
#ifdef FEAT_FOLDING
- /* Need to update automatic folding. Do this before the autocommands,
- * they may use the fold info. */
+ // Need to update automatic folding. Do this before the autocommands,
+ // they may use the fold info.
foldUpdateAll(curwin);
#endif
- /* need to set w_topline, unless some autocommand already did that. */
+ // need to set w_topline, unless some autocommand already did that.
if (!(curwin->w_valid & VALID_TOPLINE))
{
curwin->w_topline = 1;
@@ -358,7 +358,7 @@ open_buffer(
{
aco_save_T aco;
- /* Go to the buffer that was opened. */
+ // Go to the buffer that was opened.
aucmd_prepbuf(&aco, old_curbuf.br_buf);
do_modelines(0);
curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);
@@ -370,7 +370,7 @@ open_buffer(
apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf);
#endif
- /* restore curwin/curbuf and a few other things */
+ // restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
}
}
@@ -413,8 +413,8 @@ buf_valid(buf_T *buf)
{
buf_T *bp;
- /* Assume that we more often have a recent buffer, start with the last
- * one. */
+ // Assume that we more often have a recent buffer, start with the last
+ // one.
for (bp = lastbuf; bp != NULL; bp = bp->b_prev)
if (bp == buf)
return TRUE;
@@ -490,7 +490,7 @@ can_unload_buffer(buf_T *buf)
*/
void
close_buffer(
- win_T *win, /* if not NULL, set b_last_cursor */
+ win_T *win, // if not NULL, set b_last_cursor
buf_T *buf,
int action,
int abort_if_last)
@@ -510,18 +510,18 @@ close_buffer(
* The caller must take care of NOT deleting/freeing when 'bufhidden' is
* "hide" (otherwise we could never free or delete a buffer).
*/
- if (buf->b_p_bh[0] == 'd') /* 'bufhidden' == "delete" */
+ if (buf->b_p_bh[0] == 'd') // 'bufhidden' == "delete"
{
del_buf = TRUE;
unload_buf = TRUE;
}
- else if (buf->b_p_bh[0] == 'w') /* 'bufhidden' == "wipe" */
+ else if (buf->b_p_bh[0] == 'w') // 'bufhidden' == "wipe"
{
del_buf = TRUE;
unload_buf = TRUE;
wipe_buf = TRUE;
}
- else if (buf->b_p_bh[0] == 'u') /* 'bufhidden' == "unload" */
+ else if (buf->b_p_bh[0] == 'u') // 'bufhidden' == "unload"
unload_buf = TRUE;
#ifdef FEAT_TERMINAL
@@ -534,19 +534,19 @@ close_buffer(
if (!can_unload_buffer(buf))
return;
- /* Wiping out or unloading a terminal buffer kills the job. */
+ // Wiping out or unloading a terminal buffer kills the job.
free_terminal(buf);
}
else
{
- /* The job keeps running, hide the buffer. */
+ // The job keeps running, hide the buffer.
del_buf = FALSE;
unload_buf = FALSE;
}
}
else
{
- /* A terminal buffer is wiped out if the job has finished. */
+ // A terminal buffer is wiped out if the job has finished.
del_buf = TRUE;
unload_buf = TRUE;
wipe_buf = TRUE;
@@ -554,18 +554,18 @@ close_buffer(
}
#endif
- /* Disallow deleting the buffer when it is locked (already being closed or
- * halfway a command that relies on it). Unloading is allowed. */
+ // Disallow deleting the buffer when it is locked (already being closed or
+ // halfway a command that relies on it). Unloading is allowed.
if ((del_buf || wipe_buf) && !can_unload_buffer(buf))
return;
- /* check no autocommands closed the window */
+ // check no autocommands closed the window
if (win != NULL && win_valid_any_tab(win))
{
- /* Set b_last_cursor when closing the last window for the buffer.
- * Remember the last cursor position and window options of the buffer.
- * This used to be only for the current window, but then options like
- * 'foldmethod' may be lost with a ":only" command. */
+ // Set b_last_cursor when closing the last window for the buffer.
+ // Remember the last cursor position and window options of the buffer.
+ // This used to be only for the current window, but then options like
+ // 'foldmethod' may be lost with a ":only" command.
if (buf->b_nwindows == 1)
set_last_cursor(win);
buflist_setfpos(buf, win,
@@ -575,7 +575,7 @@ close_buffer(
set_bufref(&bufref, buf);
- /* When the buffer is no longer in a window, trigger BufWinLeave */
+ // When the buffer is no longer in a window, trigger BufWinLeave
if (buf->b_nwindows == 1)
{
++buf->b_locked;
@@ -583,40 +583,40 @@ close_buffer(
FALSE, buf)
&& !bufref_valid(&bufref))
{
- /* Autocommands deleted the buffer. */
+ // Autocommands deleted the buffer.
aucmd_abort:
emsg(_(e_auabort));
return;
}
--buf->b_locked;
if (abort_if_last && one_window())
- /* Autocommands made this the only window. */
+ // Autocommands made this the only window.
goto aucmd_abort;
- /* When the buffer becomes hidden, but is not unloaded, trigger
- * BufHidden */
+ // When the buffer becomes hidden, but is not unloaded, trigger
+ // BufHidden
if (!unload_buf)
{
++buf->b_locked;
if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname,
FALSE, buf)
&& !bufref_valid(&bufref))
- /* Autocommands deleted the buffer. */
+ // Autocommands deleted the buffer.
goto aucmd_abort;
--buf->b_locked;
if (abort_if_last && one_window())
- /* Autocommands made this the only window. */
+ // Autocommands made this the only window.
goto aucmd_abort;
}
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return;
#endif
}
- /* If the buffer was in curwin and the window has changed, go back to that
- * window, if it still exists. This avoids that ":edit x" triggering a
- * "tabnext" BufUnload autocmd leaves a window behind without a buffer. */
+ // If the buffer was in curwin and the window has changed, go back to that
+ // window, if it still exists. This avoids that ":edit x" triggering a
+ // "tabnext" BufUnload autocmd leaves a window behind without a buffer.
if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin))
{
block_autocmds();
@@ -626,26 +626,26 @@ aucmd_abort:
nwindows = buf->b_nwindows;
- /* decrease the link count from windows (unless not in any window) */
+ // decrease the link count from windows (unless not in any window)
if (buf->b_nwindows > 0)
--buf->b_nwindows;
#ifdef FEAT_DIFF
if (diffopt_hiddenoff() && !unload_buf && buf->b_nwindows == 0)
- diff_buf_delete(buf); /* Clear 'diff' for hidden buffer. */
+ diff_buf_delete(buf); // Clear 'diff' for hidden buffer.
#endif
- /* Return when a window is displaying the buffer or when it's not
- * unloaded. */
+ // Return when a window is displaying the buffer or when it's not
+ // unloaded.
if (buf->b_nwindows > 0 || !unload_buf)
return;
- /* Always remove the buffer when there is no file name. */
+ // Always remove the buffer when there is no file name.
if (buf->b_ffname == NULL)
del_buf = TRUE;
- /* When closing the current buffer stop Visual mode before freeing
- * anything. */
+ // When closing the current buffer stop Visual mode before freeing
+ // anything.
if (buf == curbuf && VIsual_active
#if defined(EXITFREE)
&& !entered_free_all_mem
@@ -657,18 +657,18 @@ aucmd_abort:
* Free all things allocated for this buffer.
* Also calls the "BufDelete" autocommands when del_buf is TRUE.
*/
- /* Remember if we are closing the current buffer. Restore the number of
- * windows, so that autocommands in buf_freeall() don't get confused. */
+ // Remember if we are closing the current buffer. Restore the number of
+ // windows, so that autocommands in buf_freeall() don't get confused.
is_curbuf = (buf == curbuf);
buf->b_nwindows = nwindows;
buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
- /* Autocommands may have deleted the buffer. */
+ // Autocommands may have deleted the buffer.
if (!bufref_valid(&bufref))
return;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return;
#endif
@@ -683,10 +683,10 @@ aucmd_abort:
return;
if (win_valid_any_tab(win) && win->w_buffer == buf)
- win->w_buffer = NULL; /* make sure we don't use the buffer now */
+ win->w_buffer = NULL; // make sure we don't use the buffer now
- /* Autocommands may have opened or closed windows for this buffer.
- * Decrement the count for the close we do here. */
+ // Autocommands may have opened or closed windows for this buffer.
+ // Decrement the count for the close we do here.
if (buf->b_nwindows > 0)
--buf->b_nwindows;
@@ -722,14 +722,14 @@ aucmd_abort:
{
if (del_buf)
{
- /* Free all internal variables and reset option values, to make
- * ":bdel" compatible with Vim 5.7. */
+ // Free all internal variables and reset option values, to make
+ // ":bdel" compatible with Vim 5.7.
free_buffer_stuff(buf, TRUE);
- /* Make it look like a new buffer. */
+ // Make it look like a new buffer.
buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED;
- /* Init the options when loaded again. */
+ // Init the options when loaded again.
buf->b_p_initialized = FALSE;
}
buf_clear_file(buf);
@@ -752,7 +752,7 @@ buf_clear_file(buf_T *buf)
buf->b_p_bomb = FALSE;
buf->b_start_bomb = FALSE;
buf->b_ml.ml_mfp = NULL;
- buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */
+ buf->b_ml.ml_flags = ML_EMPTY; // empty buffer
#ifdef FEAT_NETBEANS_INTG
netbeans_deleted_all_lines(buf);
#endif
@@ -775,7 +775,7 @@ buf_freeall(buf_T *buf, int flags)
win_T *the_curwin = curwin;
tabpage_T *the_curtab = curtab;
- /* Make sure the buffer isn't closed by autocommands. */
+ // Make sure the buffer isn't closed by autocommands.
++buf->b_locked;
set_bufref(&bufref, buf);
if (buf->b_ml.ml_mfp != NULL)
@@ -783,7 +783,7 @@ buf_freeall(buf_T *buf, int flags)
if (apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname,
FALSE, buf)
&& !bufref_valid(&bufref))
- /* autocommands deleted the buffer */
+ // autocommands deleted the buffer
return;
}
if ((flags & BFA_DEL) && buf->b_p_bl)
@@ -791,7 +791,7 @@ buf_freeall(buf_T *buf, int flags)
if (apply_autocmds(EVENT_BUFDELETE, buf->b_fname, buf->b_fname,
FALSE, buf)
&& !bufref_valid(&bufref))
- /* autocommands deleted the buffer */
+ // autocommands deleted the buffer
return;
}
if (flags & BFA_WIPE)
@@ -799,14 +799,14 @@ buf_freeall(buf_T *buf, int flags)
if (apply_autocmds(EVENT_BUFWIPEOUT, buf->b_fname, buf->b_fname,
FALSE, buf)
&& !bufref_valid(&bufref))
- /* autocommands deleted the buffer */
+ // autocommands deleted the buffer
return;
}
--buf->b_locked;
- /* If the buffer was in curwin and the window has changed, go back to that
- * window, if it still exists. This avoids that ":edit x" triggering a
- * "tabnext" BufUnload autocmd leaves a window behind without a buffer. */
+ // If the buffer was in curwin and the window has changed, go back to that
+ // window, if it still exists. This avoids that ":edit x" triggering a
+ // "tabnext" BufUnload autocmd leaves a window behind without a buffer.
if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin))
{
block_autocmds();
@@ -815,7 +815,7 @@ buf_freeall(buf_T *buf, int flags)
}
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return;
#endif
@@ -828,16 +828,16 @@ buf_freeall(buf_T *buf, int flags)
if (buf == curbuf && !is_curbuf)
return;
#ifdef FEAT_DIFF
- diff_buf_delete(buf); /* Can't use 'diff' for unloaded buffer. */
+ diff_buf_delete(buf); // Can't use 'diff' for unloaded buffer.
#endif
#ifdef FEAT_SYN_HL
- /* Remove any ownsyntax, unless exiting. */
+ // Remove any ownsyntax, unless exiting.
if (curwin != NULL && curwin->w_buffer == buf)
reset_synblock(curwin);
#endif
#ifdef FEAT_FOLDING
- /* No folds in an empty buffer. */
+ // No folds in an empty buffer.
{
win_T *win;
tabpage_T *tp;
@@ -851,20 +851,20 @@ buf_freeall(buf_T *buf, int flags)
#ifdef FEAT_TCL
tcl_buffer_free(buf);
#endif
- ml_close(buf, TRUE); /* close and delete the memline/memfile */
- buf->b_ml.ml_line_count = 0; /* no lines in buffer */
+ ml_close(buf, TRUE); // close and delete the memline/memfile
+ buf->b_ml.ml_line_count = 0; // no lines in buffer
if ((flags & BFA_KEEP_UNDO) == 0)
{
- u_blockfree(buf); /* free the memory allocated for undo */
- u_clearall(buf); /* reset all undo information */
+ u_blockfree(buf); // free the memory allocated for undo
+ u_clearall(buf); // reset all undo information
}
#ifdef FEAT_SYN_HL
- syntax_clear(&buf->b_s); /* reset syntax info */
+ syntax_clear(&buf->b_s); // reset syntax info
#endif
#ifdef FEAT_TEXT_PROP
clear_buf_prop_types(buf);
#endif
- buf->b_flags &= ~BF_READERR; /* a read error is no longer relevant */
+ buf->b_flags &= ~BF_READERR; // a read error is no longer relevant
}
/*
@@ -877,7 +877,7 @@ free_buffer(buf_T *buf)
++buf_free_count;
free_buffer_stuff(buf, TRUE);
#ifdef FEAT_EVAL
- /* b:changedtick uses an item in buf_T, remove it now */
+ // b:changedtick uses an item in buf_T, remove it now
dictitem_remove(buf->b_vars, (dictitem_T *)&buf->b_ct_di);
unref_var_dict(buf->b_vars);
remove_listeners(buf);
@@ -918,8 +918,8 @@ free_buffer(buf_T *buf)
if (autocmd_busy)
{
- /* Do not free the buffer structure while autocommands are executing,
- * it's still needed. Free it when autocmd_busy is reset. */
+ // Do not free the buffer structure while autocommands are executing,
+ // it's still needed. Free it when autocmd_busy is reset.
buf->b_next = au_pending_free_buf;
au_pending_free_buf = buf;
}
@@ -952,11 +952,11 @@ init_changedtick(buf_T *buf)
static void
free_buffer_stuff(
buf_T *buf,
- int free_options) /* free options as well */
+ int free_options) // free options as well
{
if (free_options)
{
- clear_wininfo(buf); /* including window-local options */
+ clear_wininfo(buf); // including window-local options
free_buf_options(buf, TRUE);
#ifdef FEAT_SPELL
ga_clear(&buf->b_s.b_langp);
@@ -966,7 +966,7 @@ free_buffer_stuff(
{
varnumber_T tick = CHANGEDTICK(buf);
- vars_clear(&buf->b_vars->dv_hashtab); /* free all buffer variables */
+ vars_clear(&buf->b_vars->dv_hashtab); // free all buffer variables
hash_init(&buf->b_vars->dv_hashtab);
init_changedtick(buf);
CHANGEDTICK(buf) = tick;
@@ -979,8 +979,8 @@ free_buffer_stuff(
#ifdef FEAT_NETBEANS_INTG
netbeans_file_killed(buf);
#endif
- map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */
- map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */
+ map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); // clear local mappings
+ map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); // clear local abbrevs
VIM_CLEAR(buf->b_start_fenc);
}
@@ -1029,19 +1029,19 @@ goto_buffer(
#if defined(FEAT_EVAL)
cleanup_T cs;
- /* Reset the error/interrupt/exception state here so that
- * aborting() returns FALSE when closing a window. */
+ // Reset the error/interrupt/exception state here so that
+ // aborting() returns FALSE when closing a window.
enter_cleanup(&cs);
#endif
- /* Quitting means closing the split window, nothing else. */
+ // Quitting means closing the split window, nothing else.
win_close(curwin, TRUE);
swap_exists_action = SEA_NONE;
swap_exists_did_quit = TRUE;
#if defined(FEAT_EVAL)
- /* Restore the error/interrupt/exception state if not discarded by a
- * new aborting error, interrupt, or uncaught exception. */
+ // Restore the error/interrupt/exception state if not discarded by a
+ // new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
#endif
}
@@ -1067,15 +1067,15 @@ handle_swap_exists(bufref_T *old_curbuf)
if (swap_exists_action == SEA_QUIT)
{
#if defined(FEAT_EVAL)
- /* Reset the error/interrupt/exception state here so that
- * aborting() returns FALSE when closing a buffer. */
+ // Reset the error/interrupt/exception state here so that
+ // aborting() returns FALSE when closing a buffer.
enter_cleanup(&cs);
#endif
- /* User selected Quit at ATTENTION prompt. Go back to previous
- * buffer. If that buffer is gone or the same as the current one,
- * open a new, empty buffer. */
- swap_exists_action = SEA_NONE; /* don't want it again */
+ // User selected Quit at ATTENTION prompt. Go back to previous
+ // buffer. If that buffer is gone or the same as the current one,
+ // open a new, empty buffer.
+ swap_exists_action = SEA_NONE; // don't want it again
swap_exists_did_quit = TRUE;
close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE);
if (old_curbuf == NULL || !bufref_valid(old_curbuf)
@@ -1098,32 +1098,32 @@ handle_swap_exists(bufref_T *old_curbuf)
check_colorcolumn(curwin);
#endif
}
- /* If "old_curbuf" is NULL we are in big trouble here... */
+ // If "old_curbuf" is NULL we are in big trouble here...
#if defined(FEAT_EVAL)
- /* Restore the error/interrupt/exception state if not discarded by a
- * new aborting error, interrupt, or uncaught exception. */
+ // Restore the error/interrupt/exception state if not discarded by a
+ // new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
#endif
}
else if (swap_exists_action == SEA_RECOVER)
{
#if defined(FEAT_EVAL)
- /* Reset the error/interrupt/exception state here so that
- * aborting() returns FALSE when closing a buffer. */
+ // Reset the error/interrupt/exception state here so that
+ // aborting() returns FALSE when closing a buffer.
enter_cleanup(&cs);
#endif
- /* User selected Recover at ATTENTION prompt. */
+ // User selected Recover at ATTENTION prompt.
msg_scroll = TRUE;
ml_recover(FALSE);
- msg_puts("\n"); /* don't overwrite the last message */
+ msg_puts("\n"); // don't overwrite the last message
cmdline_row = msg_row;
do_modelines(0);
#if defined(FEAT_EVAL)
- /* Restore the error/interrupt/exception state if not discarded by a
- * new aborting error, interrupt, or uncaught exception. */
+ // Restore the error/interrupt/exception state if not discarded by a
+ // new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
#endif
}
@@ -1146,16 +1146,16 @@ handle_swap_exists(bufref_T *old_curbuf)
char *
do_bufdel(
int command,
- char_u *arg, /* pointer to extra arguments */
+ char_u *arg, // pointer to extra arguments
int addr_count,
- int start_bnr, /* first buffer number in a range */
- int end_bnr, /* buffer nr or last buffer nr in a range */
+ int start_bnr, // first buffer number in a range
+ int end_bnr, // buffer nr or last buffer nr in a range
int forceit)
{
- int do_current = 0; /* delete current buffer? */
- int deleted = 0; /* number of buffers deleted */
- char *errormsg = NULL; /* return value */
- int bnr; /* buffer number */
+ int do_current = 0; // delete current buffer?
+ int deleted = 0; // number of buffers deleted
+ char *errormsg = NULL; // return value
+ int bnr; // buffer number
char_u *p;
if (addr_count == 0)
@@ -1166,11 +1166,11 @@ do_bufdel(
{
if (addr_count == 2)
{
- if (*arg) /* both range and argument is not allowed */
+ if (*arg) // both range and argument is not allowed
return _(e_trailing);
bnr = start_bnr;
}
- else /* addr_count == 1 */
+ else // addr_count == 1
bnr = end_bnr;
for ( ;!got_int; ui_breakcheck())
@@ -1195,7 +1195,7 @@ do_bufdel(
if (++bnr > end_bnr)
break;
}
- else /* addr_count == 1 */
+ else // addr_count == 1
{
arg = skipwhite(arg);
if (*arg == NUL)
@@ -1206,7 +1206,7 @@ do_bufdel(
bnr = buflist_findpat(arg, p,
command == DOBUF_WIPE || command == DOBUF_WIPE_REUSE,
FALSE, FALSE);
- if (bnr < 0) /* failed */
+ if (bnr < 0) // failed
break;
arg = p;
}
@@ -1268,7 +1268,7 @@ empty_curbuf(
set_bufref(&bufref, buf);
if (close_others)
- /* Close any other windows on this buffer, then make it empty. */
+ // Close any other windows on this buffer, then make it empty.
close_windows(buf, TRUE);
setpcmark();
@@ -1308,9 +1308,9 @@ empty_curbuf(
do_buffer(
int action,
int start,
- int dir, /* FORWARD or BACKWARD */
- int count, /* buffer number or number of buffers */
- int forceit) /* TRUE for :...! */
+ int dir, // FORWARD or BACKWARD
+ int count, // buffer number or number of buffers
+ int forceit) // TRUE for :...!
{
buf_T *buf;
buf_T *bp;
@@ -1323,7 +1323,7 @@ do_buffer(
case DOBUF_LAST: buf = lastbuf; break;
default: buf = curbuf; break;
}
- if (start == DOBUF_MOD) /* find next modified buffer */
+ if (start == DOBUF_MOD) // find next modified buffer
{
while (count-- > 0)
{
@@ -1341,7 +1341,7 @@ do_buffer(
return FAIL;
}
}
- else if (start == DOBUF_FIRST && count) /* find specified buffer number */
+ else if (start == DOBUF_FIRST && count) // find specified buffer number
{
while (buf != NULL && buf->b_fnum != count)
buf = buf->b_next;
@@ -1351,8 +1351,8 @@ do_buffer(
bp = NULL;
while (count > 0 || (!unload && !buf->b_p_bl && bp != buf))
{
- /* remember the buffer where we start, we come back there when all
- * buffers are unlisted. */
+ // remember the buffer where we start, we come back there when all
+ // buffers are unlisted.
if (bp == NULL)
bp = buf;
if (dir == FORWARD)
@@ -1367,26 +1367,26 @@ do_buffer(
if (buf == NULL)
buf = lastbuf;
}
- /* don't count unlisted buffers */
+ // don't count unlisted buffers
if (unload || buf->b_p_bl)
{
--count;
- bp = NULL; /* use this buffer as new starting point */
+ bp = NULL; // use this buffer as new starting point
}
if (bp == buf)
{
- /* back where we started, didn't find anything. */
+ // back where we started, didn't find anything.
emsg(_("E85: There is no listed buffer"));
return FAIL;
}
}
}
- if (buf == NULL) /* could not find it */
+ if (buf == NULL) // could not find it
{
if (start == DOBUF_FIRST)
{
- /* don't warn when deleting */
+ // don't warn when deleting
if (!unload)
semsg(_(e_nobufnr), count);
}
@@ -1414,8 +1414,8 @@ do_buffer(
set_bufref(&bufref, buf);
- /* When unloading or deleting a buffer that's already unloaded and
- * unlisted: fail silently. */
+ // When unloading or deleting a buffer that's already unloaded and
+ // unlisted: fail silently.
if (action != DOBUF_WIPE && action != DOBUF_WIPE_REUSE
&& buf->b_ml.ml_mfp == NULL && !buf->b_p_bl)
return FAIL;
@@ -1427,11 +1427,11 @@ do_buffer(
{
dialog_changed(buf, FALSE);
if (!bufref_valid(&bufref))
- /* Autocommand deleted buffer, oops! It's not changed
- * now. */
+ // Autocommand deleted buffer, oops! It's not changed
+ // now.
return FAIL;
- /* If it's still changed fail silently, the dialog already
- * mentioned why it fails. */
+ // If it's still changed fail silently, the dialog already
+ // mentioned why it fails.
if (bufIsChanged(buf))
return FAIL;
}
@@ -1444,7 +1444,7 @@ do_buffer(
}
}
- /* When closing the current buffer stop Visual mode. */
+ // When closing the current buffer stop Visual mode.
if (buf == curbuf && VIsual_active)
end_visual_mode();
@@ -1492,8 +1492,8 @@ do_buffer(
* then before the current buffer.
* Finally use any buffer.
*/
- buf = NULL; /* selected buffer */
- bp = NULL; /* used when no loaded buffer found */
+ buf = NULL; // selected buffer
+ bp = NULL; // used when no loaded buffer found
if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf))
buf = au_new_curbuf.br_buf;
#ifdef FEAT_JUMPLIST
@@ -1512,29 +1512,29 @@ do_buffer(
if (buf != NULL)
{
if (buf == curbuf || !buf->b_p_bl)
- buf = NULL; /* skip current and unlisted bufs */
+ buf = NULL; // skip current and unlisted bufs
else if (buf->b_ml.ml_mfp == NULL)
{
- /* skip unloaded buf, but may keep it for later */
+ // skip unloaded buf, but may keep it for later
if (bp == NULL)
bp = buf;
buf = NULL;
}
}
- if (buf != NULL) /* found a valid buffer: stop searching */
+ if (buf != NULL) // found a valid buffer: stop searching
break;
- /* advance to older entry in jump list */
+ // advance to older entry in jump list
if (!jumpidx && curwin->w_jumplistidx == curwin->w_jumplistlen)
break;
if (--jumpidx < 0)
jumpidx = curwin->w_jumplistlen - 1;
- if (jumpidx == forward) /* List exhausted for sure */
+ if (jumpidx == forward) // List exhausted for sure
break;
}
}
#endif
- if (buf == NULL) /* No previous buffer, Try 2'nd approach */
+ if (buf == NULL) // No previous buffer, Try 2'nd approach
{
forward = TRUE;
buf = curbuf->b_next;
@@ -1542,18 +1542,18 @@ do_buffer(
{
if (buf == NULL)
{
- if (!forward) /* tried both directions */
+ if (!forward) // tried both directions
break;
buf = curbuf->b_prev;
forward = FALSE;
continue;
}
- /* in non-help buffer, try to skip help buffers, and vv */
+ // in non-help buffer, try to skip help buffers, and vv
if (buf->b_help == curbuf->b_help && buf->b_p_bl)
{
- if (buf->b_ml.ml_mfp != NULL) /* found loaded buffer */
+ if (buf->b_ml.ml_mfp != NULL) // found loaded buffer
break;
- if (bp == NULL) /* remember unloaded buf for later */
+ if (bp == NULL) // remember unloaded buf for later
bp = buf;
}
if (forward)
@@ -1562,15 +1562,15 @@ do_buffer(
buf = buf->b_prev;
}
}
- if (buf == NULL) /* No loaded buffer, use unloaded one */
+ if (buf == NULL) // No loaded buffer, use unloaded one
buf = bp;
- if (buf == NULL) /* No loaded buffer, find listed one */
+ if (buf == NULL) // No loaded buffer, find listed one
{
FOR_ALL_BUFFERS(buf)
if (buf->b_p_bl && buf != curbuf)
break;
}
- if (buf == NULL) /* Still no buffer, just take one */
+ if (buf == NULL) // Still no buffer, just take one
{
if (curbuf->b_next != NULL)
buf = curbuf->b_next;
@@ -1581,29 +1581,29 @@ do_buffer(
if (buf == NULL)
{
- /* Autocommands must have wiped out all other buffers. Only option
- * now is to make the current buffer empty. */
+ // Autocommands must have wiped out all other buffers. Only option
+ // now is to make the current buffer empty.
return empty_curbuf(FALSE, forceit, action);
}
/*
* make buf current buffer
*/
- if (action == DOBUF_SPLIT) /* split window first */
+ if (action == DOBUF_SPLIT) // split window first
{
- /* If 'switchbuf' contains "useopen": jump to first window containing
- * "buf" if one exists */
+ // If 'switchbuf' contains "useopen": jump to first window containing
+ // "buf" if one exists
if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf))
return OK;
- /* If 'switchbuf' contains "usetab": jump to first window in any tab
- * page containing "buf" if one exists */
+ // If 'switchbuf' contains "usetab": jump to first window in any tab
+ // page containing "buf" if one exists
if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf))
return OK;
if (win_split(0, 0) == FAIL)
return FAIL;
}
- /* go to current buffer - nothing to do */
+ // go to current buffer - nothing to do
if (buf == curbuf)
return OK;
@@ -1620,7 +1620,7 @@ do_buffer(
set_bufref(&bufref, buf);
dialog_changed(curbuf, FALSE);
if (!bufref_valid(&bufref))
- /* Autocommand deleted buffer, oops! */
+ // Autocommand deleted buffer, oops!
return FAIL;
}
if (bufIsChanged(curbuf))
@@ -1631,14 +1631,14 @@ do_buffer(
}
}
- /* Go to the other buffer. */
+ // Go to the other buffer.
set_curbuf(buf, action);
if (action == DOBUF_SPLIT)
- RESET_BINDING(curwin); /* reset 'scrollbind' and 'cursorbind' */
+ RESET_BINDING(curwin); // reset 'scrollbind' and 'cursorbind'
#if defined(FEAT_EVAL)
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
@@ -1669,20 +1669,19 @@ set_curbuf(buf_T *buf, int action)
setpcmark();
if (!cmdmod.keepalt)
- curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */
- buflist_altfpos(curwin); /* remember curpos */
+ curwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file
+ buflist_altfpos(curwin); // remember curpos
- /* Don't restart Select mode after switching to another buffer. */
+ // Don't restart Select mode after switching to another buffer.
VIsual_reselect = FALSE;
- /* close_windows() or apply_autocmds() may change curbuf and wipe out "buf"
- */
+ // close_windows() or apply_autocmds() may change curbuf and wipe out "buf"
prevbuf = curbuf;
set_bufref(&prevbufref, prevbuf);
set_bufref(&newbufref, buf);
- /* Autocommands may delete the curren buffer and/or the buffer we wan to go
- * to. In those cases don't close the buffer. */
+ // Autocommands may delete the curren buffer and/or the buffer we wan to go
+ // to. In those cases don't close the buffer.
if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)
|| (bufref_valid(&prevbufref)
&& bufref_valid(&newbufref)
@@ -1711,13 +1710,13 @@ set_curbuf(buf_T *buf, int action)
&& !buf_hide(prevbuf)
&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0, FALSE);
if (curwin != previouswin && win_valid(previouswin))
- /* autocommands changed curwin, Grr! */
+ // autocommands changed curwin, Grr!
curwin = previouswin;
}
}
- /* An autocommand may have deleted "buf", already entered it (e.g., when
- * it did ":bunload") or aborted the script processing.
- * If curwin->w_buffer is null, enter_buffer() will make it valid again */
+ // An autocommand may have deleted "buf", already entered it (e.g., when
+ // it did ":bunload") or aborted the script processing.
+ // If curwin->w_buffer is null, enter_buffer() will make it valid again
if ((buf_valid(buf) && buf != curbuf
#ifdef FEAT_EVAL
&& !aborting()
@@ -1765,25 +1764,25 @@ enter_buffer(buf_T *buf)
curwin->w_s = &(curbuf->b_s);
#endif
- /* Cursor on first line by default. */
+ // Cursor on first line by default.
curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
curwin->w_cursor.coladd = 0;
curwin->w_set_curswant = TRUE;
curwin->w_topline_was_set = FALSE;
- /* mark cursor position as being invalid */
+ // mark cursor position as being invalid
curwin->w_valid = 0;
buflist_setfpos(curbuf, curwin, curbuf->b_last_cursor.lnum,
curbuf->b_last_cursor.col, TRUE);
- /* Make sure the buffer is loaded. */
- if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */
+ // Make sure the buffer is loaded.
+ if (curbuf->b_ml.ml_mfp == NULL) // need to load the file
{
- /* If there is no filetype, allow for detecting one. Esp. useful for
- * ":ball" used in a autocommand. If there already is a filetype we
- * might prefer to keep it. */
+ // If there is no filetype, allow for detecting one. Esp. useful for
+ // ":ball" used in a autocommand. If there already is a filetype we
+ // might prefer to keep it.
if (*curbuf->b_p_ft == NUL)
did_filetype = FALSE;
@@ -1805,25 +1804,25 @@ enter_buffer(buf_T *buf)
apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf);
}
- /* If autocommands did not change the cursor position, restore cursor lnum
- * and possibly cursor col. */
+ // If autocommands did not change the cursor position, restore cursor lnum
+ // and possibly cursor col.
if (curwin->w_cursor.lnum == 1 && inindent(0))
buflist_getfpos();
- check_arg_idx(curwin); /* check for valid arg_idx */
+ check_arg_idx(curwin); // check for valid arg_idx
#ifdef FEAT_TITLE
maketitle();
#endif
- /* when autocmds didn't change it */
+ // when autocmds didn't change it
if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
- scroll_cursor_halfway(FALSE); /* redisplay at correct position */
+ scroll_cursor_halfway(FALSE); // redisplay at correct position
#ifdef FEAT_NETBEANS_INTG
- /* Send fileOpened event because we've changed buffers. */
+ // Send fileOpened event because we've changed buffers.
netbeans_file_activated(curbuf);
#endif
- /* Change directories when the 'acd' option is set. */
+ // Change directories when the 'acd' option is set.
DO_AUTOCHDIR;
#ifdef FEAT_KEYMAP
@@ -1831,8 +1830,8 @@ enter_buffer(buf_T *buf)
(void)keymap_init();
#endif
#ifdef FEAT_SPELL
- /* May need to set the spell language. Can only do this after the buffer
- * has been properly setup. */
+ // May need to set the spell language. Can only do this after the buffer
+ // has been properly setup.
if (!curbuf->b_help && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
(void)did_set_spelllang(curwin);
#endif
@@ -1937,8 +1936,8 @@ buflist_new(
* If file name already exists in the list, update the entry.
*/
#ifdef UNIX
- /* On Unix we can use inode numbers when the file exists. Works better
- * for hard links. */
+ // On Unix we can use inode numbers when the file exists. Works better
+ // for hard links.
if (sfname == NULL || mch_stat((char *)sfname, &st) < 0)
st.st_dev = (dev_T)-1;
#endif
@@ -1955,8 +1954,8 @@ buflist_new(
buflist_setfpos(buf, curwin, lnum, (colnr_T)0, FALSE);
if ((flags & BLN_NOOPT) == 0)
- /* copy the options now, if 'cpo' doesn't have 's' and not done
- * already */
+ // copy the options now, if 'cpo' doesn't have 's' and not done
+ // already
buf_copy_options(buf, 0);
if ((flags & BLN_LISTED) && !buf->b_p_bl)
@@ -1987,19 +1986,19 @@ buflist_new(
if ((flags & BLN_CURBUF) && curbuf_reusable())
{
buf = curbuf;
- /* It's like this buffer is deleted. Watch out for autocommands that
- * change curbuf! If that happens, allocate a new buffer anyway. */
+ // It's like this buffer is deleted. Watch out for autocommands that
+ // change curbuf! If that happens, allocate a new buffer anyway.
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
if (buf == curbuf)
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return NULL;
#endif
if (buf == curbuf)
{
- /* Make sure 'bufhidden' and 'buftype' are empty */
+ // Make sure 'bufhidden' and 'buftype' are empty
clear_string_option(&buf->b_p_bh);
clear_string_option(&buf->b_p_bt);
}
@@ -2013,7 +2012,7 @@ buflist_new(
return NULL;
}
#ifdef FEAT_EVAL
- /* init b: variables */
+ // init b: variables
buf->b_vars = dict_alloc();
if (buf->b_vars == NULL)
{
@@ -2050,22 +2049,22 @@ buflist_new(
if (buf == curbuf)
{
- /* free all things allocated for this buffer */
+ // free all things allocated for this buffer
buf_freeall(buf, 0);
- if (buf != curbuf) /* autocommands deleted the buffer! */
+ if (buf != curbuf) // autocommands deleted the buffer!
return NULL;
#if defined(FEAT_EVAL)
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return NULL;
#endif
- free_buffer_stuff(buf, FALSE); /* delete local variables et al. */
+ free_buffer_stuff(buf, FALSE); // delete local variables et al.
- /* Init the options. */
+ // Init the options.
buf->b_p_initialized = FALSE;
buf_copy_options(buf, BCO_ENTER);
#ifdef FEAT_KEYMAP
- /* need to reload lmaps and set b:keymap_name */
+ // need to reload lmaps and set b:keymap_name
curbuf->b_kmap_state |= KEYMAP_INIT;
#endif
}
@@ -2075,12 +2074,12 @@ buflist_new(
* put new buffer at the end of the buffer list
*/
buf->b_next = NULL;
- if (firstbuf == NULL) /* buffer list is empty */
+ if (firstbuf == NULL) // buffer list is empty
{
buf->b_prev = NULL;
firstbuf = buf;
}
- else /* append new buffer at end of list */
+ else // append new buffer at end of list
{
lastbuf->b_next = buf;
buf->b_prev = lastbuf;
@@ -2097,7 +2096,7 @@ buflist_new(
}
else
buf->b_fnum = top_file_num++;
- if (top_file_num < 0) /* wrap around (may cause duplicates) */
+ if (top_file_num < 0) // wrap around (may cause duplicates)
{
emsg(_("W14: Warning: List of file names overflow"));
if (emsg_silent == 0)
@@ -2139,16 +2138,16 @@ buflist_new(
if (flags & BLN_DUMMY)
buf->b_flags |= BF_DUMMY;
buf_clear_file(buf);
- clrallmarks(buf); /* clear marks */
- fmarks_check_names(buf); /* check file marks for this file */
- buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */
+ clrallmarks(buf); // clear marks
+ fmarks_check_names(buf); // check file marks for this file
+ buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; // init 'buflisted'
if (!(flags & BLN_DUMMY))
{
bufref_T bufref;
- /* Tricky: these autocommands may change the buffer list. They could
- * also split the window with re-using the one empty buffer. This may
- * result in unexpectedly losing the empty buffer. */
+ // Tricky: these autocommands may change the buffer list. They could
+ // also split the window with re-using the one empty buffer. This may
+ // result in unexpectedly losing the empty buffer.
set_bufref(&bufref, buf);
if (apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, buf)
&& !bufref_valid(&bufref))
@@ -2160,7 +2159,7 @@ buflist_new(
return NULL;
}
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return NULL;
#endif
}
@@ -2318,7 +2317,7 @@ buflist_getfile(
return FAIL;
}
- /* if alternate file is the current buffer, nothing to do */
+ // if alternate file is the current buffer, nothing to do
if (buf == curbuf)
return OK;
@@ -2330,7 +2329,7 @@ buflist_getfile(
if (curbuf_locked())
return FAIL;
- /* altfpos may be changed by getfile(), get it now */
+ // altfpos may be changed by getfile(), get it now
if (lnum == 0)
{
fpos = buflist_findfpos(buf);
@@ -2342,18 +2341,18 @@ buflist_getfile(
if (options & GETF_SWITCH)
{
- /* If 'switchbuf' contains "useopen": jump to first window containing
- * "buf" if one exists */
+ // If 'switchbuf' contains "useopen": jump to first window containing
+ // "buf" if one exists
if (swb_flags & SWB_USEOPEN)
wp = buf_jump_open_win(buf);
- /* If 'switchbuf' contains "usetab": jump to first window in any tab
- * page containing "buf" if one exists */
+ // If 'switchbuf' contains "usetab": jump to first window in any tab
+ // page containing "buf" if one exists
if (wp == NULL && (swb_flags & SWB_USETAB))
wp = buf_jump_open_tab(buf);
- /* If 'switchbuf' contains "split", "vsplit" or "newtab" and the
- * current buffer isn't empty: open new tab or window */
+ // If 'switchbuf' contains "split", "vsplit" or "newtab" and the
+ // current buffer isn't empty: open new tab or window
if (wp == NULL && (swb_flags & (SWB_VSPLIT | SWB_SPLIT | SWB_NEWTAB))
&& !BUFEMPTY())
{
@@ -2372,7 +2371,7 @@ buflist_getfile(
{
--RedrawingDisabled;
- /* cursor is at to BOL and w_cursor.lnum is checked due to getfile() */
+ // cursor is at to BOL and w_cursor.lnum is checked due to getfile()
if (!p_sol && col != 0)
{
curwin->w_cursor.col = col;
@@ -2421,10 +2420,10 @@ buflist_findname_exp(char_u *fname)
char_u *ffname;
buf_T *buf = NULL;
- /* First make the name into a full path name */
+ // First make the name into a full path name
ffname = FullName_save(fname,
#ifdef UNIX
- TRUE /* force expansion, get rid of symbolic links */
+ TRUE // force expansion, get rid of symbolic links
#else
FALSE
#endif
@@ -2468,7 +2467,7 @@ buflist_findname_stat(
#endif
buf_T *buf;
- /* Start at the last buffer, expect to find a match sooner. */
+ // Start at the last buffer, expect to find a match sooner.
for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname
#ifdef UNIX
@@ -2487,10 +2486,10 @@ buflist_findname_stat(
int
buflist_findpat(
char_u *pattern,
- char_u *pattern_end, /* pointer to first char after pattern */
- int unlisted, /* find unlisted buffers */
- int diffmode UNUSED, /* find diff-mode buffers only */
- int curtab_only) /* find buffers in current tab only */
+ char_u *pattern_end, // pointer to first char after pattern
+ int unlisted, // find unlisted buffers
+ int diffmode UNUSED, // find diff-mode buffers only
+ int curtab_only) // find buffers in current tab only
{
buf_T *buf;
int match = -1;
@@ -2530,8 +2529,8 @@ buflist_findpat(
patend = pat + STRLEN(pat) - 1;
toggledollar = (patend > pat && *patend == '$');
- /* First try finding a listed buffer. If not found and "unlisted"
- * is TRUE, try finding an unlisted buffer. */
+ // First try finding a listed buffer. If not found and "unlisted"
+ // is TRUE, try finding an unlisted buffer.
find_listed = TRUE;
for (;;)
{
@@ -2539,11 +2538,11 @@ buflist_findpat(
{
regmatch_T regmatch;
- /* may add '^' and '$' */
+ // may add '^' and '$'
if (toggledollar)
- *patend = (attempt < 2) ? NUL : '$'; /* add/remove '$' */
+ *patend = (attempt < 2) ? NUL : '$'; // add/remove '$'
p = pat;
- if (*p == '^' && !(attempt & 1)) /* add/remove '^' */
+ if (*p == '^' && !(attempt & 1)) // add/remove '^'
++p;
regmatch.regprog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog == NULL)
@@ -2561,8 +2560,8 @@ buflist_findpat(
{
if (curtab_only)
{
- /* Ignore the match if the buffer is not open in
- * the current tab. */
+ // Ignore the match if the buffer is not open in
+ // the current tab.
win_T *wp;
FOR_ALL_WINDOWS(wp)
@@ -2571,21 +2570,21 @@ buflist_findpat(
if (wp == NULL)
continue;
}
- if (match >= 0) /* already found a match */
+ if (match >= 0) // already found a match
{
match = -2;
break;
}
- match = buf->b_fnum; /* remember first match */
+ match = buf->b_fnum; // remember first match
}
vim_regfree(regmatch.regprog);
- if (match >= 0) /* found one match */
+ if (match >= 0) // found one match
break;
}
- /* Only search for unlisted buffers if there was no match with
- * a listed buffer. */
+ // Only search for unlisted buffers if there was no match with
+ // a listed buffer.
if (!unlisted || !find_listed || match != -1)
break;
find_listed = FALSE;
@@ -2630,10 +2629,10 @@ ExpandBufnames(
bufmatch_T *matches = NULL;
#endif
- *num_file = 0; /* return values in case of FAIL */
+ *num_file = 0; // return values in case of FAIL
*file = NULL;
- /* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
+ // Make a copy of "pat" and change "^" to "\(^\|[\/]\)".
if (*pat == '^')
{
patc = alloc(STRLEN(pat) + 11);
@@ -2654,7 +2653,7 @@ ExpandBufnames(
regmatch_T regmatch;
if (attempt > 0 && patc == pat)
- break; /* there was no anchor, no need to try again */
+ break; // there was no anchor, no need to try again
regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
if (regmatch.regprog == NULL)
{
@@ -2672,7 +2671,7 @@ ExpandBufnames(
count = 0;
FOR_ALL_BUFFERS(buf)
{
- if (!buf->b_p_bl) /* skip unlisted buffers */
+ if (!buf->b_p_bl) // skip unlisted buffers
continue;
p = buflist_match(&regmatch, buf, p_wic);
if (p != NULL)
@@ -2698,7 +2697,7 @@ ExpandBufnames(
}
}
}
- if (count == 0) /* no match found, break here */
+ if (count == 0) // no match found, break here
break;
if (round == 1)
{
@@ -2717,7 +2716,7 @@ ExpandBufnames(
}
}
vim_regfree(regmatch.regprog);
- if (count) /* match(es) found, break here */
+ if (count) // match(es) found, break here
break;
}
@@ -2757,11 +2756,11 @@ ExpandBufnames(
buflist_match(
regmatch_T *rmp,
buf_T *buf,
- int ignore_case) /* when TRUE ignore case, when FALSE use 'fic' */
+ int ignore_case) // when TRUE ignore case, when FALSE use 'fic'
{
char_u *match;
- /* First try the short file name, then the long file name. */
+ // First try the short file name, then the long file name.
match = fname_match(rmp, buf->b_sfname, ignore_case);
if (match == NULL)
match = fname_match(rmp, buf->b_ffname, ignore_case);
@@ -2777,20 +2776,20 @@ buflist_match(
fname_match(
regmatch_T *rmp,
char_u *name,
- int ignore_case) /* when TRUE ignore case, when FALSE use 'fic' */
+ int ignore_case) // when TRUE ignore case, when FALSE use 'fic'
{
char_u *match = NULL;
char_u *p;
if (name != NULL)
{
- /* Ignore case when 'fileignorecase' or the argument is set. */
+ // Ignore case when 'fileignorecase' or the argument is set.
rmp->rm_ic = p_fic || ignore_case;
if (vim_regexec(rmp, name, (colnr_T)0))
match = name;
else
{
- /* Replace $(HOME) with '~' and try matching again. */
+ // Replace $(HOME) with '~' and try matching again.
p = home_replace_save(NULL, name);
if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))
match = name;
@@ -2831,7 +2830,7 @@ buflist_findnr(int nr)
buflist_nr2name(
int n,
int fullname,
- int helptail) /* for help buffers return tail only */
+ int helptail) // for help buffers return tail only
{
buf_T *buf;
@@ -2862,17 +2861,17 @@ buflist_setfpos(
break;
if (wip == NULL)
{
- /* allocate a new entry */
+ // allocate a new entry
wip = ALLOC_CLEAR_ONE(wininfo_T);
if (wip == NULL)
return;
wip->wi_win = win;
- if (lnum == 0) /* set lnum even when it's 0 */
+ if (lnum == 0) // set lnum even when it's 0
lnum = 1;
}
else
{
- /* remove the entry from the list */
+ // remove the entry from the list
if (wip->wi_prev)
wip->wi_prev->wi_next = wip->wi_next;
else
@@ -2894,7 +2893,7 @@ buflist_setfpos(
}
if (copy_options)
{
- /* Save the window-specific option values. */
+ // Save the window-specific option values.
copy_winopt(&win->w_onebuf_opt, &wip->wi_opt);
#ifdef FEAT_FOLDING
wip->wi_fold_manual = win->w_fold_manual;
@@ -2903,7 +2902,7 @@ buflist_setfpos(
wip->wi_optset = TRUE;
}
- /* insert the entry in front of the list */
+ // insert the entry in front of the list
wip->wi_next = buf->b_wininfo;
buf->b_wininfo = wip;
wip->wi_prev = NULL;
@@ -2926,8 +2925,8 @@ wininfo_other_tab_diff(wininfo_T *wip)
if (wip->wi_opt.wo_diff)
{
FOR_ALL_WINDOWS(wp)
- /* return FALSE when it's a window in the current tab page, thus
- * the buffer was in diff mode here */
+ // return FALSE when it's a window in the current tab page, thus
+ // the buffer was in diff mode here
if (wip->wi_win == wp)
return FALSE;
return TRUE;
@@ -2958,8 +2957,8 @@ find_wininfo(
)
break;
- /* If no wininfo for curwin, use the first in the list (that doesn't have
- * 'diff' set and is in another tab page). */
+ // If no wininfo for curwin, use the first in the list (that doesn't have
+ // 'diff' set and is in another tab page).
if (wip == NULL)
{
#ifdef FEAT_DIFF
@@ -2996,8 +2995,8 @@ get_winopts(buf_T *buf)
if (wip != NULL && wip->wi_win != NULL
&& wip->wi_win != curwin && wip->wi_win->w_buffer == buf)
{
- /* The buffer is currently displayed in the window: use the actual
- * option values instead of the saved (possibly outdated) values. */
+ // The buffer is currently displayed in the window: use the actual
+ // option values instead of the saved (possibly outdated) values.
win_T *wp = wip->wi_win;
copy_winopt(&wp->w_onebuf_opt, &curwin->w_onebuf_opt);
@@ -3009,7 +3008,7 @@ get_winopts(buf_T *buf)
}
else if (wip != NULL && wip->wi_optset)
{
- /* the buffer was displayed in the current window earlier */
+ // the buffer was displayed in the current window earlier
copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt);
#ifdef FEAT_FOLDING
curwin->w_fold_manual = wip->wi_fold_manual;
@@ -3021,7 +3020,7 @@ get_winopts(buf_T *buf)
copy_winopt(&curwin->w_allbuf_opt, &curwin->w_onebuf_opt);
#ifdef FEAT_FOLDING
- /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */
+ // Set 'foldlevel' to 'foldlevelstart' if it's not negative.
if (p_fdls >= 0)
curwin->w_p_fdl = p_fdls;
#endif
@@ -3103,7 +3102,7 @@ buflist_list(exarg_T *eap)
job_running = term_job_running(buf->b_term);
job_none_open = job_running && term_none_open(buf->b_term);
#endif
- /* skip unlisted buffers, unless ! was used */
+ // skip unlisted buffers, unless ! was used
if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u'))
|| (vim_strchr(eap->arg, 'u') && buf->b_p_bl)
|| (vim_strchr(eap->arg, '+')
@@ -3143,8 +3142,8 @@ buflist_list(exarg_T *eap)
ro_char = '?';
else
ro_char = 'R';
- changed_char = ' '; /* bufIsChanged() returns TRUE to avoid
- * closing, but it's not actually changed. */
+ changed_char = ' '; // bufIsChanged() returns TRUE to avoid
+ // closing, but it's not actually changed.
}
else if (buf->b_term != NULL)
ro_char = 'F';
@@ -3166,7 +3165,7 @@ buflist_list(exarg_T *eap)
if (len > IOSIZE - 20)
len = IOSIZE - 20;
- /* put "line 999" in column 40 or after the file name */
+ // put "line 999" in column 40 or after the file name
i = 40 - vim_strsize(IObuff);
do
IObuff[len++] = ' ';
@@ -3180,7 +3179,7 @@ buflist_list(exarg_T *eap)
_("line %ld"), buf == curbuf ? curwin->w_cursor.lnum
: (long)buflist_findlnum(buf));
msg_outtrans(IObuff);
- out_flush(); /* output one line at a time */
+ out_flush(); // output one line at a time
ui_breakcheck();
}
@@ -3226,7 +3225,7 @@ setfname(
buf_T *buf,
char_u *ffname_arg,
char_u *sfname_arg,
- int message) /* give message when buffer already exists */
+ int message) // give message when buffer already exists
{
char_u *ffname = ffname_arg;
char_u *sfname = sfname_arg;
@@ -3237,7 +3236,7 @@ setfname(
if (ffname == NULL || *ffname == NUL)
{
- /* Removing the name. */
+ // Removing the name.
if (buf->b_sfname != buf->b_ffname)
VIM_CLEAR(buf->b_sfname);
else
@@ -3249,8 +3248,8 @@ setfname(
}
else
{
- fname_expand(buf, &ffname, &sfname); /* will allocate ffname */
- if (ffname == NULL) /* out of memory */
+ fname_expand(buf, &ffname, &sfname); // will allocate ffname
+ if (ffname == NULL) // out of memory
return FAIL;
/*
@@ -3270,14 +3269,14 @@ setfname(
#endif
if (obuf != NULL && obuf != buf)
{
- if (obuf->b_ml.ml_mfp != NULL) /* it's loaded, fail */
+ if (obuf->b_ml.ml_mfp != NULL) // it's loaded, fail
{
if (message)
emsg(_("E95: Buffer with this name already exists"));
vim_free(ffname);
return FAIL;
}
- /* delete from the list */
+ // delete from the list
close_buffer(NULL, obuf, DOBUF_WIPE, FALSE);
}
sfname = vim_strsave(sfname);
@@ -3288,7 +3287,7 @@ setfname(
return FAIL;
}
#ifdef USE_FNAME_CASE
- fname_case(sfname, 0); /* set correct case for short file name */
+ fname_case(sfname, 0); // set correct case for short file name
#endif
if (buf->b_sfname != buf->b_ffname)
vim_free(buf->b_sfname);
@@ -3331,8 +3330,8 @@ buf_set_name(int fnum, char_u *name)
vim_free(buf->b_ffname);
buf->b_ffname = vim_strsave(name);
buf->b_sfname = NULL;
- /* Allocate ffname and expand into full path. Also resolves .lnk
- * files on Win32. */
+ // Allocate ffname and expand into full path. Also resolves .lnk
+ // files on Win32.
fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
buf->b_fname = buf->b_sfname;
}
@@ -3352,13 +3351,13 @@ buf_name_changed(buf_T *buf)
ml_setname(buf);
if (curwin->w_buffer == buf)
- check_arg_idx(curwin); /* check file name for arg list */
+ check_arg_idx(curwin); // check file name for arg list
#ifdef FEAT_TITLE
- maketitle(); /* set window title */
+ maketitle(); // set window title
#endif
- status_redraw_all(); /* status lines need to be redrawn */
- fmarks_check_names(buf); /* check named file marks */
- ml_timestamp(buf); /* reset timestamp */
+ status_redraw_all(); // status lines need to be redrawn
+ fmarks_check_names(buf); // check named file marks
+ ml_timestamp(buf); // reset timestamp
}
/*
@@ -3375,7 +3374,7 @@ setaltfname(
{
buf_T *buf;
- /* Create a buffer. 'buflisted' is not set if it's a new buffer */
+ // Create a buffer. 'buflisted' is not set if it's a new buffer
buf = buflist_new(ffname, sfname, lnum, 0);
if (buf != NULL && !cmdmod.keepalt)
curwin->w_alt_fnum = buf->b_fnum;
@@ -3388,7 +3387,7 @@ setaltfname(
*/
char_u *
getaltfname(
- int errmsg) /* give error message */
+ int errmsg) // give error message
{
char_u *fname;
linenr_T dummy;
@@ -3471,7 +3470,7 @@ otherfile_buf(
#endif
)
{
- /* no name is different */
+ // no name is different
if (ffname == NULL || *ffname == NUL || buf->b_ffname == NULL)
return TRUE;
if (fnamecmp(ffname, buf->b_ffname) == 0)
@@ -3480,22 +3479,22 @@ otherfile_buf(
{
stat_T st;
- /* If no stat_T given, get it now */
+ // If no stat_T given, get it now
if (stp == NULL)
{
if (!buf->b_dev_valid || mch_stat((char *)ffname, &st) < 0)
st.st_dev = (dev_T)-1;
stp = &st;
}
- /* Use dev/ino to check if the files are the same, even when the names
- * are different (possible with links). Still need to compare the
- * name above, for when the file doesn't exist yet.
- * Problem: The dev/ino changes when a file is deleted (and created
- * again) and remains the same when renamed/moved. We don't want to
- * mch_stat() each buffer each time, that would be too slow. Get the
- * dev/ino again when they appear to match, but not when they appear
- * to be different: Could skip a buffer when it's actually the same
- * file. */
+ // Use dev/ino to check if the files are the same, even when the names
+ // are different (possible with links). Still need to compare the
+ // name above, for when the file doesn't exist yet.
+ // Problem: The dev/ino changes when a file is deleted (and created
+ // again) and remains the same when renamed/moved. We don't want to
+ // mch_stat() each buffer each time, that would be too slow. Get the
+ // dev/ino again when they appear to match, but not when they appear
+ // to be different: Could skip a buffer when it's actually the same
+ // file.
if (buf_same_ino(buf, stp))
{
buf_setino(buf);
@@ -3546,7 +3545,7 @@ buf_same_ino(
*/
void
fileinfo(
- int fullname, /* when non-zero print full path */
+ int fullname, // when non-zero print full path
int shorthelp,
int dont_truncate)
{
@@ -3560,7 +3559,7 @@ fileinfo(
if (buffer == NULL)
return;
- if (fullname > 1) /* 2 CTRL-G: include buffer number */
+ if (fullname > 1) // 2 CTRL-G: include buffer number
{
vim_snprintf(buffer, IOSIZE, "buf %d: ", curbuf->b_fnum);
p = buffer + STRLEN(buffer);
@@ -3600,8 +3599,8 @@ fileinfo(
(curbufIsChanged() || (curbuf->b_flags & BF_WRITE_MASK)
|| curbuf->b_p_ro) ?
" " : "");
- /* With 32 bit longs and more than 21,474,836 lines multiplying by 100
- * causes an overflow, thus for large numbers divide instead. */
+ // With 32 bit longs and more than 21,474,836 lines multiplying by 100
+ // causes an overflow, thus for large numbers divide instead.
if (curwin->w_cursor.lnum > 1000000L)
n = (int)(((long)curwin->w_cursor.lnum) /
((long)curbuf->b_ml.ml_line_count / 100L));
@@ -3612,7 +3611,7 @@ fileinfo(
vim_snprintf_add(buffer, IOSIZE, "%s", _(no_lines_msg));
#ifdef FEAT_CMDL_INFO
else if (p_ru)
- /* Current line and column are already on the screen -- webb */
+ // Current line and column are already on the screen -- webb
vim_snprintf_add(buffer, IOSIZE,
NGETTEXT("%ld line --%d%%--", "%ld lines --%d%%--",
curbuf->b_ml.ml_line_count),
@@ -3636,8 +3635,8 @@ fileinfo(
if (dont_truncate)
{
- /* Temporarily set msg_scroll to avoid the message being truncated.
- * First call msg_start() to get the message in the right place. */
+ // Temporarily set msg_scroll to avoid the message being truncated.
+ // First call msg_start() to get the message in the right place.
msg_start();
n = msg_scroll;
msg_scroll = TRUE;
@@ -3648,11 +3647,11 @@ fileinfo(
{
p = (char *)msg_trunc_attr(buffer, FALSE, 0);
if (restart_edit != 0 || (msg_scrolled && !need_wait_return))
- /* Need to repeat the message after redrawing when:
- * - When restart_edit is set (otherwise there will be a delay
- * before redrawing).
- * - When the screen was scrolled but there is no wait-return
- * prompt. */
+ // Need to repeat the message after redrawing when:
+ // - When restart_edit is set (otherwise there will be a delay
+ // before redrawing).
+ // - When the screen was scrolled but there is no wait-return
+ // prompt.
set_keep_msg((char_u *)p, 0);
}
@@ -3693,7 +3692,7 @@ maketitle(void)
if (!redrawing())
{
- /* Postpone updating the title when 'lazyredraw' is set. */
+ // Postpone updating the title when 'lazyredraw' is set.
need_maketitle = TRUE;
return;
}
@@ -3738,11 +3737,11 @@ maketitle(void)
}
else
{
- /* format: "fname + (path) (1 of 2) - VIM" */
+ // format: "fname + (path) (1 of 2) - VIM"
#define SPACE_FOR_FNAME (IOSIZE - 100)
#define SPACE_FOR_DIR (IOSIZE - 20)
-#define SPACE_FOR_ARGNR (IOSIZE - 10) /* at least room for " - VIM" */
+#define SPACE_FOR_ARGNR (IOSIZE - 10) // at least room for " - VIM"
if (curbuf->b_fname == NULL)
vim_strncpy(buf, (char_u *)_("[No Name]"), SPACE_FOR_FNAME);
#ifdef FEAT_TERMINAL
@@ -3781,31 +3780,31 @@ maketitle(void)
#endif
)
{
- /* Get path of file, replace home dir with ~ */
+ // Get path of file, replace home dir with ~
off = (int)STRLEN(buf);
buf[off++] = ' ';
buf[off++] = '(';
home_replace(curbuf, curbuf->b_ffname,
buf + off, SPACE_FOR_DIR - off, TRUE);
#ifdef BACKSLASH_IN_FILENAME
- /* avoid "c:/name" to be reduced to "c" */
+ // avoid "c:/name" to be reduced to "c"
if (isalpha(buf[off]) && buf[off + 1] == ':')
off += 2;
#endif
- /* remove the file name */
+ // remove the file name
p = gettail_sep(buf + off);
if (p == buf + off)
{
- /* must be a help buffer */
+ // must be a help buffer
vim_strncpy(buf + off, (char_u *)_("help"),
(size_t)(SPACE_FOR_DIR - off - 1));
}
else
*p = NUL;
- /* Translate unprintable chars and concatenate. Keep some
- * room for the server name. When there is no room (very long
- * file name) use (...). */
+ // Translate unprintable chars and concatenate. Keep some
+ // room for the server name. When there is no room (very long
+ // file name) use (...).
if (off < SPACE_FOR_DIR)
{
p = transstr(buf + off);
@@ -3834,7 +3833,7 @@ maketitle(void)
if (maxlen > 0)
{
- /* make it shorter by removing a bit in the middle */
+ // make it shorter by removing a bit in the middle
if (vim_strsize(buf) > maxlen)
trunc_string(buf, buf, maxlen, IOSIZE);
}
@@ -3873,10 +3872,10 @@ maketitle(void)
{
if (buf_spname(curbuf) != NULL)
p = buf_spname(curbuf);
- else /* use file name only in icon */
+ else // use file name only in icon
p = gettail(curbuf->b_ffname);
*icon_str = NUL;
- /* Truncate name at 100 bytes. */
+ // Truncate name at 100 bytes.
len = (int)STRLEN(p);
if (len > 100)
{
@@ -3941,7 +3940,7 @@ free_titles(void)
}
# endif
-#endif /* FEAT_TITLE */
+#endif // FEAT_TITLE
#if defined(FEAT_STL_OPT) || defined(FEAT_GUI_TABLINE) || defined(PROTO)
/*
@@ -3961,14 +3960,14 @@ free_titles(void)
int
build_stl_str_hl(
win_T *wp,
- char_u *out, /* buffer to write into != NameBuff */
- size_t outlen, /* length of out[] */
+ char_u *out, // buffer to write into != NameBuff
+ size_t outlen, // length of out[]
char_u *fmt,
- int use_sandbox UNUSED, /* "fmt" was set insecurely, use sandbox */
+ int use_sandbox UNUSED, // "fmt" was set insecurely, use sandbox
int fillchar,
int maxwidth,
- struct stl_hlrec *hltab, /* return: HL attributes (can be NULL) */
- struct stl_hlrec *tabtab) /* return: tab page nrs (can be NULL) */
+ struct stl_hlrec *hltab, // return: HL attributes (can be NULL)
+ struct stl_hlrec *tabtab) // return: tab page nrs (can be NULL)
{
linenr_T lnum;
size_t len;
@@ -4050,7 +4049,7 @@ build_stl_str_hl(
if (fillchar == 0)
fillchar = ' ';
- /* Can't handle a multi-byte fill character yet. */
+ // Can't handle a multi-byte fill character yet.
else if (mb_char2len(fillchar) > 1)
fillchar = '-';
@@ -4091,8 +4090,8 @@ build_stl_str_hl(
{
if (curitem == STL_MAX_ITEM)
{
- /* There are too many items. Add the error code to the statusline
- * to give the user a hint about what went wrong. */
+ // There are too many items. Add the error code to the statusline
+ // to give the user a hint about what went wrong.
if (p + 6 < out + outlen)
{
mch_memmove(p, " E541", (size_t)5);
@@ -4116,7 +4115,7 @@ build_stl_str_hl(
* Handle one '%' item.
*/
s++;
- if (*s == NUL) /* ignore trailing % */
+ if (*s == NUL) // ignore trailing %
break;
if (*s == '%')
{
@@ -4155,8 +4154,8 @@ build_stl_str_hl(
if (curitem > groupitem[groupdepth] + 1
&& item[groupitem[groupdepth]].minwid == 0)
{
- /* remove group if all items are empty and highlight group
- * doesn't change */
+ // remove group if all items are empty and highlight group
+ // doesn't change
group_start_userhl = group_end_userhl = 0;
for (n = groupitem[groupdepth] - 1; n >= 0; n--)
{
@@ -4181,10 +4180,10 @@ build_stl_str_hl(
}
if (l > item[groupitem[groupdepth]].maxwid)
{
- /* truncate, remove n bytes of text at the start */
+ // truncate, remove n bytes of text at the start
if (has_mbyte)
{
- /* Find the first character that should be included. */
+ // Find the first character that should be included.
n = 0;
while (l >= item[groupitem[groupdepth]].maxwid)
{
@@ -4203,7 +4202,7 @@ build_stl_str_hl(
while (++l < item[groupitem[groupdepth]].minwid)
*p++ = fillchar;
- /* correct the start of the items for the truncation */
+ // correct the start of the items for the truncation
for (l = groupitem[groupdepth] + 1; l < curitem; l++)
{
item[l].start -= n;
@@ -4213,18 +4212,18 @@ build_stl_str_hl(
}
else if (abs(item[groupitem[groupdepth]].minwid) > l)
{
- /* fill */
+ // fill
n = item[groupitem[groupdepth]].minwid;
if (n < 0)
{
- /* fill by appending characters */
+ // fill by appending characters
n = 0 - n;
while (l++ < n && p + 1 < out + outlen)
*p++ = fillchar;
}
else
{
- /* fill by inserting characters */
+ // fill by inserting characters
mch_memmove(t + n - l, t, (size_t)(p - t));
l = n - l;
if (p + l >= out + outlen)
@@ -4255,7 +4254,7 @@ build_stl_str_hl(
if (VIM_ISDIGIT(*s))
{
minwid = (int)getdigits(&s);
- if (minwid < 0) /* overflow */
+ if (minwid < 0) // overflow
minwid = 0;
}
if (*s == STL_USER_HL)
@@ -4273,8 +4272,8 @@ build_stl_str_hl(
{
if (minwid == 0)
{
- /* %X ends the close label, go back to the previously
- * define tab label nr. */
+ // %X ends the close label, go back to the previously
+ // define tab label nr.
for (n = curitem - 1; n >= 0; --n)
if (item[n].type == TabPage && item[n].minwid >= 0)
{
@@ -4283,7 +4282,7 @@ build_stl_str_hl(
}
}
else
- /* close nrs are stored as negative values */
+ // close nrs are stored as negative values
minwid = - minwid;
}
item[curitem].type = TabPage;
@@ -4299,7 +4298,7 @@ build_stl_str_hl(
if (VIM_ISDIGIT(*s))
{
maxwid = (int)getdigits(&s);
- if (maxwid <= 0) /* overflow */
+ if (maxwid <= 0) // overflow
maxwid = 50;
}
}
@@ -4322,7 +4321,7 @@ build_stl_str_hl(
}
opt = *s++;
- /* OK - now for the real work */
+ // OK - now for the real work
base = 'D';
itemisflag = FALSE;
fillable = TRUE;
@@ -4333,7 +4332,7 @@ build_stl_str_hl(
case STL_FILEPATH:
case STL_FULLPATH:
case STL_FILENAME:
- fillable = FALSE; /* don't change ' ' to fillchar */
+ fillable = FALSE; // don't change ' ' to fillchar
if (buf_spname(wp->w_buffer) != NULL)
vim_strncpy(NameBuff, buf_spname(wp->w_buffer), MAXPATHL - 1);
else
@@ -4349,12 +4348,12 @@ build_stl_str_hl(
str = gettail(NameBuff);
break;
- case STL_VIM_EXPR: /* '{' */
+ case STL_VIM_EXPR: // '{'
itemisflag = TRUE;
t = p;
while (*s != '}' && *s != NUL && p + 1 < out + outlen)
*p++ = *s++;
- if (*s != '}') /* missing '}' or out of space */
+ if (*s != '}') // missing '}' or out of space
break;
s++;
*p = 0;
@@ -4412,7 +4411,7 @@ build_stl_str_hl(
case STL_VIRTCOL:
case STL_VIRTCOL_ALT:
- /* In list mode virtcol needs to be recomputed */
+ // In list mode virtcol needs to be recomputed
virtcol = wp->w_virtcol;
if (wp->w_p_list && lcs_tab1 == NUL)
{
@@ -4421,7 +4420,7 @@ build_stl_str_hl(
wp->w_p_list = TRUE;
}
++virtcol;
- /* Don't display %V if it's the same as %c. */
+ // Don't display %V if it's the same as %c.
if (opt == STL_VIRTCOL_ALT
&& (virtcol == (colnr_T)(!(State & INSERT) && empty_line
? 0 : (int)wp->w_cursor.col + 1)))
@@ -4465,7 +4464,7 @@ build_stl_str_hl(
case STL_OFFSET_X:
base = 'X';
- /* FALLTHROUGH */
+ // FALLTHROUGH
case STL_OFFSET:
#ifdef FEAT_BYTEOFF
l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL);
@@ -4477,7 +4476,7 @@ build_stl_str_hl(
case STL_BYTEVAL_X:
base = 'X';
- /* FALLTHROUGH */
+ // FALLTHROUGH
case STL_BYTEVAL:
num = byteval;
if (num == NL)
@@ -4607,7 +4606,7 @@ build_stl_str_hl(
{
for (; l < minwid && p + 1 < out + outlen; l++)
{
- /* Don't put a "-" in front of a digit. */
+ // Don't put a "-" in front of a digit.
if (l + 1 == minwid && fillchar == '-' && VIM_ISDIGIT(*t))
*p++ = ' ';
else
@@ -4620,8 +4619,8 @@ build_stl_str_hl(
while (*t && p + 1 < out + outlen)
{
*p++ = *t++;
- /* Change a space by fillchar, unless fillchar is '-' and a
- * digit follows. */
+ // Change a space by fillchar, unless fillchar is '-' and a
+ // digit follows.
if (fillable && p[-1] == ' '
&& (!VIM_ISDIGIT(*t) || fillchar != '-'))
p[-1] = fillchar;
@@ -4635,7 +4634,7 @@ build_stl_str_hl(
char_u nstr[20];
if (p + 20 >= out + outlen)
- break; /* not sufficient space */
+ break; // not sufficient space
prevchar_isitem = TRUE;
t = nstr;
if (opt == STL_VIRTCOL_ALT)
@@ -4679,7 +4678,7 @@ build_stl_str_hl(
vim_free(str);
if (num >= 0 || (!itemisflag && str && *str))
- prevchar_isflag = FALSE; /* Item not NULL, but not a flag */
+ prevchar_isflag = FALSE; // Item not NULL, but not a flag
curitem++;
}
*p = NUL;
@@ -4693,7 +4692,7 @@ build_stl_str_hl(
width = vim_strsize(out);
if (maxwidth > 0 && width > maxwidth)
{
- /* Result is too long, must truncate somewhere. */
+ // Result is too long, must truncate somewhere.
l = 0;
if (itemcnt == 0)
s = out;
@@ -4702,13 +4701,13 @@ build_stl_str_hl(
for ( ; l < itemcnt; l++)
if (item[l].type == Trunc)
{
- /* Truncate at %< item. */
+ // Truncate at %< item.
s = item[l].start;
break;
}
if (l == itemcnt)
{
- /* No %< item, truncate first item. */
+ // No %< item, truncate first item.
s = item[0].start;
l = 0;
}
@@ -4716,7 +4715,7 @@ build_stl_str_hl(
if (width - vim_strsize(s) >= maxwidth)
{
- /* Truncation mark is beyond max length */
+ // Truncation mark is beyond max length
if (has_mbyte)
{
s = out;
@@ -4728,7 +4727,7 @@ build_stl_str_hl(
break;
s += (*mb_ptr2len)(s);
}
- /* Fill up for half a double-wide character. */
+ // Fill up for half a double-wide character.
while (++width < maxwidth)
*s++ = fillchar;
}
@@ -4758,7 +4757,7 @@ build_stl_str_hl(
STRMOVE(s + 1, p);
*s = '<';
- /* Fill up for half a double-wide character. */
+ // Fill up for half a double-wide character.
while (++width < maxwidth)
{
s = s + STRLEN(s);
@@ -4766,7 +4765,7 @@ build_stl_str_hl(
*s = NUL;
}
- --n; /* count the '<' */
+ --n; // count the '<'
for (; l < itemcnt; l++)
{
if (item[l].start - n >= s)
@@ -4779,7 +4778,7 @@ build_stl_str_hl(
}
else if (width < maxwidth && STRLEN(out) + maxwidth - width + 1 < outlen)
{
- /* Apply STL_MIDDLE if any */
+ // Apply STL_MIDDLE if any
for (l = 0; l < itemcnt; l++)
if (item[l].type == Middle)
break;
@@ -4795,7 +4794,7 @@ build_stl_str_hl(
}
}
- /* Store the info about highlighting. */
+ // Store the info about highlighting.
if (hltab != NULL)
{
sp = hltab;
@@ -4812,7 +4811,7 @@ build_stl_str_hl(
sp->userhl = 0;
}
- /* Store the info about tab pages labels. */
+ // Store the info about tab pages labels.
if (tabtab != NULL)
{
sp = tabtab;
@@ -4829,8 +4828,8 @@ build_stl_str_hl(
sp->userhl = 0;
}
- /* When inside update_screen we do not want redrawing a stausline, ruler,
- * title, etc. to trigger another redraw, it may cause an endless loop. */
+ // When inside update_screen we do not want redrawing a stausline, ruler,
+ // title, etc. to trigger another redraw, it may cause an endless loop.
if (updating_screen)
{
must_redraw = save_must_redraw;
@@ -4839,7 +4838,7 @@ build_stl_str_hl(
return width;
}
-#endif /* FEAT_STL_OPT */
+#endif // FEAT_STL_OPT
#if defined(FEAT_STL_OPT) || defined(FEAT_CMDL_INFO) \
|| defined(FEAT_GUI_TABLINE) || defined(PROTO)
@@ -4853,18 +4852,18 @@ get_rel_pos(
char_u *buf,
int buflen)
{
- long above; /* number of lines above window */
- long below; /* number of lines below window */
+ long above; // number of lines above window
+ long below; // number of lines below window
- if (buflen < 3) /* need at least 3 chars for writing */
+ if (buflen < 3) // need at least 3 chars for writing
return;
above = wp->w_topline - 1;
#ifdef FEAT_DIFF
above += diff_check_fill(wp, wp->w_topline) - wp->w_topfill;
if (wp->w_topline == 1 && wp->w_topfill >= 1)
- above = 0; /* All buffer lines are displayed and there is an
- * indication of filler lines, that can be considered
- * seeing all lines. */
+ above = 0; // All buffer lines are displayed and there is an
+ // indication of filler lines, that can be considered
+ // seeing all lines.
#endif
below = wp->w_buffer->b_ml.ml_line_count - wp->w_botline + 1;
if (below <= 0)
@@ -4888,15 +4887,15 @@ append_arg_number(
win_T *wp,
char_u *buf,
int buflen,
- int add_file) /* Add "file" before the arg number */
+ int add_file) // Add "file" before the arg number
{
char_u *p;
- if (ARGCOUNT <= 1) /* nothing to do */
+ if (ARGCOUNT <= 1) // nothing to do
return FALSE;
- p = buf + STRLEN(buf); /* go to the end of the buffer */
- if (p - buf + 35 >= buflen) /* getting too long */
+ p = buf + STRLEN(buf); // go to the end of the buffer
+ if (p - buf + 35 >= buflen) // getting too long
return FALSE;
*p++ = ' ';
*p++ = '(';
@@ -4945,7 +4944,7 @@ fix_fname(char_u *fname)
# ifdef USE_FNAME_CASE
if (fname != NULL)
- fname_case(fname, 0); /* set correct case for file name */
+ fname_case(fname, 0); // set correct case for file name
# endif
return fname;
@@ -5001,15 +5000,15 @@ ex_buffer_all(exarg_T *eap)
int p_ea_save;
int open_wins = 0;
int r;
- int count; /* Maximum number of windows to open. */
- int all; /* When TRUE also load inactive buffers. */
+ int count; // Maximum number of windows to open.
+ int all; // When TRUE also load inactive buffers.
int had_tab = cmdmod.tab;
tabpage_T *tpnext;
- if (eap->addr_count == 0) /* make as many windows as possible */
+ if (eap->addr_count == 0) // make as many windows as possible
count = 9999;
else
- count = eap->line2; /* make as many windows as specified */
+ count = eap->line2; // make as many windows as specified
if (eap->cmdidx == CMD_unhide || eap->cmdidx == CMD_sunhide)
all = FALSE;
else
@@ -5042,16 +5041,16 @@ ex_buffer_all(exarg_T *eap)
&& !(wp->w_closing || wp->w_buffer->b_locked > 0))
{
win_close(wp, FALSE);
- wpnext = firstwin; /* just in case an autocommand does
- something strange with windows */
- tpnext = first_tabpage; /* start all over... */
+ wpnext = firstwin; // just in case an autocommand does
+ // something strange with windows
+ tpnext = first_tabpage; // start all over...
open_wins = 0;
}
else
++open_wins;
}
- /* Without the ":tab" modifier only do the current tab page. */
+ // Without the ":tab" modifier only do the current tab page.
if (had_tab == 0 || tpnext == NULL)
break;
goto_tabpage_tp(tpnext, TRUE, TRUE);
@@ -5062,31 +5061,31 @@ ex_buffer_all(exarg_T *eap)
* open one. Otherwise move the window to the right position.
* Watch out for autocommands that delete buffers or windows!
*/
- /* Don't execute Win/Buf Enter/Leave autocommands here. */
+ // Don't execute Win/Buf Enter/Leave autocommands here.
++autocmd_no_enter;
win_enter(lastwin, FALSE);
++autocmd_no_leave;
for (buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next)
{
- /* Check if this buffer needs a window */
+ // Check if this buffer needs a window
if ((!all && buf->b_ml.ml_mfp == NULL) || !buf->b_p_bl)
continue;
if (had_tab != 0)
{
- /* With the ":tab" modifier don't move the window. */
+ // With the ":tab" modifier don't move the window.
if (buf->b_nwindows > 0)
- wp = lastwin; /* buffer has a window, skip it */
+ wp = lastwin; // buffer has a window, skip it
else
wp = NULL;
}
else
{
- /* Check if this buffer already has a window */
+ // Check if this buffer already has a window
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer == buf)
break;
- /* If the buffer already has a window, move it */
+ // If the buffer already has a window, move it
if (wp != NULL)
win_move_after(wp, curwin);
}
@@ -5097,21 +5096,21 @@ ex_buffer_all(exarg_T *eap)
set_bufref(&bufref, buf);
- /* Split the window and put the buffer in it */
+ // Split the window and put the buffer in it
p_ea_save = p_ea;
- p_ea = TRUE; /* use space from all windows */
+ p_ea = TRUE; // use space from all windows
split_ret = win_split(0, WSP_ROOM | WSP_BELOW);
++open_wins;
p_ea = p_ea_save;
if (split_ret == FAIL)
continue;
- /* Open the buffer in this window. */
+ // Open the buffer in this window.
swap_exists_action = SEA_DIALOG;
set_curbuf(buf, DOBUF_GOTO);
if (!bufref_valid(&bufref))
{
- /* autocommands deleted the buffer!!! */
+ // autocommands deleted the buffer!!!
swap_exists_action = SEA_NONE;
break;
}
@@ -5120,21 +5119,21 @@ ex_buffer_all(exarg_T *eap)
#if defined(FEAT_EVAL)
cleanup_T cs;
- /* Reset the error/interrupt/exception state here so that
- * aborting() returns FALSE when closing a window. */
+ // Reset the error/interrupt/exception state here so that
+ // aborting() returns FALSE when closing a window.
enter_cleanup(&cs);
#endif
- /* User selected Quit at ATTENTION prompt; close this window. */
+ // User selected Quit at ATTENTION prompt; close this window.
win_close(curwin, TRUE);
--open_wins;
swap_exists_action = SEA_NONE;
swap_exists_did_quit = TRUE;
#if defined(FEAT_EVAL)
- /* Restore the error/interrupt/exception state if not
- * discarded by a new aborting error, interrupt, or uncaught
- * exception. */
+ // Restore the error/interrupt/exception state if not
+ // discarded by a new aborting error, interrupt, or uncaught
+ // exception.
leave_cleanup(&cs);
#endif
}
@@ -5145,20 +5144,20 @@ ex_buffer_all(exarg_T *eap)
ui_breakcheck();
if (got_int)
{
- (void)vgetc(); /* only break the file loading, not the rest */
+ (void)vgetc(); // only break the file loading, not the rest
break;
}
#ifdef FEAT_EVAL
- /* Autocommands deleted the buffer or aborted script processing!!! */
+ // Autocommands deleted the buffer or aborted script processing!!!
if (aborting())
break;
#endif
- /* When ":tab" was used open a new tab for a new window repeatedly. */
+ // When ":tab" was used open a new tab for a new window repeatedly.
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm)
cmdmod.tab = 9999;
}
--autocmd_no_enter;
- win_enter(firstwin, FALSE); /* back to first window */
+ win_enter(firstwin, FALSE); // back to first window
--autocmd_no_leave;
/*
@@ -5170,7 +5169,7 @@ ex_buffer_all(exarg_T *eap)
|| autowrite(wp->w_buffer, FALSE) == OK);
if (!win_valid(wp))
{
- /* BufWrite Autocommands made the window invalid, start over */
+ // BufWrite Autocommands made the window invalid, start over
wp = lastwin;
}
else if (r)
@@ -5210,8 +5209,8 @@ do_modelines(int flags)
if (!curbuf->b_p_ml || (nmlines = (int)p_mls) == 0)
return;
- /* Disallow recursive entry here. Can happen when executing a modeline
- * triggers an autocommand, which reloads modelines with a ":do". */
+ // Disallow recursive entry here. Can happen when executing a modeline
+ // triggers an autocommand, which reloads modelines with a ":do".
if (entered)
return;
@@ -5228,7 +5227,7 @@ do_modelines(int flags)
--entered;
}
-#include "version.h" /* for version number */
+#include "version.h" // for version number
/*
* chk_modeline() - check a single line for a mode string
@@ -5237,11 +5236,11 @@ do_modelines(int flags)
static int
chk_modeline(
linenr_T lnum,
- int flags) /* Same as for do_modelines(). */
+ int flags) // Same as for do_modelines().
{
char_u *s;
char_u *e;
- char_u *linecopy; /* local copy of any modeline found */
+ char_u *linecopy; // local copy of any modeline found
int prev;
int vers;
int end;
@@ -5260,7 +5259,7 @@ chk_modeline(
if ((prev != -1 && STRNCMP(s, "ex:", (size_t)3) == 0)
|| STRNCMP(s, "vi:", (size_t)3) == 0)
break;
- /* Accept both "vim" and "Vim". */
+ // Accept both "vim" and "Vim".
if ((s[0] == 'v' || s[0] == 'V') && s[1] == 'i' && s[2] == 'm')
{
if (s[3] == '<' || s[3] == '=' || s[3] == '>')
@@ -5284,17 +5283,17 @@ chk_modeline(
if (*s)
{
- do /* skip over "ex:", "vi:" or "vim:" */
+ do // skip over "ex:", "vi:" or "vim:"
++s;
while (s[-1] != ':');
- s = linecopy = vim_strsave(s); /* copy the line, it will change */
+ s = linecopy = vim_strsave(s); // copy the line, it will change
if (linecopy == NULL)
return FAIL;
save_sourcing_lnum = sourcing_lnum;
save_sourcing_name = sourcing_name;
- sourcing_lnum = lnum; /* prepare for emsg() */
+ sourcing_lnum = lnum; // prepare for emsg()
sourcing_name = (char_u *)"modelines";
end = FALSE;
@@ -5324,14 +5323,14 @@ chk_modeline(
if (STRNCMP(s, "set ", (size_t)4) == 0
|| STRNCMP(s, "se ", (size_t)3) == 0)
{
- if (*e != ':') /* no terminating ':'? */
+ if (*e != ':') // no terminating ':'?
break;
end = TRUE;
s = vim_strchr(s, ' ') + 1;
}
- *e = NUL; /* truncate the set command */
+ *e = NUL; // truncate the set command
- if (*s != NUL) /* skip over an empty "::" */
+ if (*s != NUL) // skip over an empty "::"
{
int secure_save = secure;
#ifdef FEAT_EVAL
@@ -5350,10 +5349,10 @@ chk_modeline(
#ifdef FEAT_EVAL
current_sctx = save_current_sctx;
#endif
- if (retval == FAIL) /* stop if error found */
+ if (retval == FAIL) // stop if error found
break;
}
- s = e + 1; /* advance to next part */
+ s = e + 1; // advance to next part
}
sourcing_lnum = save_sourcing_lnum;
@@ -5477,13 +5476,13 @@ bt_dontwrite_msg(buf_T *buf)
int
buf_hide(buf_T *buf)
{
- /* 'bufhidden' overrules 'hidden' and ":hide", check it first */
+ // 'bufhidden' overrules 'hidden' and ":hide", check it first
switch (buf->b_p_bh[0])
{
- case 'u': /* "unload" */
- case 'w': /* "wipe" */
- case 'd': return FALSE; /* "delete" */
- case 'h': return TRUE; /* "hide" */
+ case 'u': // "unload"
+ case 'w': // "wipe"
+ case 'd': return FALSE; // "delete"
+ case 'h': return TRUE; // "hide"
}
return (p_hid || cmdmod.hide);
}
@@ -5509,8 +5508,8 @@ buf_spname(buf_T *buf)
}
#endif
- /* There is no _file_ when 'buftype' is "nofile", b_sfname
- * contains the name as specified by the user. */
+ // There is no _file_ when 'buftype' is "nofile", b_sfname
+ // contains the name as specified by the user.
if (bt_nofilename(buf))
{
#ifdef FEAT_TERMINAL
@@ -5564,19 +5563,19 @@ buf_contents_changed(buf_T *buf)
aco_save_T aco;
exarg_T ea;
- /* Allocate a buffer without putting it in the buffer list. */
+ // Allocate a buffer without putting it in the buffer list.
newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
if (newbuf == NULL)
return TRUE;
- /* Force the 'fileencoding' and 'fileformat' to be equal. */
+ // Force the 'fileencoding' and 'fileformat' to be equal.
if (prep_exarg(&ea, buf) == FAIL)
{
wipe_buffer(newbuf, FALSE);
return TRUE;
}
- /* set curwin/curbuf to buf and save a few things */
+ // set curwin/curbuf to buf and save a few things
aucmd_prepbuf(&aco, newbuf);
if (ml_open(curbuf) == OK
@@ -5584,7 +5583,7 @@ buf_contents_changed(buf_T *buf)
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
&ea, READ_NEW | READ_DUMMY) == OK)
{
- /* compare the two files line by line */
+ // compare the two files line by line
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count)
{
differ = FALSE;
@@ -5598,10 +5597,10 @@ buf_contents_changed(buf_T *buf)
}
vim_free(ea.cmd);
- /* restore curwin/curbuf and a few other things */
+ // restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
- if (curbuf != newbuf) /* safety check */
+ if (curbuf != newbuf) // safety check
wipe_buffer(newbuf, FALSE);
return differ;
@@ -5615,12 +5614,12 @@ buf_contents_changed(buf_T *buf)
void
wipe_buffer(
buf_T *buf,
- int aucmd UNUSED) /* When TRUE trigger autocommands. */
+ int aucmd UNUSED) // When TRUE trigger autocommands.
{
if (buf->b_fnum == top_file_num - 1)
--top_file_num;
- if (!aucmd) /* Don't trigger BufDelete autocommands here. */
+ if (!aucmd) // Don't trigger BufDelete autocommands here.
block_autocmds();
close_buffer(NULL, buf, DOBUF_WIPE, FALSE);
diff --git a/src/change.c b/src/change.c
index b4349c675..d0462dbe1 100644
--- a/src/change.c
+++ b/src/change.c
@@ -878,7 +878,7 @@ save_file_ff(buf_T *buf)
buf->b_start_eol = buf->b_p_eol;
buf->b_start_bomb = buf->b_p_bomb;
- /* Only use free/alloc when necessary, they take time. */
+ // Only use free/alloc when necessary, they take time.
if (buf->b_start_fenc == NULL
|| STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
{
@@ -899,7 +899,7 @@ save_file_ff(buf_T *buf)
int
file_ff_differs(buf_T *buf, int ignore_empty)
{
- /* In a buffer that was never loaded the options are not valid. */
+ // In a buffer that was never loaded the options are not valid.
if (buf->b_flags & BF_NEVERLOADED)
return FALSE;
if (ignore_empty
@@ -1371,7 +1371,7 @@ open_line(
// make a copy of the current line so we can mess with it
saved_line = vim_strsave(ml_get_curline());
- if (saved_line == NULL) /* out of memory! */
+ if (saved_line == NULL) // out of memory!
return FALSE;
if (State & VREPLACE_FLAG)
@@ -1646,7 +1646,7 @@ open_line(
}
// Isolate the strings of the middle and end leader.
- while (*p && p[-1] != ':') /* find end of middle flags */
+ while (*p && p[-1] != ':') // find end of middle flags
{
if (*p == COM_BLANK)
require_blank = TRUE;
@@ -2008,7 +2008,7 @@ open_line(
// When in REPLACE mode, put the deleted blanks on the replace stack,
// preceded by a NUL, so they can be put back when a BS is entered.
if (REPLACE_NORMAL(State))
- replace_push(NUL); /* end of extra blanks */
+ replace_push(NUL); // end of extra blanks
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES))
{
while ((*p_extra == ' ' || *p_extra == '\t')
@@ -2090,7 +2090,7 @@ open_line(
{
// In case we NL to a new line, BS to the previous one, and NL
// again, we don't want to save the new line for undo twice.
- (void)u_save_cursor(); /* errors are ignored! */
+ (void)u_save_cursor(); // errors are ignored!
vr_lines_changed++;
}
ml_replace(curwin->w_cursor.lnum, p_extra, TRUE);
diff --git a/src/channel.c b/src/channel.c
index 0ac971876..7edca1a19 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -14,15 +14,15 @@
#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
-/* TRUE when netbeans is running with a GUI. */
+// TRUE when netbeans is running with a GUI.
#ifdef FEAT_GUI
# define CH_HAS_GUI (gui.in_use || gui.starting)
#endif
-/* Note: when making changes here also adjust configure.ac. */
+// Note: when making changes here also adjust configure.ac.
#ifdef MSWIN
-/* WinSock API is separated from C API, thus we can't use read(), write(),
- * errno... */
+// WinSock API is separated from C API, thus we can't use read(), write(),
+// errno...
# define SOCK_ERRNO errno = WSAGetLastError()
# undef ECONNREFUSED
# define ECONNREFUSED WSAECONNREFUSED
@@ -61,11 +61,11 @@ static ch_part_T channel_part_send(channel_T *channel);
static ch_part_T channel_part_read(channel_T *channel);
static void free_job_options(jobopt_T *opt);
-/* Whether a redraw is needed for appending a line to a buffer. */
+// Whether a redraw is needed for appending a line to a buffer.
static int channel_need_redraw = FALSE;
-/* Whether we are inside channel_parse_messages() or another situation where it
- * is safe to invoke callbacks. */
+// Whether we are inside channel_parse_messages() or another situation where it
+// is safe to invoke callbacks.
static int safe_to_invoke_callback = 0;
static char *part_names[] = {"sock", "out", "err", "in"};
@@ -129,7 +129,7 @@ fd_close(sock_T fd)
}
#endif
-/* Log file opened with ch_logfile(). */
+// Log file opened with ch_logfile().
static FILE *log_fd = NULL;
#ifdef FEAT_RELTIME
static proftime_T log_start;
@@ -269,7 +269,7 @@ strerror_win32(int eno)
0,
NULL);
if (msgbuf != NULL)
- /* chomp \r or \n */
+ // chomp \r or \n
for (ptr = (char_u *)msgbuf; *ptr; ptr++)
switch (*ptr)
{
@@ -352,20 +352,20 @@ channel_still_useful(channel_T *channel)
int has_out_msg;
int has_err_msg;
- /* If the job was killed the channel is not expected to work anymore. */
+ // If the job was killed the channel is not expected to work anymore.
if (channel->ch_job_killed && channel->ch_job == NULL)
return FALSE;
- /* If there is a close callback it may still need to be invoked. */
+ // If there is a close callback it may still need to be invoked.
if (channel->ch_close_cb.cb_name != NULL)
return TRUE;
- /* If reading from or a buffer it's still useful. */
+ // If reading from or a buffer it's still useful.
if (channel->ch_part[PART_IN].ch_bufref.br_buf != NULL)
return TRUE;
- /* If there is no callback then nobody can get readahead. If the fd is
- * closed and there is no readahead then the callback won't be called. */
+ // If there is no callback then nobody can get readahead. If the fd is
+ // closed and there is no readahead then the callback won't be called.
has_sock_msg = channel->ch_part[PART_SOCK].ch_fd != INVALID_FD
|| channel->ch_part[PART_SOCK].ch_head.rq_next != NULL
|| channel->ch_part[PART_SOCK].ch_json_head.jq_next != NULL;
@@ -468,16 +468,16 @@ free_unused_channels_contents(int copyID, int mask)
int did_free = FALSE;
channel_T *ch;
- /* This is invoked from the garbage collector, which only runs at a safe
- * point. */
+ // This is invoked from the garbage collector, which only runs at a safe
+ // point.
++safe_to_invoke_callback;
for (ch = first_channel; ch != NULL; ch = ch->ch_next)
if (!channel_still_useful(ch)
&& (ch->ch_copyID & mask) != (copyID & mask))
{
- /* Free the channel and ordinary items it contains, but don't
- * recurse into Lists, Dictionaries etc. */
+ // Free the channel and ordinary items it contains, but don't
+ // recurse into Lists, Dictionaries etc.
channel_free_contents(ch);
did_free = TRUE;
}
@@ -498,7 +498,7 @@ free_unused_channels(int copyID, int mask)
if (!channel_still_useful(ch)
&& (ch->ch_copyID & mask) != (copyID & mask))
{
- /* Free the channel struct itself. */
+ // Free the channel struct itself.
channel_free_channel(ch);
}
}
@@ -566,8 +566,8 @@ messageFromServerGtk3(GIOChannel *unused1 UNUSED,
gpointer clientData)
{
channel_read_fd(GPOINTER_TO_INT(clientData));
- return TRUE; /* Return FALSE instead in case the event source is to
- * be removed after this function returns. */
+ return TRUE; // Return FALSE instead in case the event source is to
+ // be removed after this function returns.
}
# else
static void
@@ -586,13 +586,13 @@ channel_gui_register_one(channel_T *channel, ch_part_T part UNUSED)
if (!CH_HAS_GUI)
return;
- /* gets stuck in handling events for a not connected channel */
+ // gets stuck in handling events for a not connected channel
if (channel->ch_keep_open)
return;
# ifdef FEAT_GUI_X11
- /* Tell notifier we are interested in being called when there is input on
- * the editor connection socket. */
+ // Tell notifier we are interested in being called when there is input on
+ // the editor connection socket.
if (channel->ch_part[part].ch_inputHandler == (XtInputId)NULL)
{
ch_log(channel, "Registering part %s with fd %d",
@@ -607,8 +607,8 @@ channel_gui_register_one(channel_T *channel, ch_part_T part UNUSED)
}
# else
# ifdef FEAT_GUI_GTK
- /* Tell gdk we are interested in being called when there is input on the
- * editor connection socket. */
+ // Tell gdk we are interested in being called when there is input on the
+ // editor connection socket.
if (channel->ch_part[part].ch_inputHandler == 0)
{
ch_log(channel, "Registering part %s with fd %d",
@@ -740,8 +740,8 @@ channel_open(
return NULL;
}
- /* Get the server internet address and put into addr structure */
- /* fill in the socket address structure and connect to server */
+ // Get the server internet address and put into addr structure
+ // fill in the socket address structure and connect to server
vim_memset((char *)&server, 0, sizeof(server));
server.sin_family = AF_INET;
server.sin_port = htons(port);
@@ -755,15 +755,15 @@ channel_open(
{
char *p;
- /* When using host->h_addr_list[0] directly ubsan warns for it to not
- * be aligned. First copy the pointer to avoid that. */
+ // When using host->h_addr_list[0] directly ubsan warns for it to not
+ // be aligned. First copy the pointer to avoid that.
memcpy(&p, &host->h_addr_list[0], sizeof(p));
memcpy((char *)&server.sin_addr, p, host->h_length);
}
- /* On Mac and Solaris a zero timeout almost never works. At least wait
- * one millisecond. Let's do it for all systems, because we don't know why
- * this is needed. */
+ // On Mac and Solaris a zero timeout almost never works. At least wait
+ // one millisecond. Let's do it for all systems, because we don't know why
+ // this is needed.
if (waittime == 0)
waittime = 1;
@@ -789,7 +789,7 @@ channel_open(
if (waittime >= 0)
{
- /* Make connect() non-blocking. */
+ // Make connect() non-blocking.
if (
#ifdef MSWIN
ioctlsocket(sd, FIONBIO, &val) < 0
@@ -807,12 +807,12 @@ channel_open(
}
}
- /* Try connecting to the server. */
+ // Try connecting to the server.
ch_log(channel, "Connecting to %s port %d", hostname, port);
ret = connect(sd, (struct sockaddr *)&server, sizeof(server));
if (ret == 0)
- /* The connection could be established. */
+ // The connection could be established.
break;
SOCK_ERRNO;
@@ -831,12 +831,12 @@ channel_open(
return NULL;
}
- /* Limit the waittime to 50 msec. If it doesn't work within this
- * time we close the socket and try creating it again. */
+ // Limit the waittime to 50 msec. If it doesn't work within this
+ // time we close the socket and try creating it again.
waitnow = waittime > 50 ? 50 : waittime;
- /* If connect() didn't finish then try using select() to wait for the
- * connection to be made. For Win32 always use select() to wait. */
+ // If connect() didn't finish then try using select() to wait for the
+ // connection to be made. For Win32 always use select() to wait.
#ifndef MSWIN
if (errno != ECONNREFUSED)
#endif
@@ -876,8 +876,8 @@ channel_open(
}
#ifdef MSWIN
- /* On Win32: select() is expected to work and wait for up to
- * "waitnow" msec for the socket to be open. */
+ // On Win32: select() is expected to work and wait for up to
+ // "waitnow" msec for the socket to be open.
if (FD_ISSET(sd, &wfds))
break;
elapsed_msec = waitnow;
@@ -887,13 +887,13 @@ channel_open(
continue;
}
#else
- /* On Linux-like systems: See socket(7) for the behavior
- * After putting the socket in non-blocking mode, connect() will
- * return EINPROGRESS, select() will not wait (as if writing is
- * possible), need to use getsockopt() to check if the socket is
- * actually able to connect.
- * We detect a failure to connect when either read and write fds
- * are set. Use getsockopt() to find out what kind of failure. */
+ // On Linux-like systems: See socket(7) for the behavior
+ // After putting the socket in non-blocking mode, connect() will
+ // return EINPROGRESS, select() will not wait (as if writing is
+ // possible), need to use getsockopt() to check if the socket is
+ // actually able to connect.
+ // We detect a failure to connect when either read and write fds
+ // are set. Use getsockopt() to find out what kind of failure.
if (FD_ISSET(sd, &rfds) || FD_ISSET(sd, &wfds))
{
ret = getsockopt(sd,
@@ -917,7 +917,7 @@ channel_open(
}
if (FD_ISSET(sd, &wfds) && so_error == 0)
- /* Did not detect an error, connection is established. */
+ // Did not detect an error, connection is established.
break;
gettimeofday(&end_tv, NULL);
@@ -929,10 +929,10 @@ channel_open(
#ifndef MSWIN
if (waittime > 1 && elapsed_msec < waittime)
{
- /* The port isn't ready but we also didn't get an error.
- * This happens when the server didn't open the socket
- * yet. Select() may return early, wait until the remaining
- * "waitnow" and try again. */
+ // The port isn't ready but we also didn't get an error.
+ // This happens when the server didn't open the socket
+ // yet. Select() may return early, wait until the remaining
+ // "waitnow" and try again.
waitnow -= elapsed_msec;
waittime -= elapsed_msec;
if (waitnow > 0)
@@ -944,15 +944,15 @@ channel_open(
if (!got_int)
{
if (waittime <= 0)
- /* give it one more try */
+ // give it one more try
waittime = 1;
continue;
}
- /* we were interrupted, behave as if timed out */
+ // we were interrupted, behave as if timed out
}
#endif
- /* We timed out. */
+ // We timed out.
ch_error(channel, "Connection timed out");
sock_close(sd);
channel_free(channel);
@@ -1115,7 +1115,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
{
buf_T *buf;
- /* writing output to a buffer. Default mode is NL. */
+ // writing output to a buffer. Default mode is NL.
if (!(opt->jo_set & JO_OUT_MODE))
channel->ch_part[PART_OUT].ch_mode = MODE_NL;
if (opt->jo_set & JO_OUT_BUF)
@@ -1160,7 +1160,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
{
buf_T *buf;
- /* writing err to a buffer. Default mode is NL. */
+ // writing err to a buffer. Default mode is NL.
if (!(opt->jo_set & JO_ERR_MODE))
channel->ch_part[PART_ERR].ch_mode = MODE_NL;
if (opt->jo_io[PART_ERR] == JIO_OUT)
@@ -1226,7 +1226,7 @@ channel_open_func(typval_T *argvars)
return NULL;
}
- /* parse address */
+ // parse address
p = vim_strchr(address, ':');
if (p == NULL)
{
@@ -1242,7 +1242,7 @@ channel_open_func(typval_T *argvars)
return NULL;
}
- /* parse options */
+ // parse options
clear_job_options(&opt);
opt.jo_mode = MODE_JSON;
opt.jo_timeout = 2000;
@@ -1277,8 +1277,8 @@ ch_close_part(channel_T *channel, ch_part_T part)
sock_close(*fd);
else
{
- /* When using a pty the same FD is set on multiple parts, only
- * close it when the last reference is closed. */
+ // When using a pty the same FD is set on multiple parts, only
+ // close it when the last reference is closed.
if ((part == PART_IN || channel->CH_IN_FD != *fd)
&& (part == PART_OUT || channel->CH_OUT_FD != *fd)
&& (part == PART_ERR || channel->CH_ERR_FD != *fd))
@@ -1292,7 +1292,7 @@ ch_close_part(channel_T *channel, ch_part_T part)
}
*fd = INVALID_FD;
- /* channel is closed, may want to end the job if it was the last */
+ // channel is closed, may want to end the job if it was the last
channel->ch_to_be_closed &= ~(1U << part);
}
}
@@ -1305,8 +1305,8 @@ channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err)
ch_close_part(channel, PART_IN);
channel->CH_IN_FD = in;
# if defined(UNIX)
- /* Do not end the job when all output channels are closed, wait until
- * the job ended. */
+ // Do not end the job when all output channels are closed, wait until
+ // the job ended.
if (mch_isatty(in))
channel->ch_to_be_closed |= (1U << PART_IN);
# endif
@@ -1359,8 +1359,8 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *options)
{
if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT))
{
- /* Special mode: send last-but-one line when appending a line
- * to the buffer. */
+ // Special mode: send last-but-one line when appending a line
+ // to the buffer.
in_part->ch_bufref.br_buf->b_write_to_channel = TRUE;
in_part->ch_buf_append = TRUE;
in_part->ch_buf_top =
@@ -1413,7 +1413,7 @@ write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel)
char_u *p;
int i;
- /* Need to make a copy to be able to append a NL. */
+ // Need to make a copy to be able to append a NL.
if ((p = alloc(len + 2)) == NULL)
return;
memcpy((char *)p, (char *)line, len);
@@ -1443,15 +1443,15 @@ can_write_buf_line(channel_T *channel)
chanpart_T *in_part = &channel->ch_part[PART_IN];
if (in_part->ch_fd == INVALID_FD)
- return FALSE; /* pipe was closed */
+ return FALSE; // pipe was closed
- /* for testing: block every other attempt to write */
+ // for testing: block every other attempt to write
if (in_part->ch_block_write == 1)
in_part->ch_block_write = -1;
else if (in_part->ch_block_write == -1)
in_part->ch_block_write = 1;
- /* TODO: Win32 implementation, probably using WaitForMultipleObjects() */
+ // TODO: Win32 implementation, probably using WaitForMultipleObjects()
#ifndef MSWIN
{
# if defined(HAVE_SELECT)
@@ -1514,10 +1514,10 @@ channel_write_in(channel_T *channel)
int written = 0;
if (buf == NULL || in_part->ch_buf_append)
- return; /* no buffer or using appending */
+ return; // no buffer or using appending
if (!bufref_valid(&in_part->ch_bufref) || buf->b_ml.ml_mfp == NULL)
{
- /* buffer was wiped out or unloaded */
+ // buffer was wiped out or unloaded
ch_log(channel, "input buffer has been wiped out");
in_part->ch_bufref.br_buf = NULL;
return;
@@ -1541,16 +1541,16 @@ channel_write_in(channel_T *channel)
if (lnum > buf->b_ml.ml_line_count || lnum > in_part->ch_buf_bot)
{
#if defined(FEAT_TERMINAL)
- /* Send CTRL-D or "eof_chars" to close stdin on MS-Windows. */
+ // Send CTRL-D or "eof_chars" to close stdin on MS-Windows.
if (channel->ch_job != NULL)
term_send_eof(channel);
#endif
- /* Writing is done, no longer need the buffer. */
+ // Writing is done, no longer need the buffer.
in_part->ch_bufref.br_buf = NULL;
ch_log(channel, "Finished writing all lines to channel");
- /* Close the pipe/socket, so that the other side gets EOF. */
+ // Close the pipe/socket, so that the other side gets EOF.
ch_close_part(channel, PART_IN);
}
else
@@ -1621,8 +1621,8 @@ channel_write_new_lines(buf_T *buf)
channel_T *channel;
int found_one = FALSE;
- /* There could be more than one channel for the buffer, loop over all of
- * them. */
+ // There could be more than one channel for the buffer, loop over all of
+ // them.
for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
chanpart_T *in_part = &channel->ch_part[PART_IN];
@@ -1632,7 +1632,7 @@ channel_write_new_lines(buf_T *buf)
if (in_part->ch_bufref.br_buf == buf && in_part->ch_buf_append)
{
if (in_part->ch_fd == INVALID_FD)
- continue; /* pipe was closed */
+ continue; // pipe was closed
found_one = TRUE;
for (lnum = in_part->ch_buf_bot; lnum < buf->b_ml.ml_line_count;
++lnum)
@@ -1723,7 +1723,7 @@ channel_get(channel_T *channel, ch_part_T part, int *outlen)
return NULL;
if (outlen != NULL)
*outlen += node->rq_buflen;
- /* dispose of the node but keep the buffer */
+ // dispose of the node but keep the buffer
p = node->rq_buffer;
head->rq_next = node->rq_next;
if (node->rq_next == NULL)
@@ -1853,7 +1853,7 @@ channel_collapse(channel_T *channel, ch_part_T part, int want_nl)
p = newbuf = alloc(len + 1);
if (newbuf == NULL)
- return FAIL; /* out of memory */
+ return FAIL; // out of memory
mch_memmove(p, node->rq_buffer, node->rq_buflen);
p += node->rq_buflen;
vim_free(node->rq_buffer);
@@ -1868,7 +1868,7 @@ channel_collapse(channel_T *channel, ch_part_T part, int want_nl)
*p = NUL;
node->rq_buflen = (long_u)(p - newbuf);
- /* dispose of the collapsed nodes and their buffers */
+ // dispose of the collapsed nodes and their buffers
for (n = node->rq_next; n != last_node; )
{
n = n->rq_next;
@@ -1899,19 +1899,19 @@ channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len,
node = ALLOC_ONE(readq_T);
if (node == NULL)
- return FAIL; /* out of memory */
- /* A NUL is added at the end, because netbeans code expects that.
- * Otherwise a NUL may appear inside the text. */
+ return FAIL; // out of memory
+ // A NUL is added at the end, because netbeans code expects that.
+ // Otherwise a NUL may appear inside the text.
node->rq_buffer = alloc(len + 1);
if (node->rq_buffer == NULL)
{
vim_free(node);
- return FAIL; /* out of memory */
+ return FAIL; // out of memory
}
if (channel->ch_part[part].ch_mode == MODE_NL)
{
- /* Drop any CR before a NL. */
+ // Drop any CR before a NL.
p = node->rq_buffer;
for (i = 0; i < len; ++i)
if (buf[i] != CAR || i + 1 >= len || buf[i + 1] != NL)
@@ -1979,7 +1979,7 @@ channel_fill(js_read_T *reader)
keeplen = reader->js_end - reader->js_buf;
if (keeplen > 0)
{
- /* Prepend unused text. */
+ // Prepend unused text.
addlen = (int)STRLEN(next);
p = alloc(keeplen + addlen + 1);
if (p == NULL)
@@ -2023,18 +2023,18 @@ channel_parse_json(channel_T *channel, ch_part_T part)
reader.js_cookie = channel;
reader.js_cookie_arg = part;
- /* When a message is incomplete we wait for a short while for more to
- * arrive. After the delay drop the input, otherwise a truncated string
- * or list will make us hang.
- * Do not generate error messages, they will be written in a channel log. */
+ // When a message is incomplete we wait for a short while for more to
+ // arrive. After the delay drop the input, otherwise a truncated string
+ // or list will make us hang.
+ // Do not generate error messages, they will be written in a channel log.
++emsg_silent;
status = json_decode(&reader, &listtv,
chanpart->ch_mode == MODE_JS ? JSON_JS : 0);
--emsg_silent;
if (status == OK)
{
- /* Only accept the response when it is a list with at least two
- * items. */
+ // Only accept the response when it is a list with at least two
+ // items.
if (listtv.v_type != VAR_LIST || listtv.vval.v_list->lv_len < 2)
{
if (listtv.v_type != VAR_LIST)
@@ -2081,8 +2081,8 @@ channel_parse_json(channel_T *channel, ch_part_T part)
if (chanpart->ch_wait_len < buflen)
{
- /* First time encountering incomplete message or after receiving
- * more (but still incomplete): set a deadline of 100 msec. */
+ // First time encountering incomplete message or after receiving
+ // more (but still incomplete): set a deadline of 100 msec.
ch_log(channel,
"Incomplete message (%d bytes) - wait 100 msec for more",
(int)buflen);
@@ -2137,7 +2137,7 @@ channel_parse_json(channel_T *channel, ch_part_T part)
}
else if (reader.js_buf[reader.js_used] != NUL)
{
- /* Put the unread part back into the channel. */
+ // Put the unread part back into the channel.
channel_save(channel, part, reader.js_buf + reader.js_used,
(int)(reader.js_end - reader.js_buf) - reader.js_used,
TRUE, NULL);
@@ -2296,10 +2296,10 @@ channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv)
jsonq_T *newitem;
if (head->jq_prev != NULL && head->jq_prev->jq_no_callback)
- /* last item was pushed back, append to the end */
+ // last item was pushed back, append to the end
item = NULL;
else while (item != NULL && item->jq_no_callback)
- /* append after the last item that was pushed back */
+ // append after the last item that was pushed back
item = item->jq_next;
newitem = ALLOC_ONE(jsonq_T);
@@ -2319,7 +2319,7 @@ channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv)
*newitem->jq_value = *rettv;
if (item == NULL)
{
- /* append to the end */
+ // append to the end
newitem->jq_prev = head->jq_prev;
head->jq_prev = newitem;
newitem->jq_next = NULL;
@@ -2330,7 +2330,7 @@ channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv)
}
else
{
- /* append after "item" */
+ // append after "item"
newitem->jq_prev = item;
newitem->jq_next = item->jq_next;
item->jq_next = newitem;
@@ -2390,7 +2390,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
vim_memset(&ea, 0, sizeof(ea));
ea.arg = arg;
ea.addr_count = 0;
- ea.forceit = TRUE; /* no mapping */
+ ea.forceit = TRUE; // no mapping
ex_normal(&ea);
}
else if (STRCMP(cmd, "redraw") == 0)
@@ -2430,7 +2430,7 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
typval_T err_tv;
char_u *json = NULL;
- /* Don't pollute the display with errors. */
+ // Don't pollute the display with errors.
++emsg_skip;
if (!is_call)
{
@@ -2452,8 +2452,8 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
json = json_encode_nr_expr(id, tv, options | JSON_NL);
if (tv == NULL || (json != NULL && *json == NUL))
{
- /* If evaluation failed or the result can't be encoded
- * then return the string "ERROR". */
+ // If evaluation failed or the result can't be encoded
+ // then return the string "ERROR".
vim_free(json);
err_tv.v_type = VAR_STRING;
err_tv.vval.v_string = (char_u *)"ERROR";
@@ -2494,8 +2494,8 @@ invoke_one_time_callback(
{
ch_log(channel, "Invoking one-time callback %s",
(char *)item->cq_callback.cb_name);
- /* Remove the item from the list first, if the callback
- * invokes ch_close() the list will be cleared. */
+ // Remove the item from the list first, if the callback
+ // invokes ch_close() the list will be cleared.
remove_cb_node(cbhead, item);
invoke_callback(channel, &item->cq_callback, argv);
free_callback(&item->cq_callback);
@@ -2524,29 +2524,29 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
return;
}
- /* If the buffer is also used as input insert above the last
- * line. Don't write these lines. */
+ // If the buffer is also used as input insert above the last
+ // line. Don't write these lines.
if (save_write_to)
{
--lnum;
buffer->b_write_to_channel = FALSE;
}
- /* Append to the buffer */
+ // Append to the buffer
ch_log(channel, "appending line %d to buffer", (int)lnum + 1 - empty);
buffer->b_p_ma = TRUE;
- /* Save curbuf/curwin/curtab and make "buffer" the current buffer. */
+ // Save curbuf/curwin/curtab and make "buffer" the current buffer.
switch_to_win_for_buf(buffer, &save_curwin, &save_curtab, &save_curbuf);
u_sync(TRUE);
- /* ignore undo failure, undo is not very useful here */
+ // ignore undo failure, undo is not very useful here
vim_ignored = u_save(lnum - empty, lnum + 1);
if (empty)
{
- /* The buffer is empty, replace the first (dummy) line. */
+ // The buffer is empty, replace the first (dummy) line.
ml_replace(lnum, msg, TRUE);
lnum = 0;
}
@@ -2554,7 +2554,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
ml_append(lnum, msg, 0, FALSE);
appended_lines_mark(lnum, 1L);
- /* Restore curbuf/curwin/curtab */
+ // Restore curbuf/curwin/curtab
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf);
if (ch_part->ch_nomodifiable)
@@ -2598,8 +2598,8 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
{
channel_T *ch;
- /* Find channels reading from this buffer and adjust their
- * next-to-read line number. */
+ // Find channels reading from this buffer and adjust their
+ // next-to-read line number.
buffer->b_write_to_channel = TRUE;
for (ch = first_channel; ch != NULL; ch = ch->ch_next)
{
@@ -2644,10 +2644,10 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
char_u *p;
if (channel->ch_nb_close_cb != NULL)
- /* this channel is handled elsewhere (netbeans) */
+ // this channel is handled elsewhere (netbeans)
return FALSE;
- /* Use a message-specific callback, part callback or channel callback */
+ // Use a message-specific callback, part callback or channel callback
for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next)
if (cbitem->cq_seq_nr == 0)
break;
@@ -2662,7 +2662,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
if (buffer != NULL && (!bufref_valid(&ch_part->ch_bufref)
|| buffer->b_ml.ml_mfp == NULL))
{
- /* buffer was wiped out or unloaded */
+ // buffer was wiped out or unloaded
ch_log(channel, "%s buffer has been wiped out", part_names[part]);
ch_part->ch_bufref.br_buf = NULL;
buffer = NULL;
@@ -2673,10 +2673,10 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
listitem_T *item;
int argc = 0;
- /* Get any json message in the queue. */
+ // Get any json message in the queue.
if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL)
{
- /* Parse readahead, return when there is still no message. */
+ // Parse readahead, return when there is still no message.
channel_parse_json(channel, part);
if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL)
return FALSE;
@@ -2691,7 +2691,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
if (argv[0].v_type == VAR_STRING)
{
- /* ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg] */
+ // ["cmd", arg] or ["cmd", arg, arg] or ["cmd", arg, arg, arg]
channel_exe_cmd(channel, part, argv);
free_tv(listtv);
return TRUE;
@@ -2708,16 +2708,16 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
}
else if (channel_peek(channel, part) == NULL)
{
- /* nothing to read on RAW or NL channel */
+ // nothing to read on RAW or NL channel
return FALSE;
}
else
{
- /* If there is no callback or buffer drop the message. */
+ // If there is no callback or buffer drop the message.
if (callback == NULL && buffer == NULL)
{
- /* If there is a close callback it may use ch_read() to get the
- * messages. */
+ // If there is a close callback it may use ch_read() to get the
+ // messages.
if (channel->ch_close_cb.cb_name == NULL && !channel->ch_drop_never)
drop_messages(channel, part);
return FALSE;
@@ -2729,8 +2729,8 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
char_u *buf;
readq_T *node;
- /* See if we have a message ending in NL in the first buffer. If
- * not try to concatenate the first and the second buffer. */
+ // See if we have a message ending in NL in the first buffer. If
+ // not try to concatenate the first and the second buffer.
while (TRUE)
{
node = channel_peek(channel, part);
@@ -2741,7 +2741,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
{
if (ch_part->ch_fd == INVALID_FD && node->rq_buflen > 0)
break;
- return FALSE; /* incomplete message */
+ return FALSE; // incomplete message
}
}
buf = node->rq_buffer;
@@ -2765,22 +2765,22 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
}
else
{
- /* Copy the message into allocated memory (excluding the NL)
- * and remove it from the buffer (including the NL). */
+ // Copy the message into allocated memory (excluding the NL)
+ // and remove it from the buffer (including the NL).
msg = vim_strnsave(buf, (int)(nl - buf));
channel_consume(channel, part, (int)(nl - buf) + 1);
}
}
else
{
- /* For a raw channel we don't know where the message ends, just
- * get everything we have.
- * Convert NUL to NL, the internal representation. */
+ // For a raw channel we don't know where the message ends, just
+ // get everything we have.
+ // Convert NUL to NL, the internal representation.
msg = channel_get_all(channel, part, NULL);
}
if (msg == NULL)
- return FALSE; /* out of memory (and avoids Coverity warning) */
+ return FALSE; // out of memory (and avoids Coverity warning)
argv[1].v_type = VAR_STRING;
argv[1].vval.v_string = msg;
@@ -2790,7 +2790,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
{
int done = FALSE;
- /* JSON or JS mode: invoke the one-time callback with the matching nr */
+ // JSON or JS mode: invoke the one-time callback with the matching nr
for (cbitem = cbhead->cq_next; cbitem != NULL; cbitem = cbitem->cq_next)
if (cbitem->cq_seq_nr == seq_nr)
{
@@ -2802,7 +2802,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
{
if (channel->ch_drop_never)
{
- /* message must be read with ch_read() */
+ // message must be read with ch_read()
channel_push_json(channel, part, listtv);
listtv = NULL;
}
@@ -2816,7 +2816,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
if (buffer != NULL)
{
if (msg == NULL)
- /* JSON or JS mode: re-encode the message. */
+ // JSON or JS mode: re-encode the message.
msg = json_encode(listtv, ch_mode);
if (msg != NULL)
{
@@ -2835,7 +2835,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
invoke_one_time_callback(channel, cbhead, cbitem, argv);
else
{
- /* invoke the channel callback */
+ // invoke the channel callback
ch_log(channel, "Invoking channel callback %s",
(char *)callback->cb_name);
invoke_callback(channel, callback, argv);
@@ -2947,7 +2947,7 @@ channel_status(channel_T *channel, int req_part)
channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part)
{
chanpart_T *chanpart = &channel->ch_part[part];
- char namebuf[20]; /* longest is "sock_timeout" */
+ char namebuf[20]; // longest is "sock_timeout"
size_t tail;
char *status;
char *s = "";
@@ -3035,7 +3035,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
{
ch_part_T part;
- /* Invoke callbacks and flush buffers before the close callback. */
+ // Invoke callbacks and flush buffers before the close callback.
if (channel->ch_close_cb.cb_name != NULL)
ch_log(channel,
"Invoking callbacks and flushing buffers before closing");
@@ -3044,8 +3044,8 @@ channel_close(channel_T *channel, int invoke_close_cb)
if (channel->ch_close_cb.cb_name != NULL
|| channel->ch_part[part].ch_bufref.br_buf != NULL)
{
- /* Increment the refcount to avoid the channel being freed
- * halfway. */
+ // Increment the refcount to avoid the channel being freed
+ // halfway.
++channel->ch_refcount;
if (channel->ch_close_cb.cb_name == NULL)
ch_log(channel, "flushing %s buffers before closing",
@@ -3061,8 +3061,8 @@ channel_close(channel_T *channel, int invoke_close_cb)
typval_T argv[1];
typval_T rettv;
- /* Increment the refcount to avoid the channel being freed
- * halfway. */
+ // Increment the refcount to avoid the channel being freed
+ // halfway.
++channel->ch_refcount;
ch_log(channel, "Invoking close callback %s",
(char *)channel->ch_close_cb.cb_name);
@@ -3072,7 +3072,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
clear_tv(&rettv);
channel_need_redraw = TRUE;
- /* the callback is only called once */
+ // the callback is only called once
free_callback(&channel->ch_close_cb);
if (channel_need_redraw)
@@ -3082,7 +3082,7 @@ channel_close(channel_T *channel, int invoke_close_cb)
}
if (!channel->ch_drop_never)
- /* any remaining messages are useless now */
+ // any remaining messages are useless now
for (part = PART_SOCK; part < PART_IN; ++part)
drop_messages(channel, part);
@@ -3183,10 +3183,10 @@ channel_free_all(void)
#endif
-/* Sent when the netbeans channel is found closed when reading. */
+// Sent when the netbeans channel is found closed when reading.
#define DETACH_MSG_RAW "DETACH\n"
-/* Buffer size for reading incoming messages. */
+// Buffer size for reading incoming messages.
#define MAXMSGSIZE 4096
#if defined(HAVE_SELECT)
@@ -3270,7 +3270,7 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
DWORD deadline = GetTickCount() + timeout;
int delay = 1;
- /* reading from a pipe, not a socket */
+ // reading from a pipe, not a socket
while (TRUE)
{
int r = PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL);
@@ -3286,14 +3286,14 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
else if (r == 0)
return CW_ERROR;
- /* perhaps write some buffer lines */
+ // perhaps write some buffer lines
channel_write_any_lines();
sleep_time = deadline - GetTickCount();
if (sleep_time <= 0)
break;
- /* Wait for a little while. Very short at first, up to 10 msec
- * after looping a few times. */
+ // Wait for a little while. Very short at first, up to 10 msec
+ // after looping a few times.
if (sleep_time > delay)
sleep_time = delay;
Sleep(sleep_time);
@@ -3319,8 +3319,8 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
FD_ZERO(&rfds);
FD_SET((int)fd, &rfds);
- /* Write lines to a pipe when a pipe can be written to. Need to
- * set this every time, some buffers may be done. */
+ // Write lines to a pipe when a pipe can be written to. Need to
+ // set this every time, some buffers may be done.
maxfd = (int)fd + 1;
FD_ZERO(&wfds);
maxfd = channel_fill_wfds(maxfd, &wfds);
@@ -3370,30 +3370,29 @@ ch_close_part_on_error(
char msg[] = "%s(): Read %s from ch_part[%d], closing";
if (is_err)
- /* Do not call emsg(), most likely the other end just exited. */
+ // Do not call emsg(), most likely the other end just exited.
ch_error(channel, msg, func, "error", part);
else
ch_log(channel, msg, func, "EOF", part);
- /* Queue a "DETACH" netbeans message in the command queue in order to
- * terminate the netbeans session later. Do not end the session here
- * directly as we may be running in the context of a call to
- * netbeans_parse_messages():
- * netbeans_parse_messages
- * -> autocmd triggered while processing the netbeans cmd
- * -> ui_breakcheck
- * -> gui event loop or select loop
- * -> channel_read()
- * Only send "DETACH" for a netbeans channel.
- */
+ // Queue a "DETACH" netbeans message in the command queue in order to
+ // terminate the netbeans session later. Do not end the session here
+ // directly as we may be running in the context of a call to
+ // netbeans_parse_messages():
+ // netbeans_parse_messages
+ // -> autocmd triggered while processing the netbeans cmd
+ // -> ui_breakcheck
+ // -> gui event loop or select loop
+ // -> channel_read()
+ // Only send "DETACH" for a netbeans channel.
if (channel->ch_nb_close_cb != NULL)
channel_save(channel, PART_SOCK, (char_u *)DETACH_MSG_RAW,
(int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
- /* When reading is not possible close this part of the channel. Don't
- * close the channel yet, there may be something to read on another part.
- * When stdout and stderr use the same FD we get the error only on one of
- * them, also close the other. */
+ // When reading is not possible close this part of the channel. Don't
+ // close the channel yet, there may be something to read on another part.
+ // When stdout and stderr use the same FD we get the error only on one of
+ // them, also close the other.
if (part == PART_OUT || part == PART_ERR)
{
ch_part_T other = part == PART_OUT ? PART_ERR : PART_OUT;
@@ -3404,7 +3403,7 @@ ch_close_part_on_error(
ch_close_part(channel, part);
#ifdef FEAT_GUI
- /* Stop listening to GUI events right away. */
+ // Stop listening to GUI events right away.
channel_gui_unregister_one(channel, part);
#endif
}
@@ -3441,17 +3440,17 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
}
use_socket = fd == channel->CH_SOCK_FD;
- /* Allocate a buffer to read into. */
+ // Allocate a buffer to read into.
if (buf == NULL)
{
buf = alloc(MAXMSGSIZE);
if (buf == NULL)
- return; /* out of memory! */
+ return; // out of memory!
}
- /* Keep on reading for as long as there is something to read.
- * Use select() or poll() to avoid blocking on a message that is exactly
- * MAXMSGSIZE long. */
+ // Keep on reading for as long as there is something to read.
+ // Use select() or poll() to avoid blocking on a message that is exactly
+ // MAXMSGSIZE long.
for (;;)
{
if (channel_wait(channel, fd, 0) != CW_READY)
@@ -3461,16 +3460,16 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
else
len = fd_read(fd, (char *)buf, MAXMSGSIZE);
if (len <= 0)
- break; /* error or nothing more to read */
+ break; // error or nothing more to read
- /* Store the read message in the queue. */
+ // Store the read message in the queue.
channel_save(channel, part, buf, len, FALSE, "RECV ");
readlen += len;
if (len < MAXMSGSIZE)
- break; /* did read everything that's available */
+ break; // did read everything that's available
}
- /* Reading a disconnection (readlen == 0), or an error. */
+ // Reading a disconnection (readlen == 0), or an error.
if (readlen <= 0)
{
if (!channel->ch_keep_open)
@@ -3478,7 +3477,7 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
}
#if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK)
else if (CH_HAS_GUI && gtk_main_level() > 0)
- /* signal the main loop that there is something to read */
+ // signal the main loop that there is something to read
gtk_main_quit();
#endif
}
@@ -3512,17 +3511,17 @@ channel_read_block(
{
if (mode == MODE_RAW || (mode == MODE_NL
&& channel_first_nl(node) != NULL))
- /* got a complete message */
+ // got a complete message
break;
if (channel_collapse(channel, part, mode == MODE_NL) == OK)
continue;
- /* If not blocking or nothing more is coming then return what we
- * have. */
+ // If not blocking or nothing more is coming then return what we
+ // have.
if (raw || fd == INVALID_FD)
break;
}
- /* Wait for up to the channel timeout. */
+ // Wait for up to the channel timeout.
if (fd == INVALID_FD)
return NULL;
if (channel_wait(channel, fd, timeout) != CW_READY)
@@ -3533,7 +3532,7 @@ channel_read_block(
channel_read(channel, part, "channel_read_block");
}
- /* We have a complete message now. */
+ // We have a complete message now.
if (mode == MODE_RAW || outlen != NULL)
{
msg = channel_get_all(channel, part, outlen);
@@ -3545,26 +3544,26 @@ channel_read_block(
buf = node->rq_buffer;
nl = channel_first_nl(node);
- /* Convert NUL to NL, the internal representation. */
+ // Convert NUL to NL, the internal representation.
for (p = buf; (nl == NULL || p < nl) && p < buf + node->rq_buflen; ++p)
if (*p == NUL)
*p = NL;
if (nl == NULL)
{
- /* must be a closed channel with missing NL */
+ // must be a closed channel with missing NL
msg = channel_get(channel, part, NULL);
}
else if (nl + 1 == buf + node->rq_buflen)
{
- /* get the whole buffer */
+ // get the whole buffer
msg = channel_get(channel, part, NULL);
*nl = NUL;
}
else
{
- /* Copy the message into allocated memory and remove it from the
- * buffer. */
+ // Copy the message into allocated memory and remove it from the
+ // buffer.
msg = vim_strnsave(buf, (int)(nl - buf));
channel_consume(channel, part, (int)(nl - buf) + 1);
}
@@ -3627,13 +3626,13 @@ channel_read_json_block(
if (!more)
{
- /* Handle any other messages in the queue. If done some more
- * messages may have arrived. */
+ // Handle any other messages in the queue. If done some more
+ // messages may have arrived.
if (channel_parse_messages())
continue;
- /* Wait for up to the timeout. If there was an incomplete message
- * use the deadline for that. */
+ // Wait for up to the timeout. If there was an incomplete message
+ // use the deadline for that.
timeout = timeout_arg;
if (chanpart->ch_wait_len > 0)
{
@@ -3653,8 +3652,8 @@ channel_read_json_block(
#endif
if (timeout < 0)
{
- /* Something went wrong, channel_parse_json() didn't
- * discard message. Cancel waiting. */
+ // Something went wrong, channel_parse_json() didn't
+ // discard message. Cancel waiting.
chanpart->ch_wait_len = 0;
timeout = timeout_arg;
}
@@ -3737,7 +3736,7 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob)
int id = -1;
typval_T *listtv = NULL;
- /* return an empty string by default */
+ // return an empty string by default
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -3824,7 +3823,7 @@ channel_handle_events(int only_keep_open)
if (only_keep_open && !channel->ch_keep_open)
continue;
- /* check the socket and pipes */
+ // check the socket and pipes
for (part = PART_SOCK; part < PART_IN; ++part)
{
fd = channel->ch_part[part].ch_fd;
@@ -3933,7 +3932,7 @@ channel_send(
if (wq->wq_next != NULL)
{
- /* first write what was queued */
+ // first write what was queued
buf = wq->wq_next->wq_ga.ga_data;
len = wq->wq_next->wq_ga.ga_len;
did_use_queue = TRUE;
@@ -3941,7 +3940,7 @@ channel_send(
else
{
if (len_arg == 0)
- /* nothing to write, called from channel_select_check() */
+ // nothing to write, called from channel_select_check()
return OK;
buf = buf_arg;
len = len_arg;
@@ -3965,7 +3964,7 @@ channel_send(
|| errno == EAGAIN
#endif
))
- res = 0; /* nothing got written */
+ res = 0; // nothing got written
if (res >= 0 && ch_part->ch_nonblocking)
{
@@ -3975,10 +3974,10 @@ channel_send(
ch_log(channel, "Sent %d bytes now", res);
if (res == len)
{
- /* Wrote all the buf[len] bytes. */
+ // Wrote all the buf[len] bytes.
if (entry != NULL)
{
- /* Remove the entry from the write queue. */
+ // Remove the entry from the write queue.
remove_from_writeque(wq, entry);
continue;
}
@@ -3987,12 +3986,12 @@ channel_send(
}
else
{
- /* Wrote only buf[res] bytes, can't write more now. */
+ // Wrote only buf[res] bytes, can't write more now.
if (entry != NULL)
{
if (res > 0)
{
- /* Remove the bytes that were written. */
+ // Remove the bytes that were written.
mch_memmove(entry->wq_ga.ga_data,
(char *)entry->wq_ga.ga_data + res,
len - res);
@@ -4008,14 +4007,14 @@ channel_send(
}
ch_log(channel, "Adding %d bytes to the write queue", len);
- /* Append the not written bytes of the argument to the write
- * buffer. Limit entries to 4000 bytes. */
+ // Append the not written bytes of the argument to the write
+ // buffer. Limit entries to 4000 bytes.
if (wq->wq_prev != NULL
&& wq->wq_prev->wq_ga.ga_len + len < 4000)
{
writeq_T *last = wq->wq_prev;
- /* append to the last entry */
+ // append to the last entry
if (len > 0 && ga_grow(&last->wq_ga, len) == OK)
{
mch_memmove((char *)last->wq_ga.ga_data
@@ -4093,9 +4092,9 @@ send_common(
if (get_job_options(&argvars[2], opt, JO_CALLBACK + JO_TIMEOUT, 0) == FAIL)
return NULL;
- /* Set the callback. An empty callback means no callback and not reading
- * the response. With "ch_evalexpr()" and "ch_evalraw()" a callback is not
- * allowed. */
+ // Set the callback. An empty callback means no callback and not reading
+ // the response. With "ch_evalexpr()" and "ch_evalraw()" a callback is not
+ // allowed.
if (opt->jo_callback.cb_name != NULL && *opt->jo_callback.cb_name != NUL)
{
if (eval)
@@ -4128,7 +4127,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
jobopt_T opt;
int timeout;
- /* return an empty string by default */
+ // return an empty string by default
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -4164,8 +4163,8 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
{
list_T *list = listtv->vval.v_list;
- /* Move the item from the list and then change the type to
- * avoid the value being freed. */
+ // Move the item from the list and then change the type to
+ // avoid the value being freed.
*rettv = list->lv_last->li_tv;
list->lv_last->li_tv.v_type = VAR_NUMBER;
free_tv(listtv);
@@ -4188,7 +4187,7 @@ ch_raw_common(typval_T *argvars, typval_T *rettv, int eval)
jobopt_T opt;
int timeout;
- /* return an empty string by default */
+ // return an empty string by default
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -4216,7 +4215,7 @@ ch_raw_common(typval_T *argvars, typval_T *rettv, int eval)
free_job_options(&opt);
}
-#define KEEP_OPEN_TIME 20 /* msec */
+#define KEEP_OPEN_TIME 20 // msec
#if (defined(UNIX) && !defined(HAVE_SELECT)) || defined(PROTO)
/*
@@ -4242,9 +4241,9 @@ channel_poll_setup(int nfd_in, void *fds_in, int *towait)
{
if (channel->ch_keep_open)
{
- /* For unknown reason poll() returns immediately for a
- * keep-open channel. Instead of adding it to the fds add
- * a short timeout and check, like polling. */
+ // For unknown reason poll() returns immediately for a
+ // keep-open channel. Instead of adding it to the fds add
+ // a short timeout and check, like polling.
if (*towait < 0 || *towait > KEEP_OPEN_TIME)
*towait = KEEP_OPEN_TIME;
}
@@ -4293,7 +4292,7 @@ channel_poll_check(int ret_in, void *fds_in)
else if (channel->ch_part[part].ch_fd != INVALID_FD
&& channel->ch_keep_open)
{
- /* polling a keep-open channel */
+ // polling a keep-open channel
channel_read(channel, part, "channel_poll_check_keep_open");
}
}
@@ -4309,7 +4308,7 @@ channel_poll_check(int ret_in, void *fds_in)
return ret;
}
-#endif /* UNIX && !HAVE_SELECT */
+#endif // UNIX && !HAVE_SELECT
#if (!defined(MSWIN) && defined(HAVE_SELECT)) || defined(PROTO)
@@ -4340,9 +4339,9 @@ channel_select_setup(
{
if (channel->ch_keep_open)
{
- /* For unknown reason select() returns immediately for a
- * keep-open channel. Instead of adding it to the rfds add
- * a short timeout and check, like polling. */
+ // For unknown reason select() returns immediately for a
+ // keep-open channel. Instead of adding it to the rfds add
+ // a short timeout and check, like polling.
if (*tvp == NULL || tv->tv_sec > 0
|| tv->tv_usec > KEEP_OPEN_TIME * 1000)
{
@@ -4393,7 +4392,7 @@ channel_select_check(int ret_in, void *rfds_in, void *wfds_in)
}
else if (fd != INVALID_FD && channel->ch_keep_open)
{
- /* polling a keep-open channel */
+ // polling a keep-open channel
channel_read(channel, part, "channel_select_check_keep_open");
}
}
@@ -4434,8 +4433,8 @@ channel_parse_messages(void)
++safe_to_invoke_callback;
- /* Only do this message when another message was given, otherwise we get
- * lots of them. */
+ // Only do this message when another message was given, otherwise we get
+ // lots of them.
if ((did_repeated_msg & REPEATED_MSG_LOOKING) == 0)
{
ch_log(NULL, "looking for messages on channels");
@@ -4475,22 +4474,22 @@ channel_parse_messages(void)
if (channel->ch_part[part].ch_fd != INVALID_FD
|| channel_has_readahead(channel, part))
{
- /* Increase the refcount, in case the handler causes the channel
- * to be unreferenced or closed. */
+ // Increase the refcount, in case the handler causes the channel
+ // to be unreferenced or closed.
++channel->ch_refcount;
r = may_invoke_callback(channel, part);
if (r == OK)
ret = TRUE;
if (channel_unref(channel) || (r == OK
#ifdef ELAPSED_FUNC
- /* Limit the time we loop here to 100 msec, otherwise
- * Vim becomes unresponsive when the callback takes
- * more than a bit of time. */
+ // Limit the time we loop here to 100 msec, otherwise
+ // Vim becomes unresponsive when the callback takes
+ // more than a bit of time.
&& ELAPSED_FUNC(start_tv) < 100L
#endif
))
{
- /* channel was freed or something was done, start over */
+ // channel was freed or something was done, start over
channel = first_channel;
part = PART_SOCK;
continue;
@@ -4983,7 +4982,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
p = opt->jo_term_opencmd = tv_get_string_chk(item);
if (p != NULL)
{
- /* Must have %d and no other %. */
+ // Must have %d and no other %.
p = vim_strchr(p, '%');
if (p != NULL && (p[1] != 'd'
|| vim_strchr(p + 2, '%') != NULL))
@@ -5283,11 +5282,11 @@ job_free_contents(job_T *job)
ch_log(job->jv_channel, "Freeing job");
if (job->jv_channel != NULL)
{
- /* The link from the channel to the job doesn't count as a reference,
- * thus don't decrement the refcount of the job. The reference from
- * the job to the channel does count the reference, decrement it and
- * NULL the reference. We don't set ch_job_killed, unreferencing the
- * job doesn't mean it stops running. */
+ // The link from the channel to the job doesn't count as a reference,
+ // thus don't decrement the refcount of the job. The reference from
+ // the job to the channel does count the reference, decrement it and
+ // NULL the reference. We don't set ch_job_killed, unreferencing the
+ // job doesn't mean it stops running.
job->jv_channel->ch_job = NULL;
channel_unref(job->jv_channel);
}
@@ -5456,7 +5455,7 @@ win32_escape_arg(char_u *arg)
char_u *escaped_arg;
int has_spaces = FALSE;
- /* First count the number of extra bytes required. */
+ // First count the number of extra bytes required.
slen = (int)STRLEN(arg);
dlen = slen;
for (s = arg; *s != NUL; MB_PTR_ADV(s))
@@ -5473,7 +5472,7 @@ win32_escape_arg(char_u *arg)
if (dlen == slen)
return vim_strsave(arg);
- /* Allocate memory for the result and fill it. */
+ // Allocate memory for the result and fill it.
escaped_arg = alloc(dlen + 1);
if (escaped_arg == NULL)
return NULL;
@@ -5506,7 +5505,7 @@ win32_escape_arg(char_u *arg)
}
}
- /* add terminating quote and finish with a NUL */
+ // add terminating quote and finish with a NUL
if (has_spaces)
{
for (i = 0; i < escaping; i++)
@@ -5559,10 +5558,10 @@ job_cleanup(job_T *job)
if (job->jv_status != JOB_ENDED)
return;
- /* Ready to cleanup the job. */
+ // Ready to cleanup the job.
job->jv_status = JOB_FINISHED;
- /* When only channel-in is kept open, close explicitly. */
+ // When only channel-in is kept open, close explicitly.
if (job->jv_channel != NULL)
ch_close_part(job->jv_channel, PART_IN);
@@ -5571,7 +5570,7 @@ job_cleanup(job_T *job)
typval_T argv[3];
typval_T rettv;
- /* Invoke the exit callback. Make sure the refcount is > 0. */
+ // Invoke the exit callback. Make sure the refcount is > 0.
ch_log(job->jv_channel, "Invoking exit callback %s",
job->jv_exit_cb.cb_name);
++job->jv_refcount;
@@ -5625,20 +5624,20 @@ job_unref(job_T *job)
{
if (job != NULL && --job->jv_refcount <= 0)
{
- /* Do not free the job if there is a channel where the close callback
- * may get the job info. */
+ // Do not free the job if there is a channel where the close callback
+ // may get the job info.
if (!job_channel_still_useful(job))
{
- /* Do not free the job when it has not ended yet and there is a
- * "stoponexit" flag or an exit callback. */
+ // Do not free the job when it has not ended yet and there is a
+ // "stoponexit" flag or an exit callback.
if (!job_need_end_check(job))
{
job_free(job);
}
else if (job->jv_channel != NULL)
{
- /* Do remove the link to the channel, otherwise it hangs
- * around until Vim exits. See job_free() for refcount. */
+ // Do remove the link to the channel, otherwise it hangs
+ // around until Vim exits. See job_free() for refcount.
ch_log(job->jv_channel, "detaching channel from job");
job->jv_channel->ch_job = NULL;
channel_unref(job->jv_channel);
@@ -5658,8 +5657,8 @@ free_unused_jobs_contents(int copyID, int mask)
if ((job->jv_copyID & mask) != (copyID & mask)
&& !job_still_useful(job))
{
- /* Free the channel and ordinary items it contains, but don't
- * recurse into Lists, Dictionaries etc. */
+ // Free the channel and ordinary items it contains, but don't
+ // recurse into Lists, Dictionaries etc.
job_free_contents(job);
did_free = TRUE;
}
@@ -5678,7 +5677,7 @@ free_unused_jobs(int copyID, int mask)
if ((job->jv_copyID & mask) != (copyID & mask)
&& !job_still_useful(job))
{
- /* Free the job struct itself. */
+ // Free the job struct itself.
job_free_job(job);
}
}
@@ -5755,8 +5754,8 @@ has_pending_job(void)
job_T *job;
for (job = first_job; job != NULL; job = job->jv_next)
- /* Only should check if the channel has been closed, if the channel is
- * open the job won't exit. */
+ // Only should check if the channel has been closed, if the channel is
+ // open the job won't exit.
if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job))
|| (job->jv_status == JOB_FINISHED
&& job_channel_can_close(job)))
@@ -5843,7 +5842,7 @@ job_start(
opt = *opt_arg;
else
{
- /* Default mode is NL. */
+ // Default mode is NL.
clear_job_options(&opt);
opt.jo_mode = MODE_NL;
if (get_job_options(&argvars[1], &opt,
@@ -5853,7 +5852,7 @@ job_start(
goto theend;
}
- /* Check that when io is "file" that there is a file name. */
+ // Check that when io is "file" that there is a file name.
for (part = PART_OUT; part < PART_COUNT; ++part)
if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT)))
&& opt.jo_io[part] == JIO_FILE
@@ -5868,7 +5867,7 @@ job_start(
{
buf_T *buf = NULL;
- /* check that we can find the buffer before starting the job */
+ // check that we can find the buffer before starting the job
if (opt.jo_set & JO_IN_BUF)
{
buf = buflist_findnr(opt.jo_io_buf[PART_IN]);
@@ -5906,7 +5905,7 @@ job_start(
#ifdef USE_ARGV
if (argv_arg != NULL)
{
- /* Make a copy of argv_arg for job->jv_argv. */
+ // Make a copy of argv_arg for job->jv_argv.
for (i = 0; argv_arg[i] != NULL; i++)
argc++;
argv = ALLOC_MULT(char *, argc + 1);
@@ -5920,7 +5919,7 @@ job_start(
#endif
if (argvars[0].v_type == VAR_STRING)
{
- /* Command is a string. */
+ // Command is a string.
cmd = argvars[0].vval.v_string;
if (cmd == NULL || *cmd == NUL)
{
@@ -5951,7 +5950,7 @@ job_start(
#endif
}
- /* Save the command used to start the job. */
+ // Save the command used to start the job.
job->jv_argv = argv;
#ifdef USE_ARGV
@@ -5976,7 +5975,7 @@ job_start(
mch_job_start((char *)cmd, job, &opt);
#endif
- /* If the channel is reading from a buffer, write lines now. */
+ // If the channel is reading from a buffer, write lines now.
if (job->jv_channel != NULL)
channel_write_in(job->jv_channel);
@@ -6000,7 +5999,7 @@ job_status(job_T *job)
char *result;
if (job->jv_status >= JOB_ENDED)
- /* No need to check, dead is dead. */
+ // No need to check, dead is dead.
result = "dead";
else if (job->jv_status == JOB_FAILED)
result = "fail";
@@ -6050,12 +6049,12 @@ job_stop(job_T *job, typval_T *argvars, char *type)
if (mch_signal_job(job, arg) == FAIL)
return 0;
- /* Assume that only "kill" will kill the job. */
+ // Assume that only "kill" will kill the job.
if (job->jv_channel != NULL && STRCMP(arg, "kill") == 0)
job->jv_channel->ch_job_killed = TRUE;
- /* We don't try freeing the job, obviously the caller still has a
- * reference to it. */
+ // We don't try freeing the job, obviously the caller still has a
+ // reference to it.
return 1;
}
@@ -6300,7 +6299,7 @@ f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED)
char_u *opt = (char_u *)"";
char_u buf[NUMBUFLEN];
- /* Don't open a file in restricted mode. */
+ // Don't open a file in restricted mode.
if (check_restricted() || check_secure())
return;
fname = tv_get_string(&argvars[0]);
@@ -6413,7 +6412,7 @@ f_ch_status(typval_T *argvars, typval_T *rettv)
jobopt_T opt;
int part = -1;
- /* return an empty string by default */
+ // return an empty string by default
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -6612,4 +6611,4 @@ f_job_stop(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = job_stop(job, argvars, NULL);
}
-#endif /* FEAT_JOB_CHANNEL */
+#endif // FEAT_JOB_CHANNEL
diff --git a/src/charset.c b/src/charset.c
index 25d6d3851..7505fea2e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -10,7 +10,7 @@
#include "vim.h"
#if defined(HAVE_WCHAR_H)
-# include <wchar.h> /* for towupper() and towlower() */
+# include <wchar.h> // for towupper() and towlower()
#endif
static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp);
@@ -18,22 +18,22 @@ static unsigned nr2hex(unsigned c);
static int chartab_initialized = FALSE;
-/* b_chartab[] is an array of 32 bytes, each bit representing one of the
- * characters 0-255. */
+// b_chartab[] is an array of 32 bytes, each bit representing one of the
+// characters 0-255.
#define SET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] |= (1 << ((c) & 0x7))
#define RESET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] &= ~(1 << ((c) & 0x7))
#define GET_CHARTAB(buf, c) ((buf)->b_chartab[(unsigned)(c) >> 3] & (1 << ((c) & 0x7)))
-/* table used below, see init_chartab() for an explanation */
+// table used below, see init_chartab() for an explanation
static char_u g_chartab[256];
/*
* Flags for g_chartab[].
*/
-#define CT_CELL_MASK 0x07 /* mask: nr of display cells (1, 2 or 4) */
-#define CT_PRINT_CHAR 0x10 /* flag: set for printable chars */
-#define CT_ID_CHAR 0x20 /* flag: set for ID chars */
-#define CT_FNAME_CHAR 0x40 /* flag: set for file name chars */
+#define CT_CELL_MASK 0x07 // mask: nr of display cells (1, 2 or 4)
+#define CT_PRINT_CHAR 0x10 // flag: set for printable chars
+#define CT_ID_CHAR 0x20 // flag: set for ID chars
+#define CT_FNAME_CHAR 0x40 // flag: set for file name chars
static int in_win_border(win_T *wp, colnr_T vcol);
@@ -72,7 +72,7 @@ init_chartab(void)
int
buf_init_chartab(
buf_T *buf,
- int global) /* FALSE: only set buf->b_chartab[] */
+ int global) // FALSE: only set buf->b_chartab[]
{
int c;
int c2;
@@ -102,21 +102,21 @@ buf_init_chartab(
g_chartab[c++] = 1 + CT_PRINT_CHAR;
while (c < 256)
{
- /* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */
+ // UTF-8: bytes 0xa0 - 0xff are printable (latin1)
if (enc_utf8 && c >= 0xa0)
g_chartab[c++] = CT_PRINT_CHAR + 1;
- /* euc-jp characters starting with 0x8e are single width */
+ // euc-jp characters starting with 0x8e are single width
else if (enc_dbcs == DBCS_JPNU && c == 0x8e)
g_chartab[c++] = CT_PRINT_CHAR + 1;
- /* other double-byte chars can be printable AND double-width */
+ // other double-byte chars can be printable AND double-width
else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2)
g_chartab[c++] = CT_PRINT_CHAR + 2;
else
- /* the rest is unprintable by default */
+ // the rest is unprintable by default
g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
}
- /* Assume that every multi-byte char is a filename character. */
+ // Assume that every multi-byte char is a filename character.
for (c = 1; c < 256; ++c)
if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1)
|| (enc_dbcs == DBCS_JPNU && c == 0x8e)
@@ -131,7 +131,7 @@ buf_init_chartab(
if (enc_dbcs != 0)
for (c = 0; c < 256; ++c)
{
- /* double-byte characters are probably word characters */
+ // double-byte characters are probably word characters
if (MB_BYTE2LEN(c) == 2)
SET_CHARTAB(buf, c);
}
@@ -144,20 +144,19 @@ buf_init_chartab(
SET_CHARTAB(buf, '-');
#endif
- /* Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'
- * options Each option is a list of characters, character numbers or
- * ranges, separated by commas, e.g.: "200-210,x,#-178,-"
- */
+ // Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'
+ // options Each option is a list of characters, character numbers or
+ // ranges, separated by commas, e.g.: "200-210,x,#-178,-"
for (i = global ? 0 : 3; i <= 3; ++i)
{
if (i == 0)
- p = p_isi; /* first round: 'isident' */
+ p = p_isi; // first round: 'isident'
else if (i == 1)
- p = p_isp; /* second round: 'isprint' */
+ p = p_isp; // second round: 'isprint'
else if (i == 2)
- p = p_isf; /* third round: 'isfname' */
- else /* i == 3 */
- p = buf->b_p_isk; /* fourth round: 'iskeyword' */
+ p = p_isf; // third round: 'isfname'
+ else // i == 3
+ p = buf->b_p_isk; // fourth round: 'iskeyword'
while (*p)
{
@@ -191,7 +190,7 @@ buf_init_chartab(
|| !(*p == NUL || *p == ','))
return FAIL;
- if (c2 == -1) /* not a range */
+ if (c2 == -1) // not a range
{
/*
* A single '@' (not "@-@"):
@@ -210,19 +209,19 @@ buf_init_chartab(
}
while (c <= c2)
{
- /* Use the MB_ functions here, because isalpha() doesn't
- * work properly when 'encoding' is "latin1" and the locale is
- * "C". */
+ // Use the MB_ functions here, because isalpha() doesn't
+ // work properly when 'encoding' is "latin1" and the locale is
+ // "C".
if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c))
{
- if (i == 0) /* (re)set ID flag */
+ if (i == 0) // (re)set ID flag
{
if (tilde)
g_chartab[c] &= ~CT_ID_CHAR;
else
g_chartab[c] |= CT_ID_CHAR;
}
- else if (i == 1) /* (re)set printable */
+ else if (i == 1) // (re)set printable
{
if ((c < ' '
#ifndef EBCDIC
@@ -245,14 +244,14 @@ buf_init_chartab(
}
}
}
- else if (i == 2) /* (re)set fname flag */
+ else if (i == 2) // (re)set fname flag
{
if (tilde)
g_chartab[c] &= ~CT_FNAME_CHAR;
else
g_chartab[c] |= CT_FNAME_CHAR;
}
- else /* i == 3 */ /* (re)set keyword flag */
+ else // i == 3 (re)set keyword flag
{
if (tilde)
RESET_CHARTAB(buf, c);
@@ -266,7 +265,7 @@ buf_init_chartab(
c = *p;
p = skip_to_option_part(p);
if (c == ',' && *p == NUL)
- /* Trailing comma is not allowed. */
+ // Trailing comma is not allowed.
return FAIL;
}
}
@@ -284,16 +283,16 @@ trans_characters(
char_u *buf,
int bufsize)
{
- int len; /* length of string needing translation */
- int room; /* room in buffer after string */
- char_u *trs; /* translated character */
- int trs_len; /* length of trs[] */
+ int len; // length of string needing translation
+ int room; // room in buffer after string
+ char_u *trs; // translated character
+ int trs_len; // length of trs[]
len = (int)STRLEN(buf);
room = bufsize - len;
while (*buf != 0)
{
- /* Assume a multi-byte character doesn't need translation. */
+ // Assume a multi-byte character doesn't need translation.
if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)
len -= trs_len;
else
@@ -328,8 +327,8 @@ transstr(char_u *s)
if (has_mbyte)
{
- /* Compute the length of the result, taking account of unprintable
- * multi-byte characters. */
+ // Compute the length of the result, taking account of unprintable
+ // multi-byte characters.
len = 0;
p = s;
while (*p != NUL)
@@ -352,7 +351,7 @@ transstr(char_u *s)
if (l > 0)
len += l;
else
- len += 4; /* illegal byte sequence */
+ len += 4; // illegal byte sequence
}
}
res = alloc(len + 1);
@@ -369,7 +368,7 @@ transstr(char_u *s)
{
c = (*mb_ptr2char)(p);
if (vim_isprintc(c))
- STRNCAT(res, p, l); /* append printable multi-byte char */
+ STRNCAT(res, p, l); // append printable multi-byte char
else
transchar_hex(res + STRLEN(res), c);
p += l;
@@ -403,7 +402,7 @@ str_foldcase(
#define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i])
#define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + i)
- /* Copy "str" into "buf" or allocated memory, unmodified. */
+ // Copy "str" into "buf" or allocated memory, unmodified.
if (buf == NULL)
{
ga_init2(&ga, 1, 10);
@@ -414,7 +413,7 @@ str_foldcase(
}
else
{
- if (len >= buflen) /* Ugly! */
+ if (len >= buflen) // Ugly!
len = buflen - 1;
mch_memmove(buf, str, (size_t)len);
}
@@ -423,7 +422,7 @@ str_foldcase(
else
buf[len] = NUL;
- /* Make each character lower case. */
+ // Make each character lower case.
i = 0;
while (STR_CHAR(i) != NUL)
{
@@ -435,15 +434,15 @@ str_foldcase(
int olen = utf_ptr2len(STR_PTR(i));
int lc = utf_tolower(c);
- /* Only replace the character when it is not an invalid
- * sequence (ASCII character or more than one byte) and
- * utf_tolower() doesn't return the original character. */
+ // Only replace the character when it is not an invalid
+ // sequence (ASCII character or more than one byte) and
+ // utf_tolower() doesn't return the original character.
if ((c < 0x80 || olen > 1) && c != lc)
{
int nlen = utf_char2len(lc);
- /* If the byte length changes need to shift the following
- * characters forward or backward. */
+ // If the byte length changes need to shift the following
+ // characters forward or backward.
if (olen != nlen)
{
if (nlen > olen)
@@ -452,7 +451,7 @@ str_foldcase(
? ga_grow(&ga, nlen - olen + 1) == FAIL
: len + nlen - olen >= buflen)
{
- /* out of memory, keep old char */
+ // out of memory, keep old char
lc = c;
nlen = olen;
}
@@ -474,7 +473,7 @@ str_foldcase(
(void)utf_char2bytes(lc, STR_PTR(i));
}
}
- /* skip to next multi-byte char */
+ // skip to next multi-byte char
i += (*mb_ptr2len)(STR_PTR(i));
}
else
@@ -508,7 +507,7 @@ transchar(int c)
int i;
i = 0;
- if (IS_SPECIAL(c)) /* special key code, display as ~@ char */
+ if (IS_SPECIAL(c)) // special key code, display as ~@ char
{
transchar_buf[0] = '~';
transchar_buf[1] = '@';
@@ -524,7 +523,7 @@ transchar(int c)
#endif
)) || (c < 256 && vim_isprintc_strict(c)))
{
- /* printable character */
+ // printable character
transchar_buf[i] = c;
transchar_buf[i + 1] = NUL;
}
@@ -557,28 +556,28 @@ transchar_byte(int c)
transchar_nonprint(char_u *buf, int c)
{
if (c == NL)
- c = NUL; /* we use newline in place of a NUL */
+ c = NUL; // we use newline in place of a NUL
else if (c == CAR && get_fileformat(curbuf) == EOL_MAC)
- c = NL; /* we use CR in place of NL in this case */
+ c = NL; // we use CR in place of NL in this case
- if (dy_flags & DY_UHEX) /* 'display' has "uhex" */
+ if (dy_flags & DY_UHEX) // 'display' has "uhex"
transchar_hex(buf, c);
#ifdef EBCDIC
- /* For EBCDIC only the characters 0-63 and 255 are not printable */
+ // For EBCDIC only the characters 0-63 and 255 are not printable
else if (CtrlChar(c) != 0 || c == DEL)
#else
- else if (c <= 0x7f) /* 0x00 - 0x1f and 0x7f */
+ else if (c <= 0x7f) // 0x00 - 0x1f and 0x7f
#endif
{
buf[0] = '^';
#ifdef EBCDIC
if (c == DEL)
- buf[1] = '?'; /* DEL displayed as ^? */
+ buf[1] = '?'; // DEL displayed as ^?
else
buf[1] = CtrlChar(c);
#else
- buf[1] = c ^ 0x40; /* DEL displayed as ^? */
+ buf[1] = c ^ 0x40; // DEL displayed as ^?
#endif
buf[2] = NUL;
@@ -588,7 +587,7 @@ transchar_nonprint(char_u *buf, int c)
transchar_hex(buf, c);
}
#ifndef EBCDIC
- else if (c >= ' ' + 0x80 && c <= '~' + 0x80) /* 0xa0 - 0xfe */
+ else if (c >= ' ' + 0x80 && c <= '~' + 0x80) // 0xa0 - 0xfe
{
buf[0] = '|';
buf[1] = c - 0x80;
@@ -602,7 +601,7 @@ transchar_nonprint(char_u *buf, int c)
buf[2] = NUL;
}
#endif
- else /* 0x80 - 0x9f and 0xff */
+ else // 0x80 - 0x9f and 0xff
{
/*
* TODO: EBCDIC I don't know what to do with this chars, so I display
@@ -610,9 +609,9 @@ transchar_nonprint(char_u *buf, int c)
*/
buf[0] = '~';
#ifdef EBCDIC
- buf[1] = '?'; /* 0xff displayed as ~? */
+ buf[1] = '?'; // 0xff displayed as ~?
#else
- buf[1] = (c - 0x80) ^ 0x40; /* 0xff displayed as ~? */
+ buf[1] = (c - 0x80) ^ 0x40; // 0xff displayed as ~?
#endif
buf[2] = NUL;
}
@@ -676,11 +675,11 @@ char2cells(int c)
return char2cells(K_SECOND(c)) + 2;
if (c >= 0x80)
{
- /* UTF-8: above 0x80 need to check the value */
+ // UTF-8: above 0x80 need to check the value
if (enc_utf8)
return utf_char2cells(c);
- /* DBCS: double-byte means double-width, except for euc-jp with first
- * byte 0x8e */
+ // DBCS: double-byte means double-width, except for euc-jp with first
+ // byte 0x8e
if (enc_dbcs != 0 && c >= 0x100)
{
if (enc_dbcs == DBCS_JPNU && ((unsigned)c >> 8) == 0x8e)
@@ -698,10 +697,10 @@ char2cells(int c)
int
ptr2cells(char_u *p)
{
- /* For UTF-8 we need to look at more bytes if the first byte is >= 0x80. */
+ // For UTF-8 we need to look at more bytes if the first byte is >= 0x80.
if (enc_utf8 && *p >= 0x80)
return utf_ptr2cells(p);
- /* For DBCS we can tell the cell count from the first byte. */
+ // For DBCS we can tell the cell count from the first byte.
return (g_chartab[*p] & CT_CELL_MASK);
}
@@ -797,7 +796,7 @@ linetabsize(char_u *s)
linetabsize_col(int startcol, char_u *s)
{
colnr_T col = startcol;
- char_u *line = s; /* pointer to start of line, for breakindent */
+ char_u *line = s; // pointer to start of line, for breakindent
while (*s != NUL)
col += lbr_chartabsize_adv(line, &s, col);
@@ -931,7 +930,7 @@ vim_isprintc_strict(int c)
*/
int
lbr_chartabsize(
- char_u *line UNUSED, /* start of the line */
+ char_u *line UNUSED, // start of the line
unsigned char *s,
colnr_T col)
{
@@ -954,7 +953,7 @@ lbr_chartabsize(
*/
int
lbr_chartabsize_adv(
- char_u *line, /* start of the line */
+ char_u *line, // start of the line
char_u **s,
colnr_T col)
{
@@ -975,7 +974,7 @@ lbr_chartabsize_adv(
int
win_lbr_chartabsize(
win_T *wp,
- char_u *line UNUSED, /* start of the line */
+ char_u *line UNUSED, // start of the line
char_u *s,
colnr_T col,
int *headp UNUSED)
@@ -984,7 +983,7 @@ win_lbr_chartabsize(
int c;
int size;
colnr_T col2;
- colnr_T col_adj = 0; /* col + screen size of tab */
+ colnr_T col_adj = 0; // col + screen size of tab
colnr_T colmax;
int added;
int mb_added = 0;
@@ -1051,7 +1050,7 @@ win_lbr_chartabsize(
break;
col2 += win_chartabsize(wp, s, col2);
- if (col2 >= colmax) /* doesn't fit */
+ if (col2 >= colmax) // doesn't fit
{
size = colmax - col + col_adj;
break;
@@ -1061,7 +1060,7 @@ win_lbr_chartabsize(
else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1
&& wp->w_p_wrap && in_win_border(wp, col))
{
- ++size; /* Count the ">" in the last column. */
+ ++size; // Count the ">" in the last column.
mb_added = 1;
}
@@ -1159,8 +1158,8 @@ win_nolbr_chartabsize(
# endif
}
n = ptr2cells(s);
- /* Add one cell for a double-width character in the last column of the
- * window, displayed with a ">". */
+ // Add one cell for a double-width character in the last column of the
+ // window, displayed with a ">".
if (n == 2 && MB_BYTE2LEN(*s) > 1 && in_win_border(wp, col))
{
if (headp != NULL)
@@ -1177,10 +1176,10 @@ win_nolbr_chartabsize(
static int
in_win_border(win_T *wp, colnr_T vcol)
{
- int width1; /* width of first line (after line number) */
- int width2; /* width of further lines */
+ int width1; // width of first line (after line number)
+ int width2; // width of further lines
- if (wp->w_width == 0) /* there is no border */
+ if (wp->w_width == 0) // there is no border
return FALSE;
width1 = wp->w_width - win_col_off(wp);
if ((int)vcol < width1 - 1)
@@ -1210,9 +1209,9 @@ getvcol(
colnr_T *end)
{
colnr_T vcol;
- char_u *ptr; /* points to current char */
- char_u *posptr; /* points to char at pos->col */
- char_u *line; /* start of the line */
+ char_u *ptr; // points to current char
+ char_u *posptr; // points to char at pos->col
+ char_u *line; // start of the line
int incr;
int head;
#ifdef FEAT_VARTABS
@@ -1224,16 +1223,16 @@ getvcol(
vcol = 0;
line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col == MAXCOL)
- posptr = NULL; /* continue until the NUL */
+ posptr = NULL; // continue until the NUL
else
{
- /* Special check for an empty line, which can happen on exit, when
- * ml_get_buf() always returns an empty string. */
+ // Special check for an empty line, which can happen on exit, when
+ // ml_get_buf() always returns an empty string.
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
if (has_mbyte)
- /* always start on the first byte */
+ // always start on the first byte
posptr -= (*mb_head_off)(line, posptr);
}
@@ -1253,13 +1252,13 @@ getvcol(
{
head = 0;
c = *ptr;
- /* make sure we don't go past the end of the line */
+ // make sure we don't go past the end of the line
if (c == NUL)
{
- incr = 1; /* NUL at end of line only takes one column */
+ incr = 1; // NUL at end of line only takes one column
break;
}
- /* A tab gets expanded, depending on the current column */
+ // A tab gets expanded, depending on the current column
if (c == TAB)
#ifdef FEAT_VARTABS
incr = tabstop_padding(vcol, ts, vts);
@@ -1270,16 +1269,16 @@ getvcol(
{
if (has_mbyte)
{
- /* For utf-8, if the byte is >= 0x80, need to look at
- * further bytes to find the cell width. */
+ // For utf-8, if the byte is >= 0x80, need to look at
+ // further bytes to find the cell width.
if (enc_utf8 && c >= 0x80)
incr = utf_ptr2cells(ptr);
else
incr = g_chartab[c] & CT_CELL_MASK;
- /* If a double-cell char doesn't fit at the end of a line
- * it wraps to the next line, it's like this char is three
- * cells wide. */
+ // If a double-cell char doesn't fit at the end of a line
+ // it wraps to the next line, it's like this char is three
+ // cells wide.
if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1
&& in_win_border(wp, vcol))
{
@@ -1291,7 +1290,7 @@ getvcol(
incr = g_chartab[c] & CT_CELL_MASK;
}
- if (posptr != NULL && ptr >= posptr) /* character at pos->col */
+ if (posptr != NULL && ptr >= posptr) // character at pos->col
break;
vcol += incr;
@@ -1302,17 +1301,17 @@ getvcol(
{
for (;;)
{
- /* A tab gets expanded, depending on the current column */
+ // A tab gets expanded, depending on the current column
head = 0;
incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);
- /* make sure we don't go past the end of the line */
+ // make sure we don't go past the end of the line
if (*ptr == NUL)
{
- incr = 1; /* NUL at end of line only takes one column */
+ incr = 1; // NUL at end of line only takes one column
break;
}
- if (posptr != NULL && ptr >= posptr) /* character at pos->col */
+ if (posptr != NULL && ptr >= posptr) // character at pos->col
break;
vcol += incr;
@@ -1332,9 +1331,9 @@ getvcol(
&& !(VIsual_active
&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))
)
- *cursor = vcol + incr - 1; /* cursor at end */
+ *cursor = vcol + incr - 1; // cursor at end
else
- *cursor = vcol + head; /* cursor at start */
+ *cursor = vcol + head; // cursor at start
}
}
@@ -1374,12 +1373,12 @@ getvvcol(
if (virtual_active())
{
- /* For virtual mode, only want one value */
+ // For virtual mode, only want one value
getvcol(wp, pos, &col, NULL, NULL);
coladd = pos->coladd;
endadd = 0;
- /* Cannot put the cursor on part of a wide character. */
+ // Cannot put the cursor on part of a wide character.
ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col < (colnr_T)STRLEN(ptr))
{
@@ -1388,7 +1387,7 @@ getvvcol(
if (c != TAB && vim_isprintc(c))
{
endadd = (colnr_T)(char2cells(c) - 1);
- if (coladd > endadd) /* past end of line */
+ if (coladd > endadd) // past end of line
endadd = 0;
else
coladd = 0;
@@ -1453,7 +1452,7 @@ skipwhite(char_u *q)
{
char_u *p = q;
- while (VIM_ISWHITE(*p)) /* skip to next non-white */
+ while (VIM_ISWHITE(*p)) // skip to next non-white
++p;
return p;
}
@@ -1482,7 +1481,7 @@ skipdigits(char_u *q)
{
char_u *p = q;
- while (VIM_ISDIGIT(*p)) /* skip to next non-digit */
+ while (VIM_ISDIGIT(*p)) // skip to next non-digit
++p;
return p;
}
@@ -1496,7 +1495,7 @@ skipbin(char_u *q)
{
char_u *p = q;
- while (vim_isbdigit(*p)) /* skip to next non-digit */
+ while (vim_isbdigit(*p)) // skip to next non-digit
++p;
return p;
}
@@ -1509,7 +1508,7 @@ skiphex(char_u *q)
{
char_u *p = q;
- while (vim_isxdigit(*p)) /* skip to next non-digit */
+ while (vim_isxdigit(*p)) // skip to next non-digit
++p;
return p;
}
@@ -1523,7 +1522,7 @@ skiptobin(char_u *q)
{
char_u *p = q;
- while (*p != NUL && !vim_isbdigit(*p)) /* skip to next digit */
+ while (*p != NUL && !vim_isbdigit(*p)) // skip to next digit
++p;
return p;
}
@@ -1536,7 +1535,7 @@ skiptodigit(char_u *q)
{
char_u *p = q;
- while (*p != NUL && !VIM_ISDIGIT(*p)) /* skip to next digit */
+ while (*p != NUL && !VIM_ISDIGIT(*p)) // skip to next digit
++p;
return p;
}
@@ -1549,7 +1548,7 @@ skiptohex(char_u *q)
{
char_u *p = q;
- while (*p != NUL && !vim_isxdigit(*p)) /* skip to next digit */
+ while (*p != NUL && !vim_isxdigit(*p)) // skip to next digit
++p;
return p;
}
@@ -1617,7 +1616,7 @@ vim_islower(int c)
if (has_mbyte)
return iswlower(c);
#endif
- /* islower() can't handle these chars and may crash */
+ // islower() can't handle these chars and may crash
return FALSE;
}
if (enc_latin1like)
@@ -1641,7 +1640,7 @@ vim_isupper(int c)
if (has_mbyte)
return iswupper(c);
#endif
- /* islower() can't handle these chars and may crash */
+ // islower() can't handle these chars and may crash
return FALSE;
}
if (enc_latin1like)
@@ -1665,7 +1664,7 @@ vim_toupper(int c)
if (has_mbyte)
return towupper(c);
#endif
- /* toupper() can't handle these chars and may crash */
+ // toupper() can't handle these chars and may crash
return c;
}
if (enc_latin1like)
@@ -1691,7 +1690,7 @@ vim_tolower(int c)
if (has_mbyte)
return towlower(c);
#endif
- /* tolower() can't handle these chars and may crash */
+ // tolower() can't handle these chars and may crash
return c;
}
if (enc_latin1like)
@@ -1740,9 +1739,9 @@ getdigits(char_u **pp)
p = *pp;
retval = atol((char *)p);
- if (*p == '-') /* skip negative sign */
+ if (*p == '-') // skip negative sign
++p;
- p = skipdigits(p); /* skip to next non-digit */
+ p = skipdigits(p); // skip to next non-digit
*pp = p;
return retval;
}
@@ -1808,7 +1807,7 @@ vim_str2nr(
++ptr;
}
- /* Recognize hex, octal, and bin. */
+ // Recognize hex, octal, and bin.
if (ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9'
&& (maxlen == 0 || maxlen > 1))
{
@@ -1816,28 +1815,28 @@ vim_str2nr(
if ((what & STR2NR_HEX)
&& (pre == 'X' || pre == 'x') && vim_isxdigit(ptr[2])
&& (maxlen == 0 || maxlen > 2))
- /* hexadecimal */
+ // hexadecimal
ptr += 2;
else if ((what & STR2NR_BIN)
&& (pre == 'B' || pre == 'b') && vim_isbdigit(ptr[2])
&& (maxlen == 0 || maxlen > 2))
- /* binary */
+ // binary
ptr += 2;
else
{
- /* decimal or octal, default is decimal */
+ // decimal or octal, default is decimal
pre = 0;
if (what & STR2NR_OCT)
{
- /* Don't interpret "0", "08" or "0129" as octal. */
+ // Don't interpret "0", "08" or "0129" as octal.
for (n = 1; n != maxlen && VIM_ISDIGIT(ptr[n]); ++n)
{
if (ptr[n] > '7')
{
- pre = 0; /* can't be octal */
+ pre = 0; // can't be octal
break;
}
- pre = '0'; /* assume octal */
+ pre = '0'; // assume octal
}
}
}
@@ -1848,12 +1847,12 @@ vim_str2nr(
if (pre == 'B' || pre == 'b'
|| ((what & STR2NR_BIN) && (what & STR2NR_FORCE)))
{
- /* bin */
+ // bin
if (pre != 0)
- n += 2; /* skip over "0b" */
+ n += 2; // skip over "0b"
while ('0' <= *ptr && *ptr <= '1')
{
- /* avoid ubsan error for overflow */
+ // avoid ubsan error for overflow
if (un <= UVARNUM_MAX / 2)
un = 2 * un + (uvarnumber_T)(*ptr - '0');
else
@@ -1872,10 +1871,10 @@ vim_str2nr(
}
else if (pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE)))
{
- /* octal */
+ // octal
while ('0' <= *ptr && *ptr <= '7')
{
- /* avoid ubsan error for overflow */
+ // avoid ubsan error for overflow
if (un <= UVARNUM_MAX / 8)
un = 8 * un + (uvarnumber_T)(*ptr - '0');
else
@@ -1894,12 +1893,12 @@ vim_str2nr(
}
else if (pre != 0 || ((what & STR2NR_HEX) && (what & STR2NR_FORCE)))
{
- /* hex */
+ // hex
if (pre != 0)
- n += 2; /* skip over "0x" */
+ n += 2; // skip over "0x"
while (vim_isxdigit(*ptr))
{
- /* avoid ubsan error for overflow */
+ // avoid ubsan error for overflow
if (un <= UVARNUM_MAX / 16)
un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
else
@@ -1917,12 +1916,12 @@ vim_str2nr(
}
else
{
- /* decimal */
+ // decimal
while (VIM_ISDIGIT(*ptr))
{
uvarnumber_T digit = (uvarnumber_T)(*ptr - '0');
- /* avoid ubsan error for overflow */
+ // avoid ubsan error for overflow
if (un < UVARNUM_MAX / 10
|| (un == UVARNUM_MAX / 10 && digit <= UVARNUM_MAX % 10))
un = 10 * un + digit;
@@ -1951,9 +1950,9 @@ vim_str2nr(
*len = (int)(ptr - start);
if (nptr != NULL)
{
- if (negative) /* account for leading '-' for decimal numbers */
+ if (negative) // account for leading '-' for decimal numbers
{
- /* avoid ubsan error for overflow */
+ // avoid ubsan error for overflow
if (un > VARNUM_MAX)
*nptr = VARNUM_MIN;
else
diff --git a/src/cindent.c b/src/cindent.c
index c37682c39..c7caed68f 100644
--- a/src/cindent.c
+++ b/src/cindent.c
@@ -1628,9 +1628,9 @@ get_baseclass_amount(int col)
* Ignore a '{' that is in a comment, makes indenting the next three lines
* work.
*/
-/* foo() */
-/* { */
-/* } */
+// foo()
+// {
+// }
static pos_T *
find_start_brace(void) // XXX
diff --git a/src/crypt.c b/src/crypt.c
index 729073a86..0164f1ce9 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -30,53 +30,52 @@
*/
typedef struct {
- char *name; /* encryption name as used in 'cryptmethod' */
- char *magic; /* magic bytes stored in file header */
- int salt_len; /* length of salt, or 0 when not using salt */
- int seed_len; /* length of seed, or 0 when not using salt */
+ char *name; // encryption name as used in 'cryptmethod'
+ char *magic; // magic bytes stored in file header
+ int salt_len; // length of salt, or 0 when not using salt
+ int seed_len; // length of seed, or 0 when not using salt
#ifdef CRYPT_NOT_INPLACE
- int works_inplace; /* encryption/decryption can be done in-place */
+ int works_inplace; // encryption/decryption can be done in-place
#endif
- int whole_undofile; /* whole undo file is encrypted */
+ int whole_undofile; // whole undo file is encrypted
- /* Optional function pointer for a self-test. */
+ // Optional function pointer for a self-test.
int (* self_test_fn)();
// Function pointer for initializing encryption/decryption.
int (* init_fn)(cryptstate_T *state, char_u *key,
char_u *salt, int salt_len, char_u *seed, int seed_len);
- /* Function pointers for encoding/decoding from one buffer into another.
- * Optional, however, these or the _buffer ones should be configured. */
+ // Function pointers for encoding/decoding from one buffer into another.
+ // Optional, however, these or the _buffer ones should be configured.
void (*encode_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u *to);
void (*decode_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u *to);
- /* Function pointers for encoding and decoding, can buffer data if needed.
- * Optional (however, these or the above should be configured). */
+ // Function pointers for encoding and decoding, can buffer data if needed.
+ // Optional (however, these or the above should be configured).
long (*encode_buffer_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u **newptr);
long (*decode_buffer_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u **newptr);
- /* Function pointers for in-place encoding and decoding, used for
- * crypt_*_inplace(). "from" and "to" arguments will be equal.
- * These may be the same as decode_fn and encode_fn above, however an
- * algorithm may implement them in a way that is not interchangeable with
- * the crypt_(en|de)code() interface (for example because it wishes to add
- * padding to files).
- * This method is used for swap and undo files which have a rigid format.
- */
+ // Function pointers for in-place encoding and decoding, used for
+ // crypt_*_inplace(). "from" and "to" arguments will be equal.
+ // These may be the same as decode_fn and encode_fn above, however an
+ // algorithm may implement them in a way that is not interchangeable with
+ // the crypt_(en|de)code() interface (for example because it wishes to add
+ // padding to files).
+ // This method is used for swap and undo files which have a rigid format.
void (*encode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len,
char_u *p2);
void (*decode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len,
char_u *p2);
} cryptmethod_T;
-/* index is method_nr of cryptstate_T, CRYPT_M_* */
+// index is method_nr of cryptstate_T, CRYPT_M_*
static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
- /* PK_Zip; very weak */
+ // PK_Zip; very weak
{
"zip",
"VimCrypt~01!",
@@ -93,7 +92,7 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
crypt_zip_encode, crypt_zip_decode,
},
- /* Blowfish/CFB + SHA-256 custom key derivation; implementation issues. */
+ // Blowfish/CFB + SHA-256 custom key derivation; implementation issues.
{
"blowfish",
"VimCrypt~02!",
@@ -110,7 +109,7 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
crypt_blowfish_encode, crypt_blowfish_decode,
},
- /* Blowfish/CFB + SHA-256 custom key derivation; fixed. */
+ // Blowfish/CFB + SHA-256 custom key derivation; fixed.
{
"blowfish2",
"VimCrypt~03!",
@@ -127,11 +126,11 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
crypt_blowfish_encode, crypt_blowfish_decode,
},
- /* NOTE: when adding a new method, use some random bytes for the magic key,
- * to avoid that a text file is recognized as encrypted. */
+ // NOTE: when adding a new method, use some random bytes for the magic key,
+ // to avoid that a text file is recognized as encrypted.
};
-#define CRYPT_MAGIC_LEN 12 /* cannot change */
+#define CRYPT_MAGIC_LEN 12 // cannot change
static char crypt_magic_head[] = "VimCrypt~";
/*
@@ -363,9 +362,9 @@ crypt_create_for_writing(
if (seed_len > 0)
seed = *header + CRYPT_MAGIC_LEN + salt_len;
- /* TODO: Should this be crypt method specific? (Probably not worth
- * it). sha2_seed is pretty bad for large amounts of entropy, so make
- * that into something which is suitable for anything. */
+ // TODO: Should this be crypt method specific? (Probably not worth
+ // it). sha2_seed is pretty bad for large amounts of entropy, so make
+ // that into something which is suitable for anything.
sha2_seed(salt, salt_len, seed, seed_len);
}
@@ -401,10 +400,10 @@ crypt_encode_alloc(
cryptmethod_T *method = &cryptmethods[state->method_nr];
if (method->encode_buffer_fn != NULL)
- /* Has buffer function, pass through. */
+ // Has buffer function, pass through.
return method->encode_buffer_fn(state, from, len, newptr);
if (len == 0)
- /* Not buffering, just return EOF. */
+ // Not buffering, just return EOF.
return (long)len;
*newptr = alloc(len);
@@ -429,11 +428,11 @@ crypt_decode_alloc(
cryptmethod_T *method = &cryptmethods[state->method_nr];
if (method->decode_buffer_fn != NULL)
- /* Has buffer function, pass through. */
+ // Has buffer function, pass through.
return method->decode_buffer_fn(state, ptr, len, newptr);
if (len == 0)
- /* Not buffering, just return EOF. */
+ // Not buffering, just return EOF.
return len;
*newptr = alloc(len);
@@ -542,7 +541,7 @@ crypt_check_current_method(void)
char_u *
crypt_get_key(
int store,
- int twice) /* Ask for the key twice. */
+ int twice) // Ask for the key twice.
{
char_u *p1, *p2 = NULL;
int round;
@@ -568,7 +567,7 @@ crypt_get_key(
crypt_free_key(p1);
crypt_free_key(p2);
p2 = NULL;
- round = -1; /* do it again */
+ round = -1; // do it again
continue;
}
@@ -583,7 +582,7 @@ crypt_get_key(
p2 = p1;
}
- /* since the user typed this, no need to wait for return */
+ // since the user typed this, no need to wait for return
if (msg_didout)
msg_putchar('\n');
need_wait_return = FALSE;
@@ -611,4 +610,4 @@ crypt_append_msg(
}
}
-#endif /* FEAT_CRYPT */
+#endif // FEAT_CRYPT
diff --git a/src/crypt_zip.c b/src/crypt_zip.c
index ec8c16edf..42abe9350 100644
--- a/src/crypt_zip.c
+++ b/src/crypt_zip.c
@@ -23,10 +23,10 @@
* problem since this code was originally created in Europe and India.
*/
-/* Need a type that should be 32 bits. 64 also works but wastes space. */
-typedef unsigned int u32_T; /* int is at least 32 bits */
+// Need a type that should be 32 bits. 64 also works but wastes space.
+typedef unsigned int u32_T; // int is at least 32 bits
-/* The state of encryption, referenced by cryptstate_T. */
+// The state of encryption, referenced by cryptstate_T.
typedef struct {
u32_T keys[3];
} zip_state_T;
@@ -151,4 +151,4 @@ crypt_zip_decode(
}
}
-#endif /* FEAT_CRYPT */
+#endif // FEAT_CRYPT
diff --git a/src/version.c b/src/version.c
index 8040ad0f9..32d8f92dc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2368,
+/**/
2367,
/**/
2366,