From 4ba37b5833de99db9e9afe8928b31c864182405c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 4 Dec 2019 21:57:43 +0100 Subject: patch 8.1.2388: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate. --- src/json.c | 86 ++--- src/json_test.c | 22 +- src/kword_test.c | 6 +- src/list.c | 156 ++++---- src/main.c | 925 +++++++++++++++++++++++----------------------- src/mark.c | 210 +++++------ src/mbyte.c | 1030 ++++++++++++++++++++++++++-------------------------- src/memfile.c | 198 +++++----- src/memfile_test.c | 24 +- src/memline.c | 877 ++++++++++++++++++++++---------------------- src/menu.c | 320 ++++++++-------- src/version.c | 2 + 12 files changed, 1926 insertions(+), 1930 deletions(-) (limited to 'src') diff --git a/src/json.c b/src/json.c index cca6f7044f..eedb6062af 100644 --- a/src/json.c +++ b/src/json.c @@ -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); diff --git a/src/json_test.c b/src/json_test.c index 47bec8ee65..5fb772ee05 100644 --- a/src/json_test.c +++ b/src/json_test.c @@ -14,16 +14,16 @@ #undef NDEBUG #include -/* 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 "; diff --git a/src/kword_test.c b/src/kword_test.c index 927c4fd0cd..c02ba4312c 100644 --- a/src/kword_test.c +++ b/src/kword_test.c @@ -14,11 +14,11 @@ #undef NDEBUG #include -/* 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) { diff --git a/src/list.c b/src/list.c index 3038b22f93..6f475fcef0 100644 --- a/src/list.c +++ b/src/list.c @@ -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; diff --git a/src/main.c b/src/main.c index 387f8370fa..ddb8e388d8 100644 --- a/src/main.c +++ b/src/main.c @@ -13,8 +13,8 @@ #ifdef __CYGWIN__ # ifndef MSWIN # include -# include /* for cygwin_conv_to_posix_path() and/or - * cygwin_conv_path() */ +# include // for cygwin_conv_to_posix_path() and/or + // cygwin_conv_path() # endif # include #endif @@ -23,12 +23,12 @@ # include "iscygpty.h" #endif -/* Values for edit_type. */ -#define EDIT_NONE 0 /* no edit type yet */ -#define EDIT_FILE 1 /* file name argument[s] given, use argument list */ -#define EDIT_STDIN 2 /* read file from stdin */ -#define EDIT_TAG 3 /* tag name argument given, use tagname */ -#define EDIT_QF 4 /* start in quickfix mode */ +// Values for edit_type. +#define EDIT_NONE 0 // no edit type yet +#define EDIT_FILE 1 // file name argument[s] given, use argument list +#define EDIT_STDIN 2 // read file from stdin +#define EDIT_TAG 3 // tag name argument given, use tagname +#define EDIT_QF 4 // start in quickfix mode #if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN) static int file_owned(char *fname); @@ -82,14 +82,14 @@ static char *(main_errors[]) = #define ME_INVALID_ARG 5 }; -#ifndef PROTO /* don't want a prototype for main() */ +#ifndef PROTO // don't want a prototype for main() -/* Various parameters passed between main() and other functions. */ +// Various parameters passed between main() and other functions. static mparm_T params; -#ifndef NO_VIM_MAIN /* skip this for unittests */ +#ifndef NO_VIM_MAIN // skip this for unittests -static char_u *start_dir = NULL; /* current working dir on startup */ +static char_u *start_dir = NULL; // current working dir on startup static int has_dash_c_arg = FALSE; @@ -122,9 +122,9 @@ main argc = get_cmd_argsW(&argv); #endif - /* Many variables are in "params" so that we can pass them to invoked - * functions without a lot of arguments. "argc" and "argv" are also - * copied, so that they can be changed. */ + // Many variables are in "params" so that we can pass them to invoked + // functions without a lot of arguments. "argc" and "argv" are also + // copied, so that they can be changed. vim_memset(¶ms, 0, sizeof(params)); params.argc = argc; params.argv = argv; @@ -150,7 +150,7 @@ main #endif #ifdef STARTUPTIME - /* Need to find "--startuptime" before actually parsing arguments. */ + // Need to find "--startuptime" before actually parsing arguments. for (i = 1; i < argc - 1; ++i) if (STRICMP(argv[i], "--startuptime") == 0) { @@ -162,7 +162,7 @@ main starttime = time(NULL); #ifdef CLEAN_RUNTIMEPATH - /* Need to find "--clean" before actually parsing arguments. */ + // Need to find "--clean" before actually parsing arguments. for (i = 1; i < argc; ++i) if (STRICMP(argv[i], "--clean") == 0) { @@ -219,8 +219,8 @@ main { gui.starting = FALSE; - /* When running "evim" or "gvim -y" we need the menus, exit if we - * don't have them. */ + // When running "evim" or "gvim -y" we need the menus, exit if we + // don't have them. if (params.evim_mode) mch_exit(1); } @@ -239,9 +239,9 @@ main start_dir = alloc(MAXPATHL); if (start_dir != NULL) mch_dirname(start_dir, MAXPATHL); - /* Temporarily add '(' and ')' to 'isfname'. These are valid - * filename characters but are excluded from 'isfname' to make - * "gf" work on a file name in parenthesis (e.g.: see vim.h). */ + // Temporarily add '(' and ')' to 'isfname'. These are valid + // filename characters but are excluded from 'isfname' to make + // "gf" work on a file name in parenthesis (e.g.: see vim.h). do_cmdline_cmd((char_u *)":set isf+=(,)"); alist_expand(NULL, 0); do_cmdline_cmd((char_u *)":set isf&"); @@ -256,8 +256,8 @@ main { extern void set_alist_count(void); - /* Remember the number of entries in the argument list. If it changes - * we don't react on setting 'encoding'. */ + // Remember the number of entries in the argument list. If it changes + // we don't react on setting 'encoding'. set_alist_count(); } #endif @@ -280,10 +280,10 @@ main #ifdef FEAT_DIFF if (params.diff_mode && params.window_count == -1) - params.window_count = 0; /* open up to 3 windows */ + params.window_count = 0; // open up to 3 windows #endif - /* Don't redraw until much later. */ + // Don't redraw until much later. ++RedrawingDisabled; /* @@ -308,16 +308,16 @@ main #endif #if defined(FEAT_GUI_MAC) && defined(MACOS_X_DARWIN) - /* When the GUI is started from Finder, need to display messages in a - * message box. isatty(2) returns TRUE anyway, thus we need to check the - * name to know we're not started from a terminal. */ + // When the GUI is started from Finder, need to display messages in a + // message box. isatty(2) returns TRUE anyway, thus we need to check the + // name to know we're not started from a terminal. if (gui.starting && (!isatty(2) || strcmp("/dev/console", ttyname(2)) == 0)) { params.want_full_screen = FALSE; - /* Avoid always using "/" as the current directory. Note that when - * started from Finder the arglist will be filled later in - * HandleODocAE() and "fname" will be NULL. */ + // Avoid always using "/" as the current directory. Note that when + // started from Finder the arglist will be filled later in + // HandleODocAE() and "fname" will be NULL. if (getcwd((char *)NameBuff, MAXPATHL) != NULL && STRCMP(NameBuff, "/") == 0) { @@ -368,8 +368,8 @@ main check_tty(¶ms); #ifdef _IOLBF - /* Ensure output works usefully without a tty: buffer lines instead of - * fully buffered. */ + // Ensure output works usefully without a tty: buffer lines instead of + // fully buffered. if (silent_mode) setvbuf(stdout, NULL, _IOLBF, 0); #endif @@ -381,54 +381,54 @@ main if (params.want_full_screen && !silent_mode) { - termcapinit(params.term); /* set terminal name and get terminal - capabilities (will set full_screen) */ - screen_start(); /* don't know where cursor is now */ + termcapinit(params.term); // set terminal name and get terminal + // capabilities (will set full_screen) + screen_start(); // don't know where cursor is now TIME_MSG("Termcap init"); } /* * Set the default values for the options that use Rows and Columns. */ - ui_get_shellsize(); /* inits Rows and Columns */ + ui_get_shellsize(); // inits Rows and Columns win_init_size(); #ifdef FEAT_DIFF - /* Set the 'diff' option now, so that it can be checked for in a .vimrc - * file. There is no buffer yet though. */ + // Set the 'diff' option now, so that it can be checked for in a .vimrc + // file. There is no buffer yet though. if (params.diff_mode) diff_win_options(firstwin, FALSE); #endif cmdline_row = Rows - p_ch; msg_row = cmdline_row; - screenalloc(FALSE); /* allocate screen buffers */ + screenalloc(FALSE); // allocate screen buffers set_init_2(); TIME_MSG("inits 2"); msg_scroll = TRUE; no_wait_return = TRUE; - init_mappings(); /* set up initial mappings */ + init_mappings(); // set up initial mappings - init_highlight(TRUE, FALSE); /* set the default highlight groups */ + init_highlight(TRUE, FALSE); // set the default highlight groups TIME_MSG("init highlight"); #ifdef FEAT_EVAL - /* Set the break level after the terminal is initialized. */ + // Set the break level after the terminal is initialized. debug_break_level = params.use_debug_break_level; #endif - /* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. - * Allows for setting 'loadplugins' there. */ + // Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. + // Allows for setting 'loadplugins' there. if (params.use_vimrc != NULL && (STRCMP(params.use_vimrc, "NONE") == 0 || STRCMP(params.use_vimrc, "DEFAULTS") == 0)) p_lpl = FALSE; - /* Execute --cmd arguments. */ + // Execute --cmd arguments. exe_pre_commands(¶ms); - /* Source startup scripts. */ + // Source startup scripts. source_startup_scripts(¶ms); #ifdef FEAT_MZSCHEME @@ -444,8 +444,8 @@ main return vim_main2(); #endif } -#endif /* NO_VIM_MAIN */ -#endif /* PROTO */ +#endif // NO_VIM_MAIN +#endif // PROTO /* * vim_main2() is needed for FEAT_MZSCHEME, but we define it always to keep @@ -465,11 +465,11 @@ vim_main2(void) { char_u *rtp_copy = NULL; - /* First add all package directories to 'runtimepath', so that their - * autoload directories can be found. Only if not done already with a - * :packloadall command. - * Make a copy of 'runtimepath', so that source_runtime does not use - * the pack directories. */ + // First add all package directories to 'runtimepath', so that their + // autoload directories can be found. Only if not done already with a + // :packloadall command. + // Make a copy of 'runtimepath', so that source_runtime does not use + // the pack directories. if (!did_source_packages) { rtp_copy = vim_strsave(p_rtp); @@ -477,7 +477,7 @@ vim_main2(void) } source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy, -# ifdef VMS /* Somehow VMS doesn't handle the "**". */ +# ifdef VMS // Somehow VMS doesn't handle the "**". (char_u *)"plugin/*.vim", # else (char_u *)"plugin/**/*.vim", @@ -486,13 +486,13 @@ vim_main2(void) TIME_MSG("loading plugins"); vim_free(rtp_copy); - /* Only source "start" packages if not done already with a :packloadall - * command. */ + // Only source "start" packages if not done already with a :packloadall + // command. if (!did_source_packages) load_start_packages(); TIME_MSG("loading packages"); -# ifdef VMS /* Somehow VMS doesn't handle the "**". */ +# ifdef VMS // Somehow VMS doesn't handle the "**". source_runtime((char_u *)"plugin/*.vim", DIP_ALL | DIP_AFTER); # else source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER); @@ -503,13 +503,13 @@ vim_main2(void) #endif #ifdef FEAT_DIFF - /* Decide about window layout for diff mode after reading vimrc. */ + // Decide about window layout for diff mode after reading vimrc. if (params.diff_mode && params.window_layout == 0) { if (diffopt_horizontal()) - params.window_layout = WIN_HOR; /* use horizontal split */ + params.window_layout = WIN_HOR; // use horizontal split else - params.window_layout = WIN_VER; /* use vertical split */ + params.window_layout = WIN_VER; // use vertical split } #endif @@ -542,17 +542,17 @@ vim_main2(void) if (gui.starting) { # if defined(UNIX) || defined(VMS) - /* When something caused a message from a vimrc script, need to output - * an extra newline before the shell prompt. */ + // When something caused a message from a vimrc script, need to output + // an extra newline before the shell prompt. if (did_emsg || msg_didout) putchar('\n'); # endif - gui_start(NULL); /* will set full_screen to TRUE */ + gui_start(NULL); // will set full_screen to TRUE TIME_MSG("starting GUI"); - /* When running "evim" or "gvim -y" we need the menus, exit if we - * don't have them. */ + // When running "evim" or "gvim -y" we need the menus, exit if we + // don't have them. if (!gui.in_use && params.evim_mode) mch_exit(1); } @@ -570,7 +570,7 @@ vim_main2(void) } #endif #ifdef FEAT_EVAL - /* It's better to make v:oldfiles an empty list than NULL. */ + // It's better to make v:oldfiles an empty list than NULL. if (get_vim_var_list(VV_OLDFILES) == NULL) set_vim_var_list(VV_OLDFILES, list_alloc()); #endif @@ -632,7 +632,7 @@ vim_main2(void) #endif #ifdef FEAT_XCLIPBOARD - /* Start using the X clipboard, unless the GUI was started. */ + // Start using the X clipboard, unless the GUI was started. # ifdef FEAT_GUI if (!gui.in_use) # endif @@ -643,7 +643,7 @@ vim_main2(void) #endif #ifdef FEAT_CLIENTSERVER - /* Prepare for being a Vim server. */ + // Prepare for being a Vim server. prepare_server(¶ms); #endif @@ -658,8 +658,8 @@ vim_main2(void) read_stdin(); #if defined(UNIX) || defined(VMS) - /* When switching screens and something caused a message from a vimrc - * script, need to output an extra newline on exit. */ + // When switching screens and something caused a message from a vimrc + // script, need to output an extra newline on exit. if ((did_emsg || msg_didout) && *T_TI != NUL) newline_on_exit = TRUE; #endif @@ -681,13 +681,13 @@ vim_main2(void) TIME_MSG("waiting for return"); } - starttermcap(); /* start termcap if not done by wait_return() */ + starttermcap(); // start termcap if not done by wait_return() TIME_MSG("start termcap"); setmouse(); // may start using the mouse if (scroll_region) - scroll_region_reset(); /* In case Rows changed */ - scroll_start(); /* may scroll the screen to the right position */ + scroll_region_reset(); // In case Rows changed + scroll_start(); // may scroll the screen to the right position #if defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) term_push_title(SAVE_RESTORE_BOTH); @@ -704,7 +704,7 @@ vim_main2(void) must_redraw = CLEAR; else { - screenclear(); /* clear screen */ + screenclear(); // clear screen TIME_MSG("clearing screen"); } @@ -727,11 +727,11 @@ vim_main2(void) TIME_MSG("opening buffers"); #ifdef FEAT_EVAL - /* clear v:swapcommand */ + // clear v:swapcommand set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); #endif - /* Ex starts at last line of the file */ + // Ex starts at last line of the file if (exmode_active) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; @@ -762,7 +762,7 @@ vim_main2(void) { win_T *wp; - /* set options in each window for "vimdiff". */ + // set options in each window for "vimdiff". FOR_ALL_WINDOWS(wp) diff_win_options(wp, TRUE); } @@ -785,20 +785,20 @@ vim_main2(void) do_cmdline_cmd(IObuff); TIME_MSG("jumping to tag"); - /* If the user doesn't want to edit the file then we quit here. */ + // If the user doesn't want to edit the file then we quit here. if (swap_exists_did_quit) getout(1); } - /* Execute any "+", "-c" and "-S" arguments. */ + // Execute any "+", "-c" and "-S" arguments. if (params.n_commands > 0) exe_commands(¶ms); - /* Must come before the may_req_ calls. */ + // Must come before the may_req_ calls. starting = 0; #if defined(FEAT_TERMRESPONSE) - /* Must be done before redrawing, puts a few characters on the screen. */ + // Must be done before redrawing, puts a few characters on the screen. may_req_ambiguous_char_width(); #endif @@ -806,18 +806,18 @@ vim_main2(void) redraw_all_later(NOT_VALID); no_wait_return = FALSE; - /* 'autochdir' has been postponed */ + // 'autochdir' has been postponed DO_AUTOCHDIR; #ifdef FEAT_TERMRESPONSE - /* Requesting the termresponse is postponed until here, so that a "-c q" - * argument doesn't make it appear in the shell Vim was started from. */ + // Requesting the termresponse is postponed until here, so that a "-c q" + // argument doesn't make it appear in the shell Vim was started from. may_req_termresponse(); may_req_bg_color(); #endif - /* start in insert mode */ + // start in insert mode if (p_im) need_start_insertmode = TRUE; @@ -828,10 +828,10 @@ vim_main2(void) TIME_MSG("VimEnter autocommands"); #if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD) - /* Adjust default register name for "unnamed" in 'clipboard'. Can only be - * done after the clipboard is available and all initial commands that may - * modify the 'clipboard' setting have run; i.e. just before entering the - * main loop. */ + // Adjust default register name for "unnamed" in 'clipboard'. Can only be + // done after the clipboard is available and all initial commands that may + // modify the 'clipboard' setting have run; i.e. just before entering the + // main loop. { int default_regname = 0; @@ -841,8 +841,8 @@ vim_main2(void) #endif #if defined(FEAT_DIFF) - /* When a startup script or session file setup for diff'ing and - * scrollbind, sync the scrollbind now. */ + // When a startup script or session file setup for diff'ing and + // scrollbind, sync the scrollbind now. if (curwin->w_p_diff && curwin->w_p_scb) { update_topline(); @@ -855,12 +855,12 @@ vim_main2(void) # ifdef VIMDLL if (!gui.in_use) # endif - mch_set_winsize_now(); /* Allow winsize changes from now on */ + mch_set_winsize_now(); // Allow winsize changes from now on #endif #if defined(FEAT_GUI) - /* When tab pages were created, may need to update the tab pages line and - * scrollbars. This is skipped while creating them. */ + // When tab pages were created, may need to update the tab pages line and + // scrollbars. This is skipped while creating them. if (first_tabpage->tp_next != NULL) { out_flush(); @@ -870,8 +870,8 @@ vim_main2(void) need_mouse_correct = TRUE; #endif - /* If ":startinsert" command used, stuff a dummy command to be able to - * call normal_cmd(), which will then start Insert mode. */ + // If ":startinsert" command used, stuff a dummy command to be able to + // call normal_cmd(), which will then start Insert mode. if (restart_edit != 0) stuffcharReadbuff(K_NOP); @@ -888,7 +888,7 @@ vim_main2(void) } # endif # endif - /* Tell the client that it can start sending commands. */ + // Tell the client that it can start sending commands. netbeans_open(netbeansArg + 3, TRUE); } #endif @@ -900,7 +900,7 @@ vim_main2(void) */ main_loop(FALSE, FALSE); -#endif /* NO_VIM_MAIN */ +#endif // NO_VIM_MAIN return 0; } @@ -913,16 +913,16 @@ common_init(mparm_T *paramp) { cmdline_init(); - (void)mb_init(); /* init mb_bytelen_tab[] to ones */ + (void)mb_init(); // init mb_bytelen_tab[] to ones #ifdef FEAT_EVAL - eval_init(); /* init global variables */ + eval_init(); // init global variables #endif #ifdef __QNXNTO__ - qnx_init(); /* PhAttach() for clipboard, (and gui) */ + qnx_init(); // PhAttach() for clipboard, (and gui) #endif - /* Init the table of Normal mode commands. */ + // Init the table of Normal mode commands. init_normal_cmds(); /* @@ -935,8 +935,8 @@ common_init(mparm_T *paramp) TIME_MSG("Allocated generic buffers"); #ifdef NBDEBUG - /* Wait a moment for debugging NetBeans. Must be after allocating - * NameBuff. */ + // Wait a moment for debugging NetBeans. Must be after allocating + // NameBuff. nbdebug_log_init("SPRO_GVIM_DEBUG", "SPRO_GVIM_DLEVEL"); nbdebug_wait(WT_ENV | WT_WAIT | WT_STOP, "SPRO_GVIM_WAIT", 20); TIME_MSG("NetBeans debug wait"); @@ -953,7 +953,7 @@ common_init(mparm_T *paramp) #endif #ifdef FEAT_GUI - gui.dofork = TRUE; /* default is to use fork() */ + gui.dofork = TRUE; // default is to use fork() #endif /* @@ -966,13 +966,13 @@ common_init(mparm_T *paramp) early_arg_scan(paramp); #if defined(FEAT_GUI) - /* Prepare for possibly starting GUI sometime */ + // Prepare for possibly starting GUI sometime gui_prepare(¶mp->argc, paramp->argv); TIME_MSG("GUI prepared"); #endif #ifdef FEAT_CLIPBOARD - clip_init(FALSE); /* Initialise clipboard stuff */ + clip_init(FALSE); // Initialise clipboard stuff TIME_MSG("clipboard setup"); #endif @@ -992,9 +992,9 @@ common_init(mparm_T *paramp) if (win_alloc_first() == FAIL) mch_exit(0); - init_yank(); /* init yank buffers */ + init_yank(); // init yank buffers - alist_init(&global_alist); /* Init the argument list to empty. */ + alist_init(&global_alist); // Init the argument list to empty. global_alist.id = 0; /* @@ -1004,7 +1004,7 @@ common_init(mparm_T *paramp) * msg_outtrans_len_attr(). * First find out the home directory, needed to expand "~" in options. */ - init_homedir(); /* find real value of $HOME */ + init_homedir(); // find real value of $HOME set_init_1(paramp->clean); TIME_MSG("inits 1"); @@ -1156,8 +1156,8 @@ may_trigger_safestateagain(void) */ void main_loop( - int cmdwin, /* TRUE when working in the command-line window */ - int noexmode) /* TRUE when return on entering Ex mode */ + int cmdwin, // TRUE when working in the command-line window + int noexmode) // TRUE when return on entering Ex mode { oparg_T oa; // operator arguments oparg_T *prev_oap; // operator arguments @@ -1173,10 +1173,10 @@ main_loop( current_oap = &oa; #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) - /* Setup to catch a terminating error from the X server. Just ignore - * it, restore the state and continue. This might not always work - * properly, but at least we don't exit unexpectedly when the X server - * exits while Vim is running in a console. */ + // Setup to catch a terminating error from the X server. Just ignore + // it, restore the state and continue. This might not always work + // properly, but at least we don't exit unexpectedly when the X server + // exits while Vim is running in a console. if (!cmdwin && !noexmode && SETJMP(x_jump_env)) { State = NORMAL; @@ -1213,36 +1213,36 @@ main_loop( did_check_timestamps = FALSE; if (need_check_timestamps) check_timestamps(FALSE); - if (need_wait_return) /* if wait_return still needed ... */ - wait_return(FALSE); /* ... call it now */ + if (need_wait_return) // if wait_return still needed ... + wait_return(FALSE); // ... call it now if (need_start_insertmode && goto_im() && !VIsual_active) { need_start_insertmode = FALSE; - stuffReadbuff((char_u *)"i"); /* start insert mode next */ - /* skip the fileinfo message now, because it would be shown - * after insert mode finishes! */ + stuffReadbuff((char_u *)"i"); // start insert mode next + // skip the fileinfo message now, because it would be shown + // after insert mode finishes! need_fileinfo = FALSE; } } - /* Reset "got_int" now that we got back to the main loop. Except when - * inside a ":g/pat/cmd" command, then the "got_int" needs to abort - * the ":g" command. - * For ":g/pat/vi" we reset "got_int" when used once. When used - * a second time we go back to Ex mode and abort the ":g" command. */ + // Reset "got_int" now that we got back to the main loop. Except when + // inside a ":g/pat/cmd" command, then the "got_int" needs to abort + // the ":g" command. + // For ":g/pat/vi" we reset "got_int" when used once. When used + // a second time we go back to Ex mode and abort the ":g" command. if (got_int) { if (noexmode && global_busy && !exmode_active && previous_got_int) { - /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was - * used and keep "got_int" set, so that it aborts ":g". */ + // Typed two CTRL-C in a row: go back to ex mode as if "Q" was + // used and keep "got_int" set, so that it aborts ":g". exmode_active = EXMODE_NORMAL; State = NORMAL; } else if (!global_busy || !exmode_active) { if (!quit_more) - (void)vgetc(); /* flush all buffers */ + (void)vgetc(); // flush all buffers got_int = FALSE; } previous_got_int = TRUE; @@ -1280,7 +1280,7 @@ main_loop( conceal_update_lines = FALSE; #endif - /* Trigger CursorMoved if the cursor moved. */ + // Trigger CursorMoved if the cursor moved. if (!finish_op && ( has_cursormoved() #ifdef FEAT_PROP_POPUP @@ -1327,7 +1327,7 @@ main_loop( } #endif - /* Trigger TextChanged if b:changedtick differs. */ + // Trigger TextChanged if b:changedtick differs. if (!finish_op && has_textchanged() && curbuf->b_last_changedtick != CHANGEDTICK(curbuf)) { @@ -1349,8 +1349,8 @@ main_loop( curtab->tp_diff_update = FALSE; } - /* Scroll-binding for diff mode may have been postponed until - * here. Avoids doing it for every change. */ + // Scroll-binding for diff mode may have been postponed until + // here. Avoids doing it for every change. if (diff_need_scrollbind) { check_scrollbind((linenr_T)0, 0L); @@ -1358,7 +1358,7 @@ main_loop( } #endif #if defined(FEAT_FOLDING) - /* Include a closed fold completely in the Visual area. */ + // Include a closed fold completely in the Visual area. foldAdjustVisual(); #endif #ifdef FEAT_FOLDING @@ -1410,7 +1410,7 @@ main_loop( #ifdef FEAT_VIMINFO curbuf->b_last_used = vim_time(); #endif - /* display message after redraw */ + // display message after redraw if (keep_msg != NULL) { char_u *p = vim_strsave(keep_msg); @@ -1427,16 +1427,16 @@ main_loop( vim_free(p); } } - if (need_fileinfo) /* show file info after redraw */ + if (need_fileinfo) // show file info after redraw { fileinfo(FALSE, TRUE, FALSE); need_fileinfo = FALSE; } - emsg_on_display = FALSE; /* can delete error message now */ + emsg_on_display = FALSE; // can delete error message now did_emsg = FALSE; - msg_didany = FALSE; /* reset lines_left in msg_start() */ - may_clear_sb_text(); /* clear scroll-back text on next msg */ + msg_didany = FALSE; // reset lines_left in msg_start() + may_clear_sb_text(); // clear scroll-back text on next msg showruler(FALSE); setcursor(); @@ -1445,8 +1445,8 @@ main_loop( do_redraw = FALSE; #ifdef STARTUPTIME - /* Now that we have drawn the first screen all the startup stuff - * has been done, close any file for startup messages. */ + // Now that we have drawn the first screen all the startup stuff + // has been done, close any file for startup messages. if (time_fd != NULL) { TIME_MSG("first screen update"); @@ -1483,7 +1483,7 @@ main_loop( */ if (exmode_active) { - if (noexmode) /* End of ":global/path/visual" commands */ + if (noexmode) // End of ":global/path/visual" commands goto theend; do_exmode(exmode_active == EXMODE_VIM); } @@ -1495,9 +1495,9 @@ main_loop( && !VIsual_active && !skip_term_loop) { - /* If terminal_loop() returns OK we got a key that is handled - * in Normal model. With FAIL we first need to position the - * cursor and the screen needs to be redrawn. */ + // If terminal_loop() returns OK we got a key that is handled + // in Normal model. With FAIL we first need to position the + // cursor and the screen needs to be redrawn. if (terminal_loop(TRUE) == OK) normal_cmd(&oa, TRUE); } @@ -1525,16 +1525,16 @@ theend: getout_preserve_modified(int exitval) { # if defined(SIGHUP) && defined(SIG_IGN) - /* Ignore SIGHUP, because a dropped connection causes a read error, which - * makes Vim exit and then handling SIGHUP causes various reentrance - * problems. */ + // Ignore SIGHUP, because a dropped connection causes a read error, which + // makes Vim exit and then handling SIGHUP causes various reentrance + // problems. signal(SIGHUP, SIG_IGN); # endif - ml_close_notmod(); /* close all not-modified buffers */ - ml_sync_all(FALSE, FALSE); /* preserve all swap files */ - ml_close_all(FALSE); /* close all memfiles, without deleting */ - getout(exitval); /* exit Vim properly */ + ml_close_notmod(); // close all not-modified buffers + ml_sync_all(FALSE, FALSE); // preserve all swap files + ml_close_all(FALSE); // close all memfiles, without deleting + getout(exitval); // exit Vim properly } #endif @@ -1550,20 +1550,20 @@ getout(int exitval) ch_log(NULL, "Exiting..."); #endif - /* When running in Ex mode an error causes us to exit with a non-zero exit - * code. POSIX requires this, although it's not 100% clear from the - * standard. */ + // When running in Ex mode an error causes us to exit with a non-zero exit + // code. POSIX requires this, although it's not 100% clear from the + // standard. if (exmode_active) exitval += ex_exitval; - /* Position the cursor on the last screen line, below all the text */ + // Position the cursor on the last screen line, below all the text #ifdef FEAT_GUI if (!gui.in_use) #endif windgoto((int)Rows - 1, 0); #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) - /* Optionally print hashtable efficiency. */ + // Optionally print hashtable efficiency. hash_debug_results(); #endif @@ -1578,14 +1578,14 @@ getout(int exitval) buf_T *buf; win_T *wp; - /* Trigger BufWinLeave for all windows, but only once per buffer. */ + // Trigger BufWinLeave for all windows, but only once per buffer. for (tp = first_tabpage; tp != NULL; tp = next_tp) { next_tp = tp->tp_next; FOR_ALL_WINDOWS_IN_TAB(tp, wp) { if (wp->w_buffer == NULL) - /* Autocmd must have close the buffer already, skip. */ + // Autocmd must have close the buffer already, skip. continue; buf = wp->w_buffer; if (CHANGEDTICK(buf) != -1) @@ -1596,16 +1596,16 @@ getout(int exitval) apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname, FALSE, buf); if (bufref_valid(&bufref)) - CHANGEDTICK(buf) = -1; /* note we did it already */ + CHANGEDTICK(buf) = -1; // note we did it already - /* start all over, autocommands may mess up the lists */ + // start all over, autocommands may mess up the lists next_tp = first_tabpage; break; } } } - /* Trigger BufUnload for buffers that are loaded */ + // Trigger BufUnload for buffers that are loaded FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL) { @@ -1615,7 +1615,7 @@ getout(int exitval) apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf); if (!bufref_valid(&bufref)) - /* autocmd deleted the buffer */ + // autocmd deleted the buffer break; } apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); @@ -1623,7 +1623,7 @@ getout(int exitval) #ifdef FEAT_VIMINFO if (*p_viminfo != NUL) - /* Write out the regis