summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-01 21:11:22 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-01 21:11:22 +0100
commit5d18efecfd6c45d69f55268948a22cd0465bb955 (patch)
tree409afa09cb7fb8f4684e0399f2597ba5d16edbfa /src
parentfa5612c7d836eb789e0f8ff4b10461b8640a14b2 (diff)
patch 8.1.2378: using old C style commentsv8.1.2378
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src')
-rw-r--r--src/dict.c52
-rw-r--r--src/diff.c482
-rw-r--r--src/digraph.c796
-rw-r--r--src/dosinst.c398
-rw-r--r--src/edit.c1199
-rw-r--r--src/eval.c597
-rw-r--r--src/evalbuffer.c2
-rw-r--r--src/evalfunc.c490
-rw-r--r--src/version.c2
9 files changed, 2006 insertions, 2012 deletions
diff --git a/src/dict.c b/src/dict.c
index d26356928b..5022a5fd01 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -15,10 +15,10 @@
#if defined(FEAT_EVAL) || defined(PROTO)
-/* List head for garbage collection. Although there can be a reference loop
- * from partial to dict to partial, we don't need to keep track of the partial,
- * since it will get freed when the dict is unused and gets freed. */
-static dict_T *first_dict = NULL; /* list of all dicts */
+// List head for garbage collection. Although there can be a reference loop
+// from partial to dict to partial, we don't need to keep track of the partial,
+// since it will get freed when the dict is unused and gets freed.
+static dict_T *first_dict = NULL;
/*
* Allocate an empty header for a dictionary.
@@ -31,7 +31,7 @@ dict_alloc(void)
d = ALLOC_CLEAR_ONE(dict_T);
if (d != NULL)
{
- /* Add the dict to the list of dicts for garbage collection. */
+ // Add the dict to the list of dicts for garbage collection.
if (first_dict != NULL)
first_dict->dv_used_prev = d;
d->dv_used_next = first_dict;
@@ -109,15 +109,15 @@ dict_free_contents(dict_T *d)
hashitem_T *hi;
dictitem_T *di;
- /* Lock the hashtab, we don't want it to resize while freeing items. */
+ // Lock the hashtab, we don't want it to resize while freeing items.
hash_lock(&d->dv_hashtab);
todo = (int)d->dv_hashtab.ht_used;
for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
{
if (!HASHITEM_EMPTY(hi))
{
- /* Remove the item before deleting it, just in case there is
- * something recursive causing trouble. */
+ // Remove the item before deleting it, just in case there is
+ // something recursive causing trouble.
di = HI2DI(hi);
hash_remove(&d->dv_hashtab, hi);
dictitem_free(di);
@@ -125,14 +125,14 @@ dict_free_contents(dict_T *d)
}
}
- /* The hashtab is still locked, it has to be re-initialized anyway */
+ // The hashtab is still locked, it has to be re-initialized anyway
hash_clear(&d->dv_hashtab);
}
static void
dict_free_dict(dict_T *d)
{
- /* Remove the dict from the list of dicts for garbage collection. */
+ // Remove the dict from the list of dicts for garbage collection.
if (d->dv_used_prev == NULL)
first_dict = d->dv_used_next;
else
@@ -176,9 +176,9 @@ dict_free_nonref(int copyID)
for (dd = first_dict; dd != NULL; dd = dd->dv_used_next)
if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK))
{
- /* Free the Dictionary and ordinary items it contains, but don't
- * recurse into Lists and Dictionaries, they will be in the list
- * of dicts or list of lists. */
+ // Free the Dictionary and ordinary items it contains, but don't
+ // recurse into Lists and Dictionaries, they will be in the list
+ // of dicts or list of lists.
dict_free_contents(dd);
did_free = TRUE;
}
@@ -577,7 +577,7 @@ dict_find(dict_T *d, char_u *key, int len)
}
else
{
- /* Avoid a malloc/free by using buf[]. */
+ // Avoid a malloc/free by using buf[].
vim_strncpy(buf, key, len);
akey = buf;
}
@@ -764,7 +764,7 @@ dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, int literal)
*/
if (*start != '}')
{
- if (eval1(&start, &tv, FALSE) == FAIL) /* recursive! */
+ if (eval1(&start, &tv, FALSE) == FAIL) // recursive!
return FAIL;
if (*start == '}')
return NOTDONE;
@@ -798,14 +798,14 @@ dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, int literal)
key = tv_get_string_buf_chk(&tvkey, buf);
if (key == NULL)
{
- /* "key" is NULL when tv_get_string_buf_chk() gave an errmsg */
+ // "key" is NULL when tv_get_string_buf_chk() gave an errmsg
clear_tv(&tvkey);
goto failret;
}
}
*arg = skipwhite(*arg + 1);
- if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */
+ if (eval1(arg, &tv, evaluate) == FAIL) // recursive!
{
if (evaluate)
clear_tv(&tvkey);
@@ -881,8 +881,8 @@ dict_extend(dict_T *d1, dict_T *d2, char_u *action)
di1 = dict_find(d1, hi2->hi_key, -1);
if (d1->dv_scope != 0)
{
- /* Disallow replacing a builtin function in l: and g:.
- * Check the key to be valid when adding to any scope. */
+ // Disallow replacing a builtin function in l: and g:.
+ // Check the key to be valid when adding to any scope.
if (d1->dv_scope == VAR_DEF_SCOPE
&& HI2DI(hi2)->di_tv.v_type == VAR_FUNC
&& var_check_func_name(hi2->hi_key, di1 == NULL))
@@ -929,8 +929,8 @@ dict_lookup(hashitem_T *hi)
dict_equal(
dict_T *d1,
dict_T *d2,
- int ic, /* ignore case for strings */
- int recursive) /* TRUE when used recursively */
+ int ic, // ignore case for strings
+ int recursive) // TRUE when used recursively
{
hashitem_T *hi;
dictitem_T *item2;
@@ -1004,19 +1004,19 @@ dict_list(typval_T *argvars, typval_T *rettv, int what)
if (what == 0)
{
- /* keys() */
+ // keys()
li->li_tv.v_type = VAR_STRING;
li->li_tv.v_lock = 0;
li->li_tv.vval.v_string = vim_strsave(di->di_key);
}
else if (what == 1)
{
- /* values() */
+ // values()
copy_tv(&di->di_tv, &li->li_tv);
}
else
{
- /* items() */
+ // items()
l2 = list_alloc();
li->li_tv.v_type = VAR_LIST;
li->li_tv.v_lock = 0;
@@ -1079,7 +1079,7 @@ dict_set_items_ro(dict_T *di)
int todo = (int)di->dv_hashtab.ht_used;
hashitem_T *hi;
- /* Set readonly */
+ // Set readonly
for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi)
{
if (HASHITEM_EMPTY(hi))
@@ -1139,4 +1139,4 @@ dict_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
}
}
-#endif /* defined(FEAT_EVAL) */
+#endif // defined(FEAT_EVAL)
diff --git a/src/diff.c b/src/diff.c
index dd5fb22f40..f996904543 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -24,7 +24,7 @@
static int diff_busy = FALSE; // using diff structs, don't change them
static int diff_need_update = FALSE; // ex_diffupdate needs to be called
-/* flags obtained from the 'diffopt' option */
+// flags obtained from the 'diffopt' option
#define DIFF_FILLER 0x001 // display filler lines
#define DIFF_IBLANK 0x002 // ignore empty lines
#define DIFF_ICASE 0x004 // ignore case
@@ -41,14 +41,14 @@ static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
static long diff_algorithm = 0;
-#define LBUFLEN 50 /* length of line in diff file */
+#define LBUFLEN 50 // length of line in diff file
-static int diff_a_works = MAYBE; /* TRUE when "diff -a" works, FALSE when it
- doesn't work, MAYBE when not checked yet */
+static int diff_a_works = MAYBE; // TRUE when "diff -a" works, FALSE when it
+ // doesn't work, MAYBE when not checked yet
#if defined(MSWIN)
-static int diff_bin_works = MAYBE; /* TRUE when "diff --binary" works, FALSE
- when it doesn't work, MAYBE when not
- checked yet */
+static int diff_bin_works = MAYBE; // TRUE when "diff --binary" works, FALSE
+ // when it doesn't work, MAYBE when not
+ // checked yet
#endif
// used for diff input
@@ -124,8 +124,8 @@ diff_buf_adjust(win_T *win)
if (!win->w_p_diff)
{
- /* When there is no window showing a diff for this buffer, remove
- * it from the diffs. */
+ // When there is no window showing a diff for this buffer, remove
+ // it from the diffs.
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer == win->w_buffer && wp->w_p_diff)
break;
@@ -158,7 +158,7 @@ diff_buf_add(buf_T *buf)
int i;
if (diff_buf_idx(buf) != DB_COUNT)
- return; /* It's already there. */
+ return; // It's already there.
for (i = 0; i < DB_COUNT; ++i)
if (curtab->tp_diffbuf[i] == NULL)
@@ -254,7 +254,7 @@ diff_mark_adjust(
int idx;
tabpage_T *tp;
- /* Handle all tab pages that use the current buffer in a diff. */
+ // Handle all tab pages that use the current buffer in a diff.
FOR_ALL_TABPAGES(tp)
{
idx = diff_buf_idx_tp(curbuf, tp);
@@ -286,7 +286,7 @@ diff_mark_adjust_tp(
int inserted, deleted;
int n, off;
linenr_T last;
- linenr_T lnum_deleted = line1; /* lnum of remaining deletion */
+ linenr_T lnum_deleted = line1; // lnum of remaining deletion
int check_unchanged;
if (diff_internal())
@@ -301,19 +301,19 @@ diff_mark_adjust_tp(
if (line2 == MAXLNUM)
{
- /* mark_adjust(99, MAXLNUM, 9, 0): insert lines */
+ // mark_adjust(99, MAXLNUM, 9, 0): insert lines
inserted = amount;
deleted = 0;
}
else if (amount_after > 0)
{
- /* mark_adjust(99, 98, MAXLNUM, 9): a change that inserts lines*/
+ // mark_adjust(99, 98, MAXLNUM, 9): a change that inserts lines
inserted = amount_after;
deleted = 0;
}
else
{
- /* mark_adjust(98, 99, MAXLNUM, -2): delete lines */
+ // mark_adjust(98, 99, MAXLNUM, -2): delete lines
inserted = 0;
deleted = -amount_after;
}
@@ -322,9 +322,9 @@ diff_mark_adjust_tp(
dp = tp->tp_first_diff;
for (;;)
{
- /* If the change is after the previous diff block and before the next
- * diff block, thus not touching an existing change, create a new diff
- * block. Don't do this when ex_diffgetput() is busy. */
+ // If the change is after the previous diff block and before the next
+ // diff block, thus not touching an existing change, create a new diff
+ // block. Don't do this when ex_diffgetput() is busy.
if ((dp == NULL || dp->df_lnum[idx] - 1 > line2
|| (line2 == MAXLNUM && dp->df_lnum[idx] > line1))
&& (dprev == NULL
@@ -350,7 +350,7 @@ diff_mark_adjust_tp(
}
}
- /* if at end of the list, quit */
+ // if at end of the list, quit
if (dp == NULL)
break;
@@ -365,25 +365,25 @@ diff_mark_adjust_tp(
* 3 5 6
* 3 5 6
*/
- /* compute last line of this change */
+ // compute last line of this change
last = dp->df_lnum[idx] + dp->df_count[idx] - 1;
- /* 1. change completely above line1: nothing to do */
+ // 1. change completely above line1: nothing to do
if (last >= line1 - 1)
{
- /* 6. change below line2: only adjust for amount_after; also when
- * "deleted" became zero when deleted all lines between two diffs */
+ // 6. change below line2: only adjust for amount_after; also when
+ // "deleted" became zero when deleted all lines between two diffs
if (dp->df_lnum[idx] - (deleted + inserted != 0) > line2)
{
if (amount_after == 0)
- break; /* nothing left to change */
+ break; // nothing left to change
dp->df_lnum[idx] += amount_after;
}
else
{
check_unchanged = FALSE;
- /* 2. 3. 4. 5.: inserted/deleted lines touching this diff. */
+ // 2. 3. 4. 5.: inserted/deleted lines touching this diff.
if (deleted > 0)
{
if (dp->df_lnum[idx] >= line1)
@@ -391,12 +391,12 @@ diff_mark_adjust_tp(
off = dp->df_lnum[idx] - lnum_deleted;
if (last <= line2)
{
- /* 4. delete all lines of diff */
+ // 4. delete all lines of diff
if (dp->df_next != NULL
&& dp->df_next->df_lnum[idx] - 1 <= line2)
{
- /* delete continues in next diff, only do
- * lines until that one */
+ // delete continues in next diff, only do
+ // lines until that one
n = dp->df_next->df_lnum[idx] - lnum_deleted;
deleted -= n;
n -= dp->df_count[idx];
@@ -408,7 +408,7 @@ diff_mark_adjust_tp(
}
else
{
- /* 5. delete lines at or just before top of diff */
+ // 5. delete lines at or just before top of diff
n = off;
dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;
check_unchanged = TRUE;
@@ -420,13 +420,13 @@ diff_mark_adjust_tp(
off = 0;
if (last < line2)
{
- /* 2. delete at end of diff */
+ // 2. delete at end of diff
dp->df_count[idx] -= last - lnum_deleted + 1;
if (dp->df_next != NULL
&& dp->df_next->df_lnum[idx] - 1 <= line2)
{
- /* delete continues in next diff, only do
- * lines until that one */
+ // delete continues in next diff, only do
+ // lines until that one
n = dp->df_next->df_lnum[idx] - 1 - last;
deleted -= dp->df_next->df_lnum[idx]
- lnum_deleted;
@@ -438,7 +438,7 @@ diff_mark_adjust_tp(
}
else
{
- /* 3. delete lines inside the diff */
+ // 3. delete lines inside the diff
n = 0;
dp->df_count[idx] -= deleted;
}
@@ -455,24 +455,24 @@ diff_mark_adjust_tp(
{
if (dp->df_lnum[idx] <= line1)
{
- /* inserted lines somewhere in this diff */
+ // inserted lines somewhere in this diff
dp->df_count[idx] += inserted;
check_unchanged = TRUE;
}
else
- /* inserted lines somewhere above this diff */
+ // inserted lines somewhere above this diff
dp->df_lnum[idx] += inserted;
}
if (check_unchanged)
- /* Check if inserted lines are equal, may reduce the
- * size of the diff. TODO: also check for equal lines
- * in the middle and perhaps split the block. */
+ // Check if inserted lines are equal, may reduce the
+ // size of the diff. TODO: also check for equal lines
+ // in the middle and perhaps split the block.
diff_check_unchanged(tp, dp);
}
}
- /* check if this block touches the previous one, may merge them. */
+ // check if this block touches the previous one, may merge them.
if (dprev != NULL && dprev->df_lnum[idx] + dprev->df_count[idx]
== dp->df_lnum[idx])
{
@@ -485,7 +485,7 @@ diff_mark_adjust_tp(
}
else
{
- /* Advance to next entry. */
+ // Advance to next entry.
dprev = dp;
dp = dp->df_next;
}
@@ -495,7 +495,7 @@ diff_mark_adjust_tp(
dp = tp->tp_first_diff;
while (dp != NULL)
{
- /* All counts are zero, remove this entry. */
+ // All counts are zero, remove this entry.
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && dp->df_count[i] != 0)
break;
@@ -511,7 +511,7 @@ diff_mark_adjust_tp(
}
else
{
- /* Advance to next entry. */
+ // Advance to next entry.
dprev = dp;
dp = dp->df_next;
}
@@ -523,9 +523,9 @@ diff_mark_adjust_tp(
// Don't redraw right away, this updates the diffs, which can be slow.
need_diff_redraw = TRUE;
- /* Need to recompute the scroll binding, may remove or add filler
- * lines (e.g., when adding lines above w_topline). But it's slow when
- * making many changes, postpone until redrawing. */
+ // Need to recompute the scroll binding, may remove or add filler
+ // lines (e.g., when adding lines above w_topline). But it's slow when
+ // making many changes, postpone until redrawing.
diff_need_scrollbind = TRUE;
}
}
@@ -565,27 +565,27 @@ diff_check_unchanged(tabpage_T *tp, diff_T *dp)
char_u *line_org;
int dir = FORWARD;
- /* Find the first buffers, use it as the original, compare the other
- * buffer lines against this one. */
+ // Find the first buffers, use it as the original, compare the other
+ // buffer lines against this one.
for (i_org = 0; i_org < DB_COUNT; ++i_org)
if (tp->tp_diffbuf[i_org] != NULL)
break;
- if (i_org == DB_COUNT) /* safety check */
+ if (i_org == DB_COUNT) // safety check
return;
if (diff_check_sanity(tp, dp) == FAIL)
return;
- /* First check lines at the top, then at the bottom. */
+ // First check lines at the top, then at the bottom.
off_org = 0;
off_new = 0;
for (;;)
{
- /* Repeat until a line is found which is different or the number of
- * lines has become zero. */
+ // Repeat until a line is found which is different or the number of
+ // lines has become zero.
while (dp->df_count[i_org] > 0)
{
- /* Copy the line, the next ml_get() will invalidate it. */
+ // Copy the line, the next ml_get() will invalidate it.
if (dir == BACKWARD)
off_org = dp->df_count[i_org] - 1;
line_org = vim_strsave(ml_get_buf(tp->tp_diffbuf[i_org],
@@ -598,7 +598,7 @@ diff_check_unchanged(tabpage_T *tp, diff_T *dp)
continue;
if (dir == BACKWARD)
off_new = dp->df_count[i_new] - 1;
- /* if other buffer doesn't have this line, it was inserted */
+ // if other buffer doesn't have this line, it was inserted
if (off_new < 0 || off_new >= dp->df_count[i_new])
break;
if (diff_cmp(line_org, ml_get_buf(tp->tp_diffbuf[i_new],
@@ -607,11 +607,11 @@ diff_check_unchanged(tabpage_T *tp, diff_T *dp)
}
vim_free(line_org);
- /* Stop when a line isn't equal in all diff buffers. */
+ // Stop when a line isn't equal in all diff buffers.
if (i_new != DB_COUNT)
break;
- /* Line matched in all buffers, remove it from the diff. */
+ // Line matched in all buffers, remove it from the diff.
for (i_new = i_org; i_new < DB_COUNT; ++i_new)
if (tp->tp_diffbuf[i_new] != NULL)
{
@@ -662,8 +662,8 @@ diff_redraw(
if (dofold && foldmethodIsDiff(wp))
foldUpdateAll(wp);
#endif
- /* A change may have made filler lines invalid, need to take care
- * of that for other windows. */
+ // A change may have made filler lines invalid, need to take care
+ // of that for other windows.
n = diff_check(wp, wp->w_topline);
if ((wp != curwin && wp->w_topfill > 0) || n > 0)
{
@@ -1003,7 +1003,7 @@ check_external_diff(diffio_T *diffio)
for (;;)
{
- /* There must be a line that contains "1c1". */
+ // There must be a line that contains "1c1".
if (vim_fgets(linebuf, LBUFLEN, fd))
break;
if (STRNCMP(linebuf, "1c1", 3) == 0)
@@ -1018,13 +1018,13 @@ check_external_diff(diffio_T *diffio)
}
#ifdef FEAT_EVAL
- /* When using 'diffexpr' break here. */
+ // When using 'diffexpr' break here.
if (*p_dex != NUL)
break;
#endif
#if defined(MSWIN)
- /* If the "-a" argument works, also check if "--binary" works. */
+ // If the "-a" argument works, also check if "--binary" works.
if (ok && diff_a_works == MAYBE && diff_bin_works == MAYBE)
{
diff_a_works = TRUE;
@@ -1033,18 +1033,18 @@ check_external_diff(diffio_T *diffio)
}
if (!ok && diff_a_works == TRUE && diff_bin_works == TRUE)
{
- /* Tried --binary, but it failed. "-a" works though. */
+ // Tried --binary, but it failed. "-a" works though.
diff_bin_works = FALSE;
ok = TRUE;
}
#endif
- /* If we checked if "-a" works already, break here. */
+ // If we checked if "-a" works already, break here.
if (diff_a_works != MAYBE)
break;
diff_a_works = ok;
- /* If "-a" works break here, otherwise retry without "-a". */
+ // If "-a" works break here, otherwise retry without "-a".
if (ok)
break;
}
@@ -1172,12 +1172,12 @@ diff_file(diffio_T *dio)
void
ex_diffpatch(exarg_T *eap)
{
- char_u *tmp_orig; /* name of original temp file */
- char_u *tmp_new; /* name of patched temp file */
+ char_u *tmp_orig; // name of original temp file
+ char_u *tmp_new; // name of patched temp file
char_u *buf = NULL;
size_t buflen;
win_T *old_curwin = curwin;
- char_u *newname = NULL; /* name of patched file buffer */
+ char_u *newname = NULL; // name of patched file buffer
#ifdef UNIX
char_u dirbuf[MAXPATHL];
char_u *fullname = NULL;
@@ -1196,26 +1196,26 @@ ex_diffpatch(exarg_T *eap)
eap->arg, NULL, NULL,
(char_u *)_(BROWSE_FILTER_ALL_FILES), NULL);
if (browseFile == NULL)
- return; /* operation cancelled */
+ return; // operation cancelled
eap->arg = browseFile;
- cmdmod.browse = FALSE; /* don't let do_ecmd() browse again */
+ cmdmod.browse = FALSE; // don't let do_ecmd() browse again
}
#endif
- /* We need two temp file names. */
+ // We need two temp file names.
tmp_orig = vim_tempname('o', FALSE);
tmp_new = vim_tempname('n', FALSE);
if (tmp_orig == NULL || tmp_new == NULL)
goto theend;
- /* Write the current buffer to "tmp_orig". */
+ // Write the current buffer to "tmp_orig".
if (buf_write(curbuf, tmp_orig, NULL,
(linenr_T)1, curbuf->b_ml.ml_line_count,
NULL, FALSE, FALSE, FALSE, TRUE) == FAIL)
goto theend;
#ifdef UNIX
- /* Get the absolute path of the patchfile, changing directory below. */
+ // Get the absolute path of the patchfile, changing directory below.
fullname = FullName_save(eap->arg, FALSE);
#endif
esc_name = vim_strsave_shellescape(
@@ -1231,11 +1231,11 @@ ex_diffpatch(exarg_T *eap)
goto theend;
#ifdef UNIX
- /* Temporarily chdir to /tmp, to avoid patching files in the current
- * directory when the patch file contains more than one patch. When we
- * have our own temp dir use that instead, it will be cleaned up when we
- * exit (any .rej files created). Don't change directory if we can't
- * return to the current. */
+ // Temporarily chdir to /tmp, to avoid patching files in the current
+ // directory when the patch file contains more than one patch. When we
+ // have our own temp dir use that instead, it will be cleaned up when we
+ // exit (any .rej files created). Don't change directory if we can't
+ // return to the current.
if (mch_dirname(dirbuf, MAXPATHL) != OK || mch_chdir((char *)dirbuf) != 0)
dirbuf[0] = NUL;
else
@@ -1252,7 +1252,7 @@ ex_diffpatch(exarg_T *eap)
#ifdef FEAT_EVAL
if (*p_pex != NUL)
- /* Use 'patchexpr' to generate the new file. */
+ // Use 'patchexpr' to generate the new file.
eval_patch(tmp_orig,
# ifdef UNIX
fullname != NULL ? fullname :
@@ -1261,11 +1261,11 @@ ex_diffpatch(exarg_T *eap)
else
#endif
{
- /* Build the patch command and execute it. Ignore errors. Switch to
- * cooked mode to allow the user to respond to prompts. */
+ // Build the patch command and execute it. Ignore errors. Switch to
+ // cooked mode to allow the user to respond to prompts.
vim_snprintf((char *)buf, buflen, "patch -o %s %s < %s",
tmp_new, tmp_orig, esc_name);
- block_autocmds(); /* Avoid ShellCmdPost stuff */
+ block_autocmds(); // Avoid ShellCmdPost stuff
(void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
unblock_autocmds();
}
@@ -1279,10 +1279,10 @@ ex_diffpatch(exarg_T *eap)
}
#endif
- /* patch probably has written over the screen */
+ // patch probably has written over the screen
redraw_later(CLEAR);
- /* Delete any .orig or .rej file created. */
+ // Delete any .orig or .rej file created.
STRCPY(buf, tmp_new);
STRCAT(buf, ".orig");
mch_remove(buf);
@@ -1290,7 +1290,7 @@ ex_diffpatch(exarg_T *eap)
STRCAT(buf, ".rej");
mch_remove(buf);
- /* Only continue if the output file was created. */
+ // Only continue if the output file was created.
if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
emsg(_("E816: Cannot read patch output"));
else
@@ -1306,30 +1306,30 @@ ex_diffpatch(exarg_T *eap)
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
- /* don't use a new tab page, each tab page has its own diffs */
+ // don't use a new tab page, each tab page has its own diffs
cmdmod.tab = 0;
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
{
- /* Pretend it was a ":split fname" command */
+ // Pretend it was a ":split fname" command
eap->cmdidx = CMD_split;
eap->arg = tmp_new;
do_exedit(eap, old_curwin);
- /* check that split worked and editing tmp_new */
+ // check that split worked and editing tmp_new
if (curwin != old_curwin && win_valid(old_curwin))
{
- /* Set 'diff', 'scrollbind' on and 'wrap' off. */
+ // Set 'diff', 'scrollbind' on and 'wrap' off.
diff_win_options(curwin, TRUE);
diff_win_options(old_curwin, TRUE);
if (newname != NULL)
{
- /* do a ":file filename.new" on the patched buffer */
+ // do a ":file filename.new" on the patched buffer
eap->arg = newname;
ex_file(eap);
- /* Do filetype detection with the new name. */
+ // Do filetype detection with the new name.
if (au_has_group((char_u *)"filetypedetect"))
do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
}
@@ -1369,35 +1369,35 @@ ex_diffsplit(exarg_T *eap)
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
- /* Need to compute w_fraction when no redraw happened yet. */
+ // Need to compute w_fraction when no redraw happened yet.
validate_cursor();
set_fraction(curwin);
- /* don't use a new tab page, each tab page has its own diffs */
+ // don't use a new tab page, each tab page has its own diffs
cmdmod.tab = 0;
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
{
- /* Pretend it was a ":split fname" command */
+ // Pretend it was a ":split fname" command
eap->cmdidx = CMD_split;
curwin->w_p_diff = TRUE;
do_exedit(eap, old_curwin);
- if (curwin != old_curwin) /* split must have worked */
+ if (curwin != old_curwin) // split must have worked
{
- /* Set 'diff', 'scrollbind' on and 'wrap' off. */
+ // Set 'diff', 'scrollbind' on and 'wrap' off.
diff_win_options(curwin, TRUE);
if (win_valid(old_curwin))
{
diff_win_options(old_curwin, TRUE);
if (bufref_valid(&old_curbuf))
- /* Move the cursor position to that of the old window. */
+ // Move the cursor position to that of the old window.
curwin->w_cursor.lnum = diff_get_corresponding_line(
old_curbuf.br_buf, old_curwin->w_cursor.lnum);
}
- /* Now that lines are folded scroll to show the cursor at the same
- * relative position. */
+ // Now that lines are folded scroll to show the cursor at the same
+ // relative position.
scroll_to_fraction(curwin, curwin->w_height);
}
}
@@ -1409,7 +1409,7 @@ ex_diffsplit(exarg_T *eap)
void
ex_diffthis(exarg_T *eap UNUSED)
{
- /* Set 'diff', 'scrollbind' on and 'wrap' off. */
+ // Set 'diff', 'scrollbind' on and 'wrap' off.
diff_win_options(curwin, TRUE);
}
@@ -1433,18 +1433,18 @@ set_diff_option(win_T *wp, int value)
void
diff_win_options(
win_T *wp,
- int addbuf) /* Add buffer to diff. */
+ int addbuf) // Add buffer to diff.
{
# ifdef FEAT_FOLDING
win_T *old_curwin = curwin;
- /* close the manually opened folds */
+ // close the manually opened folds
curwin = wp;
newFoldLevel();
curwin = old_curwin;
# endif
- /* Use 'scrollbind' and 'cursorbind' when available */
+ // Use 'scrollbind' and 'cursorbind' when available
if (!wp->w_p_diff)
wp->w_p_scb_save = wp->w_p_scb;
wp->w_p_scb = TRUE;
@@ -1473,12 +1473,12 @@ diff_win_options(
wp->w_p_fen = TRUE;
wp->w_p_fdl = 0;
foldUpdateAll(wp);
- /* make sure topline is not halfway a fold */
+ // make sure topline is not halfway a fold
changed_window_setting_win(wp);
# endif
if (vim_strchr(p_sbo, 'h') == NULL)
do_cmdline_cmd((char_u *)"set sbo+=hor");
- /* Save the current values, to be restored in ex_diffoff(). */
+ // Save the current values, to be restored in ex_diffoff().
wp->w_p_diff_saved = TRUE;
set_diff_option(wp, TRUE);
@@ -1502,9 +1502,9 @@ ex_diffoff(exarg_T *eap)
{
if (eap->forceit ? wp->w_p_diff : wp == curwin)
{
- /* Set 'diff' off. If option values were saved in
- * diff_win_options(), restore the ones whose settings seem to have
- * been left over from diff mode. */
+ // Set 'diff' off. If option values were saved in
+ // diff_win_options(), restore the ones whose settings seem to have
+ // been left over from diff mode.
set_diff_option(wp, FALSE);
if (wp->w_p_diff_saved)
@@ -1526,8 +1526,8 @@ ex_diffoff(exarg_T *eap)
if (wp->w_p_fdl == 0)
wp->w_p_fdl = wp->w_p_fdl_save;
- /* Only restore 'foldenable' when 'foldmethod' is not
- * "manual", otherwise we continue to show the diff folds. */
+ // Only restore 'foldenable' when 'foldmethod' is not
+ // "manual", otherwise we continue to show the diff folds.
if (wp->w_p_fen)
wp->w_p_fen = foldmethodIsManual(wp) ? FALSE
: wp->w_p_fen_save;
@@ -1535,20 +1535,20 @@ ex_diffoff(exarg_T *eap)
foldUpdateAll(wp);
#endif
}
- /* remove filler lines */
+ // remove filler lines
wp->w_topfill = 0;
- /* make sure topline is not halfway a fold and cursor is
- * invalidated */
+ // make sure topline is not halfway a fold and cursor is
+ // invalidated
changed_window_setting_win(wp);
- /* Note: 'sbo' is not restored, it's a global option. */
+ // Note: 'sbo' is not restored, it's a global option.
diff_buf_adjust(wp);
}
diffwin |= wp->w_p_diff;
}
- /* Also remove hidden buffers from the list. */
+ // Also remove hidden buffers from the list.
if (eap->forceit)
diff_buf_clear();
@@ -1560,7 +1560,7 @@ ex_diffoff(exarg_T *eap)
diff_clear(curtab);
}
- /* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
+ // Remove "hor" from from 'scrollopt' if there are no diff windows left.
if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)
do_cmdline_cmd((char_u *)"set sbo-=hor");
}
@@ -1579,13 +1579,13 @@ diff_read(
diff_T *dprev = NULL;
diff_T *dp = curtab->tp_first_diff;
diff_T *dn, *dpl;
- char_u linebuf[LBUFLEN]; /* only need to hold the diff line */
+ char_u linebuf[LBUFLEN]; // only need to hold the diff line
char_u *line;
long off;
int i;
linenr_T lnum_orig, lnum_new;
long count_orig, count_new;
- int notset = TRUE; /* block "*dp" not set yet */
+ int notset = TRUE; // block "*dp" not set yet
enum {
DIFF_ED,
DIFF_UNIFIED,
@@ -1829,7 +1829,7 @@ diff_clear(tabpage_T *tp)
int
diff_check(win_T *wp, linenr_T lnum)
{
- int idx; /* index in tp_diffbuf[] for this buffer */
+ int idx; // index in tp_diffbuf[] for this buffer
diff_T *dp;
int maxcount;
int i;
@@ -1837,26 +1837,26 @@ diff_check(win_T *wp, linenr_T lnum)
int cmp;
if (curtab->tp_diff_invalid)
- ex_diffupdate(NULL); /* update after a big change */
+ ex_diffupdate(NULL); // update after a big change
- if (curtab->tp_first_diff == NULL || !wp->w_p_diff) /* no diffs at all */
+ if (curtab->tp_first_diff == NULL || !wp->w_p_diff) // no diffs at all
return 0;
- /* safety check: "lnum" must be a buffer line */
+ // safety check: "lnum" must be a buffer line
if (lnum < 1 || lnum > buf->b_ml.ml_line_count + 1)
return 0;
idx = diff_buf_idx(buf);
if (idx == DB_COUNT)
- return 0; /* no diffs for buffer "buf" */
+ return 0; // no diffs for buffer "buf"
#ifdef FEAT_FOLDING
- /* A closed fold never has filler lines. */
+ // A closed fold never has filler lines.
if (hasFoldingWin(wp, lnum, NULL, NULL, TRUE, NULL))
return 0;
#endif
- /* search for a change that includes "lnum" in the list of diffblocks. */
+ // search for a change that includes "lnum" in the list of diffblocks.
for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
if (lnum <= dp->df_lnum[idx] + dp->df_count[idx])
break;
@@ -1867,9 +1867,9 @@ diff_check(win_T *wp, linenr_T lnum)
{
int zero = FALSE;
- /* Changed or inserted line. If the other buffers have a count of
- * zero, the lines were inserted. If the other buffers have the same
- * count, check if the lines are identical. */
+ // Changed or inserted line. If the other buffers have a count of
+ // zero, the lines were inserted. If the other buffers have the same
+ // count, check if the lines are identical.
cmp = FALSE;
for (i = 0; i < DB_COUNT; ++i)
if (i != idx && curtab->tp_diffbuf[i] != NULL)
@@ -1879,36 +1879,36 @@ diff_check(win_T *wp, linenr_T lnum)
else
{
if (dp->df_count[i] != dp->df_count[idx])
- return -1; /* nr of lines changed. */
+ return -1; // nr of lines changed.
cmp = TRUE;
}
}
if (cmp)
{
- /* Compare all lines. If they are equal the lines were inserted
- * in some buffers, deleted in others, but not changed. */
+ // Compare all lines. If they are equal the lines were inserted
+ // in some buffers, deleted in others, but not changed.
for (i = 0; i < DB_COUNT; ++i)
if (i != idx && curtab->tp_diffbuf[i] != NULL
&& dp->df_count[i] != 0)
if (!diff_equal_entry(dp, idx, i))
return -1;
}
- /* If there is no buffer with zero lines then there is no difference
- * any longer. Happens when making a change (or undo) that removes
- * the difference. Can't remove the entry here, we might be halfway
- * updating the window. Just report the text as unchanged. Other
- * windows might still show the change though. */
+ // If there is no buffer with zero lines then there is no difference
+ // any longer. Happens when making a change (or undo) that removes
+ // the difference. Can't remove the entry here, we might be halfway
+ // updating the window. Just report the text as unchanged. Other
+ // windows might still show the change though.
if (zero == FALSE)
return 0;
return -2;
}
- /* If 'diffopt' doesn't contain "filler", return 0. */
+ // If 'diffopt' doesn't contain "filler", return 0.
if (!(diff_flags & DIFF_FILLER))
return 0;
- /* Insert filler lines above the line just below the change. Will return
- * 0 when this