1
0
forked from aniani/vim

patch 8.1.2368: using old C style comments

Problem:    Using old C style comments.
Solution:   Use // comments where appropriate.
This commit is contained in:
Bram Moolenaar 2019-11-30 20:52:27 +01:00
parent 71136db1bf
commit c667da5185
12 changed files with 959 additions and 961 deletions

View File

@ -232,14 +232,14 @@ typedef struct AutoPatCmd
struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
} AutoPatCmd; } AutoPatCmd;
static AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */ static AutoPatCmd *active_apc_list = NULL; // stack of active autocommands
/* /*
* augroups stores a list of autocmd group names. * augroups stores a list of autocmd group names.
*/ */
static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL}; static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
#define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i]) #define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
/* use get_deleted_augroup() to get this */ // use get_deleted_augroup() to get this
static char_u *deleted_augroup = NULL; static char_u *deleted_augroup = NULL;
/* /*
@ -247,7 +247,7 @@ static char_u *deleted_augroup = NULL;
*/ */
static int current_augroup = AUGROUP_DEFAULT; static int current_augroup = AUGROUP_DEFAULT;
static int au_need_clean = FALSE; /* need to delete marked patterns */ static int au_need_clean = FALSE; // need to delete marked patterns
static char_u *event_nr2name(event_T event); static char_u *event_nr2name(event_T event);
static int au_get_grouparg(char_u **argp); static int au_get_grouparg(char_u **argp);
@ -258,7 +258,7 @@ static int au_find_group(char_u *name);
static event_T last_event; static event_T last_event;
static int last_group; static int last_group;
static int autocmd_blocked = 0; /* block all autocmds */ static int autocmd_blocked = 0; // block all autocmds
static char_u * static char_u *
get_deleted_augroup(void) get_deleted_augroup(void)
@ -783,7 +783,7 @@ au_event_restore(char_u *old_ei)
vim_free(old_ei); vim_free(old_ei);
} }
} }
# endif /* FEAT_SYN_HL */ # endif // FEAT_SYN_HL
/* /*
* do_autocmd() -- implements the :autocmd command. Can be used in the * do_autocmd() -- implements the :autocmd command. Can be used in the
@ -1027,7 +1027,7 @@ do_autocmd_event(
int patlen; int patlen;
int is_buflocal; int is_buflocal;
int buflocal_nr; int buflocal_nr;
char_u buflocal_pat[25]; /* for "<buffer=X>" */ char_u buflocal_pat[25]; // for "<buffer=X>"
if (group == AUGROUP_ALL) if (group == AUGROUP_ALL)
findgroup = current_augroup; findgroup = current_augroup;
@ -1120,7 +1120,8 @@ do_autocmd_event(
{ {
if (ap->pat != NULL) if (ap->pat != NULL)
{ {
/* Accept a pattern when: /*
* Accept a pattern when:
* - a group was specified and it's that group, or a group was * - a group was specified and it's that group, or a group was
* not specified and it's the current group, or a group was * not specified and it's the current group, or a group was
* not specified and we are listing * not specified and we are listing
@ -1177,7 +1178,7 @@ do_autocmd_event(
*/ */
if (ap == NULL) if (ap == NULL)
{ {
/* refuse to add buffer-local ap if buffer number is invalid */ // refuse to add buffer-local ap if buffer number is invalid
if (is_buflocal && (buflocal_nr == 0 if (is_buflocal && (buflocal_nr == 0
|| buflist_findnr(buflocal_nr) == NULL)) || buflist_findnr(buflocal_nr) == NULL))
{ {

View File

@ -239,13 +239,13 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
#endif #endif
static int recursive = FALSE; static int recursive = FALSE;
/* Don't do anything when 'ballooneval' is off, messages scrolled the // Don't do anything when 'ballooneval' is off, messages scrolled the
* windows up or we have no beval area. */ // windows up or we have no beval area.
if (!can_use_beval() || beval == NULL) if (!can_use_beval() || beval == NULL)
return; return;
/* Don't do this recursively. Happens when the expression evaluation // Don't do this recursively. Happens when the expression evaluation
* takes a long time and invokes something that checks for CTRL-C typed. */ // takes a long time and invokes something that checks for CTRL-C typed.
if (recursive) if (recursive)
return; return;
recursive = TRUE; recursive = TRUE;
@ -257,7 +257,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
: wp->w_buffer->b_p_bexpr; : wp->w_buffer->b_p_bexpr;
if (*bexpr != NUL) if (*bexpr != NUL)
{ {
/* Convert window pointer to number. */ // Convert window pointer to number.
for (cw = firstwin; cw != wp; cw = cw->w_next) for (cw = firstwin; cw != wp; cw = cw->w_next)
++winnr; ++winnr;
@ -285,9 +285,9 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
vim_free(result); vim_free(result);
result = eval_to_string(bexpr, NULL, TRUE); result = eval_to_string(bexpr, NULL, TRUE);
/* Remove one trailing newline, it is added when the result was a // Remove one trailing newline, it is added when the result was a
* list and it's hardly ever useful. If the user really wants a // list and it's hardly ever useful. If the user really wants a
* trailing newline he can add two and one remains. */ // trailing newline he can add two and one remains.
if (result != NULL) if (result != NULL)
{ {
len = STRLEN(result); len = STRLEN(result);
@ -322,4 +322,3 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
} }
#endif #endif

View File

@ -328,4 +328,4 @@ blob_remove(typval_T *argvars, typval_T *rettv)
} }
} }
#endif /* defined(FEAT_EVAL) */ #endif // defined(FEAT_EVAL)

View File

@ -35,28 +35,28 @@ typedef union {
} block8; } block8;
#if defined(MSWIN) #if defined(MSWIN)
/* MS-Windows is always little endian */ // MS-Windows is always little endian
#else #else
# ifdef HAVE_CONFIG_H # ifdef HAVE_CONFIG_H
/* in configure.ac AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed */ // in configure.ac AC_C_BIGENDIAN() defines WORDS_BIGENDIAN when needed
# else # else
error! error!
Please change this code to define WORDS_BIGENDIAN for big-endian machines. Please change this code to define WORDS_BIGENDIAN for big-endian machines.
# endif # endif
#endif #endif
/* The state of encryption, referenced by cryptstate_T. */ // The state of encryption, referenced by cryptstate_T.
typedef struct { typedef struct {
UINT32_T pax[18]; /* P-array */ UINT32_T pax[18]; // P-array
UINT32_T sbx[4][256]; /* S-boxes */ UINT32_T sbx[4][256]; // S-boxes
int randbyte_offset; int randbyte_offset;
int update_offset; int update_offset;
char_u cfb_buffer[BF_MAX_CFB_LEN]; /* up to 64 bytes used */ char_u cfb_buffer[BF_MAX_CFB_LEN]; // up to 64 bytes used
int cfb_len; /* size of cfb_buffer actually used */ int cfb_len; // size of cfb_buffer actually used
} bf_state_T; } bf_state_T;
/* Blowfish code */ // Blowfish code
static UINT32_T pax_init[18] = { static UINT32_T pax_init[18] = {
0x243f6a88u, 0x85a308d3u, 0x13198a2eu, 0x243f6a88u, 0x85a308d3u, 0x13198a2eu,
0x03707344u, 0xa4093822u, 0x299f31d0u, 0x03707344u, 0xa4093822u, 0x299f31d0u,
@ -409,13 +409,13 @@ bf_key_init(
char_u *key; char_u *key;
int keylen; int keylen;
/* Process the key 1001 times. // Process the key 1001 times.
* See http://en.wikipedia.org/wiki/Key_strengthening. */ // See http://en.wikipedia.org/wiki/Key_strengthening.
key = sha256_key(password, salt, salt_len); key = sha256_key(password, salt, salt_len);
for (i = 0; i < 1000; i++) for (i = 0; i < 1000; i++)
key = sha256_key(key, salt, salt_len); key = sha256_key(key, salt, salt_len);
/* Convert the key from 64 hex chars to 32 binary chars. */ // Convert the key from 64 hex chars to 32 binary chars.
keylen = (int)STRLEN(key) / 2; keylen = (int)STRLEN(key) / 2;
if (keylen == 0) if (keylen == 0)
{ {
@ -428,8 +428,8 @@ bf_key_init(
key[i] = u; key[i] = u;
} }
/* Use "key" to initialize the P-array ("pax") and S-boxes ("sbx") of // Use "key" to initialize the P-array ("pax") and S-boxes ("sbx") of
* Blowfish. */ // Blowfish.
mch_memmove(bfs->sbx, sbx_init, 4 * 4 * 256); mch_memmove(bfs->sbx, sbx_init, 4 * 4 * 256);
for (i = 0; i < 18; ++i) for (i = 0; i < 18; ++i)
@ -484,7 +484,7 @@ typedef struct {
char_u salt[9]; char_u salt[9];
char_u plaintxt[9]; char_u plaintxt[9];
char_u cryptxt[9]; char_u cryptxt[9];
char_u badcryptxt[9]; /* cryptxt when big/little endian is wrong */ char_u badcryptxt[9]; // cryptxt when big/little endian is wrong
UINT32_T keysum; UINT32_T keysum;
} struct_bf_test_data; } struct_bf_test_data;
@ -497,9 +497,9 @@ static struct_bf_test_data bf_test_data[] = {
"password", "password",
"salt", "salt",
"plaintxt", "plaintxt",
"\xad\x3d\xfa\x7f\xe8\xea\x40\xf6", /* cryptxt */ "\xad\x3d\xfa\x7f\xe8\xea\x40\xf6", // cryptxt
"\x72\x50\x3b\x38\x10\x60\x22\xa7", /* badcryptxt */ "\x72\x50\x3b\x38\x10\x60\x22\xa7", // badcryptxt
0x56701b5du /* keysum */ 0x56701b5du // keysum
}, },
}; };
@ -518,8 +518,8 @@ bf_self_test(void)
vim_memset(&state, 0, sizeof(bf_state_T)); vim_memset(&state, 0, sizeof(bf_state_T));
state.cfb_len = BF_MAX_CFB_LEN; state.cfb_len = BF_MAX_CFB_LEN;
/* We can't simply use sizeof(UINT32_T), it would generate a compiler // We can't simply use sizeof(UINT32_T), it would generate a compiler
* warning. */ // warning.
if (ui != 0xffffffffUL || ui + 1 != 0) { if (ui != 0xffffffffUL || ui + 1 != 0) {
err++; err++;
emsg(_("E820: sizeof(uint32_t) != 4")); emsg(_("E820: sizeof(uint32_t) != 4"));
@ -537,7 +537,7 @@ bf_self_test(void)
if (!bf_check_tables(state.pax, state.sbx, bf_test_data[i].keysum)) if (!bf_check_tables(state.pax, state.sbx, bf_test_data[i].keysum))
err++; err++;
/* Don't modify bf_test_data[i].plaintxt, self test is idempotent. */ // Don't modify bf_test_data[i].plaintxt, self test is idempotent.
memcpy(bk.uc, bf_test_data[i].plaintxt, 8); memcpy(bk.uc, bf_test_data[i].plaintxt, 8);
bf_e_cblock(&state, bk.uc); bf_e_cblock(&state, bk.uc);
if (memcmp(bk.uc, bf_test_data[i].cryptxt, 8) != 0) if (memcmp(bk.uc, bf_test_data[i].cryptxt, 8) != 0)
@ -651,8 +651,8 @@ crypt_blowfish_init(
return FAIL; return FAIL;
state->method_state = bfs; state->method_state = bfs;
/* "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8 // "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8
* times. "blowfish2" uses a 8 byte buffer to avoid repeating. */ // times. "blowfish2" uses a 8 byte buffer to avoid repeating.
bfs->cfb_len = state->method_nr == CRYPT_M_BF ? BF_MAX_CFB_LEN : BF_BLOCK; bfs->cfb_len = state->method_nr == CRYPT_M_BF ? BF_MAX_CFB_LEN : BF_BLOCK;
if (blowfish_self_test() == FAIL) if (blowfish_self_test() == FAIL)
@ -684,4 +684,4 @@ blowfish_self_test(void)
return OK; return OK;
} }
#endif /* FEAT_CRYPT */ #endif // FEAT_CRYPT

File diff suppressed because it is too large Load Diff

View File

@ -878,7 +878,7 @@ save_file_ff(buf_T *buf)
buf->b_start_eol = buf->b_p_eol; buf->b_start_eol = buf->b_p_eol;
buf->b_start_bomb = buf->b_p_bomb; buf->b_start_bomb = buf->b_p_bomb;
/* Only use free/alloc when necessary, they take time. */ // Only use free/alloc when necessary, they take time.
if (buf->b_start_fenc == NULL if (buf->b_start_fenc == NULL
|| STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
{ {
@ -899,7 +899,7 @@ save_file_ff(buf_T *buf)
int int
file_ff_differs(buf_T *buf, int ignore_empty) file_ff_differs(buf_T *buf, int ignore_empty)
{ {
/* In a buffer that was never loaded the options are not valid. */ // In a buffer that was never loaded the options are not valid.
if (buf->b_flags & BF_NEVERLOADED) if (buf->b_flags & BF_NEVERLOADED)
return FALSE; return FALSE;
if (ignore_empty if (ignore_empty
@ -1371,7 +1371,7 @@ open_line(
// make a copy of the current line so we can mess with it // make a copy of the current line so we can mess with it
saved_line = vim_strsave(ml_get_curline()); saved_line = vim_strsave(ml_get_curline());
if (saved_line == NULL) /* out of memory! */ if (saved_line == NULL) // out of memory!
return FALSE; return FALSE;
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
@ -1646,7 +1646,7 @@ open_line(
} }
// Isolate the strings of the middle and end leader. // Isolate the strings of the middle and end leader.
while (*p && p[-1] != ':') /* find end of middle flags */ while (*p && p[-1] != ':') // find end of middle flags
{ {
if (*p == COM_BLANK) if (*p == COM_BLANK)
require_blank = TRUE; require_blank = TRUE;
@ -2008,7 +2008,7 @@ open_line(
// When in REPLACE mode, put the deleted blanks on the replace stack, // When in REPLACE mode, put the deleted blanks on the replace stack,
// preceded by a NUL, so they can be put back when a BS is entered. // preceded by a NUL, so they can be put back when a BS is entered.
if (REPLACE_NORMAL(State)) if (REPLACE_NORMAL(State))
replace_push(NUL); /* end of extra blanks */ replace_push(NUL); // end of extra blanks
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES))
{ {
while ((*p_extra == ' ' || *p_extra == '\t') while ((*p_extra == ' ' || *p_extra == '\t')
@ -2090,7 +2090,7 @@ open_line(
{ {
// In case we NL to a new line, BS to the previous one, and NL // In case we NL to a new line, BS to the previous one, and NL
// again, we don't want to save the new line for undo twice. // again, we don't want to save the new line for undo twice.
(void)u_save_cursor(); /* errors are ignored! */ (void)u_save_cursor(); // errors are ignored!
vr_lines_changed++; vr_lines_changed++;
} }
ml_replace(curwin->w_cursor.lnum, p_extra, TRUE); ml_replace(curwin->w_cursor.lnum, p_extra, TRUE);

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
#include "vim.h" #include "vim.h"
#if defined(HAVE_WCHAR_H) #if defined(HAVE_WCHAR_H)
# include <wchar.h> /* for towupper() and towlower() */ # include <wchar.h> // for towupper() and towlower()
#endif #endif
static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp); static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp);
@ -18,22 +18,22 @@ static unsigned nr2hex(unsigned c);
static int chartab_initialized = FALSE; static int chartab_initialized = FALSE;
/* b_chartab[] is an array of 32 bytes, each bit representing one of the // b_chartab[] is an array of 32 bytes, each bit representing one of the
* characters 0-255. */ // characters 0-255.
#define SET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] |= (1 << ((c) & 0x7)) #define SET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] |= (1 << ((c) & 0x7))
#define RESET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] &= ~(1 << ((c) & 0x7)) #define RESET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] &= ~(1 << ((c) & 0x7))
#define GET_CHARTAB(buf, c) ((buf)->b_chartab[(unsigned)(c) >> 3] & (1 << ((c) & 0x7))) #define GET_CHARTAB(buf, c) ((buf)->b_chartab[(unsigned)(c) >> 3] & (1 << ((c) & 0x7)))
/* table used below, see init_chartab() for an explanation */ // table used below, see init_chartab() for an explanation
static char_u g_chartab[256]; static char_u g_chartab[256];
/* /*
* Flags for g_chartab[]. * Flags for g_chartab[].
*/ */
#define CT_CELL_MASK 0x07 /* mask: nr of display cells (1, 2 or 4) */ #define CT_CELL_MASK 0x07 // mask: nr of display cells (1, 2 or 4)
#define CT_PRINT_CHAR 0x10 /* flag: set for printable chars */ #define CT_PRINT_CHAR 0x10 // flag: set for printable chars
#define CT_ID_CHAR 0x20 /* flag: set for ID chars */ #define CT_ID_CHAR 0x20 // flag: set for ID chars
#define CT_FNAME_CHAR 0x40 /* flag: set for file name chars */ #define CT_FNAME_CHAR 0x40 // flag: set for file name chars
static int in_win_border(win_T *wp, colnr_T vcol); static int in_win_border(win_T *wp, colnr_T vcol);
@ -72,7 +72,7 @@ init_chartab(void)
int int
buf_init_chartab( buf_init_chartab(
buf_T *buf, buf_T *buf,
int global) /* FALSE: only set buf->b_chartab[] */ int global) // FALSE: only set buf->b_chartab[]
{ {
int c; int c;
int c2; int c2;
@ -102,21 +102,21 @@ buf_init_chartab(
g_chartab[c++] = 1 + CT_PRINT_CHAR; g_chartab[c++] = 1 + CT_PRINT_CHAR;
while (c < 256) while (c < 256)
{ {
/* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */ // UTF-8: bytes 0xa0 - 0xff are printable (latin1)
if (enc_utf8 && c >= 0xa0) if (enc_utf8 && c >= 0xa0)
g_chartab[c++] = CT_PRINT_CHAR + 1; g_chartab[c++] = CT_PRINT_CHAR + 1;
/* euc-jp characters starting with 0x8e are single width */ // euc-jp characters starting with 0x8e are single width
else if (enc_dbcs == DBCS_JPNU && c == 0x8e) else if (enc_dbcs == DBCS_JPNU && c == 0x8e)
g_chartab[c++] = CT_PRINT_CHAR + 1; g_chartab[c++] = CT_PRINT_CHAR + 1;
/* other double-byte chars can be printable AND double-width */ // other double-byte chars can be printable AND double-width
else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2)
g_chartab[c++] = CT_PRINT_CHAR + 2; g_chartab[c++] = CT_PRINT_CHAR + 2;
else else
/* the rest is unprintable by default */ // the rest is unprintable by default
g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
} }
/* Assume that every multi-byte char is a filename character. */ // Assume that every multi-byte char is a filename character.
for (c = 1; c < 256; ++c) for (c = 1; c < 256; ++c)
if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1) if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1)
|| (enc_dbcs == DBCS_JPNU && c == 0x8e) || (enc_dbcs == DBCS_JPNU && c == 0x8e)
@ -131,7 +131,7 @@ buf_init_chartab(
if (enc_dbcs != 0) if (enc_dbcs != 0)
for (c = 0; c < 256; ++c) for (c = 0; c < 256; ++c)
{ {
/* double-byte characters are probably word characters */ // double-byte characters are probably word characters
if (MB_BYTE2LEN(c) == 2) if (MB_BYTE2LEN(c) == 2)
SET_CHARTAB(buf, c); SET_CHARTAB(buf, c);
} }
@ -144,20 +144,19 @@ buf_init_chartab(
SET_CHARTAB(buf, '-'); SET_CHARTAB(buf, '-');
#endif #endif
/* Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint' // Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'
* options Each option is a list of characters, character numbers or // options Each option is a list of characters, character numbers or
* ranges, separated by commas, e.g.: "200-210,x,#-178,-" // ranges, separated by commas, e.g.: "200-210,x,#-178,-"
*/
for (i = global ? 0 : 3; i <= 3; ++i) for (i = global ? 0 : 3; i <= 3; ++i)
{ {
if (i == 0) if (i == 0)
p = p_isi; /* first round: 'isident' */ p = p_isi; // first round: 'isident'
else if (i == 1) else if (i == 1)
p = p_isp; /* second round: 'isprint' */ p = p_isp; // second round: 'isprint'
else if (i == 2) else if (i == 2)
p = p_isf; /* third round: 'isfname' */ p = p_isf; // third round: 'isfname'
else /* i == 3 */ else // i == 3
p = buf->b_p_isk; /* fourth round: 'iskeyword' */ p = buf->b_p_isk; // fourth round: 'iskeyword'
while (*p) while (*p)
{ {
@ -191,7 +190,7 @@ buf_init_chartab(
|| !(*p == NUL || *p == ',')) || !(*p == NUL || *p == ','))
return FAIL; return FAIL;
if (c2 == -1) /* not a range */ if (c2 == -1) // not a range
{ {
/* /*
* A single '@' (not "@-@"): * A single '@' (not "@-@"):
@ -210,19 +209,19 @@ buf_init_chartab(
} }
while (c <= c2) while (c <= c2)
{ {
/* Use the MB_ functions here, because isalpha() doesn't // Use the MB_ functions here, because isalpha() doesn't
* work properly when 'encoding' is "latin1" and the locale is // work properly when 'encoding' is "latin1" and the locale is
* "C". */ // "C".
if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c)) if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c))
{ {
if (i == 0) /* (re)set ID flag */ if (i == 0) // (re)set ID flag
{ {
if (tilde) if (tilde)
g_chartab[c] &= ~CT_ID_CHAR; g_chartab[c] &= ~CT_ID_CHAR;
else else
g_chartab[c] |= CT_ID_CHAR; g_chartab[c] |= CT_ID_CHAR;
} }
else if (i == 1) /* (re)set printable */ else if (i == 1) // (re)set printable
{ {
if ((c < ' ' if ((c < ' '
#ifndef EBCDIC #ifndef EBCDIC
@ -245,14 +244,14 @@ buf_init_chartab(
} }
} }
} }
else if (i == 2) /* (re)set fname flag */ else if (i == 2) // (re)set fname flag
{ {
if (tilde) if (tilde)
g_chartab[c] &= ~CT_FNAME_CHAR; g_chartab[c] &= ~CT_FNAME_CHAR;
else else
g_chartab[c] |= CT_FNAME_CHAR; g_chartab[c] |= CT_FNAME_CHAR;
} }
else /* i == 3 */ /* (re)set keyword flag */ else // i == 3 (re)set keyword flag
{ {
if (tilde) if (tilde)
RESET_CHARTAB(buf, c); RESET_CHARTAB(buf, c);
@ -266,7 +265,7 @@ buf_init_chartab(
c = *p; c = *p;
p = skip_to_option_part(p); p = skip_to_option_part(p);
if (c == ',' && *p == NUL) if (c == ',' && *p == NUL)
/* Trailing comma is not allowed. */ // Trailing comma is not allowed.
return FAIL; return FAIL;
} }
} }
@ -284,16 +283,16 @@ trans_characters(
char_u *buf, char_u *buf,
int bufsize) int bufsize)
{ {
int len; /* length of string needing translation */ int len; // length of string needing translation
int room; /* room in buffer after string */ int room; // room in buffer after string
char_u *trs; /* translated character */ char_u *trs; // translated character
int trs_len; /* length of trs[] */ int trs_len; // length of trs[]
len = (int)STRLEN(buf); len = (int)STRLEN(buf);
room = bufsize - len; room = bufsize - len;
while (*buf != 0) while (*buf != 0)
{ {
/* Assume a multi-byte character doesn't need translation. */ // Assume a multi-byte character doesn't need translation.
if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1) if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)
len -= trs_len; len -= trs_len;
else else
@ -328,8 +327,8 @@ transstr(char_u *s)
if (has_mbyte) if (has_mbyte)
{ {
/* Compute the length of the result, taking account of unprintable // Compute the length of the result, taking account of unprintable
* multi-byte characters. */ // multi-byte characters.
len = 0; len = 0;
p = s; p = s;
while (*p != NUL) while (*p != NUL)
@ -352,7 +351,7 @@ transstr(char_u *s)
if (l > 0) if (l > 0)
len += l; len += l;
else else
len += 4; /* illegal byte sequence */ len += 4; // illegal byte sequence
} }
} }
res = alloc(len + 1); res = alloc(len + 1);
@ -369,7 +368,7 @@ transstr(char_u *s)
{ {
c = (*mb_ptr2char)(p); c = (*mb_ptr2char)(p);
if (vim_isprintc(c)) if (vim_isprintc(c))
STRNCAT(res, p, l); /* append printable multi-byte char */ STRNCAT(res, p, l); // append printable multi-byte char
else else
transchar_hex(res + STRLEN(res), c); transchar_hex(res + STRLEN(res), c);
p += l; p += l;
@ -403,7 +402,7 @@ str_foldcase(
#define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i]) #define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i])
#define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + i) #define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + i)
/* Copy "str" into "buf" or allocated memory, unmodified. */ // Copy "str" into "buf" or allocated memory, unmodified.
if (buf == NULL) if (buf == NULL)
{ {
ga_init2(&ga, 1, 10); ga_init2(&ga, 1, 10);
@ -414,7 +413,7 @@ str_foldcase(
} }
else else
{ {
if (len >= buflen) /* Ugly! */ if (len >= buflen) // Ugly!
len = buflen - 1; len = buflen - 1;
mch_memmove(buf, str, (size_t)len); mch_memmove(buf, str, (size_t)len);
} }
@ -423,7 +422,7 @@ str_foldcase(
else else
buf[len] = NUL; buf[len] = NUL;
/* Make each character lower case. */ // Make each character lower case.
i = 0; i = 0;
while (STR_CHAR(i) != NUL) while (STR_CHAR(i) != NUL)
{ {
@ -435,15 +434,15 @@ str_foldcase(
int olen = utf_ptr2len(STR_PTR(i)); int olen = utf_ptr2len(STR_PTR(i));
int lc = utf_tolower(c); int lc = utf_tolower(c);
/* Only replace the character when it is not an invalid // Only replace the character when it is not an invalid
* sequence (ASCII character or more than one byte) and // sequence (ASCII character or more than one byte) and
* utf_tolower() doesn't return the original character. */ // utf_tolower() doesn't return the original character.
if ((c < 0x80 || olen > 1) && c != lc) if ((c < 0x80 || olen > 1) && c != lc)
{ {
int nlen = utf_char2len(lc); int nlen = utf_char2len(lc);
/* If the byte length changes need to shift the following // If the byte length changes need to shift the following
* characters forward or backward. */ // characters forward or backward.
if (olen != nlen) if (olen != nlen)
{ {
if (nlen > olen) if (nlen > olen)
@ -452,7 +451,7 @@ str_foldcase(
? ga_grow(&ga, nlen - olen + 1) == FAIL ? ga_grow(&ga, nlen - olen + 1) == FAIL
: len + nlen - olen >= buflen) : len + nlen - olen >= buflen)
{ {
/* out of memory, keep old char */ // out of memory, keep old char
lc = c; lc = c;
nlen = olen; nlen = olen;
} }
@ -474,7 +473,7 @@ str_foldcase(
(void)utf_char2bytes(lc, STR_PTR(i)); (void)utf_char2bytes(lc, STR_PTR(i));
} }
} }
/* skip to next multi-byte char */ // skip to next multi-byte char
i += (*mb_ptr2len)(STR_PTR(i)); i += (*mb_ptr2len)(STR_PTR(i));
} }
else else
@ -508,7 +507,7 @@ transchar(int c)
int i; int i;
i = 0; i = 0;
if (IS_SPECIAL(c)) /* special key code, display as ~@ char */ if (IS_SPECIAL(c)) // special key code, display as ~@ char
{ {
transchar_buf[0] = '~'; transchar_buf[0] = '~';
transchar_buf[1] = '@'; transchar_buf[1] = '@';
@ -524,7 +523,7 @@ transchar(int c)
#endif #endif
)) || (c < 256 && vim_isprintc_strict(c))) )) || (c < 256 && vim_isprintc_strict(c)))
{ {
/* printable character */ // printable character
transchar_buf[i] = c; transchar_buf[i] = c;
transchar_buf[i + 1] = NUL; transchar_buf[i + 1] = NUL;
} }
@ -557,28 +556,28 @@ transchar_byte(int c)
transchar_nonprint(char_u *buf, int c) transchar_nonprint(char_u *buf, int c)
{ {
if (c == NL) if (c == NL)
c = NUL; /* we use newline in place of a NUL */ c = NUL; // we use newline in place of a NUL
else if (c == CAR && get_fileformat(curbuf) == EOL_MAC) else if (c == CAR && get_fileformat(curbuf) == EOL_MAC)
c = NL; /* we use CR in place of NL in this case */ c = NL; // we use CR in place of NL in this case
if (dy_flags & DY_UHEX) /* 'display' has "uhex" */ if (dy_flags & DY_UHEX) // 'display' has "uhex"
transchar_hex(buf, c); transchar_hex(buf, c);
#ifdef EBCDIC #ifdef EBCDIC
/* For EBCDIC only the characters 0-63 and 255 are not printable */ // For EBCDIC only the characters 0-63 and 255 are not printable
else if (CtrlChar(c) != 0 || c == DEL) else if (CtrlChar(c) != 0 || c == DEL)
#else #else
else if (c <= 0x7f) /* 0x00 - 0x1f and 0x7f */ else if (c <= 0x7f) // 0x00 - 0x1f and 0x7f
#endif #endif
{ {
buf[0] = '^'; buf[0] = '^';
#ifdef EBCDIC #ifdef EBCDIC
if (c == DEL) if (c == DEL)
buf[1] = '?'; /* DEL displayed as ^? */ buf[1] = '?'; // DEL displayed as ^?
else else
buf[1] = CtrlChar(c); buf[1] = CtrlChar(c);
#else #else
buf[1] = c ^ 0x40; /* DEL displayed as ^? */ buf[1] = c ^ 0x40; // DEL displayed as ^?
#endif #endif
buf[2] = NUL; buf[2] = NUL;
@ -588,7 +587,7 @@ transchar_nonprint(char_u *buf, int c)
transchar_hex(buf, c); transchar_hex(buf, c);
} }
#ifndef EBCDIC #ifndef EBCDIC
else if (c >= ' ' + 0x80 && c <= '~' + 0x80) /* 0xa0 - 0xfe */ else if (c >= ' ' + 0x80 && c <= '~' + 0x80) // 0xa0 - 0xfe
{ {
buf[0] = '|'; buf[0] = '|';
buf[1] = c - 0x80; buf[1] = c - 0x80;
@ -602,7 +601,7 @@ transchar_nonprint(char_u *buf, int c)
buf[2] = NUL; buf[2] = NUL;
} }
#endif #endif
else /* 0x80 - 0x9f and 0xff */ else // 0x80 - 0x9f and 0xff
{ {
/* /*
* TODO: EBCDIC I don't know what to do with this chars, so I display * TODO: EBCDIC I don't know what to do with this chars, so I display
@ -610,9 +609,9 @@ transchar_nonprint(char_u *buf, int c)
*/ */
buf[0] = '~'; buf[0] = '~';
#ifdef EBCDIC #ifdef EBCDIC
buf[1] = '?'; /* 0xff displayed as ~? */ buf[1] = '?'; // 0xff displayed as ~?
#else #else
buf[1] = (c - 0x80) ^ 0x40; /* 0xff displayed as ~? */ buf[1] = (c - 0x80) ^ 0x40; // 0xff displayed as ~?
#endif #endif
buf[2] = NUL; buf[2] = NUL;
} }
@ -676,11 +675,11 @@ char2cells(int c)
return char2cells(K_SECOND(c)) + 2; return char2cells(K_SECOND(c)) + 2;
if (c >= 0x80) if (c >= 0x80)
{ {
/* UTF-8: above 0x80 need to check the value */ // UTF-8: above 0x80 need to check the value
if (enc_utf8) if (enc_utf8)
return utf_char2cells(c); return utf_char2cells(c);
/* DBCS: double-byte means double-width, except for euc-jp with first // DBCS: double-byte means double-width, except for euc-jp with first
* byte 0x8e */ // byte 0x8e
if (enc_dbcs != 0 && c >= 0x100) if (enc_dbcs != 0 && c >= 0x100)
{ {
if (enc_dbcs == DBCS_JPNU && ((unsigned)c >> 8) == 0x8e) if (enc_dbcs == DBCS_JPNU && ((unsigned)c >> 8) == 0x8e)
@ -698,10 +697,10 @@ char2cells(int c)
int int
ptr2cells(char_u *p) ptr2cells(char_u *p)
{ {
/* For UTF-8 we need to look at more bytes if the first byte is >= 0x80. */ // For UTF-8 we need to look at more bytes if the first byte is >= 0x80.
if (enc_utf8 && *p >= 0x80) if (enc_utf8 && *p >= 0x80)
return utf_ptr2cells(p); return utf_ptr2cells(p);
/* For DBCS we can tell the cell count from the first byte. */ // For DBCS we can tell the cell count from the first byte.
return (g_chartab[*p] & CT_CELL_MASK); return (g_chartab[*p] & CT_CELL_MASK);
} }
@ -797,7 +796,7 @@ linetabsize(char_u *s)
linetabsize_col(int startcol, char_u *s) linetabsize_col(int startcol, char_u *s)
{ {
colnr_T col = startcol; colnr_T col = startcol;
char_u *line = s; /* pointer to start of line, for breakindent */ char_u *line = s; // pointer to start of line, for breakindent
while (*s != NUL) while (*s != NUL)
col += lbr_chartabsize_adv(line, &s, col); col += lbr_chartabsize_adv(line, &s, col);
@ -931,7 +930,7 @@ vim_isprintc_strict(int c)
*/ */
int int
lbr_chartabsize( lbr_chartabsize(
char_u *line UNUSED, /* start of the line */ char_u *line UNUSED, // start of the line
unsigned char *s, unsigned char *s,
colnr_T col) colnr_T col)
{ {
@ -954,7 +953,7 @@ lbr_chartabsize(
*/ */
int int
lbr_chartabsize_adv( lbr_chartabsize_adv(
char_u *line, /* start of the line */ char_u *line, // start of the line
char_u **s, char_u **s,
colnr_T col) colnr_T col)
{ {
@ -975,7 +974,7 @@ lbr_chartabsize_adv(
int int
win_lbr_chartabsize( win_lbr_chartabsize(
win_T *wp, win_T *wp,
char_u *line UNUSED, /* start of the line */ char_u *line UNUSED, // start of the line
char_u *s, char_u *s,
colnr_T col, colnr_T col,
int *headp UNUSED) int *headp UNUSED)
@ -984,7 +983,7 @@ win_lbr_chartabsize(
int c; int c;
int size; int size;
colnr_T col2; colnr_T col2;
colnr_T col_adj = 0; /* col + screen size of tab */ colnr_T col_adj = 0; // col + screen size of tab
colnr_T colmax; colnr_T colmax;
int added; int added;
int mb_added = 0; int mb_added = 0;
@ -1051,7 +1050,7 @@ win_lbr_chartabsize(
break; break;
col2 += win_chartabsize(wp, s, col2); col2 += win_chartabsize(wp, s, col2);
if (col2 >= colmax) /* doesn't fit */ if (col2 >= colmax) // doesn't fit
{ {
size = colmax - col + col_adj; size = colmax - col + col_adj;
break; break;
@ -1061,7 +1060,7 @@ win_lbr_chartabsize(
else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1 else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1
&& wp->w_p_wrap && in_win_border(wp, col)) && wp->w_p_wrap && in_win_border(wp, col))
{ {
++size; /* Count the ">" in the last column. */ ++size; // Count the ">" in the last column.
mb_added = 1; mb_added = 1;
} }
@ -1159,8 +1158,8 @@ win_nolbr_chartabsize(
# endif # endif
} }
n = ptr2cells(s); n = ptr2cells(s);
/* Add one cell for a double-width character in the last column of the // Add one cell for a double-width character in the last column of the
* window, displayed with a ">". */ // window, displayed with a ">".
if (n == 2 && MB_BYTE2LEN(*s) > 1 && in_win_border(wp, col)) if (n == 2 && MB_BYTE2LEN(*s) > 1 && in_win_border(wp, col))
{ {
if (headp != NULL) if (headp != NULL)
@ -1177,10 +1176,10 @@ win_nolbr_chartabsize(
static int static int
in_win_border(win_T *wp, colnr_T vcol) in_win_border(win_T *wp, colnr_T vcol)
{ {
int width1; /* width of first line (after line number) */ int width1; // width of first line (after line number)
int width2; /* width of further lines */ int width2; // width of further lines
if (wp->w_width == 0) /* there is no border */ if (wp->w_width == 0) // there is no border
return FALSE; return FALSE;
width1 = wp->w_width - win_col_off(wp); width1 = wp->w_width - win_col_off(wp);
if ((int)vcol < width1 - 1) if ((int)vcol < width1 - 1)
@ -1210,9 +1209,9 @@ getvcol(
colnr_T *end) colnr_T *end)
{ {
colnr_T vcol; colnr_T vcol;
char_u *ptr; /* points to current char */ char_u *ptr; // points to current char
char_u *posptr; /* points to char at pos->col */ char_u *posptr; // points to char at pos->col
char_u *line; /* start of the line */ char_u *line; // start of the line
int incr; int incr;
int head; int head;
#ifdef FEAT_VARTABS #ifdef FEAT_VARTABS
@ -1224,16 +1223,16 @@ getvcol(
vcol = 0; vcol = 0;
line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col == MAXCOL) if (pos->col == MAXCOL)
posptr = NULL; /* continue until the NUL */ posptr = NULL; // continue until the NUL
else else
{ {
/* Special check for an empty line, which can happen on exit, when // Special check for an empty line, which can happen on exit, when
* ml_get_buf() always returns an empty string. */ // ml_get_buf() always returns an empty string.
if (*ptr == NUL) if (*ptr == NUL)
pos->col = 0; pos->col = 0;
posptr = ptr + pos->col; posptr = ptr + pos->col;
if (has_mbyte) if (has_mbyte)
/* always start on the first byte */ // always start on the first byte
posptr -= (*mb_head_off)(line, posptr); posptr -= (*mb_head_off)(line, posptr);
} }
@ -1253,13 +1252,13 @@ getvcol(
{ {
head = 0; head = 0;
c = *ptr; c = *ptr;
/* make sure we don't go past the end of the line */ // make sure we don't go past the end of the line
if (c == NUL) if (c == NUL)
{ {
incr = 1; /* NUL at end of line only takes one column */ incr = 1; // NUL at end of line only takes one column
break; break;
} }
/* A tab gets expanded, depending on the current column */ // A tab gets expanded, depending on the current column
if (c == TAB) if (c == TAB)
#ifdef FEAT_VARTABS #ifdef FEAT_VARTABS
incr = tabstop_padding(vcol, ts, vts); incr = tabstop_padding(vcol, ts, vts);
@ -1270,16 +1269,16 @@ getvcol(
{ {
if (has_mbyte) if (has_mbyte)
{ {
/* For utf-8, if the byte is >= 0x80, need to look at // For utf-8, if the byte is >= 0x80, need to look at
* further bytes to find the cell width. */ // further bytes to find the cell width.
if (enc_utf8 && c >= 0x80) if (enc_utf8 && c >= 0x80)
incr = utf_ptr2cells(ptr); incr = utf_ptr2cells(ptr);
else else
incr = g_chartab[c] & CT_CELL_MASK; incr = g_chartab[c] & CT_CELL_MASK;
/* If a double-cell char doesn't fit at the end of a line // If a double-cell char doesn't fit at the end of a line
* it wraps to the next line, it's like this char is three // it wraps to the next line, it's like this char is three
* cells wide. */ // cells wide.
if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1 if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1
&& in_win_border(wp, vcol)) && in_win_border(wp, vcol))
{ {
@ -1291,7 +1290,7 @@ getvcol(
incr = g_chartab[c] & CT_CELL_MASK; incr = g_chartab[c] & CT_CELL_MASK;
} }
if (posptr != NULL && ptr >= posptr) /* character at pos->col */ if (posptr != NULL && ptr >= posptr) // character at pos->col
break; break;
vcol += incr; vcol += incr;
@ -1302,17 +1301,17 @@ getvcol(
{ {
for (;;) for (;;)
{ {
/* A tab gets expanded, depending on the current column */ // A tab gets expanded, depending on the current column
head = 0; head = 0;
incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head); incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);
/* make sure we don't go past the end of the line */ // make sure we don't go past the end of the line
if (*ptr == NUL) if (*ptr == NUL)
{ {
incr = 1; /* NUL at end of line only takes one column */ incr = 1; // NUL at end of line only takes one column
break; break;
} }
if (posptr != NULL && ptr >= posptr) /* character at pos->col */ if (posptr != NULL && ptr >= posptr) // character at pos->col
break; break;
vcol += incr; vcol += incr;
@ -1332,9 +1331,9 @@ getvcol(
&& !(VIsual_active && !(VIsual_active
&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual))) && (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))
) )
*cursor = vcol + incr - 1; /* cursor at end */ *cursor = vcol + incr - 1; // cursor at end
else else
*cursor = vcol + head; /* cursor at start */ *cursor = vcol + head; // cursor at start
} }
} }
@ -1374,12 +1373,12 @@ getvvcol(
if (virtual_active()) if (virtual_active())
{ {
/* For virtual mode, only want one value */ // For virtual mode, only want one value
getvcol(wp, pos, &col, NULL, NULL); getvcol(wp, pos, &col, NULL, NULL);
coladd = pos->coladd; coladd = pos->coladd;
endadd = 0; endadd = 0;
/* Cannot put the cursor on part of a wide character. */ // Cannot put the cursor on part of a wide character.
ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col < (colnr_T)STRLEN(ptr)) if (pos->col < (colnr_T)STRLEN(ptr))
{ {
@ -1388,7 +1387,7 @@ getvvcol(
if (c != TAB && vim_isprintc(c)) if (c != TAB && vim_isprintc(c))
{ {
endadd = (colnr_T)(char2cells(c) - 1); endadd = (colnr_T)(char2cells(c) - 1);
if (coladd > endadd) /* past end of line */ if (coladd > endadd) // past end of line
endadd = 0; endadd = 0;
else else
coladd = 0; coladd = 0;
@ -1453,7 +1452,7 @@ skipwhite(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (VIM_ISWHITE(*p)) /* skip to next non-white */ while (VIM_ISWHITE(*p)) // skip to next non-white
++p; ++p;
return p; return p;
} }
@ -1482,7 +1481,7 @@ skipdigits(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (VIM_ISDIGIT(*p)) /* skip to next non-digit */ while (VIM_ISDIGIT(*p)) // skip to next non-digit
++p; ++p;
return p; return p;
} }
@ -1496,7 +1495,7 @@ skipbin(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (vim_isbdigit(*p)) /* skip to next non-digit */ while (vim_isbdigit(*p)) // skip to next non-digit
++p; ++p;
return p; return p;
} }
@ -1509,7 +1508,7 @@ skiphex(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (vim_isxdigit(*p)) /* skip to next non-digit */ while (vim_isxdigit(*p)) // skip to next non-digit
++p; ++p;
return p; return p;
} }
@ -1523,7 +1522,7 @@ skiptobin(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (*p != NUL && !vim_isbdigit(*p)) /* skip to next digit */ while (*p != NUL && !vim_isbdigit(*p)) // skip to next digit
++p; ++p;
return p; return p;
} }
@ -1536,7 +1535,7 @@ skiptodigit(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (*p != NUL && !VIM_ISDIGIT(*p)) /* skip to next digit */ while (*p != NUL && !VIM_ISDIGIT(*p)) // skip to next digit
++p; ++p;
return p; return p;
} }
@ -1549,7 +1548,7 @@ skiptohex(char_u *q)
{ {
char_u *p = q; char_u *p = q;
while (*p != NUL && !vim_isxdigit(*p)) /* skip to next digit */ while (*p != NUL && !vim_isxdigit(*p)) // skip to next digit
++p; ++p;
return p; return p;
} }
@ -1617,7 +1616,7 @@ vim_islower(int c)
if (has_mbyte) if (has_mbyte)
return iswlower(c); return iswlower(c);
#endif #endif
/* islower() can't handle these chars and may crash */ // islower() can't handle these chars and may crash
return FALSE; return FALSE;
} }
if (enc_latin1like) if (enc_latin1like)
@ -1641,7 +1640,7 @@ vim_isupper(int c)
if (has_mbyte) if (has_mbyte)
return iswupper(c); return iswupper(c);
#endif #endif
/* islower() can't handle these chars and may crash */ // islower() can't handle these chars and may crash
return FALSE; return FALSE;
} }
if (enc_latin1like) if (enc_latin1like)
@ -1665,7 +1664,7 @@ vim_toupper(int c)
if (has_mbyte) if (has_mbyte)
return towupper(c); return towupper(c);
#endif #endif
/* toupper() can't handle these chars and may crash */ // toupper() can't handle these chars and may crash
return c; return c;
} }
if (enc_latin1like) if (enc_latin1like)
@ -1691,7 +1690,7 @@ vim_tolower(int c)
if (has_mbyte) if (has_mbyte)
return towlower(c); return towlower(c);
#endif #endif
/* tolower() can't handle these chars and may crash */ // tolower() can't handle these chars and may crash
return c; return c;
} }
if (enc_latin1like) if (enc_latin1like)
@ -1740,9 +1739,9 @@ getdigits(char_u **pp)
p = *pp; p = *pp;
retval = atol((char *)p); retval = atol((char *)p);
if (*p == '-') /* skip negative sign */ if (*p == '-') // skip negative sign
++p; ++p;
p = skipdigits(p); /* skip to next non-digit */ p = skipdigits(p); // skip to next non-digit
*pp = p; *pp = p;
return retval; return retval;
} }
@ -1808,7 +1807,7 @@ vim_str2nr(
++ptr; ++ptr;
} }
/* Recognize hex, octal, and bin. */ // Recognize hex, octal, and bin.
if (ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9' if (ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9'
&& (maxlen == 0 || maxlen > 1)) && (maxlen == 0 || maxlen > 1))
{ {
@ -1816,28 +1815,28 @@ vim_str2nr(
if ((what & STR2NR_HEX) if ((what & STR2NR_HEX)
&& (pre == 'X' || pre == 'x') && vim_isxdigit(ptr[2]) && (pre == 'X' || pre == 'x') && vim_isxdigit(ptr[2])
&& (maxlen == 0 || maxlen > 2)) && (maxlen == 0 || maxlen > 2))
/* hexadecimal */ // hexadecimal
ptr += 2; ptr += 2;
else if ((what & STR2NR_BIN) else if ((what & STR2NR_BIN)
&& (pre == 'B' || pre == 'b') && vim_isbdigit(ptr[2]) && (pre == 'B' || pre == 'b') && vim_isbdigit(ptr[2])
&& (maxlen == 0 || maxlen > 2)) && (maxlen == 0 || maxlen > 2))
/* binary */ // binary
ptr += 2; ptr += 2;
else else
{ {
/* decimal or octal, default is decimal */ // decimal or octal, default is decimal
pre = 0; pre = 0;
if (what & STR2NR_OCT) if (what & STR2NR_OCT)
{ {
/* Don't interpret "0", "08" or "0129" as octal. */ // Don't interpret "0", "08" or "0129" as octal.
for (n = 1; n != maxlen && VIM_ISDIGIT(ptr[n]); ++n) for (n = 1; n != maxlen && VIM_ISDIGIT(ptr[n]); ++n)
{ {
if (ptr[n] > '7') if (ptr[n] > '7')
{ {
pre = 0; /* can't be octal */ pre = 0; // can't be octal
break; break;
} }
pre = '0'; /* assume octal */ pre = '0'; // assume octal
} }
} }
} }
@ -1848,12 +1847,12 @@ vim_str2nr(
if (pre == 'B' || pre == 'b' if (pre == 'B' || pre == 'b'
|| ((what & STR2NR_BIN) && (what & STR2NR_FORCE))) || ((what & STR2NR_BIN) && (what & STR2NR_FORCE)))
{ {
/* bin */ // bin
if (pre != 0) if (pre != 0)
n += 2; /* skip over "0b" */ n += 2; // skip over "0b"
while ('0' <= *ptr && *ptr <= '1') while ('0' <= *ptr && *ptr <= '1')
{ {
/* avoid ubsan error for overflow */ // avoid ubsan error for overflow
if (un <= UVARNUM_MAX / 2) if (un <= UVARNUM_MAX / 2)
un = 2 * un + (uvarnumber_T)(*ptr - '0'); un = 2 * un + (uvarnumber_T)(*ptr - '0');
else else
@ -1872,10 +1871,10 @@ vim_str2nr(
} }
else if (pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE))) else if (pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE)))
{ {
/* octal */ // octal
while ('0' <= *ptr && *ptr <= '7') while ('0' <= *ptr && *ptr <= '7')
{ {
/* avoid ubsan error for overflow */ // avoid ubsan error for overflow
if (un <= UVARNUM_MAX / 8) if (un <= UVARNUM_MAX / 8)
un = 8 * un + (uvarnumber_T)(*ptr - '0'); un = 8 * un + (uvarnumber_T)(*ptr - '0');
else else
@ -1894,12 +1893,12 @@ vim_str2nr(
} }
else if (pre != 0 || ((what & STR2NR_HEX) && (what & STR2NR_FORCE))) else if (pre != 0 || ((what & STR2NR_HEX) && (what & STR2NR_FORCE)))
{ {
/* hex */ // hex
if (pre != 0) if (pre != 0)
n += 2; /* skip over "0x" */ n += 2; // skip over "0x"
while (vim_isxdigit(*ptr)) while (vim_isxdigit(*ptr))
{ {
/* avoid ubsan error for overflow */ // avoid ubsan error for overflow
if (un <= UVARNUM_MAX / 16) if (un <= UVARNUM_MAX / 16)
un = 16 * un + (uvarnumber_T)hex2nr(*ptr); un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
else else
@ -1917,12 +1916,12 @@ vim_str2nr(
} }
else else
{ {
/* decimal */ // decimal
while (VIM_ISDIGIT(*ptr)) while (VIM_ISDIGIT(*ptr))
{ {
uvarnumber_T digit = (uvarnumber_T)(*ptr - '0'); uvarnumber_T digit = (uvarnumber_T)(*ptr - '0');
/* avoid ubsan error for overflow */ // avoid ubsan error for overflow
if (un < UVARNUM_MAX / 10 if (un < UVARNUM_MAX / 10
|| (un == UVARNUM_MAX / 10 && digit <= UVARNUM_MAX % 10)) || (un == UVARNUM_MAX / 10 && digit <= UVARNUM_MAX % 10))
un = 10 * un + digit; un = 10 * un + digit;
@ -1951,9 +1950,9 @@ vim_str2nr(
*len = (int)(ptr - start); *len = (int)(ptr - start);
if (nptr != NULL) if (nptr != NULL)
{ {
if (negative) /* account for leading '-' for decimal numbers */ if (negative) // account for leading '-' for decimal numbers
{ {
/* avoid ubsan error for overflow */ // avoid ubsan error for overflow
if (un > VARNUM_MAX) if (un > VARNUM_MAX)
*nptr = VARNUM_MIN; *nptr = VARNUM_MIN;
else else

View File

@ -1628,9 +1628,9 @@ get_baseclass_amount(int col)
* Ignore a '{' that is in a comment, makes indenting the next three lines * Ignore a '{' that is in a comment, makes indenting the next three lines
* work. * work.
*/ */
/* foo() */ // foo()
/* { */ // {
/* } */ // }
static pos_T * static pos_T *
find_start_brace(void) // XXX find_start_brace(void) // XXX

View File

@ -30,53 +30,52 @@
*/ */
typedef struct { typedef struct {
char *name; /* encryption name as used in 'cryptmethod' */ char *name; // encryption name as used in 'cryptmethod'
char *magic; /* magic bytes stored in file header */ char *magic; // magic bytes stored in file header
int salt_len; /* length of salt, or 0 when not using salt */ int salt_len; // length of salt, or 0 when not using salt
int seed_len; /* length of seed, or 0 when not using salt */ int seed_len; // length of seed, or 0 when not using salt
#ifdef CRYPT_NOT_INPLACE #ifdef CRYPT_NOT_INPLACE
int works_inplace; /* encryption/decryption can be done in-place */ int works_inplace; // encryption/decryption can be done in-place
#endif #endif
int whole_undofile; /* whole undo file is encrypted */ int whole_undofile; // whole undo file is encrypted
/* Optional function pointer for a self-test. */ // Optional function pointer for a self-test.
int (* self_test_fn)(); int (* self_test_fn)();
// Function pointer for initializing encryption/decryption. // Function pointer for initializing encryption/decryption.
int (* init_fn)(cryptstate_T *state, char_u *key, int (* init_fn)(cryptstate_T *state, char_u *key,
char_u *salt, int salt_len, char_u *seed, int seed_len); char_u *salt, int salt_len, char_u *seed, int seed_len);
/* Function pointers for encoding/decoding from one buffer into another. // Function pointers for encoding/decoding from one buffer into another.
* Optional, however, these or the _buffer ones should be configured. */ // Optional, however, these or the _buffer ones should be configured.
void (*encode_fn)(cryptstate_T *state, char_u *from, size_t len, void (*encode_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u *to); char_u *to);
void (*decode_fn)(cryptstate_T *state, char_u *from, size_t len, void (*decode_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u *to); char_u *to);
/* Function pointers for encoding and decoding, can buffer data if needed. // Function pointers for encoding and decoding, can buffer data if needed.
* Optional (however, these or the above should be configured). */ // Optional (however, these or the above should be configured).
long (*encode_buffer_fn)(cryptstate_T *state, char_u *from, size_t len, long (*encode_buffer_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u **newptr); char_u **newptr);
long (*decode_buffer_fn)(cryptstate_T *state, char_u *from, size_t len, long (*decode_buffer_fn)(cryptstate_T *state, char_u *from, size_t len,
char_u **newptr); char_u **newptr);
/* Function pointers for in-place encoding and decoding, used for // Function pointers for in-place encoding and decoding, used for
* crypt_*_inplace(). "from" and "to" arguments will be equal. // crypt_*_inplace(). "from" and "to" arguments will be equal.
* These may be the same as decode_fn and encode_fn above, however an // These may be the same as decode_fn and encode_fn above, however an
* algorithm may implement them in a way that is not interchangeable with // algorithm may implement them in a way that is not interchangeable with
* the crypt_(en|de)code() interface (for example because it wishes to add // the crypt_(en|de)code() interface (for example because it wishes to add
* padding to files). // padding to files).
* This method is used for swap and undo files which have a rigid format. // This method is used for swap and undo files which have a rigid format.
*/
void (*encode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len, void (*encode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len,
char_u *p2); char_u *p2);
void (*decode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len, void (*decode_inplace_fn)(cryptstate_T *state, char_u *p1, size_t len,
char_u *p2); char_u *p2);
} cryptmethod_T; } cryptmethod_T;
/* index is method_nr of cryptstate_T, CRYPT_M_* */ // index is method_nr of cryptstate_T, CRYPT_M_*
static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = { static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
/* PK_Zip; very weak */ // PK_Zip; very weak
{ {
"zip", "zip",
"VimCrypt~01!", "VimCrypt~01!",
@ -93,7 +92,7 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
crypt_zip_encode, crypt_zip_decode, crypt_zip_encode, crypt_zip_decode,
}, },
/* Blowfish/CFB + SHA-256 custom key derivation; implementation issues. */ // Blowfish/CFB + SHA-256 custom key derivation; implementation issues.
{ {
"blowfish", "blowfish",
"VimCrypt~02!", "VimCrypt~02!",
@ -110,7 +109,7 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
crypt_blowfish_encode, crypt_blowfish_decode, crypt_blowfish_encode, crypt_blowfish_decode,
}, },
/* Blowfish/CFB + SHA-256 custom key derivation; fixed. */ // Blowfish/CFB + SHA-256 custom key derivation; fixed.
{ {
"blowfish2", "blowfish2",
"VimCrypt~03!", "VimCrypt~03!",
@ -127,11 +126,11 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
crypt_blowfish_encode, crypt_blowfish_decode, crypt_blowfish_encode, crypt_blowfish_decode,
}, },
/* NOTE: when adding a new method, use some random bytes for the magic key, // NOTE: when adding a new method, use some random bytes for the magic key,
* to avoid that a text file is recognized as encrypted. */ // to avoid that a text file is recognized as encrypted.
}; };
#define CRYPT_MAGIC_LEN 12 /* cannot change */ #define CRYPT_MAGIC_LEN 12 // cannot change
static char crypt_magic_head[] = "VimCrypt~"; static char crypt_magic_head[] = "VimCrypt~";
/* /*
@ -363,9 +362,9 @@ crypt_create_for_writing(
if (seed_len > 0) if (seed_len > 0)
seed = *header + CRYPT_MAGIC_LEN + salt_len; seed = *header + CRYPT_MAGIC_LEN + salt_len;
/* TODO: Should this be crypt method specific? (Probably not worth // TODO: Should this be crypt method specific? (Probably not worth
* it). sha2_seed is pretty bad for large amounts of entropy, so make // it). sha2_seed is pretty bad for large amounts of entropy, so make
* that into something which is suitable for anything. */ // that into something which is suitable for anything.
sha2_seed(salt, salt_len, seed, seed_len); sha2_seed(salt, salt_len, seed, seed_len);
} }
@ -401,10 +400,10 @@ crypt_encode_alloc(
cryptmethod_T *method = &cryptmethods[state->method_nr]; cryptmethod_T *method = &cryptmethods[state->method_nr];
if (method->encode_buffer_fn != NULL) if (method->encode_buffer_fn != NULL)
/* Has buffer function, pass through. */ // Has buffer function, pass through.
return method->encode_buffer_fn(state, from, len, newptr); return method->encode_buffer_fn(state, from, len, newptr);
if (len == 0) if (len == 0)
/* Not buffering, just return EOF. */ // Not buffering, just return EOF.
return (long)len; return (long)len;
*newptr = alloc(len); *newptr = alloc(len);
@ -429,11 +428,11 @@ crypt_decode_alloc(
cryptmethod_T *method = &cryptmethods[state->method_nr]; cryptmethod_T *method = &cryptmethods[state->method_nr];
if (method->decode_buffer_fn != NULL) if (method->decode_buffer_fn != NULL)
/* Has buffer function, pass through. */ // Has buffer function, pass through.
return method->decode_buffer_fn(state, ptr, len, newptr); return method->decode_buffer_fn(state, ptr, len, newptr);
if (len == 0) if (len == 0)
/* Not buffering, just return EOF. */ // Not buffering, just return EOF.
return len; return len;
*newptr = alloc(len); *newptr = alloc(len);
@ -542,7 +541,7 @@ crypt_check_current_method(void)
char_u * char_u *
crypt_get_key( crypt_get_key(
int store, int store,
int twice) /* Ask for the key twice. */ int twice) // Ask for the key twice.
{ {
char_u *p1, *p2 = NULL; char_u *p1, *p2 = NULL;
int round; int round;
@ -568,7 +567,7 @@ crypt_get_key(
crypt_free_key(p1); crypt_free_key(p1);
crypt_free_key(p2); crypt_free_key(p2);
p2 = NULL; p2 = NULL;
round = -1; /* do it again */ round = -1; // do it again
continue; continue;
} }
@ -583,7 +582,7 @@ crypt_get_key(
p2 = p1; p2 = p1;
} }
/* since the user typed this, no need to wait for return */ // since the user typed this, no need to wait for return
if (msg_didout) if (msg_didout)
msg_putchar('\n'); msg_putchar('\n');
need_wait_return = FALSE; need_wait_return = FALSE;
@ -611,4 +610,4 @@ crypt_append_msg(
} }
} }
#endif /* FEAT_CRYPT */ #endif // FEAT_CRYPT

View File

@ -23,10 +23,10 @@
* problem since this code was originally created in Europe and India. * problem since this code was originally created in Europe and India.
*/ */
/* Need a type that should be 32 bits. 64 also works but wastes space. */ // Need a type that should be 32 bits. 64 also works but wastes space.
typedef unsigned int u32_T; /* int is at least 32 bits */ typedef unsigned int u32_T; // int is at least 32 bits
/* The state of encryption, referenced by cryptstate_T. */ // The state of encryption, referenced by cryptstate_T.
typedef struct { typedef struct {
u32_T keys[3]; u32_T keys[3];
} zip_state_T; } zip_state_T;
@ -151,4 +151,4 @@ crypt_zip_decode(
} }
} }
#endif /* FEAT_CRYPT */ #endif // FEAT_CRYPT

View File

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