1
0
forked from aniani/vim

patch 8.1.2388: using old C style comments

Problem:    Using old C style comments.
Solution:   Use // comments where appropriate.
This commit is contained in:
Bram Moolenaar 2019-12-04 21:57:43 +01:00
parent 2ab2e8608f
commit 4ba37b5833
12 changed files with 1926 additions and 1930 deletions

View File

@ -48,7 +48,7 @@ json_encode(typval_T *val, int options)
{
garray_T ga;
/* Store bytes in the growarray. */
// Store bytes in the growarray.
ga_init2(&ga, 1, 4000);
json_encode_gap(&ga, val, options);
ga_append(&ga, NUL);
@ -104,8 +104,8 @@ write_string(garray_T *gap, char_u *str)
if (!enc_utf8)
{
/* Convert the text from 'encoding' to utf-8, the JSON string is
* always utf-8. */
// Convert the text from 'encoding' to utf-8, the JSON string is
// always utf-8.
conv.vc_type = CONV_NONE;
convert_setup(&conv, p_enc, (char_u*)"utf-8");
if (conv.vc_type != CONV_NONE)
@ -117,7 +117,7 @@ write_string(garray_T *gap, char_u *str)
while (*res != NUL)
{
int c;
/* always use utf-8 encoding, ignore 'encoding' */
// always use utf-8 encoding, ignore 'encoding'
c = utf_ptr2char(res);
switch (c)
@ -132,8 +132,8 @@ write_string(garray_T *gap, char_u *str)
ga_append(gap, '\\'); ga_append(gap, 'f'); break;
case 0x0d:
ga_append(gap, '\\'); ga_append(gap, 'r'); break;
case 0x22: /* " */
case 0x5c: /* \ */
case 0x22: // "
case 0x5c: // backslash
ga_append(gap, '\\');
ga_append(gap, c);
break;
@ -200,9 +200,9 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
case VVAL_TRUE: ga_concat(gap, (char_u *)"true"); break;
case VVAL_NONE: if ((options & JSON_JS) != 0
&& (options & JSON_NO_NONE) == 0)
/* empty item */
// empty item
break;
/* FALLTHROUGH */
// FALLTHROUGH
case VVAL_NULL: ga_concat(gap, (char_u *)"null"); break;
}
break;
@ -222,7 +222,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
case VAR_PARTIAL:
case VAR_JOB:
case VAR_CHANNEL:
/* no JSON equivalent TODO: better error */
// no JSON equivalent TODO: better error
emsg(_(e_invarg));
return FAIL;
@ -268,7 +268,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
&& li->li_next == NULL
&& li->li_tv.v_type == VAR_SPECIAL
&& li->li_tv.vval.v_number == VVAL_NONE)
/* add an extra comma if the last item is v:none */
// add an extra comma if the last item is v:none
ga_append(gap, ',');
li = li->li_next;
if (li != NULL)
@ -405,21 +405,21 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
if (res != NULL)
ga_init2(&ga, 1, 200);
p = reader->js_buf + reader->js_used + 1; /* skip over " or ' */
p = reader->js_buf + reader->js_used + 1; // skip over " or '
while (*p != quote)
{
/* The JSON is always expected to be utf-8, thus use utf functions
* here. The string is converted below if needed. */
// The JSON is always expected to be utf-8, thus use utf functions
// here. The string is converted below if needed.
if (*p == NUL || p[1] == NUL || utf_ptr2len(p) < utf_byte2len(*p))
{
/* Not enough bytes to make a character or end of the string. Get
* more if possible. */
// Not enough bytes to make a character or end of the string. Get
// more if possible.
if (reader->js_fill == NULL)
break;
len = (int)(reader->js_end - p);
reader->js_used = (int)(p - reader->js_buf);
if (!reader->js_fill(reader))
break; /* didn't get more */
break; // didn't get more
p = reader->js_buf + reader->js_used;
reader->js_end = reader->js_buf + STRLEN(reader->js_buf);
continue;
@ -466,7 +466,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
{
varnumber_T nr2 = 0;
/* decode surrogate pair: \ud812\u3456 */
// decode surrogate pair: \ud812\u3456
len = 0;
vim_str2nr(p + 2, NULL, &len,
STR2NR_HEX + STR2NR_FORCE, &nr2, NULL, 4, TRUE);
@ -492,7 +492,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
}
break;
default:
/* not a special char, skip over \ */
// not a special char, skip over backslash
++p;
continue;
}
@ -533,7 +533,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
{
vimconv_T conv;
/* Convert the utf-8 string to 'encoding'. */
// Convert the utf-8 string to 'encoding'.
conv.vc_type = CONV_NONE;
convert_setup(&conv, (char_u*)"utf-8", p_enc);
if (conv.vc_type != CONV_NONE)
@ -560,14 +560,14 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
}
typedef enum {
JSON_ARRAY, /* parsing items in an array */
JSON_OBJECT_KEY, /* parsing key of an object */
JSON_OBJECT /* parsing item in an object, after the key */
JSON_ARRAY, // parsing items in an array
JSON_OBJECT_KEY, // parsing key of an object
JSON_OBJECT // parsing item in an object, after the key
} json_decode_T;
typedef struct {
json_decode_T jd_type;
typval_T jd_tv; /* the list or dict */
typval_T jd_tv; // the list or dict
typval_T jd_key_tv;
char_u *jd_key;
} json_dec_item_T;
@ -611,17 +611,17 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
{
retval = MAYBE;
if (top_item->jd_type == JSON_OBJECT)
/* did get the key, clear it */
// did get the key, clear it
clear_tv(&top_item->jd_key_tv);
goto theend;
}
if (top_item->jd_type == JSON_OBJECT_KEY
|| top_item->jd_type == JSON_ARRAY)
{
/* Check for end of object or array. */
// Check for end of object or array.
if (*p == (top_item->jd_type == JSON_ARRAY ? ']' : '}'))
{
++reader->js_used; /* consume the ']' or '}' */
++reader->js_used; // consume the ']' or '}'
--stack.ga_len;
if (stack.ga_len == 0)
{
@ -644,7 +644,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
{
char_u *key;
/* accept an object key that is not in quotes */
// accept an object key that is not in quotes
key = p = reader->js_buf + reader->js_used;
while (*p != NUL && *p != ':' && *p > ' ')
++p;
@ -660,7 +660,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
{
switch (*p)
{
case '[': /* start of array */
case '[': // start of array
if (top_item && top_item->jd_type == JSON_OBJECT_KEY)
{
retval = FAIL;
@ -679,7 +679,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
break;
}
++reader->js_used; /* consume the '[' */
++reader->js_used; // consume the '['
top_item = ((json_dec_item_T *)stack.ga_data)
+ stack.ga_len;
top_item->jd_type = JSON_ARRAY;
@ -691,7 +691,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
}
continue;
case '{': /* start of object */
case '{': // start of object
if (top_item && top_item->jd_type == JSON_OBJECT_KEY)
{
retval = FAIL;
@ -710,7 +710,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
break;
}
++reader->js_used; /* consume the '{' */
++reader->js_used; // consume the '{'
top_item = ((json_dec_item_T *)stack.ga_data)
+ stack.ga_len;
top_item->jd_type = JSON_OBJECT_KEY;
@ -722,7 +722,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
}
continue;
case '"': /* string */
case '"': // string
retval = json_decode_string(reader, cur_item, *p);
break;
@ -736,15 +736,15 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
}
break;
case ',': /* comma: empty item */
case ',': // comma: empty item
if ((options & JSON_JS) == 0)
{
emsg(_(e_invarg));
retval = FAIL;
break;
}
/* FALLTHROUGH */
case NUL: /* empty */
// FALLTHROUGH
case NUL: // empty
if (cur_item != NULL)
{
cur_item->v_type = VAR_SPECIAL;
@ -795,7 +795,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
varnumber_T nr;
vim_str2nr(reader->js_buf + reader->js_used,
NULL, &len, 0, /* what */
NULL, &len, 0, // what
&nr, NULL, 0, TRUE);
if (len == 0)
{
@ -881,7 +881,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
break;
}
#endif
/* check for truncated name */
// check for truncated name
len = (int)(reader->js_end - (reader->js_buf + reader->js_used));
if (
(len < 5 && STRNICMP((char *)p, "false", len) == 0)
@ -899,8 +899,8 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
break;
}
/* We are finished when retval is FAIL or MAYBE and when at the
* toplevel. */
// We are finished when retval is FAIL or MAYBE and when at the
// toplevel.
if (retval == FAIL)
break;
if (retval == MAYBE || stack.ga_len == 0)
@ -1037,7 +1037,7 @@ item_end:
}
}
/* Get here when parsing failed. */
// Get here when parsing failed.
if (res != NULL)
{
clear_tv(res);
@ -1061,7 +1061,7 @@ json_decode_all(js_read_T *reader, typval_T *res, int options)
{
int ret;
/* We find the end once, to avoid calling strlen() many times. */
// We find the end once, to avoid calling strlen() many times.
reader->js_end = reader->js_buf + STRLEN(reader->js_buf);
json_skip_white(reader);
ret = json_decode_item(reader, res, options);
@ -1093,7 +1093,7 @@ json_decode(js_read_T *reader, typval_T *res, int options)
{
int ret;
/* We find the end once, to avoid calling strlen() many times. */
// We find the end once, to avoid calling strlen() many times.
reader->js_end = reader->js_buf + STRLEN(reader->js_buf);
json_skip_white(reader);
ret = json_decode_item(reader, res, options);
@ -1119,7 +1119,7 @@ json_find_end(js_read_T *reader, int options)
int used_save = reader->js_used;
int ret;
/* We find the end once, to avoid calling strlen() many times. */
// We find the end once, to avoid calling strlen() many times.
reader->js_end = reader->js_buf + STRLEN(reader->js_buf);
json_skip_white(reader);
ret = json_decode_item(reader, NULL, options);

View File

@ -14,16 +14,16 @@
#undef NDEBUG
#include <assert.h>
/* Must include main.c because it contains much more than just main() */
// Must include main.c because it contains much more than just main()
#define NO_VIM_MAIN
#include "main.c"
/* This file has to be included because the tested functions are static */
// This file has to be included because the tested functions are static
#include "json.c"
#if defined(FEAT_EVAL)
/*
* Test json_find_end() with imcomplete items.
* Test json_find_end() with incomplete items.
*/
static void
test_decode_find_end(void)
@ -33,7 +33,7 @@ test_decode_find_end(void)
reader.js_fill = NULL;
reader.js_used = 0;
/* string and incomplete string */
// string and incomplete string
reader.js_buf = (char_u *)"\"hello\"";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" \"hello\" ";
@ -41,13 +41,13 @@ test_decode_find_end(void)
reader.js_buf = (char_u *)"\"hello";
assert(json_find_end(&reader, 0) == MAYBE);
/* number and dash (incomplete number) */
// number and dash (incomplete number)
reader.js_buf = (char_u *)"123";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"-";
assert(json_find_end(&reader, 0) == MAYBE);
/* false, true and null, also incomplete */
// false, true and null, also incomplete
reader.js_buf = (char_u *)"false";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"f";
@ -77,7 +77,7 @@ test_decode_find_end(void)
reader.js_buf = (char_u *)"nul";
assert(json_find_end(&reader, 0) == MAYBE);
/* object without white space */
// object without white space
reader.js_buf = (char_u *)"{\"a\":123}";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"{\"a\":123";
@ -93,7 +93,7 @@ test_decode_find_end(void)
reader.js_buf = (char_u *)"{";
assert(json_find_end(&reader, 0) == MAYBE);
/* object with white space */
// object with white space
reader.js_buf = (char_u *)" { \"a\" : 123 } ";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" { \"a\" : 123 ";
@ -107,13 +107,13 @@ test_decode_find_end(void)
reader.js_buf = (char_u *)" { ";
assert(json_find_end(&reader, 0) == MAYBE);
/* JS object with white space */
// JS object with white space
reader.js_buf = (char_u *)" { a : 123 } ";
assert(json_find_end(&reader, JSON_JS) == OK);
reader.js_buf = (char_u *)" { a : ";
assert(json_find_end(&reader, JSON_JS) == MAYBE);
/* array without white space */
// array without white space
reader.js_buf = (char_u *)"[\"a\",123]";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)"[\"a\",123";
@ -129,7 +129,7 @@ test_decode_find_end(void)
reader.js_buf = (char_u *)"[";
assert(json_find_end(&reader, 0) == MAYBE);
/* array with white space */
// array with white space
reader.js_buf = (char_u *)" [ \"a\" , 123 ] ";
assert(json_find_end(&reader, 0) == OK);
reader.js_buf = (char_u *)" [ \"a\" , 123 ";

View File

@ -14,11 +14,11 @@
#undef NDEBUG
#include <assert.h>
/* Must include main.c because it contains much more than just main() */
// Must include main.c because it contains much more than just main()
#define NO_VIM_MAIN
#include "main.c"
/* This file has to be included because the tested functions are static */
// This file has to be included because the tested functions are static
#include "charset.c"
/*
@ -38,7 +38,7 @@ test_isword_funcs_utf8(void)
buf.b_p_isk = (char_u *)"@,48-57,_,128-167,224-235";
curbuf = &buf;
mb_init(); /* calls init_chartab() */
mb_init(); // calls init_chartab()
for (c = 0; c < 0x10000; ++c)
{

View File

@ -17,8 +17,8 @@
static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob");
/* List heads for garbage collection. */
static list_T *first_list = NULL; /* list of all lists */
// List heads for garbage collection.
static list_T *first_list = NULL; // list of all lists
/*
* Add a watcher to a list.
@ -77,7 +77,7 @@ list_alloc(void)
l = ALLOC_CLEAR_ONE(list_T);
if (l != NULL)
{
/* Prepend the list to the list of lists for garbage collection. */
// Prepend the list to the list of lists for garbage collection.
if (first_list != NULL)
first_list->lv_used_prev = l;
l->lv_used_prev = NULL;
@ -165,7 +165,7 @@ list_free_contents(list_T *l)
for (item = l->lv_first; item != NULL; item = l->lv_first)
{
/* Remove the item before deleting it. */
// Remove the item before deleting it.
l->lv_first = item->li_next;
clear_tv(&item->li_tv);
vim_free(item);
@ -187,9 +187,9 @@ list_free_nonref(int copyID)
if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
&& ll->lv_watch == NULL)
{
/* Free the List 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 List 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.
list_free_contents(ll);
did_free = TRUE;
}
@ -199,7 +199,7 @@ list_free_nonref(int copyID)
static void
list_free_list(list_T *l)
{
/* Remove the list from the list of lists for garbage collection. */
// Remove the list from the list of lists for garbage collection.
if (l->lv_used_prev == NULL)
first_list = l->lv_used_next;
else
@ -221,9 +221,9 @@ list_free_items(int copyID)
if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
&& ll->lv_watch == NULL)
{
/* Free the List 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 List 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.
list_free_list(ll);
}
}
@ -287,8 +287,8 @@ list_len(list_T *l)
list_equal(
list_T *l1,
list_T *l2,
int ic, /* ignore case for strings */
int recursive) /* TRUE when used recursively */
int ic, // ignore case for strings
int recursive) // TRUE when used recursively
{
listitem_T *item1, *item2;
@ -321,32 +321,32 @@ list_find(list_T *l, long n)
if (l == NULL)
return NULL;
/* Negative index is relative to the end. */
// Negative index is relative to the end.
if (n < 0)
n = l->lv_len + n;
/* Check for index out of range. */
// Check for index out of range.
if (n < 0 || n >= l->lv_len)
return NULL;
/* When there is a cached index may start search from there. */
// When there is a cached index may start search from there.
if (l->lv_idx_item != NULL)
{
if (n < l->lv_idx / 2)
{
/* closest to the start of the list */
// closest to the start of the list
item = l->lv_first;
idx = 0;
}
else if (n > (l->lv_idx + l->lv_len) / 2)
{
/* closest to the end of the list */
// closest to the end of the list
item = l->lv_last;
idx = l->lv_len - 1;
}
else
{
/* closest to the cached index */
// closest to the cached index
item = l->lv_idx_item;
idx = l->lv_idx;
}
@ -355,13 +355,13 @@ list_find(list_T *l, long n)
{
if (n < l->lv_len / 2)
{
/* closest to the start of the list */
// closest to the start of the list
item = l->lv_first;
idx = 0;
}
else
{
/* closest to the end of the list */
// closest to the end of the list
item = l->lv_last;
idx = l->lv_len - 1;
}
@ -369,18 +369,18 @@ list_find(list_T *l, long n)
while (n > idx)
{
/* search forward */
// search forward
item = item->li_next;
++idx;
}
while (n < idx)
{
/* search backward */
// search backward
item = item->li_prev;
--idx;
}
/* cache the used index */
// cache the used index
l->lv_idx = idx;
l->lv_idx_item = item;
@ -394,7 +394,7 @@ list_find(list_T *l, long n)
list_find_nr(
list_T *l,
long idx,
int *errorp) /* set to TRUE when something wrong */
int *errorp) // set to TRUE when something wrong
{
listitem_T *li;
@ -453,7 +453,7 @@ list_append(list_T *l, listitem_T *item)
{
if (l->lv_last == NULL)
{
/* empty list */
// empty list
l->lv_first = item;
l->lv_last = item;
item->li_prev = NULL;
@ -585,11 +585,11 @@ list_insert_tv(list_T *l, typval_T *tv, listitem_T *item)
list_insert(list_T *l, listitem_T *ni, listitem_T *item)
{
if (item == NULL)
/* Append new item at end of list. */
// Append new item at end of list.
list_append(l, ni);
else
{
/* Insert new item before existing item. */
// Insert new item before existing item.
ni->li_prev = item->li_prev;
ni->li_next = item;
if (item->li_prev == NULL)
@ -618,8 +618,8 @@ list_extend(list_T *l1, list_T *l2, listitem_T *bef)
listitem_T *item;
int todo = l2->lv_len;
/* We also quit the loop when we have inserted the original item count of
* the list, avoid a hang when we extend a list with itself. */
// We also quit the loop when we have inserted the original item count of
// the list, avoid a hang when we extend a list with itself.
for (item = l2->lv_first; item != NULL && --todo >= 0; item = item->li_next)
if (list_insert_tv(l1, &item->li_tv, bef) == FAIL)
return FAIL;
@ -638,14 +638,14 @@ list_concat(list_T *l1, list_T *l2, typval_T *tv)
if (l1 == NULL || l2 == NULL)
return FAIL;
/* make a copy of the first list. */
// make a copy of the first list.
l = list_copy(l1, FALSE, 0);
if (l == NULL)
return FAIL;
tv->v_type = VAR_LIST;
tv->vval.v_list = l;
/* append all items from the second list */
// append all items from the second list
return list_extend(l, l2, NULL);
}
@ -670,8 +670,8 @@ list_copy(list_T *orig, int deep, int copyID)
{
if (copyID != 0)
{
/* Do this before adding the items, because one of the items may
* refer back to this list. */
// Do this before adding the items, because one of the items may
// refer back to this list.
orig->lv_copyID = copyID;
orig->lv_copylist = copy;
}
@ -715,7 +715,7 @@ vimlist_remove(list_T *l, listitem_T *item, listitem_T *item2)
{
listitem_T *ip;
/* notify watchers */
// notify watchers
for (ip = item; ip != NULL; ip = ip->li_next)
{
--l->lv_len;
@ -766,13 +766,13 @@ typedef struct join_S {
static int
list_join_inner(
garray_T *gap, /* to store the result in */
garray_T *gap, // to store the result in
list_T *l,
char_u *sep,
int echo_style,
int restore_copyID,
int copyID,
garray_T *join_gap) /* to keep each list item string */
garray_T *join_gap) // to keep each list item string
{
int i;
join_T *p;
@ -784,7 +784,7 @@ list_join_inner(
listitem_T *item;
char_u *s;
/* Stringify each item in the list. */
// Stringify each item in the list.
for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
{
s = echo_string_core(&item->li_tv, &tofree, numbuf, copyID,
@ -809,12 +809,12 @@ list_join_inner(
}
line_breakcheck();
if (did_echo_string_emsg) /* recursion error, bail out */
if (did_echo_string_emsg) // recursion error, bail out
break;
}
/* Allocate result buffer with its total size, avoid re-allocation and
* multiple copy operations. Add 2 for a tailing ']' and NUL. */
// Allocate result buffer with its total size, avoid re-allocation and
// multiple copy operations. Add 2 for a tailing ']' and NUL.
if (join_gap->ga_len >= 2)
sumlen += (int)STRLEN(sep) * (join_gap->ga_len - 1);
if (ga_grow(gap, sumlen + 2) == FAIL)
@ -856,12 +856,12 @@ list_join(
int i;
if (l->lv_len < 1)
return OK; /* nothing to do */
return OK; // nothing to do
ga_init2(&join_ga, (int)sizeof(join_T), l->lv_len);
retval = list_join_inner(gap, l, sep, echo_style, restore_copyID,
copyID, &join_ga);
/* Dispose each item in join_ga. */
// Dispose each item in join_ga.
if (join_ga.ga_data != NULL)
{
p = (join_T *)join_ga.ga_data;
@ -931,7 +931,7 @@ get_list_tv(char_u **arg, typval_T *rettv, int evaluate)
*arg = skipwhite(*arg + 1);
while (**arg != ']' && **arg != NUL)
{
if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */
if (eval1(arg, &tv, evaluate) == FAIL) // recursive!
goto failret;
if (evaluate)
{
@ -1120,7 +1120,7 @@ list_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
{
if (argvars[2].v_type == VAR_UNKNOWN)
{
/* Remove one item, return its value. */
// Remove one item, return its value.
vimlist_remove(l, item, item);
*rettv = item->li_tv;
vim_free(item);
@ -1144,7 +1144,7 @@ list_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
if (li == item2)
break;
}
if (li == NULL) /* didn't find "item2" after "item" */
if (li == NULL) // didn't find "item2" after "item"
emsg(_(e_invrange));
else
{
@ -1167,14 +1167,14 @@ list_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
static int item_compare(const void *s1, const void *s2);
static int item_compare2(const void *s1, const void *s2);
/* struct used in the array that's given to qsort() */
// struct used in the array that's given to qsort()
typedef struct
{
listitem_T *item;
int idx;
} sortItem_T;
/* struct storing information about current sort */
// struct storing information about current sort
typedef struct
{
int item_compare_ic;
@ -1229,9 +1229,9 @@ item_compare(const void *s1, const void *s2)
}
#endif
/* tv2string() puts quotes around a string and allocates memory. Don't do
* that for string variables. Use a single quote when comparing with a
* non-string to do what the docs promise. */
// tv2string() puts quotes around a string and allocates memory. Don't do
// that for string variables. Use a single quote when comparing with a
// non-string to do what the docs promise.
if (tv1->v_type == VAR_STRING)
{
if (tv2->v_type != VAR_STRING || sortinfo->item_compare_numeric)
@ -1269,8 +1269,8 @@ item_compare(const void *s1, const void *s2)
res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
}
/* When the result would be zero, compare the item indexes. Makes the
* sort stable. */
// When the result would be zero, compare the item indexes. Makes the
// sort stable.
if (res == 0 && !sortinfo->item_compare_keep_zero)
res = si1->idx > si2->idx ? 1 : -1;
@ -1290,7 +1290,7 @@ item_compare2(const void *s1, const void *s2)
partial_T *partial = sortinfo->item_compare_partial;
funcexe_T funcexe;
/* shortcut after failure in previous call; compare all items equal */
// shortcut after failure in previous call; compare all items equal
if (sortinfo->item_compare_func_err)
return 0;
@ -1302,12 +1302,12 @@ item_compare2(const void *s1, const void *s2)
else
func_name = partial_name(partial);
/* Copy the values. This is needed to be able to set v_lock to VAR_FIXED
* in the copy without changing the original list items. */
// Copy the values. This is needed to be able to set v_lock to VAR_FIXED
// in the copy without changing the original list items.
copy_tv(&si1->item->li_tv, &argv[0]);
copy_tv(&si2->item->li_tv, &argv[1]);
rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this
vim_memset(&funcexe, 0, sizeof(funcexe));
funcexe.evaluate = TRUE;
funcexe.partial = partial;
@ -1321,11 +1321,11 @@ item_compare2(const void *s1, const void *s2)
else
res = (int)tv_get_number_chk(&rettv, &sortinfo->item_compare_func_err);
if (sortinfo->item_compare_func_err)
res = ITEM_COMPARE_FAIL; /* return value has wrong type */
res = ITEM_COMPARE_FAIL; // return value has wrong type
clear_tv(&rettv);
/* When the result would be zero, compare the pointers themselves. Makes
* the sort stable. */
// When the result would be zero, compare the pointers themselves. Makes
// the sort stable.
if (res == 0 && !sortinfo->item_compare_keep_zero)
res = si1->idx > si2->idx ? 1 : -1;
@ -1346,8 +1346,8 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
long len;
long i;
/* Pointer to current info struct used in compare function. Save and
* restore the current one for nested calls. */
// Pointer to current info struct used in compare function. Save and
// restore the current one for nested calls.
old_sortinfo = sortinfo;
sortinfo = &info;
@ -1364,7 +1364,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
len = list_len(l);
if (len <= 1)
goto theend; /* short list sorts pretty quickly */
goto theend; // short list sorts pretty quickly
info.item_compare_ic = FALSE;
info.item_compare_numeric = FALSE;
@ -1377,7 +1377,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
info.item_compare_selfdict = NULL;
if (argvars[1].v_type != VAR_UNKNOWN)
{
/* optional second argument: {func} */
// optional second argument: {func}
if (argvars[1].v_type == VAR_FUNC)
info.item_compare_func = argvars[1].vval.v_string;
else if (argvars[1].v_type == VAR_PARTIAL)
@ -1388,7 +1388,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
i = (long)tv_get_number_chk(&argvars[1], &error);
if (error)
goto theend; /* type error; errmsg already given */
goto theend; // type error; errmsg already given
if (i == 1)
info.item_compare_ic = TRUE;
else if (argvars[1].v_type != VAR_NUMBER)
@ -1402,7 +1402,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
{
if (*info.item_compare_func == NUL)
{
/* empty string means default sort */
// empty string means default sort
info.item_compare_func = NULL;
}
else if (STRCMP(info.item_compare_func, "n") == 0)
@ -1432,7 +1432,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
if (argvars[2].v_type != VAR_UNKNOWN)
{
/* optional third argument: {dict} */
// optional third argument: {dict}
if (argvars[2].v_type != VAR_DICT)
{
emsg(_(e_dictreq));
@ -1442,7 +1442,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
}
}
/* Make an array with each entry pointing to an item in the List. */
// Make an array with each entry pointing to an item in the List.
ptrs = ALLOC_MULT(sortItem_T, len);
if (ptrs == NULL)
goto theend;
@ -1450,7 +1450,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
i = 0;
if (sort)
{
/* sort(): ptrs will be the list to sort */
// sort(): ptrs will be the list to sort
for (li = l->lv_first; li != NULL; li = li->li_next)
{
ptrs[i].item = li;
@ -1460,7 +1460,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
info.item_compare_func_err = FALSE;
info.item_compare_keep_zero = FALSE;
/* test the compare function */
// test the compare function
if ((info.item_compare_func != NULL
|| info.item_compare_partial != NULL)
&& item_compare2((void *)&ptrs[0], (void *)&ptrs[1])
@ -1468,7 +1468,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
emsg(_("E702: Sort compare function failed"));
else
{
/* Sort the array with item pointers. */
// Sort the array with item pointers.
qsort((void *)ptrs, (size_t)len, sizeof(sortItem_T),
info.item_compare_func == NULL
&& info.item_compare_partial == NULL
@ -1476,7 +1476,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
if (!info.item_compare_func_err)
{
/* Clear the List and append the items in sorted order. */
// Clear the List and append the items in sorted order.
l->lv_first = l->lv_last = l->lv_idx_item = NULL;
l->lv_len = 0;
for (i = 0; i < len; ++i)
@ -1488,7 +1488,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
{
int (*item_compare_func_ptr)(const void *, const void *);
/* f_uniq(): ptrs will be a stack of items to remove */
// f_uniq(): ptrs will be a stack of items to remove
info.item_compare_func_err = FALSE;
info.item_compare_keep_zero = TRUE;
item_compare_func_ptr = info.item_compare_func != NULL
@ -1774,7 +1774,7 @@ f_add(typval_T *argvars, typval_T *rettv)
list_T *l;
blob_T *b;
rettv->vval.v_number = 1; /* Default: Failed */
rettv->vval.v_number = 1; // Default: Failed
if (argvars[0].v_type == VAR_LIST)
{
if ((l = argvars[0].vval.v_list) != NULL
@ -1935,7 +1935,7 @@ f_extend(typval_T *argvars, typval_T *rettv)
{
before = (long)tv_get_number_chk(&argvars[2], &error);
if (error)
return; /* type error; errmsg already given */
return; // type error; errmsg already given
if (before == l1->lv_len)
item = NULL;
@ -1967,14 +1967,14 @@ f_extend(typval_T *argvars, typval_T *rettv)
if (d1 != NULL && !var_check_lock(d1->dv_lock, arg_errmsg, TRUE)
&& d2 != NULL)
{
/* Check the third argument. */
// Check the third argument.
if (argvars[2].v_type != VAR_UNKNOWN)
{
static char *(av[]) = {"keep", "force", "error"};
action = tv_get_string_chk(&argvars[2]);
if (action == NULL)
return; /* type error; errmsg already given */
return; // type error; errmsg already given
for (i = 0; i < 3; ++i)
if (STRCMP(action, av[i]) == 0)
break;
@ -2051,7 +2051,7 @@ f_insert(typval_T *argvars, typval_T *rettv)
if (argvars[2].v_type != VAR_UNKNOWN)
before = (long)tv_get_number_chk(&argvars[2], &error);
if (error)
return; /* type error; errmsg already given */
return; // type error; errmsg already given
if (before == l->lv_len)
item = NULL;

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
* There are marks 'A - 'Z (set by user) and '0 to '9 (set when writing
* viminfo).
*/
static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; /* marks with file nr */
static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; // marks with file nr
static void fname2fnum(xfmark_T *fm);
static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf);
@ -54,7 +54,7 @@ setmark_pos(int c, pos_T *pos, int fnum)
int i;
buf_T *buf;
/* Check for a special key (may cause islower() to crash). */
// Check for a special key (may cause islower() to crash).
if (c < 0)
return FAIL;
@ -63,7 +63,7 @@ setmark_pos(int c, pos_T *pos, int fnum)
if (pos == &curwin->w_cursor)
{
setpcmark();
/* keep it even when the cursor doesn't move */
// keep it even when the cursor doesn't move
curwin->w_prev_pcmark = curwin->w_pcmark;
}
else
@ -81,8 +81,8 @@ setmark_pos(int c, pos_T *pos, int fnum)
return OK;
}
/* Allow setting '[ and '] for an autocommand that simulates reading a
* file. */
// Allow setting '[ and '] for an autocommand that simulates reading a
// file.
if (c == '[')
{
buf->b_op_start = *pos;
@ -101,7 +101,7 @@ setmark_pos(int c, pos_T *pos, int fnum)
else
buf->b_visual.vi_end = *pos;
if (buf->b_visual.vi_mode == NUL)
/* Visual_mode has not yet been set, use a sane default. */
// Visual_mode has not yet been set, use a sane default.
buf->b_visual.vi_mode = 'v';
return OK;
}
@ -144,7 +144,7 @@ setpcmark(void)
xfmark_T tempmark;
#endif
/* for :global the mark is set only once */
// for :global the mark is set only once
if (global_busy || listcmd_busy || cmdmod.keepjumps)
return;
@ -170,7 +170,7 @@ setpcmark(void)
}
# endif
/* If jumplist is full: remove oldest entry */
// If jumplist is full: remove oldest entry
if (++curwin->w_jumplistlen > JUMPLISTSIZE)
{
curwin->w_jumplistlen = JUMPLISTSIZE;
@ -204,7 +204,7 @@ checkpcmark(void)
|| curwin->w_pcmark.lnum == 0))
{
curwin->w_pcmark = curwin->w_prev_pcmark;
curwin->w_prev_pcmark.lnum = 0; /* Show it has been checked */
curwin->w_prev_pcmark.lnum = 0; // Show it has been checked
}
}
@ -220,7 +220,7 @@ movemark(int count)
cleanup_jumplist(curwin, TRUE);
if (curwin->w_jumplistlen == 0) /* nothing to jump to */
if (curwin->w_jumplistlen == 0) // nothing to jump to
return (pos_T *)NULL;
for (;;)
@ -237,7 +237,7 @@ movemark(int count)
if (curwin->w_jumplistidx == curwin->w_jumplistlen)
{
setpcmark();
--curwin->w_jumplistidx; /* skip the new entry */
--curwin->w_jumplistidx; // skip the new entry
if (curwin->w_jumplistidx + count < 0)
return (pos_T *)NULL;
}
@ -249,16 +249,16 @@ movemark(int count)
fname2fnum(jmp);
if (jmp->fmark.fnum != curbuf->b_fnum)
{
/* jump to other file */
// jump to other file
if (buflist_findnr(jmp->fmark.fnum) == NULL)
{ /* Skip this one .. */
{ // Skip this one ..
count += count < 0 ? -1 : 1;
continue;
}
if (buflist_getfile(jmp->fmark.fnum, jmp->fmark.mark.lnum,
0, FALSE) == FAIL)
return (pos_T *)NULL;
/* Set lnum again, autocommands my have changed it */
// Set lnum again, autocommands my have changed it
curwin->w_cursor = jmp->fmark.mark;
pos = (pos_T *)-1;
}
@ -276,7 +276,7 @@ movechangelist(int count)
{
int n;
if (curbuf->b_changelistlen == 0) /* nothing to jump to */
if (curbuf->b_changelistlen == 0) // nothing to jump to
return (pos_T *)NULL;
n = curwin->w_changelistidx;
@ -335,38 +335,38 @@ getmark_buf_fnum(
posp = NULL;
/* Check for special key, can't be a mark name and might cause islower()
* to crash. */
// Check for special key, can't be a mark name and might cause islower()
// to crash.
if (c < 0)
return posp;
#ifndef EBCDIC
if (c > '~') /* check for islower()/isupper() */
if (c > '~') // check for islower()/isupper()
;
else
#endif
if (c == '\'' || c == '`') /* previous context mark */
if (c == '\'' || c == '`') // previous context mark
{
pos_copy = curwin->w_pcmark; /* need to make a copy because */
posp = &pos_copy; /* w_pcmark may be changed soon */
pos_copy = curwin->w_pcmark; // need to make a copy because
posp = &pos_copy; // w_pcmark may be changed soon
}
else if (c == '"') /* to pos when leaving buffer */
else if (c == '"') // to pos when leaving buffer
posp = &(buf->b_last_cursor);
else if (c == '^') /* to where Insert mode stopped */
else if (c == '^') // to where Insert mode stopped
posp = &(buf->b_last_insert);
else if (c == '.') /* to where last change was made */
else if (c == '.') // to where last change was made
posp = &(buf->b_last_change);
else if (c == '[') /* to start of previous operator */
else if (c == '[') // to start of previous operator
posp = &(buf->b_op_start);
else if (c == ']') /* to end of previous operator */
else if (c == ']') // to end of previous operator
posp = &(buf->b_op_end);
else if (c == '{' || c == '}') /* to previous/next paragraph */
else if (c == '{' || c == '}') // to previous/next paragraph
{
pos_T pos;
oparg_T oa;
int slcb = listcmd_busy;
pos = curwin->w_cursor;
listcmd_busy = TRUE; /* avoid that '' is changed */
listcmd_busy = TRUE; // avoid that '' is changed
if (findpar(&oa.inclusive,
c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE))
{
@ -376,13 +376,13 @@ getmark_buf_fnum(
curwin->w_cursor = pos;
listcmd_busy = slcb;
}
else if (c == '(' || c == ')') /* to previous/next sentence */
else if (c == '(' || c == ')') // to previous/next sentence
{
pos_T pos;
int slcb = listcmd_busy;
pos = curwin->w_cursor;
listcmd_busy = TRUE; /* avoid that '' is changed */
listcmd_busy = TRUE; // avoid that '' is changed
if (findsent(c == ')' ? FORWARD : BACKWARD, 1L))
{
pos_copy = curwin->w_cursor;
@ -391,7 +391,7 @@ getmark_buf_fnum(
curwin->w_cursor = pos;
listcmd_busy = slcb;
}
else if (c == '<' || c == '>') /* start/end of visual area */
else if (c == '<' || c == '>') // start/end of visual area
{
startp = &buf->b_visual.vi_start;
endp = &buf->b_visual.vi_end;
@ -414,11 +414,11 @@ getmark_buf_fnum(
pos_copy.coladd = 0;
}
}
else if (ASCII_ISLOWER(c)) /* normal named mark */
else if (ASCII_ISLOWER(c)) // normal named mark
{
posp = &(buf->b_namedm[c - 'a']);
}
else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) /* named file mark */
else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) // named file mark
{
if (VIM_ISDIGIT(c))
c = c - '0' + NMARKS;
@ -433,7 +433,7 @@ getmark_buf_fnum(
*fnum = namedfm[c].fmark.fnum;
else if (namedfm[c].fmark.fnum != buf->b_fnum)
{
/* mark is in another file */
// mark is in another file
posp = &pos_copy;
if (namedfm[c].fmark.mark.lnum != 0
@ -442,15 +442,15 @@ getmark_buf_fnum(
if (buflist_getfile(namedfm[c].fmark.fnum,
(linenr_T)1, GETF_SETMARK, FALSE) == OK)
{
/* Set the lnum now, autocommands could have changed it */
// Set the lnum now, autocommands could have changed it
curwin->w_cursor = namedfm[c].fmark.mark;
return (pos_T *)-1;
}
pos_copy.lnum = -1; /* can't get file */
pos_copy.lnum = -1; // can't get file
}
else
pos_copy.lnum = 0; /* mark exists, but is not valid in
current buffer */
pos_copy.lnum = 0; // mark exists, but is not valid in
// current buffer
}
}
@ -464,8 +464,8 @@ getmark_buf_fnum(
*/
pos_T *
getnextmark(
pos_T *startpos, /* where to start */
int dir, /* direction for search */
pos_T *startpos, // where to start
int dir, // direction for search
int begin_line)
{
int i;
@ -474,10 +474,10 @@ getnextmark(
pos = *startpos;
/* When searching backward and leaving the cursor on the first non-blank,
* position must be in a previous line.
* When searching forward and leaving the cursor on the first non-blank,
* position must be in a next line. */
// When searching backward and leaving the cursor on the first non-blank,
// position must be in a previous line.
// When searching forward and leaving the cursor on the first non-blank,
// position must be in a next line.
if (dir == BACKWARD && begin_line)
pos.col = 0;
else if (dir == FORWARD && begin_line)
@ -536,11 +536,11 @@ fname2fnum(xfmark_T *fm)
else
vim_strncpy(NameBuff, fm->fname, MAXPATHL - 1);
/* Try to shorten the file name. */
// Try to shorten the file name.
mch_dirname(IObuff, IOSIZE);
p = shorten_fname(NameBuff, IObuff);
/* buflist_new() will call fmarks_check_names() */
// buflist_new() will call fmarks_check_names()
(void)buflist_new(NameBuff, p, (linenr_T)1, 0);
}
}
@ -606,8 +606,8 @@ check_mark(pos_T *pos)
}
if (pos->lnum <= 0)
{
/* lnum is negative if mark is in another file can can't get that
* file, error message already give then. */
// lnum is negative if mark is in another file can can't get that
// file, error message already give then.
if (pos->lnum == 0)
emsg(_(e_marknotset));
return FAIL;
@ -630,7 +630,7 @@ clrallmarks(buf_T *buf)
{
static int i = -1;
if (i == -1) /* first call ever: initialize */
if (i == -1) // first call ever: initialize
for (i = 0; i < NMARKS + 1; i++)
{
namedfm[i].fmark.mark.lnum = 0;
@ -642,13 +642,13 @@ clrallmarks(buf_T *buf)
for (i = 0; i < NMARKS; i++)
buf->b_namedm[i].lnum = 0;
buf->b_op_start.lnum = 0; /* start/end op mark cleared */
buf->b_op_start.lnum = 0; // start/end op mark cleared
buf->b_op_end.lnum = 0;
buf->b_last_cursor.lnum = 1; /* '" mark cleared */
buf->b_last_cursor.lnum = 1; // '" mark cleared
buf->b_last_cursor.col = 0;
buf->b_last_cursor.coladd = 0;
buf->b_last_insert.lnum = 0; /* '^ mark cleared */
buf->b_last_change.lnum = 0; /* '. mark cleared */
buf->b_last_insert.lnum = 0; // '^ mark cleared
buf->b_last_change.lnum = 0; // '. mark cleared
#ifdef FEAT_JUMPLIST
buf->b_changelistlen = 0;
#endif
@ -662,7 +662,7 @@ clrallmarks(buf_T *buf)
char_u *
fm_getname(fmark_T *fmark, int lead_len)
{
if (fmark->fnum == curbuf->b_fnum) /* current buffer */
if (fmark->fnum == curbuf->b_fnum) // current buffer
return mark_line(&(fmark->mark), lead_len);
return buflist_nr2name(fmark->fnum, FALSE, TRUE);
}
@ -742,13 +742,13 @@ show_one_mark(
char_u *arg,
pos_T *p,
char_u *name_arg,
int current) /* in current file */
int current) // in current file
{
static int did_title = FALSE;
int mustfree = FALSE;
char_u *name = name_arg;
if (c == -1) /* finish up */
if (c == -1) // finish up
{
if (did_title)
did_title = FALSE;
@ -809,7 +809,7 @@ ex_delmarks(exarg_T *eap)
int n;
if (*eap->arg == NUL && eap->forceit)
/* clear all marks */
// clear all marks
clrallmarks(curbuf);
else if (eap->forceit)
emsg(_(e_invarg));
@ -817,7 +817,7 @@ ex_delmarks(exarg_T *eap)
emsg(_(e_argreq));
else
{
/* clear specified marks only */
// clear specified marks only
for (p = eap->arg; *p != NUL; ++p)
{
lower = ASCII_ISLOWER(*p);
@ -826,7 +826,7 @@ ex_delmarks(exarg_T *eap)
{
if (p[1] == '-')
{
/* clear range of marks */
// clear range of marks
from = *p;
to = p[2];
if (!(lower ? ASCII_ISLOWER(p[2])
@ -840,7 +840,7 @@ ex_delmarks(exarg_T *eap)
p += 2;
}
else
/* clear one lower case mark */
// clear one lower case mark
from = to = *p;
for (i = from; i <= to; ++i)
@ -891,7 +891,7 @@ ex_jumps(exarg_T *eap UNUSED)
cleanup_jumplist(curwin, TRUE);
/* Highlight title */
// Highlight title
msg_puts_title(_("\n jump line col file/text"));
for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i)
{
@ -948,7 +948,7 @@ ex_changes(exarg_T *eap UNUSED)
int i;
char_u *name;
/* Highlight title */
// Highlight title
msg_puts_title(_("\nchange line col text"));
for (i = 0; i < curbuf->b_changelistlen && !got_int; ++i)
@ -993,7 +993,7 @@ ex_changes(exarg_T *eap UNUSED)
*lp += amount_after; \
}
/* don't delete the line, just put at first deleted line */
// don't delete the line, just put at first deleted line
#define one_adjust_nodel(add) \
{ \
lp = add; \
@ -1054,12 +1054,12 @@ mark_adjust_internal(
tabpage_T *tab;
static pos_T initpos = {1, 0, 0};
if (line2 < line1 && amount_after == 0L) /* nothing to do */
if (line2 < line1 && amount_after == 0L) // nothing to do
return;
if (!cmdmod.lockmarks)
{
/* named marks, lower case and upper case */
// named marks, lower case and upper case
for (i = 0; i < NMARKS; i++)
{
one_adjust(&(curbuf->b_namedm[i].lnum));
@ -1072,31 +1072,31 @@ mark_adjust_internal(
one_adjust_nodel(&(namedfm[i].fmark.mark.lnum));
}
/* last Insert position */
// last Insert position
one_adjust(&(curbuf->b_last_insert.lnum));
/* last change position */
// last change position
one_adjust(&(curbuf->b_last_change.lnum));
/* last cursor position, if it was set */
// last cursor position, if it was set
if (!EQUAL_POS(curbuf->b_last_cursor, initpos))
one_adjust(&(curbuf->b_last_cursor.lnum));
#ifdef FEAT_JUMPLIST
/* list of change positions */
// list of change positions
for (i = 0; i < curbuf->b_changelistlen; ++i)
one_adjust_nodel(&(curbuf->b_changelist[i].lnum));
#endif
/* Visual area */
// Visual area
one_adjust_nodel(&(curbuf->b_visual.vi_start.lnum));
one_adjust_nodel(&(curbuf->b_visual.vi_end.lnum));
#ifdef FEAT_QUICKFIX
/* quickfix marks */
// quickfix marks
qf_mark_adjust(NULL, line1, line2, amount, amount_after);
/* location lists */
// location lists
FOR_ALL_TAB_WINDOWS(tab, win)
qf_mark_adjust(win, line1, line2, amount, amount_after);
#endif
@ -1106,13 +1106,13 @@ mark_adjust_internal(
#endif
}
/* previous context mark */
// previous context mark
one_adjust(&(curwin->w_pcmark.lnum));
/* previous pcmark */
// previous pcmark
one_adjust(&(curwin->w_prev_pcmark.lnum));
/* saved cursor for formatting */
// saved cursor for formatting
if (saved_cursor.lnum != 0)
one_adjust_nodel(&(saved_cursor.lnum));
@ -1123,8 +1123,8 @@ mark_adjust_internal(
{
#ifdef FEAT_JUMPLIST
if (!cmdmod.lockmarks)
/* Marks in the jumplist. When deleting lines, this may create
* duplicate marks in the jumplist, they will be removed later. */
// Marks in the jumplist. When deleting lines, this may create
// duplicate marks in the jumplist, they will be removed later.
for (i = 0; i < win->w_jumplistlen; ++i)
if (win->w_jumplist[i].fmark.fnum == fnum)
one_adjust_nodel(&(win->w_jumplist[i].fmark.mark.lnum));
@ -1133,32 +1133,32 @@ mark_adjust_internal(
if (win->w_buffer == curbuf)
{
if (!cmdmod.lockmarks)
/* marks in the tag stack */
// marks in the tag stack
for (i = 0; i < win->w_tagstacklen; i++)
if (win->w_tagstack[i].fmark.fnum == fnum)
one_adjust_nodel(&(win->w_tagstack[i].fmark.mark.lnum));
/* the displayed Visual area */
// the displayed Visual area
if (win->w_old_cursor_lnum != 0)
{
one_adjust_nodel(&(win->w_old_cursor_lnum));
one_adjust_nodel(&(win->w_old_visual_lnum));
}
/* topline and cursor position for windows with the same buffer
* other than the current window */
// topline and cursor position for windows with the same buffer
// other than the current window
if (win != curwin)
{
if (win->w_topline >= line1 && win->w_topline <= line2)
{
if (amount == MAXLNUM) /* topline is deleted */
if (amount == MAXLNUM) // topline is deleted
{
if (line1 <= 1)
win->w_topline = 1;
else
win->w_topline = line1 - 1;
}
else /* keep topline on the same line */
else // keep topline on the same line
win->w_topline += amount;
#ifdef FEAT_DIFF
win->w_topfill = 0;
@ -1173,7 +1173,7 @@ mark_adjust_internal(
}
if (win->w_cursor.lnum >= line1 && win->w_cursor.lnum <= line2)
{
if (amount == MAXLNUM) /* line with cursor is deleted */
if (amount == MAXLNUM) // line with cursor is deleted
{
if (line1 <= 1)
win->w_cursor.lnum = 1;
@ -1181,7 +1181,7 @@ mark_adjust_internal(
win->w_cursor.lnum = line1 - 1;
win->w_cursor.col = 0;
}
else /* keep cursor on the same line */
else // keep cursor on the same line
win->w_cursor.lnum += amount;
}
else if (amount_after && win->w_cursor.lnum > line2)
@ -1189,7 +1189,7 @@ mark_adjust_internal(
}
#ifdef FEAT_FOLDING
/* adjust folds */
// adjust folds
if (adjust_folds)
foldMarkAdjust(win, line1, line2, amount, amount_after);
#endif
@ -1197,12 +1197,12 @@ mark_adjust_internal(
}
#ifdef FEAT_DIFF
/* adjust diffs */
// adjust diffs
diff_mark_adjust(line1, line2, amount, amount_after);
#endif
}
/* This code is used often, needs to be fast. */
// This code is used often, needs to be fast.
#define col_adjust(pp) \
{ \
posp = pp; \
@ -1239,9 +1239,9 @@ mark_col_adjust(
pos_T *posp;
if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks)
return; /* nothing to do */
return; // nothing to do
/* named marks, lower case and upper case */
// named marks, lower case and upper case
for (i = 0; i < NMARKS; i++)
{
col_adjust(&(curbuf->b_namedm[i]));
@ -1254,29 +1254,29 @@ mark_col_adjust(
col_adjust(&(namedfm[i].fmark.mark));
}
/* last Insert position */
// last Insert position
col_adjust(&(curbuf->b_last_insert));
/* last change position */
// last change position
col_adjust(&(curbuf->b_last_change));
#ifdef FEAT_JUMPLIST
/* list of change positions */
// list of change positions
for (i = 0; i < curbuf->b_changelistlen; ++i)
col_adjust(&(curbuf->b_changelist[i]));
#endif
/* Visual area */
// Visual area
col_adjust(&(curbuf->b_visual.vi_start));
col_adjust(&(curbuf->b_visual.vi_end));
/* previous context mark */
// previous context mark
col_adjust(&(curwin->w_pcmark));
/* previous pcmark */
// previous pcmark
col_adjust(&(curwin->w_prev_pcmark));
/* saved cursor for formatting */
// saved cursor for formatting
col_adjust(&saved_cursor);
/*
@ -1285,7 +1285,7 @@ mark_col_adjust(
FOR_ALL_WINDOWS(win)
{
#ifdef FEAT_JUMPLIST
/* marks in the jumplist */
// marks in the jumplist
for (i = 0; i < win->w_jumplistlen; ++i)
if (win->w_jumplist[i].fmark.fnum == fnum)
col_adjust(&(win->w_jumplist[i].fmark.mark));
@ -1293,12 +1293,12 @@ mark_col_adjust(
if (win->w_buffer == curbuf)
{
/* marks in the tag stack */
// marks in the tag stack
for (i = 0; i < win->w_tagstacklen; i++)
if (win->w_tagstack[i].fmark.fnum == fnum)
col_adjust(&(win->w_tagstack[i].fmark.mark));
/* cursor position for other windows with the same buffer */
// cursor position for other windows with the same buffer
if (win != curwin)
col_adjust(&win->w_cursor);
}
@ -1320,9 +1320,9 @@ cleanup_jumplist(win_T *wp, int loadfiles)
if (loadfiles)
{
/* If specified, load all the files from the jump list. This is
* needed to properly clean up duplicate entries, but will take some
* time. */
// If specified, load all the files from the jump list. This is
// needed to properly clean up duplicate entries, but will take some
// time.
for (i = 0; i < wp->w_jumplistlen; ++i)
{
if ((wp->w_jumplist[i].fmark.fnum == 0) &&
@ -1343,7 +1343,7 @@ cleanup_jumplist(win_T *wp, int loadfiles)
&& wp->w_jumplist[i].fmark.mark.lnum
== wp->w_jumplist[from].fmark.mark.lnum)
break;
if (i >= wp->w_jumplistlen) /* no duplicate */
if (i >= wp->w_jumplistlen) // no duplicate
wp->w_jumplist[to++] = wp->w_jumplist[from];
else
vim_free(wp->w_jumplist[from].fname);
@ -1382,7 +1382,7 @@ free_jumplist(win_T *wp)
for (i = 0; i < wp->w_jumplistlen; ++i)
vim_free(wp->w_jumplist[i].fname);
}
#endif /* FEAT_JUMPLIST */
#endif // FEAT_JUMPLIST
void
set_last_cursor(win_T *win)

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@
# include <sys/statfs.h>
# define STATFS statfs
# define F_BSIZE f_bsize
# ifdef __MINT__ /* do we still need this? */
# ifdef __MINT__ // do we still need this?
# define fstatfs(fd, buf, len, nul) mch_fstat((fd), (buf))
# endif
# endif
@ -57,17 +57,17 @@
*/
#ifdef AMIGA
# ifdef FEAT_ARP
extern int dos2; /* this is in os_amiga.c */
extern int dos2; // this is in os_amiga.c
# endif
# ifdef SASC
# include <proto/dos.h>
# include <ios1.h> /* for chkufb() */
# include <ios1.h> // for chkufb()
# endif
#endif
#define MEMFILE_PAGE_SIZE 4096 /* default page size */
#define MEMFILE_PAGE_SIZE 4096 // default page size
static long_u total_mem_used = 0; /* total memory used for memfiles */
static long_u total_mem_used = 0; // total memory used for memfiles
static void mf_ins_hash(memfile_T *, bhdr_T *);
static void mf_rem_hash(memfile_T *, bhdr_T *);
@ -133,7 +133,7 @@ mf_open(char_u *fname, int flags)
if ((mfp = ALLOC_ONE(memfile_T)) == NULL)
return NULL;
if (fname == NULL) /* no file for this memfile, use memory only */
if (fname == NULL) // no file for this memfile, use memory only
{
mfp->mf_fname = NULL;
mfp->mf_ffname = NULL;
@ -141,9 +141,9 @@ mf_open(char_u *fname, int flags)
}
else
{
mf_do_open(mfp, fname, flags); /* try to open the file */
mf_do_open(mfp, fname, flags); // try to open the file
/* if the file cannot be opened, return here */
// if the file cannot be opened, return here
if (mfp->mf_fd < 0)
{
vim_free(mfp);
@ -151,8 +151,8 @@ mf_open(char_u *fname, int flags)
}
}
mfp->mf_free_first = NULL; /* free list is empty */
mfp->mf_used_first = NULL; /* used list is empty */
mfp->mf_free_first = NULL; // free list is empty
mfp->mf_used_first = NULL; // used list is empty
mfp->mf_used_last = NULL;
mfp->mf_dirty = FALSE;
mfp->mf_used_count = 0;
@ -180,7 +180,7 @@ mf_open(char_u *fname, int flags)
if (mfp->mf_fd < 0 || (flags & (O_TRUNC|O_EXCL))
|| (size = vim_lseek(mfp->mf_fd, (off_T)0L, SEEK_END)) <= 0)
mfp->mf_blocknr_max = 0; /* no file or empty file */
mfp->mf_blocknr_max = 0; // no file or empty file
else
mfp->mf_blocknr_max = (blocknr_T)((size + mfp->mf_page_size - 1)
/ mfp->mf_page_size);
@ -223,7 +223,7 @@ mf_open(char_u *fname, int flags)
int
mf_open_file(memfile_T *mfp, char_u *fname)
{
mf_do_open(mfp, fname, O_RDWR|O_CREAT|O_EXCL); /* try to open the file */
mf_do_open(mfp, fname, O_RDWR|O_CREAT|O_EXCL); // try to open the file
if (mfp->mf_fd < 0)
return FAIL;
@ -240,7 +240,7 @@ mf_close(memfile_T *mfp, int del_file)
{
bhdr_T *hp, *nextp;
if (mfp == NULL) /* safety check */
if (mfp == NULL) // safety check
return;
if (mfp->mf_fd >= 0)
{
@ -249,17 +249,17 @@ mf_close(memfile_T *mfp, int del_file)
}
if (del_file && mfp->mf_fname != NULL)
mch_remove(mfp->mf_fname);
/* free entries in used list */
// free entries in used list
for (hp = mfp->mf_used_first; hp != NULL; hp = nextp)
{
total_mem_used -= hp->bh_page_count * mfp->mf_page_size;
nextp = hp->bh_next;
mf_free_bhdr(hp);
}
while (mfp->mf_free_first != NULL) /* free entries in free list */
while (mfp->mf_free_first != NULL) // free entries in free list
vim_free(mf_rem_free(mfp));
mf_hash_free(&mfp->mf_hash);
mf_hash_free_all(&mfp->mf_trans); /* free hashtable and its items */
mf_hash_free_all(&mfp->mf_trans); // free hashtable and its items
vim_free(mfp->mf_fname);
vim_free(mfp->mf_ffname);
vim_free(mfp);
@ -271,32 +271,32 @@ mf_close(memfile_T *mfp, int del_file)
void
mf_close_file(
buf_T *buf,
int getlines) /* get all lines into memory? */
int getlines) // get all lines into memory?
{
memfile_T *mfp;
linenr_T lnum;
mfp = buf->b_ml.ml_mfp;
if (mfp == NULL || mfp->mf_fd < 0) /* nothing to close */
if (mfp == NULL || mfp->mf_fd < 0) // nothing to close
return;
if (getlines)
{
/* get all blocks in memory by accessing all lines (clumsy!) */
// get all blocks in memory by accessing all lines (clumsy!)
mf_dont_release = TRUE;
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum)
(void)ml_get_buf(buf, lnum, FALSE);
mf_dont_release = FALSE;
/* TODO: should check if all blocks are really in core */
// TODO: should check if all blocks are really in core
}
if (close(mfp->mf_fd) < 0) /* close the file */
if (close(mfp->mf_fd) < 0) // close the file
emsg(_(e_swapclose));
mfp->mf_fd = -1;
if (mfp->mf_fname != NULL)
{
mch_remove(mfp->mf_fname); /* delete the swap file */
mch_remove(mfp->mf_fname); // delete the swap file
VIM_CLEAR(mfp->mf_fname);
VIM_CLEAR(mfp->mf_ffname);
}
@ -309,8 +309,8 @@ mf_close_file(
void
mf_new_page_size(memfile_T *mfp, unsigned new_size)
{
/* Correct the memory used for block 0 to the new size, because it will be
* freed with that size later on. */
// Correct the memory used for block 0 to the new size, because it will be
// freed with that size later on.
total_mem_used += new_size - mfp->mf_page_size;
mfp->mf_page_size = new_size;
}
@ -323,8 +323,8 @@ mf_new_page_size(memfile_T *mfp, unsigned new_size)
bhdr_T *
mf_new(memfile_T *mfp, int negative, int page_count)
{
bhdr_T *hp; /* new bhdr_T */
bhdr_T *freep; /* first block in free list */
bhdr_T *hp; // new bhdr_T
bhdr_T *freep; // first block in free list
char_u *p;
/*
@ -360,21 +360,21 @@ mf_new(memfile_T *mfp, int negative, int page_count)
freep->bh_bnum += page_count;
freep->bh_page_count -= page_count;
}
else if (hp == NULL) /* need to allocate memory for this block */
else if (hp == NULL) // need to allocate memory for this block
{
if ((p = alloc(mfp->mf_page_size * page_count)) == NULL)
return NULL;
hp = mf_rem_free(mfp);
hp->bh_data = p;
}
else /* use the number, remove entry from free list */
else // use the number, remove entry from free list
{
freep = mf_rem_free(mfp);
hp->bh_bnum = freep->bh_bnum;
vim_free(freep);
}
}
else /* get a new number */
else // get a new number
{
if (hp == NULL && (hp = mf_alloc_bhdr(mfp, page_count)) == NULL)
return NULL;
@ -389,7 +389,7 @@ mf_new(memfile_T *mfp, int negative, int page_count)
mfp->mf_blocknr_max += page_count;
}
}
hp->bh_flags = BH_LOCKED | BH_DIRTY; /* new block is always dirty */
hp->bh_flags = BH_LOCKED | BH_DIRTY; // new block is always dirty
mfp->mf_dirty = TRUE;
hp->bh_page_count = page_count;
mf_ins_used(mfp, hp);
@ -414,7 +414,7 @@ mf_new(memfile_T *mfp, int negative, int page_count)
mf_get(memfile_T *mfp, blocknr_T nr, int page_count)
{
bhdr_T *hp;
/* doesn't exist */
// doesn't exist
if (nr >= mfp->mf_blocknr_max || nr <= mfp->mf_blocknr_min)
return NULL;
@ -422,12 +422,12 @@ mf_get(memfile_T *mfp, blocknr_T nr, int page_count)
* see if it is in the cache
*/
hp = mf_find_hash(mfp, nr);
if (hp == NULL) /* not in the hash list */
if (hp == NULL) // not in the hash list
{
if (nr < 0 || nr >= mfp->mf_infile_count) /* can't be in the file */
if (nr < 0 || nr >= mfp->mf_infile_count) // can't be in the file
return NULL;
/* could check here if the block is in the free list */
// could check here if the block is in the free list
/*
* Check if we need to flush an existing block.
@ -441,7 +441,7 @@ mf_get(memfile_T *mfp, blocknr_T nr, int page_count)
hp->bh_bnum = nr;
hp->bh_flags = 0;
hp->bh_page_count = page_count;
if (mf_read(mfp, hp) == FAIL) /* cannot read the block! */
if (mf_read(mfp, hp) == FAIL) // cannot read the block!
{
mf_free_bhdr(hp);
return NULL;
@ -449,13 +449,13 @@ mf_get(memfile_T *mfp, blocknr_T nr, int page_count)
}
else
{
mf_rem_used(mfp, hp); /* remove from list, insert in front below */
mf_rem_used(mfp, hp); // remove from list, insert in front below
mf_rem_hash(mfp, hp);
}
hp->bh_flags |= BH_LOCKED;
mf_ins_used(mfp, hp); /* put in front of used list */
mf_ins_hash(mfp, hp); /* put in front of hash list */
mf_ins_used(mfp, hp); // put in front of used list
mf_ins_hash(mfp, hp); // put in front of hash list
return hp;
}
@ -489,7 +489,7 @@ mf_put(
}
hp->bh_flags = flags;
if (infile)
mf_trans_add(mfp, hp); /* may translate negative in positive nr */
mf_trans_add(mfp, hp); // may translate negative in positive nr
}
/*
@ -498,20 +498,20 @@ mf_put(
void
mf_free(memfile_T *mfp, bhdr_T *hp)
{
vim_free(hp->bh_data); /* free the memory */
mf_rem_hash(mfp, hp); /* get *hp out of the hash list */
mf_rem_used(mfp, hp); /* get *hp out of the used list */
vim_free(hp->bh_data); // free the memory
mf_rem_hash(mfp, hp); // get *hp out of the hash list
mf_rem_used(mfp, hp); // get *hp out of the used list
if (hp->bh_bnum < 0)
{
vim_free(hp); /* don't want negative numbers in free list */
vim_free(hp); // don't want negative numbers in free list
mfp->mf_neg_count--;
}
else
mf_ins_free(mfp, hp); /* put *hp in the free list */
mf_ins_free(mfp, hp); // put *hp in the free list
}
#if defined(__MORPHOS__) && defined(__libnix__)
/* function is missing in MorphOS libnix version */
// function is missing in MorphOS libnix version
extern unsigned long *__stdfiledes;
static unsigned long
@ -541,14 +541,14 @@ mf_sync(memfile_T *mfp, int flags)
bhdr_T *hp;
int got_int_save = got_int;
if (mfp->mf_fd < 0) /* there is no file, nothing to do */
if (mfp->mf_fd < 0) // there is no file, nothing to do
{
mfp->mf_dirty = FALSE;
return FAIL;
}
/* Only a CTRL-C while writing will break us here, not one typed
* previously. */
// Only a CTRL-C while writing will break us here, not one typed
// previously.
got_int = FALSE;
/*
@ -568,13 +568,13 @@ mf_sync(memfile_T *mfp, int flags)
continue;
if (mf_write(mfp, hp) == FAIL)
{
if (status == FAIL) /* double error: quit syncing */
if (status == FAIL) // double error: quit syncing
break;
status = FAIL;
}
if (flags & MFS_STOP)
{
/* Stop when char available now. */
// Stop when char available now.
if (ui_char_avail())
break;
}
@ -605,9 +605,9 @@ mf_sync(memfile_T *mfp, int flags)
}
else
# endif
/* OpenNT is strictly POSIX (Benzinger) */
/* Tandem/Himalaya NSK-OSS doesn't have sync() */
/* No sync() on Stratus VOS */
// OpenNT is strictly POSIX (Benzinger)
// Tandem/Himalaya NSK-OSS doesn't have sync()
// No sync() on Stratus VOS
# if defined(__OPENNT) || defined(__TANDEM) || defined(__VOS__)
fflush(NULL);
# else
@ -649,8 +649,8 @@ mf_sync(memfile_T *mfp, int flags)
# if defined(_DCC) || defined(__GNUC__) || defined(__MORPHOS__)
{
# if defined(__GNUC__) && !defined(__MORPHOS__) && defined(__libnix__)
/* Have function (in libnix at least),
* but ain't got no prototype anywhere. */
// Have function (in libnix at least),
// but ain't got no prototype anywhere.
extern unsigned long fdtofh(int filedescriptor);
# endif
# if !defined(__libnix__)
@ -662,12 +662,12 @@ mf_sync(memfile_T *mfp, int flags)
Flush(fh);
# endif
}
# else /* assume Manx */
# else // assume Manx
Flush(_devtab[mfp->mf_fd].fd);
# endif
# endif
# endif
#endif /* AMIGA */
#endif // AMIGA
}
got_int |= got_int_save;
@ -727,7 +727,7 @@ mf_ins_used(memfile_T *mfp, bhdr_T *hp)
hp->bh_next = mfp->mf_used_first;
mfp->mf_used_first = hp;
hp->bh_prev = NULL;
if (hp->bh_next == NULL) /* list was empty, adjust last pointer */
if (hp->bh_next == NULL) // list was empty, adjust last pointer
mfp->mf_used_last = hp;
else
hp->bh_next->bh_prev = hp;
@ -741,11 +741,11 @@ mf_ins_used(memfile_T *mfp, bhdr_T *hp)
static void
mf_rem_used(memfile_T *mfp, bhdr_T *hp)
{
if (hp->bh_next == NULL) /* last block in used list */
if (hp->bh_next == NULL) // last block in used list
mfp->mf_used_last = hp->bh_prev;
else
hp->bh_next->bh_prev = hp->bh_prev;
if (hp->bh_prev == NULL) /* first block in used list */
if (hp->bh_prev == NULL) // first block in used list
mfp->mf_used_first = hp->bh_next;
else
hp->bh_prev->bh_next = hp->bh_next;
@ -769,7 +769,7 @@ mf_release(memfile_T *mfp, int page_count)
int need_release;
buf_T *buf;
/* don't release while in mf_close_file() */
// don't release while in mf_close_file()
if (mf_dont_release)
return NULL;
@ -786,7 +786,7 @@ mf_release(memfile_T *mfp, int page_count)
*/
if (mfp->mf_fd < 0 && need_release && p_uc)
{
/* find for which buffer this memfile is */
// find for which buffer this memfile is
FOR_ALL_BUFFERS(buf)
if (buf->b_ml.ml_mfp == mfp)
break;
@ -808,7 +808,7 @@ mf_release(memfile_T *mfp, int page_count)
for (hp = mfp->mf_used_last; hp != NULL; hp = hp->bh_prev)
if (!(hp->bh_flags & BH_LOCKED))
break;
if (hp == NULL) /* not a single one that can be released */
if (hp == NULL) // not a single one that can be released
return NULL;
/*
@ -857,11 +857,11 @@ mf_release_all(void)
mfp = buf->b_ml.ml_mfp;
if (mfp != NULL)
{
/* If no swap file yet, may open one */
// If no swap file yet, may open one
if (mfp->mf_fd < 0 && buf->b_may_swap)
ml_open_file(buf);
/* only if there is a swapfile */
// only if there is a swapfile
if (mfp->mf_fd >= 0)
{
for (hp = mfp->mf_used_last; hp != NULL; )
@ -873,7 +873,7 @@ mf_release_all(void)
mf_rem_used(mfp, hp);
mf_rem_hash(mfp, hp);
mf_free_bhdr(hp);
hp = mfp->mf_used_last; /* re-start, list was changed */
hp = mfp->mf_used_last; // re-start, list was changed
retval = TRUE;
}
else
@ -897,7 +897,7 @@ mf_alloc_bhdr(memfile_T *mfp, int page_count)
{
if ((hp->bh_data = alloc(mfp->mf_page_size * page_count)) == NULL)
{
vim_free(hp); /* not enough memory */
vim_free(hp); // not enough memory
return NULL;
}
hp->bh_page_count = page_count;
@ -951,7 +951,7 @@ mf_read(memfile_T *mfp, bhdr_T *hp)
unsigned page_size;
unsigned size;
if (mfp->mf_fd < 0) /* there is no file, can't read */
if (mfp->mf_fd < 0) // there is no file, can't read
return FAIL;
page_size = mfp->mf_page_size;
@ -969,8 +969,8 @@ mf_read(memfile_T *mfp, bhdr_T *hp)
}
#ifdef FEAT_CRYPT
/* Decrypt if 'key' is set and this is a data block. And when changing the
* key. */
// Decrypt if 'key' is set and this is a data block. And when changing the
// key.
if (*mfp->mf_buffer->b_p_key != NUL || mfp->mf_old_key != NULL)
ml_decrypt_data(mfp, hp->bh_data, offset, size);
#endif
@ -986,18 +986,18 @@ mf_read(memfile_T *mfp, bhdr_T *hp)
static int
mf_write(memfile_T *mfp, bhdr_T *hp)
{
off_T offset; /* offset in the file */
blocknr_T nr; /* block nr which is being written */
off_T offset; // offset in the file
blocknr_T nr; // block nr which is being written
bhdr_T *hp2;
unsigned page_size; /* number of bytes in a page */
unsigned page_count; /* number of pages written */
unsigned size; /* number of bytes written */
unsigned page_size; // number of bytes in a page
unsigned page_count; // number of pages written
unsigned size; // number of bytes written
if (mfp->mf_fd < 0 && !mfp->mf_reopen)
// there is no file and there was no file, can't write
return FAIL;
if (hp->bh_bnum < 0) /* must assign file block number */
if (hp->bh_bnum < 0) // must assign file block number
if (mf_trans_add(mfp, hp) == FAIL)
return FAIL;
@ -1014,16 +1014,16 @@ mf_write(memfile_T *mfp, bhdr_T *hp)
int attempt;
nr = hp->bh_bnum;
if (nr > mfp->mf_infile_count) /* beyond end of file */
if (nr > mfp->mf_infile_count) // beyond end of file
{
nr = mfp->mf_infile_count;
hp2 = mf_find_hash(mfp, nr); /* NULL caught below */
hp2 = mf_find_hash(mfp, nr); // NULL caught below
}
else
hp2 = hp;
offset = (off_T)page_size * nr;
if (hp2 == NULL) /* freed block, fill with dummy data */
if (hp2 == NULL) // freed block, fill with dummy data
page_count = 1;
else
page_count = hp2->bh_page_count;
@ -1067,12 +1067,12 @@ mf_write(memfile_T *mfp, bhdr_T *hp)
}
did_swapwrite_msg = FALSE;
if (hp2 != NULL) /* written a non-dummy block */
if (hp2 != NULL) // written a non-dummy block
hp2->bh_flags &= ~BH_DIRTY;
/* appended to the file */
// appended to the file
if (nr + (blocknr_T)page_count > mfp->mf_infile_count)
mfp->mf_infile_count = nr + page_count;
if (nr == hp->bh_bnum) /* written the desired block */
if (nr == hp->bh_bnum) // written the desired block
break;
}
return OK;
@ -1094,7 +1094,7 @@ mf_write_block(
int result = OK;
#ifdef FEAT_CRYPT
/* Encrypt if 'key' is set and this is a data block. */
// Encrypt if 'key' is set and this is a data block.
if (*mfp->mf_buffer->b_p_key != NUL)
{
data = ml_encrypt_data(mfp, data, offset, size);
@ -1127,7 +1127,7 @@ mf_trans_add(memfile_T *mfp, bhdr_T *hp)
NR_TRANS *np;
int page_count;
if (hp->bh_bnum >= 0) /* it's already positive */
if (hp->bh_bnum >= 0) // it's already positive
return OK;
if ((np = ALLOC_ONE(NR_TRANS)) == NULL)
@ -1164,14 +1164,14 @@ mf_trans_add(memfile_T *mfp, bhdr_T *hp)
mfp->mf_blocknr_max += page_count;
}
np->nt_old_bnum = hp->bh_bnum; /* adjust number */
np->nt_old_bnum = hp->bh_bnum; // adjust number
np->nt_new_bnum = new_bnum;
mf_rem_hash(mfp, hp); /* remove from old hash list */
mf_rem_hash(mfp, hp); // remove from old hash list
hp->bh_bnum = new_bnum;
mf_ins_hash(mfp, hp); /* insert in new hash list */
mf_ins_hash(mfp, hp); // insert in new hash list
/* Insert "np" into "mf_trans" hashtable with key "np->nt_old_bnum" */
// Insert "np" into "mf_trans" hashtable with key "np->nt_old_bnum"
mf_hash_add_item(&mfp->mf_trans, (mf_hashitem_T *)np);
return OK;
@ -1190,13 +1190,13 @@ mf_trans_del(memfile_T *mfp, blocknr_T old_nr)
np = (NR_TRANS *)mf_hash_find(&mfp->mf_trans, old_nr);
if (np == NULL) /* not found */
if (np == NULL) // not found
return old_nr;
mfp->mf_neg_count--;
new_bnum = np->nt_new_bnum;
/* remove entry from the trans list */
// remove entry from the trans list
mf_hash_rem_item(&mfp->mf_trans, (mf_hashitem_T *)np);
vim_free(np);
@ -1248,7 +1248,7 @@ mf_need_trans(memfile_T *mfp)
mf_do_open(
memfile_T *mfp,
char_u *fname,
int flags) /* flags for open() */
int flags) // flags for open()
{
#ifdef HAVE_LSTAT
stat_T sb;
@ -1288,9 +1288,9 @@ mf_do_open(
*/
flags |= O_EXTRA | O_NOFOLLOW;
#ifdef MSWIN
/* Prevent handle inheritance that cause problems with Cscope
* (swap file may not be deleted if cscope connection was open after
* the file) */
// Prevent handle inheritance that cause problems with Cscope
// (swap file may not be deleted if cscope connection was open after
// the file)
flags |= O_NOINHERIT;
#endif
mfp->mf_flags = flags;
@ -1315,7 +1315,7 @@ mf_do_open(
#if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
mch_copy_sec(fname, mfp->mf_fname);
#endif
mch_hide(mfp->mf_fname); /* try setting the 'hidden' flag */
mch_hide(mfp->mf_fname); // try setting the 'hidden' flag
}
}
@ -1329,7 +1329,7 @@ mf_do_open(
* exceeds 2 ^ MHT_LOG_LOAD_FACTOR.
*/
#define MHT_LOG_LOAD_FACTOR 6
#define MHT_GROWTH_FACTOR 2 /* must be a power of two */
#define MHT_GROWTH_FACTOR 2 // must be a power of two
/*
* Initialize an empty hash table.
@ -1416,7 +1416,7 @@ mf_hash_add_item(mf_hashtab_T *mht, mf_hashitem_T *mhi)
{
if (mf_hash_grow(mht) == FAIL)
{
/* stop trying to grow after first failure to allocate memory */
// stop trying to grow after first failure to allocate memory
mht->mht_fixed = 1;
}
}
@ -1439,8 +1439,8 @@ mf_hash_rem_item(mf_hashtab_T *mht, mf_hashitem_T *mhi)
mht->mht_count--;
/* We could shrink the table here, but it typically takes little memory,
* so why bother? */
// We could shrink the table here, but it typically takes little memory,
// so why bother?
}
/*

View File

@ -15,11 +15,11 @@
#undef NDEBUG
#include <assert.h>
/* Must include main.c because it contains much more than just main() */
// Must include main.c because it contains much more than just main()
#define NO_VIM_MAIN
#include "main.c"
/* This file has to be included because the tested functions are static */
// This file has to be included because the tested functions are static
#include "memfile.c"
#define index_to_key(i) ((i) ^ 15167)
@ -39,21 +39,21 @@ test_mf_hash(void)
mf_hash_init(&ht);
/* insert some items and check invariants */
// insert some items and check invariants
for (i = 0; i < TEST_COUNT; i++)
{
assert(ht.mht_count == i);
/* check that number of buckets is a power of 2 */
// check that number of buckets is a power of 2
num_buckets = ht.mht_mask + 1;
assert(num_buckets > 0 && (num_buckets & (num_buckets - 1)) == 0);
/* check load factor */
// check load factor
assert(ht.mht_count <= (num_buckets << MHT_LOG_LOAD_FACTOR));
if (i < (MHT_INIT_SIZE << MHT_LOG_LOAD_FACTOR))
{
/* first expansion shouldn't have occurred yet */
// first expansion shouldn't have occurred yet
assert(num_buckets == MHT_INIT_SIZE);
assert(ht.mht_buckets == ht.mht_small_buckets);
}
@ -66,7 +66,7 @@ test_mf_hash(void)
key = index_to_key(i);
assert(mf_hash_find(&ht, key) == NULL);
/* allocate and add new item */
// allocate and add new item
item = LALLOC_CLEAR_ONE(mf_hashitem_T);
assert(item != NULL);
item->mhi_key = key;
@ -76,13 +76,13 @@ test_mf_hash(void)
if (ht.mht_mask + 1 != num_buckets)
{
/* hash table was expanded */
// hash table was expanded
assert(ht.mht_mask + 1 == num_buckets * MHT_GROWTH_FACTOR);
assert(i + 1 == (num_buckets << MHT_LOG_LOAD_FACTOR));
}
}
/* check presence of inserted items */
// check presence of inserted items
for (i = 0; i < TEST_COUNT; i++)
{
key = index_to_key(i);
@ -91,7 +91,7 @@ test_mf_hash(void)
assert(item->mhi_key == key);
}
/* delete some items */
// delete some items
for (i = 0; i < TEST_COUNT; i++)
{
if (i % 100 < 70)
@ -114,7 +114,7 @@ test_mf_hash(void)
}
}
/* check again */
// check again
for (i = 0; i < TEST_COUNT; i++)
{
key = index_to_key(i);
@ -131,7 +131,7 @@ test_mf_hash(void)
}
}
/* free hash table and all remaining items */
// free hash table and all remaining items
mf_hash_free_all(&ht);
}

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@
#if defined(FEAT_MENU) || defined(PROTO)
#define MENUDEPTH 10 /* maximum depth of menus */
#define MENUDEPTH 10 // maximum depth of menus
#ifdef FEAT_GUI_MSWIN
static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *, int);
@ -56,7 +56,7 @@ static void menu_unescape_name(char_u *p);
static char_u *menu_translate_tab_and_shift(char_u *arg_start);
/* The character for each menu mode */
// The character for each menu mode
static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"};
static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
@ -106,7 +106,7 @@ get_root_menu(char_u *name)
*/
void
ex_menu(
exarg_T *eap) /* Ex command arguments */
exarg_T *eap) // Ex command arguments
{
char_u *menu_path;
int modes;
@ -126,8 +126,8 @@ ex_menu(
# endif
#endif
int pri_tab[MENUDEPTH + 1];
int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu
* disable */
int enable = MAYBE; // TRUE for "menu enable", FALSE for "menu
// disable
#ifdef FEAT_TOOLBAR
char_u *icon = NULL;
#endif
@ -161,7 +161,7 @@ ex_menu(
}
/* Locate an optional "icon=filename" argument. */
// Locate an optional "icon=filename" argument.
if (STRNCMP(arg, "icon=", 5) == 0)
{
arg += 5;
@ -208,7 +208,7 @@ ex_menu(
i = 0;
while (i < MENUDEPTH)
pri_tab[i++] = 500;
pri_tab[MENUDEPTH] = -1; /* mark end of the table */
pri_tab[MENUDEPTH] = -1; // mark end of the table
/*
* Check for "disable" or "enable" argument.
@ -301,7 +301,7 @@ ex_menu(
root_menu_ptr = get_root_menu(menu_path);
if (root_menu_ptr == &curwin->w_winbar)
/* Assume the window toolbar menu will change. */
// Assume the window toolbar menu will change.
redraw_later(NOT_VALID);
if (enable != MAYBE)
@ -311,7 +311,7 @@ ex_menu(
* For the PopUp menu, remove a menu for each mode separately.
* Careful: menu_nable_recurse() changes menu_path.
*/
if (STRCMP(menu_path, "*") == 0) /* meaning: do all menus */
if (STRCMP(menu_path, "*") == 0) // meaning: do all menus
menu_path = (char_u *)"";
if (menu_is_popup(menu_path))
@ -335,7 +335,7 @@ ex_menu(
/*
* Delete menu(s).
*/
if (STRCMP(menu_path, "*") == 0) /* meaning: remove all menus */
if (STRCMP(menu_path, "*") == 0) // meaning: remove all menus
menu_path = (char_u *)"";
/*
@ -355,7 +355,7 @@ ex_menu(
}
}
/* Careful: remove_menu() changes menu_path */
// Careful: remove_menu() changes menu_path
remove_menu(root_menu_ptr, menu_path, modes, FALSE);
}
else
@ -364,13 +364,13 @@ ex_menu(
* Add menu(s).
* Replace special key codes.
*/
if (STRICMP(map_to, "<nop>") == 0) /* "<Nop>" means nothing */
if (STRICMP(map_to, "<nop>") == 0) // "<Nop>" means nothing
{
map_to = (char_u *)"";
map_buf = NULL;
}
else if (modes & MENU_TIP_MODE)
map_buf = NULL; /* Menu tips are plain text. */
map_buf = NULL; // Menu tips are plain text.
else
map_to = replace_termcodes(map_to, &map_buf,
REPTERM_DO_LT | (special ? REPTERM_SPECIAL : 0), NULL);
@ -397,7 +397,7 @@ ex_menu(
p = popup_mode_name(menu_path, i);
if (p != NULL)
{
/* Include all modes, to make ":amenu" work */
// Include all modes, to make ":amenu" work
menuarg.modes = modes;
#ifdef FEAT_TOOLBAR
menuarg.iconfile = NULL;
@ -418,7 +418,7 @@ ex_menu(
}
#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK))
/* If the menubar height changed, resize the window */
// If the menubar height changed, resize the window
if (gui.in_use
&& (gui.menu_height != old_menu_height
# if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
@ -451,12 +451,12 @@ theend:
static int
add_menu_path(
char_u *menu_path,
vimmenu_T *menuarg, /* passes modes, iconfile, iconidx,
icon_builtin, silent[0], noremap[0] */
vimmenu_T *menuarg, // passes modes, iconfile, iconidx,
// icon_builtin, silent[0], noremap[0]
int *pri_tab,
char_u *call_data
#ifdef FEAT_GUI_MSWIN
, int addtearoff /* may add tearoff item */
, int addtearoff // may add tearoff item
#endif
)
{
@ -486,7 +486,7 @@ add_menu_path(
#endif
vimmenu_T **root_menu_ptr;
/* Make a copy so we can stuff around with it, since it could be const */
// Make a copy so we can stuff around with it, since it could be const
path_name = vim_strsave(menu_path);
if (path_name == NULL)
return FAIL;
@ -496,8 +496,8 @@ add_menu_path(
name = path_name;
while (*name)
{
/* Get name of this element in the menu hierarchy, and the simplified
* name (without mnemonic and accelerator text). */
// Get name of this element in the menu hierarchy, and the simplified
// name (without mnemonic and accelerator text).
next_name = menu_name_skip(name);
#ifdef FEAT_MULTI_LANG
map_to = menutrans_lookup(name, (int)STRLEN(name));
@ -514,12 +514,12 @@ add_menu_path(
goto erret;
if (*dname == NUL)
{
/* Only a mnemonic or accelerator is not valid. */
// Only a mnemonic or accelerator is not valid.
emsg(_("E792: Empty menu name"));
goto erret;
}
/* See if it's already there */
// See if it's already there
lower_pri = menup;
#ifdef FEAT_GUI
idx = 0;
@ -550,8 +550,8 @@ add_menu_path(
}
menup = &menu->next;
/* Count menus, to find where this one needs to be inserted.
* Ignore menus that are not in the menubar (PopUp and Toolbar) */
// Count menus, to find where this one needs to be inserted.
// Ignore menus that are not in the menubar (PopUp and Toolbar)
if (parent != NULL || menu_is_menubar(menu->name))
{
#ifdef FEAT_GUI
@ -582,7 +582,7 @@ add_menu_path(
goto erret;
}
/* Not already there, so lets add it */
// Not already there, so lets add it
menu = ALLOC_CLEAR_ONE(vimmenu_T);
if (menu == NULL)
goto erret;
@ -590,7 +590,7 @@ add_menu_path(
menu->modes = modes;
menu->enabled = MENU_ALL_MODES;
menu->name = vim_strsave(name);
/* separate mnemonic and accelerator text from actual menu name */
// separate mnemonic and accelerator text from actual menu name
menu->dname = menu_text(name, &menu->mnemonic, &menu->actext);
#ifdef FEAT_MULTI_LANG
if (en_name != NULL)
@ -607,13 +607,13 @@ add_menu_path(
menu->priority = pri_tab[pri_idx];
menu->parent = parent;
#ifdef FEAT_GUI_MOTIF
menu->sensitive = TRUE; /* the default */
menu->sensitive = TRUE; // the default
#endif
#ifdef FEAT_BEVAL_TIP
menu->tip = NULL;
#endif
#ifdef FEAT_GUI_ATHENA
menu->image = None; /* X-Windows definition for NULL*/
menu->image = None; // X-Windows definition for NULL
#endif
/*
@ -631,7 +631,7 @@ add_menu_path(
menu->iconfile = vim_strsave(menuarg->iconfile);
#endif
#if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)
/* the tearoff item must be present in the modes of each item. */
// the tearoff item must be present in the modes of each item.
if (parent != NULL && menu_is_tearoff(parent->children->dname))
parent->children->modes |= modes;
#endif
@ -646,7 +646,7 @@ add_menu_path(
* Also enable a menu when it's created or changed.
*/
#ifdef FEAT_GUI_MSWIN
/* If adding a tearbar (addtearoff == FALSE) don't update modes */
// If adding a tearbar (addtearoff == FALSE) don't update modes
if (addtearoff)
#endif
{
@ -663,25 +663,25 @@ add_menu_path(
if ((old_modes & MENU_ALL_MODES) == 0
&& (menu->modes & MENU_ALL_MODES) != 0)
{
if (gui.in_use) /* Otherwise it will be added when GUI starts */
if (gui.in_use) // Otherwise it will be added when GUI starts
{
if (*next_name == NUL)
{
/* Real menu item, not sub-menu */
// Real menu item, not sub-menu
gui_mch_add_menu_item(menu, new_idx);
/* Want to update menus now even if mode not changed */
// Want to update menus now even if mode not changed
force_menu_update = TRUE;
}
else
{
/* Sub-menu (not at end of path yet) */
// Sub-menu (not at end of path yet)
gui_mch_add_menu(menu, new_idx);
}
}
# if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
/* When adding a new submenu, may add a tearoff item */
// When adding a new submenu, may add a tearoff item
if ( addtearoff
&& *next_name
&& vim_strchr(p_go, GO_TEAROFF) != NULL
@ -721,7 +721,7 @@ add_menu_path(
}
# endif
}
#endif /* FEAT_GUI */
#endif // FEAT_GUI
menup = &menu->children;
parent = menu;
@ -748,17 +748,17 @@ add_menu_path(
#endif
p = (call_data == NULL) ? NULL : vim_strsave(call_data);
/* loop over all modes, may add more than one */
// loop over all modes, may add more than one
for (i = 0; i < MENU_MODES; ++i)
{
if (modes & (1 << i))
{
/* free any old menu */
// free any old menu
free_menu_string(menu, i);
/* For "amenu", may insert an extra character.
* Don't do this if adding a tearbar (addtearoff == FALSE).
* Don't do this for "<Nop>". */
// For "amenu", may insert an extra character.
// Don't do this if adding a tearbar (addtearoff == FALSE).
// Don't do this for "<Nop>".
c = 0;
d = 0;
if (amenu && call_data != NULL && *call_data != NUL
@ -799,7 +799,7 @@ add_menu_path(
{
int len = (int)STRLEN(menu->strings[i]);
/* Append CTRL-\ CTRL-G to obey 'insertmode'. */
// Append CTRL-\ CTRL-G to obey 'insertmode'.
menu->strings[i][len] = Ctrl_BSL;
menu->strings[i][len + 1] = Ctrl_G;
menu->strings[i][len + 2] = NUL;
@ -814,7 +814,7 @@ add_menu_path(
}
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \
&& (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK))
/* Need to update the menu tip. */
// Need to update the menu tip.
if (modes & MENU_TIP_MODE)
gui_mch_menu_set_tip(menu);
#endif
@ -825,8 +825,8 @@ erret:
vim_free(path_name);
vim_free(dname);
/* Delete any empty submenu we added before discovering the error. Repeat
* for higher levels. */
// Delete any empty submenu we added before discovering the error. Repeat
// for higher levels.
while (parent != NULL && parent->children == NULL)
{
if (parent->parent == NULL)
@ -835,7 +835,7 @@ erret:
menup = &parent->parent->children;
for ( ; *menup != NULL && *menup != parent; menup = &((*menup)->next))
;
if (*menup == NULL) /* safety check */
if (*menup == NULL) // safety check
break;
parent = parent->parent;
free_menu(menup);
@ -857,12 +857,12 @@ menu_nable_recurse(
char_u *p;
if (menu == NULL)
return OK; /* Got to bottom of hierarchy */
return OK; // Got to bottom of hierarchy
/* Get name of this element in the menu hierarchy */
// Get name of this element in the menu hierarchy
p = menu_name_skip(name);
/* Find the menu */
// Find the menu
while (menu != NULL)
{
if (*name == NUL || *name == '*' || menu_name_equal(name, menu))
@ -901,7 +901,7 @@ menu_nable_recurse(
}
#ifdef FEAT_GUI
/* Want to update menus now even if mode not changed */
// Want to update menus now even if mode not changed
force_menu_update = TRUE;
#endif
@ -917,19 +917,19 @@ remove_menu(
vimmenu_T **menup,
char_u *name,
int modes,
int silent) /* don't give error messages */
int silent) // don't give error messages
{
vimmenu_T *menu;
vimmenu_T *child;
char_u *p;
if (*menup == NULL)
return OK; /* Got to bottom of hierarchy */
return OK; // Got to bottom of hierarchy
/* Get name of this element in the menu hierarchy */
// Get name of this element in the menu hierarchy
p = menu_name_skip(name);
/* Find the menu */
// Find the menu
while ((menu = *menup) != NULL)
{
if (*name == NUL || menu_name_equal(name, menu))
@ -971,8 +971,8 @@ remove_menu(
if (*name != NUL)
break;
/* Remove the menu item for the given mode[s]. If the menu item
* is no longer valid in ANY mode, delete it */
// Remove the menu item for the given mode[s]. If the menu item
// is no longer valid in ANY mode, delete it
menu->modes &= ~modes;
if (modes & MENU_TIP_MODE)
free_menu_string(menu, MENU_INDEX_TIP);
@ -994,11 +994,11 @@ remove_menu(
}
/* Recalculate modes for menu based on the new updated children */
// Recalculate modes for menu based on the new updated children
menu->modes &= ~modes;
#if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
if ((s_tearoffs) && (menu->children != NULL)) /* there's a tear bar.. */
child = menu->children->next; /* don't count tearoff bar */
if ((s_tearoffs) && (menu->children != NULL)) // there's a tear bar..
child = menu->children->next; // don't count tearoff bar
else
#endif
child = menu->children;
@ -1009,16 +1009,16 @@ remove_menu(
free_menu_string(menu, MENU_INDEX_TIP);
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \
&& (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK))
/* Need to update the menu tip. */
// Need to update the menu tip.
if (gui.in_use)
gui_mch_menu_set_tip(menu);
#endif
}
if ((menu->modes & MENU_ALL_MODES) == 0)
{
/* The menu item is no longer valid in ANY mode, so delete it */
// The menu item is no longer valid in ANY mode, so delete it
#if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
if (s_tearoffs && menu->children != NULL) /* there's a tear bar.. */
if (s_tearoffs && menu->children != NULL) // there's a tear bar..
free_menu(&menu->children);
#endif
*menup = menu;
@ -1051,14 +1051,14 @@ free_menu(vimmenu_T **menup)
menu = *menup;
#ifdef FEAT_GUI
/* Free machine specific menu structures (only when already created) */
/* Also may rebuild a tearoff'ed menu */
// Free machine specific menu structures (only when already created)
// Also may rebuild a tearoff'ed menu
if (gui.in_use)
gui_mch_destroy_menu(menu);
#endif
/* Don't change *menup until after calling gui_mch_destroy_menu(). The
* MacOS code needs the original structure to properly delete the menu. */
// Don't change *menup until after calling gui_mch_destroy_menu(). The
// MacOS code needs the original structure to properly delete the menu.
*menup = menu->next;
vim_free(menu->name);
vim_free(menu->dname);
@ -1078,7 +1078,7 @@ free_menu(vimmenu_T **menup)
vim_free(menu);
#ifdef FEAT_GUI
/* Want to update menus now even if mode not changed */
// Want to update menus now even if mode not changed
force_menu_update = TRUE;
#endif
}
@ -1116,7 +1116,7 @@ show_menus(char_u *path_name, int modes)
return FAIL;
menu = *get_root_menu(path_name);
/* First, find the (sub)menu with the given name */
// First, find the (sub)menu with the given name
while (*name)
{
p = menu_name_skip(name);
@ -1124,7 +1124,7 @@ show_menus(char_u *path_name, int modes)
{
if (menu_name_equal(name, menu))
{
/* Found menu */
// Found menu
if (*p != NUL && menu->children == NULL)
{
emsg(_(e_notsubmenu));
@ -1153,8 +1153,8 @@ show_menus(char_u *path_name, int modes)
}
vim_free(path_name);
/* Now we have found the matching menu, and we list the mappings */
/* Highlight title */
// Now we have found the matching menu, and we list the mappings
// Highlight title
msg_puts_title(_("\n--- Menus ---"));
show_menus_recursive(parent, modes, 0);
@ -1176,7 +1176,7 @@ show_menus_recursive(vimmenu_T *menu, int modes, int depth)
if (menu != NULL)
{
msg_putchar('\n');
if (got_int) /* "q" hit for "--more--" */
if (got_int) // "q" hit for "--more--"
return;
for (i = 0; i < depth; i++)
msg_puts(" ");
@ -1185,7 +1185,7 @@ show_menus_recursive(vimmenu_T *menu, int modes, int depth)
msg_outnum((long)menu->priority);
msg_puts(" ");
}
/* Same highlighting as for directories!? */
// Same highlighting as for directories!?
msg_outtrans_attr(menu->name, HL_ATTR(HLF_D));
}
@ -1195,7 +1195,7 @@ show_menus_recursive(vimmenu_T *menu, int modes, int depth)
if ((menu->modes & modes & (1 << bit)) != 0)
{
msg_putchar('\n');
if (got_int) /* "q" hit for "--more--" */
if (got_int) // "q" hit for "--more--"
return;
for (i = 0; i < depth + 2; i++)
msg_puts(" ");
@ -1231,7 +1231,7 @@ show_menus_recursive(vimmenu_T *menu, int modes, int depth)
else
menu = menu->children;
/* recursively show all children. Skip PopUp[nvoci]. */
// recursively show all children. Skip PopUp[nvoci].
for (; menu != NULL && !got_int; menu = menu->next)
if (!menu_is_hidden(menu->dname))
show_menus_recursive(menu, modes, depth + 1);
@ -1244,7 +1244,7 @@ show_menus_recursive(vimmenu_T *menu, int modes, int depth)
static vimmenu_T *expand_menu = NULL;
static vimmenu_T *expand_menu_alt = NULL;
static int expand_modes = 0x0;
static int expand_emenu; /* TRUE for ":emenu" command */
static int expand_emenu; // TRUE for ":emenu" command
/*
* Work out what to complete when doing command line completion of menu names.
@ -1267,7 +1267,7 @@ set_context_in_menu_cmd(
xp->xp_context = EXPAND_UNSUCCESSFUL;
/* Check for priority numbers, enable and disable */
// Check for priority numbers, enable and disable
for (p = arg; *p; ++p)
if (!VIM_ISDIGIT(*p) && *p != '.')
break;
@ -1297,12 +1297,12 @@ set_context_in_menu_cmd(
after_dot = p + 1;
}
/* ":tearoff" and ":popup" only use menus, not entries */
// ":tearoff" and ":popup" only use menus, not entries
expand_menus = !((*cmd == 't' && cmd[1] == 'e') || *cmd == 'p');
expand_emenu = (*cmd == 'e');
if (expand_menus && VIM_ISWHITE(*p))
return NULL; /* TODO: check for next command? */
if (*p == NUL) /* Complete the menu name */
return NULL; // TODO: check for next command?
if (*p == NUL) // Complete the menu name
{
int try_alt_menu = TRUE;
@ -1331,7 +1331,7 @@ set_context_in_menu_cmd(
{
if (menu_name_equal(name, menu))
{
/* Found menu */
// Found menu
if ((*p != NUL && menu->children == NULL)
|| ((menu->modes & expand_modes) == 0x0))
{
@ -1353,7 +1353,7 @@ set_context_in_menu_cmd(
}
if (menu == NULL)
{
/* No menu found with the name we were looking for */
// No menu found with the name we were looking for
vim_free(path_name);
return NULL;
}
@ -1371,7 +1371,7 @@ set_context_in_menu_cmd(
else
expand_menu_alt = NULL;
}
else /* We're in the mapping part */
else // We're in the mapping part
xp->xp_context = EXPAND_NOTHING;
return NULL;
}
@ -1390,7 +1390,7 @@ get_menu_name(expand_T *xp UNUSED, int idx)
static int should_advance = FALSE;
#endif
if (idx == 0) /* first call: start at first item */
if (idx == 0) // first call: start at first item
{
menu = expand_menu;
did_alt_menu = FALSE;
@ -1399,7 +1399,7 @@ get_menu_name(expand_T *xp UNUSED, int idx)
#endif
}
/* Skip PopUp[nvoci]. */
// Skip PopUp[nvoci].
while (menu != NULL && (menu_is_hidden(menu->dname)
|| menu_is_separator(menu->dname)
|| menu_is_tearoff(menu->dname)
@ -1413,7 +1413,7 @@ get_menu_name(expand_T *xp UNUSED, int idx)
}
}
if (menu == NULL) /* at end of linked list */
if (menu == NULL) // at end of linked list
return NULL;
if (menu->modes & expand_modes)
@ -1436,7 +1436,7 @@ get_menu_name(expand_T *xp UNUSED, int idx)
if (should_advance)
#endif
{
/* Advance to next menu entry. */
// Advance to next menu entry.
menu = menu->next;
if (menu == NULL && !did_alt_menu)
{
@ -1462,13 +1462,13 @@ get_menu_names(expand_T *xp UNUSED, int idx)
static vimmenu_T *menu = NULL;
static int did_alt_menu = FALSE;
#define TBUFFER_LEN 256
static char_u tbuffer[TBUFFER_LEN]; /*hack*/
static char_u tbuffer[TBUFFER_LEN]; //hack
char_u *str;
#ifdef FEAT_MULTI_LANG
static int should_advance = FALSE;
#endif
if (idx == 0) /* first call: start at first item */
if (idx == 0) // first call: start at first item
{
menu = expand_menu;
did_alt_menu = FALSE;
@ -1477,7 +1477,7 @@ get_menu_names(expand_T *xp UNUSED, int idx)
#endif
}
/* Skip Browse-style entries, popup menus and separators. */
// Skip Browse-style entries, popup menus and separators.
while (menu != NULL
&& ( menu_is_hidden(menu->dname)
|| (expand_emenu && menu_is_separator(menu->dname))
@ -1495,7 +1495,7 @@ get_menu_names(expand_T *xp UNUSED, int idx)
}
}
if (menu == NULL) /* at end of linked list */
if (menu == NULL) // at end of linked list
return NULL;
if (menu->modes & expand_modes)
@ -1514,8 +1514,8 @@ get_menu_names(expand_T *xp UNUSED, int idx)
should_advance = TRUE;
}
#endif
/* hack on menu separators: use a 'magic' char for the separator
* so that '.' in names gets escaped properly */
// hack on menu separators: use a 'magic' char for the separator
// so that '.' in names gets escaped properly
STRCAT(tbuffer, "\001");
str = tbuffer;
}
@ -1542,7 +1542,7 @@ get_menu_names(expand_T *xp UNUSED, int idx)
if (should_advance)
#endif
{
/* Advance to next menu entry. */
// Advance to next menu entry.
menu = menu->next;
if (menu == NULL && !did_alt_menu)
{
@ -1621,7 +1621,7 @@ menu_namecmp(char_u *name, char_u *mname)
static int
get_menu_cmd_modes(
char_u *cmd,
int forceit, /* Was there a "!" after the command? */
int forceit, // Was there a "!" after the command?
int *noremap,
int *unmenu)
{
@ -1629,50 +1629,50 @@ get_menu_cmd_modes(
switch (*cmd++)
{
case 'v': /* vmenu, vunmenu, vnoremenu */
case 'v': // vmenu, vunmenu, vnoremenu
modes = MENU_VISUAL_MODE | MENU_SELECT_MODE;
break;
case 'x': /* xmenu, xunmenu, xnoremenu */
case 'x': // xmenu, xunmenu, xnoremenu
modes = MENU_VISUAL_MODE;
break;
case 's': /* smenu, sunmenu, snoremenu */
case 's': // smenu, sunmenu, snoremenu
modes = MENU_SELECT_MODE;
break;
case 'o': /* omenu */
case 'o': // omenu
modes = MENU_OP_PENDING_MODE;
break;
case 'i': /* imenu */
case 'i': // imenu
modes = MENU_INSERT_MODE;
break;
case 't':
if (*cmd == 'l') /* tlmenu, tlunmenu, tlnoremenu */
if (*cmd == 'l') // tlmenu, tlunmenu, tlnoremenu
{
modes = MENU_TERMINAL_MODE;
++cmd;
break;
}
modes = MENU_TIP_MODE; /* tmenu */
modes = MENU_TIP_MODE; // tmenu
break;
case 'c': /* cmenu */
case 'c': // cmenu
modes = MENU_CMDLINE_MODE;
break;
case 'a': /* amenu */
case 'a': // amenu
modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE | MENU_NORMAL_MODE
| MENU_VISUAL_MODE | MENU_SELECT_MODE
| MENU_OP_PENDING_MODE;
break;
case 'n':
if (*cmd != 'o') /* nmenu, not noremenu */
if (*cmd != 'o') // nmenu, not noremenu
{
modes = MENU_NORMAL_MODE;
break;
}
/* FALLTHROUGH */
// FALLTHROUGH
default:
--cmd;
if (forceit) /* menu!! */
if (forceit) // menu!!
modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE;
else /* menu */
else // menu
modes = MENU_NORMAL_MODE | MENU_VISUAL_MODE | MENU_SELECT_MODE
| MENU_OP_PENDING_MODE;
}
@ -1761,7 +1761,7 @@ menu_text(char_u *str, int *mnemonic, char_u **actext)
char_u *p;
char_u *text;
/* Locate accelerator text, after the first TAB */
// Locate accelerator text, after the first TAB
p = vim_strchr(str, TAB);
if (p != NULL)
{
@ -1772,13 +1772,13 @@ menu_text(char_u *str, int *mnemonic, char_u **actext)
else
text = vim_strsave(str);
/* Find mnemonic characters "&a" and reduce "&&" to "&". */
// Find mnemonic characters "&a" and reduce "&&" to "&".
for (p = text; p != NULL; )
{
p = vim_strchr(p, '&');
if (p != NULL)
{
if (p[1] == NUL) /* trailing "&" */
if (p[1] == NUL) // trailing "&"
break;
if (mnemonic != NULL && p[1] != '&')
#if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED)
@ -1901,7 +1901,7 @@ get_menu_mode(void)
return MENU_INDEX_OP_PENDING;
if (State & NORMAL)
return MENU_INDEX_NORMAL;
if (State & LANGMAP) /* must be a "r" command, like Insert mode */
if (State & LANGMAP) // must be a "r" command, like Insert mode
return MENU_INDEX_INSERT;
return MENU_INDEX_INVALID;
}
@ -1941,14 +1941,14 @@ show_popupmenu(void)
if (STRNCMP("PopUp", menu->name, 5) == 0 && STRNCMP(menu->name + 5, mode, mode_len) == 0)
break;
/* Only show a popup when it is defined and has entries */
// Only show a popup when it is defined and has entries
if (menu != NULL && menu->children != NULL)
{
# if defined(FEAT_GUI)
if (gui.in_use)
{
/* Update the menus now, in case the MenuPopup autocommand did
* anything. */
// Update the menus now, in case the MenuPopup autocommand did
// anything.
gui_update_menus(0);
gui_mch_show_popupmenu(menu);
}
@ -1998,7 +1998,7 @@ gui_create_initial_menus(vimmenu_T *menu)
while (menu != NULL)
{
/* Don't add a menu when only a tip was defined. */
// Don't add a menu when only a tip was defined.
if (menu->modes & MENU_ALL_MODES)
{
if (menu->children != NULL)
@ -2033,11 +2033,11 @@ gui_update_menus_recurse(vimmenu_T *menu, int mode)
else
grey = TRUE;
# ifdef FEAT_GUI_ATHENA
/* Hiding menus doesn't work for Athena, it can cause a crash. */
// Hiding menus doesn't work for Athena, it can cause a crash.
gui_mch_menu_grey(menu, grey);
# else
/* Never hide a toplevel menu, it may make the menubar resize or
* disappear. Same problem for ToolBar items. */
// Never hide a toplevel menu, it may make the menubar resize or
// disappear. Same problem for ToolBar items.
if (vim_strchr(p_go, GO_GREY) != NULL || menu->parent == NULL
# ifdef FEAT_TOOLBAR
|| menu_is_toolbar(menu->parent->name)
@ -2097,7 +2097,7 @@ gui_is_menu_shortcut(int key)
return FALSE;
}
# endif
#endif /* FEAT_GUI */
#endif // FEAT_GUI
#if (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) || defined(PROTO)
@ -2145,8 +2145,8 @@ gui_create_tearoffs_recurse(
{
if (menu->children != NULL && menu_is_menubar(menu->name))
{
/* Add the menu name to the menu path. Insert a backslash before
* dots (it's used to separate menu names). */
// Add the menu name to the menu path. Insert a backslash before
// dots (it's used to separate menu names).
len = (int)STRLEN(pname) + (int)STRLEN(menu->name);
for (s = menu->name; *s; ++s)
if (*s == '.' || *s == '\\')
@ -2164,11 +2164,11 @@ gui_create_tearoffs_recurse(
}
*d = NUL;
/* check if tearoff already exists */
// check if tearoff already exists
if (STRCMP(menu->children->name, TEAR_STRING) != 0)
{
gui_add_tearoff(newpname, pri_tab, pri_idx - 1);
*d = NUL; /* remove TEAR_STRING */
*d = NUL; // remove TEAR_STRING
}
STRCAT(newpname, ".");
@ -2204,7 +2204,7 @@ gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx)
STRCAT(tearpath, ".");
STRCAT(tearpath, TEAR_STRING);
/* Priority of tear-off is always 1 */
// Priority of tear-off is always 1
t = pri_tab[pri_idx + 1];
pri_tab[pri_idx + 1] = 1;
@ -2238,20 +2238,20 @@ gui_destroy_tearoffs_recurse(vimmenu_T *menu)
{
if (menu->children)
{
/* check if tearoff exists */
// check if tearoff exists
if (STRCMP(menu->children->name, TEAR_STRING) == 0)
{
/* Disconnect the item and free the memory */
// Disconnect the item and free the memory
free_menu(&menu->children);
}
if (menu->children != NULL) /* if not the last one */
if (menu->children != NULL) // if not the last one
gui_destroy_tearoffs_recurse(menu->children);
}
menu = menu->next;
}
}
#endif /* FEAT_GUI_MSWIN && FEAT_TEAROFF */
#endif // FEAT_GUI_MSWIN && FEAT_TEAROFF
/*
* Execute "menu". Use by ":emenu" and the window toolbar.
@ -2266,7 +2266,7 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
if (idx < 0)
{
/* Use the Insert mode entry when returning to Insert mode. */
// Use the Insert mode entry when returning to Insert mode.
if (restart_edit
#ifdef FEAT_EVAL
&& !current_sctx.sc_sid
@ -2291,14 +2291,14 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
idx = MENU_INDEX_VISUAL;
/* GEDDES: This is not perfect - but it is a
* quick way of detecting whether we are doing this from a
* selection - see if the range matches up with the visual
* select start and end. */
// GEDDES: This is not perfect - but it is a
// quick way of detecting whether we are doing this from a
// selection - see if the range matches up with the visual
// select start and end.
if ((curbuf->b_visual.vi_start.lnum == eap->line1)
&& (curbuf->b_visual.vi_end.lnum) == eap->line2)
{
/* Set it up for visual mode - equivalent to gv. */
// Set it up for visual mode - equivalent to gv.
VIsual_mode = curbuf->b_visual.vi_mode;
tpos = curbuf->b_visual.vi_end;
curwin->w_cursor = curbuf->b_visual.vi_start;
@ -2306,7 +2306,7 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
}
else
{
/* Set it up for line-wise visual mode */
// Set it up for line-wise visual mode
VIsual_mode = 'V';
curwin->w_cursor.lnum = eap->line1;
curwin->w_cursor.col = 1;
@ -2315,7 +2315,7 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
tpos.coladd = 0;
}
/* Activate visual mode */
// Activate visual mode
VIsual_active = TRUE;
VIsual_reselect = TRUE;
check_cursor();
@ -2324,23 +2324,23 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
check_cursor();
/* Adjust the cursor to make sure it is in the correct pos
* for exclusive mode */
// Adjust the cursor to make sure it is in the correct pos
// for exclusive mode
if (*p_sel == 'e' && gchar_cursor() != NUL)
++curwin->w_cursor.col;
}
}
/* For the WinBar menu always use the Normal mode menu. */
// For the WinBar menu always use the Normal mode menu.
if (idx == -1 || eap == NULL)
idx = MENU_INDEX_NORMAL;
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL
&& (menu->modes & (1 << idx)))
{
/* When executing a script or function execute the commands right now.
* Also for the window toolbar.
* Otherwise put them in the typeahead buffer. */
// When executing a script or function execute the commands right now.
// Also for the window toolbar.
// Otherwise put them in the typeahead buffer.
if (eap == NULL
#ifdef FEAT_EVAL
|| current_sctx.sc_sid != 0
@ -2432,7 +2432,7 @@ ex_emenu(exarg_T *eap)
name = saved_name;
while (*name)
{
/* Find in the menu hierarchy */
// Find in the menu hierarchy
p = menu_name_skip(name);
while (menu != NULL)
@ -2496,8 +2496,8 @@ winbar_click(win_T *wp, int col)
if (wp != curwin)
{
/* Clicking in the window toolbar of a not-current window.
* Make that window the current one and save Visual mode. */
// Clicking in the window toolbar of a not-current window.
// Make that window the current one and save Visual mode.
save_curwin = curwin;
VIsual_active = FALSE;
curwin = wp;
@ -2547,7 +2547,7 @@ gui_find_menu(char_u *path_name)
name = saved_name;
while (*name)
{
/* find the end of one dot-separated name and put a NUL at the dot */
// find the end of one dot-separated name and put a NUL at the dot
p = menu_name_skip(name);
while (menu != NULL)
@ -2556,7 +2556,7 @@ gui_find_menu(char_u *path_name)
{
if (menu->children == NULL)
{
/* found a menu item instead of a sub-menu */
// found a menu item instead of a sub-menu
if (*p == NUL)
emsg(_("E336: Menu path must lead to a sub-menu"));
else
@ -2564,16 +2564,16 @@ gui_find_menu(char_u *path_name)
menu = NULL;
goto theend;
}
if (*p == NUL) /* found a full match */
if (*p == NUL) // found a full match
goto theend;
break;
}
menu = menu->next;
}
if (menu == NULL) /* didn't find it */
if (menu == NULL) // didn't find it
break;
/* Found a match, search the sub-menu. */
// Found a match, search the sub-menu.
menu = menu->children;
name = p;
}
@ -2593,9 +2593,9 @@ theend:
typedef struct
{
char_u *from; /* English name */
char_u *from_noamp; /* same, without '&' */
char_u *to; /* translated name */
char_u *from; // English name
char_u *from_noamp; // same, without '&'
char_u *to; // translated name
} menutrans_T;
static garray_T menutrans_ga = {0, 0, 0, 0, NULL};
@ -2632,13 +2632,13 @@ ex_menutranslate(exarg_T *eap UNUSED)
}
ga_clear(&menutrans_ga);
# ifdef FEAT_EVAL
/* Delete all "menutrans_" global variables. */
// Delete all "menutrans_" global variables.
del_menutrans_vars();
# endif
}
else
{
/* ":menutrans from to": add translation */
// ":menutrans from to": add translation
from = arg;
arg = menu_skip_part(arg);
to = skipwhite(arg);
@ -2713,7 +2713,7 @@ menutrans_lookup(char_u *name, int len)
if (STRNICMP(name, tp[i].from, len) == 0 && tp[i].from[len] == NUL)
return tp[i].to;
/* Now try again while ignoring '&' characters. */
// Now try again while ignoring '&' characters.
i = name[len];
name[len] = NUL;
dname = menu_text(name, NULL, NULL);
@ -2744,7 +2744,7 @@ menu_unescape_name(char_u *name)
if (*p == '\\')
STRMOVE(p, p + 1);
}
#endif /* FEAT_MULTI_LANG */
#endif // FEAT_MULTI_LANG
/*
* Isolate the menu name.
@ -2773,4 +2773,4 @@ menu_translate_tab_and_shift(char_u *arg_start)
return arg;
}
#endif /* FEAT_MENU */
#endif // FEAT_MENU

View File

@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2388,
/**/
2387,
/**/