refactor: migrate comment style 2 #20080

This commit is contained in:
dundargoc
2022-09-06 16:23:00 +02:00
committed by GitHub
parent 84d1094958
commit 12afc344de
15 changed files with 196 additions and 214 deletions

View File

@@ -789,8 +789,8 @@ struct file_buffer {
int b_ind_cpp_extern_c; int b_ind_cpp_extern_c;
int b_ind_pragma; int b_ind_pragma;
linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary linenr_T b_no_eol_lnum; // non-zero lnum when last line of next binary
* write should not have an end-of-line */ // write should not have an end-of-line
int b_start_eol; // last line had eol when it was read int b_start_eol; // last line had eol when it was read
int b_start_ffc; // first char of 'ff' when edit started int b_start_ffc; // first char of 'ff' when edit started
@@ -805,8 +805,8 @@ struct file_buffer {
// then set to indicate that a swap file may be opened later. It is reset // then set to indicate that a swap file may be opened later. It is reset
// if a swap file could not be opened. // if a swap file could not be opened.
bool b_may_swap; bool b_may_swap;
bool b_did_warn; /* Set to true if user has been warned on first bool b_did_warn; // Set to true if user has been warned on first
change of a read-only file */ // change of a read-only file
// Two special kinds of buffers: // Two special kinds of buffers:
// help buffer - used for help files, won't use a swap file. // help buffer - used for help files, won't use a swap file.
@@ -1237,8 +1237,7 @@ struct window_S {
// w_valid is a bitfield of flags, which indicate if specific values are // w_valid is a bitfield of flags, which indicate if specific values are
// valid or need to be recomputed. // valid or need to be recomputed.
int w_valid; int w_valid;
pos_T w_valid_cursor; /* last known position of w_cursor, used pos_T w_valid_cursor; // last known position of w_cursor, used to adjust w_valid
to adjust w_valid */
colnr_T w_valid_leftcol; // last known w_leftcol colnr_T w_valid_leftcol; // last known w_leftcol
bool w_viewport_invalid; bool w_viewport_invalid;
@@ -1383,8 +1382,7 @@ struct window_S {
int w_fraction; int w_fraction;
int w_prev_fraction_row; int w_prev_fraction_row;
linenr_T w_nrwidth_line_count; /* line count when ml_nrwidth_width linenr_T w_nrwidth_line_count; // line count when ml_nrwidth_width was computed.
* was computed. */
int w_nrwidth_width; // nr of chars to print line count. int w_nrwidth_width; // nr of chars to print line count.
qf_info_T *w_llist; // Location list for this window qf_info_T *w_llist; // Location list for this window

View File

@@ -2330,8 +2330,8 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
if (gchar_cursor() != NUL) { if (gchar_cursor() != NUL) {
inc_cursor(); inc_cursor();
} }
/* If the cursor is still at the same character, also keep // If the cursor is still at the same character, also keep
* the "coladd". */ // the "coladd".
if (gchar_cursor() == NUL if (gchar_cursor() == NUL
&& curwin->w_cursor.lnum == tpos.lnum && curwin->w_cursor.lnum == tpos.lnum
&& curwin->w_cursor.col == tpos.col) { && curwin->w_cursor.col == tpos.col) {
@@ -3165,8 +3165,8 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
if (keytyped == KEY_COMPLETE) { if (keytyped == KEY_COMPLETE) {
char_u *n, *s; char_u *n, *s;
/* Just completed a word, check if it starts with "look". // Just completed a word, check if it starts with "look".
* search back for the start of a word. */ // search back for the start of a word.
line = (char_u *)get_cursor_line_ptr(); line = (char_u *)get_cursor_line_ptr();
for (s = line + curwin->w_cursor.col; s > line; s = n) { for (s = line + curwin->w_cursor.col; s > line; s = n) {
n = mb_prevptr(line, s); n = mb_prevptr(line, s);
@@ -3198,8 +3198,8 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} }
} }
if (match && try_match_word && !try_match) { if (match && try_match_word && !try_match) {
/* "0=word": Check if there are only blanks before the // "0=word": Check if there are only blanks before the
* word. */ // word.
if (getwhitecols_curline() != if (getwhitecols_curline() !=
(int)(curwin->w_cursor.col - (p - look))) { (int)(curwin->w_cursor.col - (p - look))) {
match = false; match = false;

View File

@@ -75,9 +75,8 @@ static char_u *ff_expand_buffer = NULL; // used for expanding filenames
typedef struct ff_stack { typedef struct ff_stack {
struct ff_stack *ffs_prev; struct ff_stack *ffs_prev;
/* the fix part (no wildcards) and the part containing the wildcards // the fix part (no wildcards) and the part containing the wildcards
* of the search path // of the search path
*/
char_u *ffs_fix_path; char_u *ffs_fix_path;
char_u *ffs_wc_path; char_u *ffs_wc_path;
@@ -87,15 +86,13 @@ typedef struct ff_stack {
int ffs_filearray_size; int ffs_filearray_size;
int ffs_filearray_cur; // needed for partly handled dirs int ffs_filearray_cur; // needed for partly handled dirs
/* to store status of partly handled directories // to store status of partly handled directories
* 0: we work on this directory for the first time // 0: we work on this directory for the first time
* 1: this directory was partly searched in an earlier step // 1: this directory was partly searched in an earlier step
*/
int ffs_stage; int ffs_stage;
/* How deep are we in the directory tree? // How deep are we in the directory tree?
* Counts backward from value of level parameter to vim_findfile_init // Counts backward from value of level parameter to vim_findfile_init
*/
int ffs_level; int ffs_level;
// Did we already expand '**' to an empty string? // Did we already expand '**' to an empty string?
@@ -242,9 +239,8 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
ff_stack_T *sptr; ff_stack_T *sptr;
ff_search_ctx_T *search_ctx; ff_search_ctx_T *search_ctx;
/* If a search context is given by the caller, reuse it, else allocate a // If a search context is given by the caller, reuse it, else allocate a
* new one. // new one.
*/
if (search_ctx_arg != NULL) { if (search_ctx_arg != NULL) {
search_ctx = search_ctx_arg; search_ctx = search_ctx_arg;
} else { } else {
@@ -260,9 +256,9 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
if (free_visited == true) { if (free_visited == true) {
vim_findfile_free_visited(search_ctx); vim_findfile_free_visited(search_ctx);
} else { } else {
/* Reuse old visited lists. Get the visited list for the given // Reuse old visited lists. Get the visited list for the given
* filename. If no list for the current filename exists, creates a new // filename. If no list for the current filename exists, creates a new
* one. */ // one.
search_ctx->ffsc_visited_list = ff_get_visited_list((char_u *)filename, search_ctx->ffsc_visited_list = ff_get_visited_list((char_u *)filename,
&search_ctx->ffsc_visited_lists_list); &search_ctx->ffsc_visited_lists_list);
if (search_ctx->ffsc_visited_list == NULL) { if (search_ctx->ffsc_visited_list == NULL) {
@@ -279,8 +275,8 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
ff_expand_buffer = xmalloc(MAXPATHL); ff_expand_buffer = xmalloc(MAXPATHL);
} }
/* Store information on starting dir now if path is relative. // Store information on starting dir now if path is relative.
* If path is absolute, we do that later. */ // If path is absolute, we do that later.
if (path[0] == '.' if (path[0] == '.'
&& (vim_ispathsep(path[1]) || path[1] == NUL) && (vim_ispathsep(path[1]) || path[1] == NUL)
&& (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL)
@@ -321,8 +317,8 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
search_ctx->ffsc_start_dir = (char *)vim_strsave(ff_expand_buffer); search_ctx->ffsc_start_dir = (char *)vim_strsave(ff_expand_buffer);
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
/* A path that starts with "/dir" is relative to the drive, not to the // A path that starts with "/dir" is relative to the drive, not to the
* directory (but not for "//machine/dir"). Only use the drive name. */ // directory (but not for "//machine/dir"). Only use the drive name.
if ((*path == '/' || *path == '\\') if ((*path == '/' || *path == '\\')
&& path[1] != path[0] && path[1] != path[0]
&& search_ctx->ffsc_start_dir[1] == ':') { && search_ctx->ffsc_start_dir[1] == ':') {
@@ -362,9 +358,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrnsave(helper, (size_t)(walker - helper)); search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrnsave(helper, (size_t)(walker - helper));
walker++; walker++;
} else { } else {
/* this might be "", which means ascent till top // this might be "", which means ascent till top of directory tree.
* of directory tree.
*/
search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrdup(helper); search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrdup(helper);
} }
@@ -375,10 +369,9 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
search_ctx->ffsc_level = level; search_ctx->ffsc_level = level;
/* split into: // split into:
* -fix path // -fix path
* -wildcard_stuff (might be NULL) // -wildcard_stuff (might be NULL)
*/
wc_part = vim_strchr(path, '*'); wc_part = vim_strchr(path, '*');
if (wc_part != NULL) { if (wc_part != NULL) {
int64_t llevel; int64_t llevel;
@@ -433,9 +426,8 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
} }
if (search_ctx->ffsc_start_dir == NULL) { if (search_ctx->ffsc_start_dir == NULL) {
/* store the fix part as startdir. // store the fix part as startdir.
* This is needed if the parameter path is fully qualified. // This is needed if the parameter path is fully qualified.
*/
search_ctx->ffsc_start_dir = xstrdup(search_ctx->ffsc_fix_path); search_ctx->ffsc_start_dir = xstrdup(search_ctx->ffsc_fix_path);
search_ctx->ffsc_fix_path[0] = NUL; search_ctx->ffsc_fix_path[0] = NUL;
} }
@@ -513,8 +505,8 @@ char_u *vim_findfile_stopdir(char_u *buf)
while (*r_ptr != NUL && *r_ptr != ';') { while (*r_ptr != NUL && *r_ptr != ';') {
if (r_ptr[0] == '\\' && r_ptr[1] == ';') { if (r_ptr[0] == '\\' && r_ptr[1] == ';') {
/* Overwrite the escape char, // Overwrite the escape char,
* use STRLEN(r_ptr) to move the trailing '\0'. */ // use STRLEN(r_ptr) to move the trailing '\0'.
STRMOVE(r_ptr, r_ptr + 1); STRMOVE(r_ptr, r_ptr + 1);
r_ptr++; r_ptr++;
} }
@@ -653,9 +645,7 @@ char_u *vim_findfile(void *search_ctx_arg)
if (stackp->ffs_filearray == NULL) { if (stackp->ffs_filearray == NULL) {
char *dirptrs[2]; char *dirptrs[2];
/* we use filepath to build the path expand_wildcards() should // we use filepath to build the path expand_wildcards() should expand.
* expand.
*/
dirptrs[0] = (char *)file_path; dirptrs[0] = (char *)file_path;
dirptrs[1] = NULL; dirptrs[1] = NULL;
@@ -742,9 +732,9 @@ char_u *vim_findfile(void *search_ctx_arg)
stackp->ffs_filearray[0] = xstrdup(dirptrs[0]); stackp->ffs_filearray[0] = xstrdup(dirptrs[0]);
stackp->ffs_filearray_size = 1; stackp->ffs_filearray_size = 1;
} else { } else {
/* Add EW_NOTWILD because the expanded path may contain // Add EW_NOTWILD because the expanded path may contain
* wildcard characters that are to be taken literally. // wildcard characters that are to be taken literally.
* This is a bit of a hack. */ // This is a bit of a hack.
expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs, expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs,
&stackp->ffs_filearray_size, &stackp->ffs_filearray_size,
&stackp->ffs_filearray, &stackp->ffs_filearray,
@@ -886,9 +876,8 @@ char_u *vim_findfile(void *search_ctx_arg)
ff_free_stack_element(stackp); ff_free_stack_element(stackp);
} }
/* If we reached this, we didn't find anything downwards. // If we reached this, we didn't find anything downwards.
* Let's check if we should do an upward search. // Let's check if we should do an upward search.
*/
if (search_ctx->ffsc_start_dir if (search_ctx->ffsc_start_dir
&& search_ctx->ffsc_stopdirs_v != NULL && !got_int) { && search_ctx->ffsc_stopdirs_v != NULL && !got_int) {
ff_stack_T *sptr; ff_stack_T *sptr;
@@ -1157,8 +1146,8 @@ static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, in
/// Push a dir on the directory stack. /// Push a dir on the directory stack.
static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr) static void ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr)
{ {
/* check for NULL pointer, not to return an error to the user, but // check for NULL pointer, not to return an error to the user, but
* to prevent a crash */ // to prevent a crash
if (stack_ptr != NULL) { if (stack_ptr != NULL) {
stack_ptr->ffs_prev = search_ctx->ffsc_stack_ptr; stack_ptr->ffs_prev = search_ctx->ffsc_stack_ptr;
search_ctx->ffsc_stack_ptr = stack_ptr; search_ctx->ffsc_stack_ptr = stack_ptr;
@@ -1251,10 +1240,9 @@ static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v)
for (i = 0; stopdirs_v[i] != NULL; i++) { for (i = 0; stopdirs_v[i] != NULL; i++) {
if ((int)STRLEN(stopdirs_v[i]) > path_len) { if ((int)STRLEN(stopdirs_v[i]) > path_len) {
/* match for parent directory. So '/home' also matches // match for parent directory. So '/home' also matches
* '/home/rks'. Check for PATHSEP in stopdirs_v[i], else // '/home/rks'. Check for PATHSEP in stopdirs_v[i], else
* '/home/r' would also match '/home/rks' // '/home/r' would also match '/home/rks'
*/
if (FNAMENCMP(stopdirs_v[i], path, path_len) == 0 if (FNAMENCMP(stopdirs_v[i], path, path_len) == 0
&& vim_ispathsep(stopdirs_v[i][path_len])) { && vim_ispathsep(stopdirs_v[i][path_len])) {
return true; return true;
@@ -1407,8 +1395,8 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
goto theend; goto theend;
} }
/* When FNAME_REL flag given first use the directory of the file. // When FNAME_REL flag given first use the directory of the file.
* Otherwise or when this fails use the current directory. */ // Otherwise or when this fails use the current directory.
for (int run = 1; run <= 2; run++) { for (int run = 1; run <= 2; run++) {
size_t l = STRLEN(ff_file_to_find); size_t l = STRLEN(ff_file_to_find);
if (run == 1 if (run == 1
@@ -1424,8 +1412,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
run = 2; run = 2;
} }
/* When the file doesn't exist, try adding parts of // When the file doesn't exist, try adding parts of 'suffixesadd'.
* 'suffixesadd'. */
buf = (char *)suffixes; buf = (char *)suffixes;
for (;;) { for (;;) {
if ( if (
@@ -1467,8 +1454,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
char_u *r_ptr; char_u *r_ptr;
if (dir == NULL || *dir == NUL) { if (dir == NULL || *dir == NUL) {
/* We searched all paths of the option, now we can // We searched all paths of the option, now we can free the search context.
* free the search context. */
vim_findfile_cleanup(fdip_search_ctx); vim_findfile_cleanup(fdip_search_ctx);
fdip_search_ctx = NULL; fdip_search_ctx = NULL;
break; break;

View File

@@ -82,12 +82,12 @@
#define FIO_UCSBOM 0x4000 // check for BOM at start of file #define FIO_UCSBOM 0x4000 // check for BOM at start of file
#define FIO_ALL (-1) // allow all formats #define FIO_ALL (-1) // allow all formats
/* When converting, a read() or write() may leave some bytes to be converted // When converting, a read() or write() may leave some bytes to be converted
* for the next call. The value is guessed... */ // for the next call. The value is guessed...
#define CONV_RESTLEN 30 #define CONV_RESTLEN 30
/* We have to guess how much a sequence of bytes may expand when converting // We have to guess how much a sequence of bytes may expand when converting
* with iconv() to be able to allocate a buffer. */ // with iconv() to be able to allocate a buffer.
#define ICONV_MULT 8 #define ICONV_MULT 8
// Structure to pass arguments from buf_write() to buf_write_bytes(). // Structure to pass arguments from buf_write() to buf_write_bytes().
@@ -2091,8 +2091,8 @@ static void check_marks_read(void)
shada_read_marks(); shada_read_marks();
} }
/* Always set b_marks_read; needed when 'shada' is changed to include // Always set b_marks_read; needed when 'shada' is changed to include
* the ' parameter after opening a buffer. */ // the ' parameter after opening a buffer.
curbuf->b_marks_read = true; curbuf->b_marks_read = true;
} }
@@ -2177,8 +2177,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
int wb_flags = 0; int wb_flags = 0;
#endif #endif
#ifdef HAVE_ACL #ifdef HAVE_ACL
vim_acl_T acl = NULL; /* ACL copied from original file to vim_acl_T acl = NULL; // ACL copied from original file to
backup or new file */ // backup or new file
#endif #endif
int write_undo_file = false; int write_undo_file = false;
context_sha256_T sha_ctx; context_sha256_T sha_ctx;
@@ -2190,8 +2190,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
return FAIL; return FAIL;
} }
if (buf->b_ml.ml_mfp == NULL) { if (buf->b_ml.ml_mfp == NULL) {
/* This can happen during startup when there is a stray "w" in the // This can happen during startup when there is a stray "w" in the
* vimrc file. */ // vimrc file.
emsg(_(e_emptybuf)); emsg(_(e_emptybuf));
return FAIL; return FAIL;
} }
@@ -2217,8 +2217,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
write_info.bw_iconv_fd = (iconv_t)-1; write_info.bw_iconv_fd = (iconv_t)-1;
#endif #endif
/* After writing a file changedtick changes but we don't want to display // After writing a file changedtick changes but we don't want to display
* the line. */ // the line.
ex_no_reprint = true; ex_no_reprint = true;
// If there is no file name yet, use the one for the written file. // If there is no file name yet, use the one for the written file.
@@ -2318,9 +2318,9 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
sfname, sfname, false, curbuf, eap); sfname, sfname, false, curbuf, eap);
if (did_cmd) { if (did_cmd) {
if (was_changed && !curbufIsChanged()) { if (was_changed && !curbufIsChanged()) {
/* Written everything correctly and BufWriteCmd has reset // Written everything correctly and BufWriteCmd has reset
* 'modified': Correct the undo information so that an // 'modified': Correct the undo information so that an
* undo now sets 'modified'. */ // undo now sets 'modified'.
u_unchanged(curbuf); u_unchanged(curbuf);
u_update_save_nr(curbuf); u_update_save_nr(curbuf);
} }
@@ -2371,14 +2371,14 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
if (nofile_err if (nofile_err
|| aborting()) { || aborting()) {
/* An aborting error, interrupt or exception in the // An aborting error, interrupt or exception in the
* autocommands. */ // autocommands.
return FAIL; return FAIL;
} }
if (did_cmd) { if (did_cmd) {
if (buf == NULL) { if (buf == NULL) {
/* The buffer was deleted. We assume it was written // The buffer was deleted. We assume it was written
* (can't retry anyway). */ // (can't retry anyway).
return OK; return OK;
} }
if (overwriting) { if (overwriting) {
@@ -2488,8 +2488,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
SET_ERRMSG_NUM("E503", _("is not a file or writable device")); SET_ERRMSG_NUM("E503", _("is not a file or writable device"));
goto fail; goto fail;
} }
/* It's a device of some kind (or a fifo) which we can write to // It's a device of some kind (or a fifo) which we can write to
* but for which we can't make a backup. */ // but for which we can't make a backup.
device = true; device = true;
newfile = true; newfile = true;
perm = -1; perm = -1;
@@ -2616,8 +2616,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
backup_copy = true; backup_copy = true;
} }
#endif #endif
/* Close the file before removing it, on MS-Windows we // Close the file before removing it, on MS-Windows we
* can't delete an open file. */ // can't delete an open file.
close(fd); close(fd);
os_remove((char *)IObuff); os_remove((char *)IObuff);
} }
@@ -3433,8 +3433,8 @@ restore_backup:
set_keep_msg(msg_trunc_attr((char *)IObuff, false, 0), 0); set_keep_msg(msg_trunc_attr((char *)IObuff, false, 0), 0);
} }
/* When written everything correctly: reset 'modified'. Unless not // When written everything correctly: reset 'modified'. Unless not
* writing to the original file and '+' is not in 'cpoptions'. */ // writing to the original file and '+' is not in 'cpoptions'.
if (reset_changed && whole && !append if (reset_changed && whole && !append
&& !write_info.bw_conv_error && !write_info.bw_conv_error
&& (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)) { && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)) {
@@ -3815,9 +3815,9 @@ static int buf_write_bytes(struct bw_info *ip)
if (wlen == 0 && ip->bw_restlen != 0) { if (wlen == 0 && ip->bw_restlen != 0) {
int l; int l;
/* Use remainder of previous call. Append the start of // Use remainder of previous call. Append the start of
* buf[] to get a full sequence. Might still be too // buf[] to get a full sequence. Might still be too
* short! */ // short!
l = CONV_RESTLEN - ip->bw_restlen; l = CONV_RESTLEN - ip->bw_restlen;
if (l > len) { if (l > len) {
l = len; l = len;
@@ -3825,9 +3825,9 @@ static int buf_write_bytes(struct bw_info *ip)
memmove(ip->bw_rest + ip->bw_restlen, buf, (size_t)l); memmove(ip->bw_rest + ip->bw_restlen, buf, (size_t)l);
n = utf_ptr2len_len(ip->bw_rest, ip->bw_restlen + l); n = utf_ptr2len_len(ip->bw_rest, ip->bw_restlen + l);
if (n > ip->bw_restlen + len) { if (n > ip->bw_restlen + len) {
/* We have an incomplete byte sequence at the end to // We have an incomplete byte sequence at the end to
* be written. We can't convert it without the // be written. We can't convert it without the
* remaining bytes. Keep them for the next call. */ // remaining bytes. Keep them for the next call.
if (ip->bw_restlen + len > CONV_RESTLEN) { if (ip->bw_restlen + len > CONV_RESTLEN) {
return FAIL; return FAIL;
} }
@@ -3851,9 +3851,9 @@ static int buf_write_bytes(struct bw_info *ip)
} else { } else {
n = utf_ptr2len_len(buf + wlen, len - wlen); n = utf_ptr2len_len(buf + wlen, len - wlen);
if (n > len - wlen) { if (n > len - wlen) {
/* We have an incomplete byte sequence at the end to // We have an incomplete byte sequence at the end to
* be written. We can't convert it without the // be written. We can't convert it without the
* remaining bytes. Keep them for the next call. */ // remaining bytes. Keep them for the next call.
if (len - wlen > CONV_RESTLEN) { if (len - wlen > CONV_RESTLEN) {
return FAIL; return FAIL;
} }
@@ -3896,9 +3896,9 @@ static int buf_write_bytes(struct bw_info *ip)
if (ip->bw_restlen > 0) { if (ip->bw_restlen > 0) {
char *fp; char *fp;
/* Need to concatenate the remainder of the previous call and // Need to concatenate the remainder of the previous call and
* the bytes of the current call. Use the end of the // the bytes of the current call. Use the end of the
* conversion buffer for this. */ // conversion buffer for this.
fromlen = (size_t)len + (size_t)ip->bw_restlen; fromlen = (size_t)len + (size_t)ip->bw_restlen;
fp = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen; fp = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
memmove(fp, ip->bw_rest, (size_t)ip->bw_restlen); memmove(fp, ip->bw_rest, (size_t)ip->bw_restlen);
@@ -3918,9 +3918,8 @@ static int buf_write_bytes(struct bw_info *ip)
// output the initial shift state sequence // output the initial shift state sequence
(void)iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen); (void)iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen);
/* There is a bug in iconv() on Linux (which appears to be // There is a bug in iconv() on Linux (which appears to be
* wide-spread) which sets "to" to NULL and messes up "tolen". // wide-spread) which sets "to" to NULL and messes up "tolen".
*/
if (to == NULL) { if (to == NULL) {
to = (char *)ip->bw_conv_buf; to = (char *)ip->bw_conv_buf;
tolen = save_len; tolen = save_len;
@@ -3984,8 +3983,8 @@ static bool ucs2bytes(unsigned c, char_u **pp, int flags) FUNC_ATTR_NONNULL_ALL
} else if (flags & (FIO_UCS2 | FIO_UTF16)) { } else if (flags & (FIO_UCS2 | FIO_UTF16)) {
if (c >= 0x10000) { if (c >= 0x10000) {
if (flags & FIO_UTF16) { if (flags & FIO_UTF16) {
/* Make two words, ten bits of the character in each. First // Make two words, ten bits of the character in each. First
* word is 0xd800 - 0xdbff, second one 0xdc00 - 0xdfff */ // word is 0xd800 - 0xdbff, second one 0xdc00 - 0xdfff
c -= 0x10000; c -= 0x10000;
if (c >= 0x100000) { if (c >= 0x100000) {
error = true; error = true;

View File

@@ -176,8 +176,8 @@ struct prt_ps_font_S {
char *(ps_fontname[4]); char *(ps_fontname[4]);
}; };
/* Structures to map user named encoding and mapping to PS equivalents for // Structures to map user named encoding and mapping to PS equivalents for
* building CID font name */ // building CID font name
struct prt_ps_encoding_S { struct prt_ps_encoding_S {
char *encoding; char *encoding;
char *cmap_encoding; char *cmap_encoding;
@@ -235,8 +235,8 @@ struct prt_dsc_line_S {
int len; int len;
}; };
/* Static buffer to read initial comments in a resource file, some can have a // Static buffer to read initial comments in a resource file, some can have a
* couple of KB of comments! */ // couple of KB of comments!
#define PRT_FILE_BUFFER_LEN (2048) #define PRT_FILE_BUFFER_LEN (2048)
struct prt_resfile_buffer_S { struct prt_resfile_buffer_S {
char_u buffer[PRT_FILE_BUFFER_LEN]; char_u buffer[PRT_FILE_BUFFER_LEN];
@@ -1162,16 +1162,15 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
} }
}; };
/* The PS prolog file version number has to match - if the prolog file is // The PS prolog file version number has to match - if the prolog file is
* updated, increment the number in the file and here. Version checking was // updated, increment the number in the file and here. Version checking was
* added as of VIM 6.2. // added as of VIM 6.2.
* The CID prolog file version number behaves as per PS prolog. // The CID prolog file version number behaves as per PS prolog.
* Table of VIM and prolog versions: // Table of VIM and prolog versions:
* //
* VIM Prolog CIDProlog // VIM Prolog CIDProlog
* 6.2 1.3 // 6.2 1.3
* 7.0 1.4 1.0 // 7.0 1.4 1.0
*/
#define PRT_PROLOG_VERSION ((char_u *)"1.4") #define PRT_PROLOG_VERSION ((char_u *)"1.4")
#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0") #define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
@@ -1182,8 +1181,8 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
#define PRT_RESOURCE_ENCODING "Encoding" #define PRT_RESOURCE_ENCODING "Encoding"
#define PRT_RESOURCE_CMAP "CMap" #define PRT_RESOURCE_CMAP "CMap"
/* Data for table based DSC comment recognition, easy to extend if VIM needs to // Data for table based DSC comment recognition, easy to extend if VIM needs to
* read more comments. */ // read more comments.
#define PRT_DSC_MISC_TYPE (-1) #define PRT_DSC_MISC_TYPE (-1)
#define PRT_DSC_TITLE_TYPE (1) #define PRT_DSC_TITLE_TYPE (1)
#define PRT_DSC_VERSION_TYPE (2) #define PRT_DSC_VERSION_TYPE (2)
@@ -1573,8 +1572,9 @@ static int prt_resfile_skip_ws(int offset)
return -1; return -1;
} }
/* prt_next_dsc() - returns detail on next DSC comment line found. Returns true /// Returns detail on next DSC comment line found.
* if a DSC comment is found, else false */ ///
/// @return true if a DSC comment is found, else false
static bool prt_next_dsc(struct prt_dsc_line_S *p_dsc_line) static bool prt_next_dsc(struct prt_dsc_line_S *p_dsc_line)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {

View File

@@ -681,9 +681,9 @@ void op_reindent(oparg_T *oap, Indenter how)
curwin->w_cursor.lnum = start_lnum; curwin->w_cursor.lnum = start_lnum;
beginline(BL_SOL | BL_FIX); beginline(BL_SOL | BL_FIX);
/* Mark changed lines so that they will be redrawn. When Visual // Mark changed lines so that they will be redrawn. When Visual
* highlighting was present, need to continue until the last line. When // highlighting was present, need to continue until the last line. When
* there is no change still need to remove the Visual highlighting. */ // there is no change still need to remove the Visual highlighting.
if (last_changed != 0) { if (last_changed != 0) {
changed_lines(first_changed, 0, changed_lines(first_changed, 0,
oap->is_VIsual ? start_lnum + (linenr_T)oap->line_count : oap->is_VIsual ? start_lnum + (linenr_T)oap->line_count :
@@ -748,12 +748,12 @@ char_u *get_expr_line(void)
return NULL; return NULL;
} }
/* Make a copy of the expression, because evaluating it may cause it to be // Make a copy of the expression, because evaluating it may cause it to be
* changed. */ // changed.
expr_copy = vim_strsave(expr_line); expr_copy = vim_strsave(expr_line);
/* When we are invoked recursively limit the evaluation to 10 levels. // When we are invoked recursively limit the evaluation to 10 levels.
* Then return the string as-is. */ // Then return the string as-is.
if (nested >= 10) { if (nested >= 10) {
return expr_copy; return expr_copy;
} }
@@ -1431,8 +1431,8 @@ bool cmdline_paste_reg(int regname, bool literally_arg, bool remcr)
cmdline_paste_str((char_u *)"\r", literally); cmdline_paste_str((char_u *)"\r", literally);
} }
/* Check for CTRL-C, in case someone tries to paste a few thousand // Check for CTRL-C, in case someone tries to paste a few thousand
* lines and gets bored. */ // lines and gets bored.
os_breakcheck(); os_breakcheck();
if (got_int) { if (got_int) {
return FAIL; return FAIL;
@@ -2677,8 +2677,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
if (virtual_op) { if (virtual_op) {
getvcol(curwin, &oap->start, &cs, NULL, &ce); getvcol(curwin, &oap->start, &cs, NULL, &ce);
if (ce != cs && oap->start.coladd > 0) { if (ce != cs && oap->start.coladd > 0) {
/* Part of a tab selected -- but don't // Part of a tab selected -- but don't double-count it.
* double-count it. */
bd.startspaces = (ce - cs + 1) bd.startspaces = (ce - cs + 1)
- oap->start.coladd; - oap->start.coladd;
startcol++; startcol++;
@@ -3043,9 +3042,9 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
if (insert_string != NULL) { if (insert_string != NULL) {
y_type = kMTCharWise; y_type = kMTCharWise;
if (regname == '=') { if (regname == '=') {
/* For the = register we need to split the string at NL // For the = register we need to split the string at NL
* characters. // characters.
* Loop twice: count the number of lines and save them. */ // Loop twice: count the number of lines and save them.
for (;;) { for (;;) {
y_size = 0; y_size = 0;
ptr = insert_string; ptr = insert_string;
@@ -3285,9 +3284,9 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
delcount = 1; delcount = 1;
bd.textcol -= utf_head_off(oldp, oldp + bd.textcol); bd.textcol -= utf_head_off(oldp, oldp + bd.textcol);
if (oldp[bd.textcol] != TAB) { if (oldp[bd.textcol] != TAB) {
/* Only a Tab can be split into spaces. Other // Only a Tab can be split into spaces. Other
* characters will have to be moved to after the // characters will have to be moved to after the
* block, causing misalignment. */ // block, causing misalignment.
delcount = 0; delcount = 0;
bd.endspaces = 0; bd.endspaces = 0;
} }

View File

@@ -625,8 +625,8 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
char_u *e = NULL; char_u *e = NULL;
const char_u *path_end = path; const char_u *path_end = path;
while (*path_end != NUL) { while (*path_end != NUL) {
/* May ignore a wildcard that has a backslash before it; it will // May ignore a wildcard that has a backslash before it; it will
* be removed by rem_backslash() or file_pat_to_reg_pat() below. */ // be removed by rem_backslash() or file_pat_to_reg_pat() below.
if (path_end >= path + wildoff && rem_backslash((char *)path_end)) { if (path_end >= path + wildoff && rem_backslash((char *)path_end)) {
*p++ = *path_end++; *p++ = *path_end++;
} else if (vim_ispathsep_nocolon(*path_end)) { } else if (vim_ispathsep_nocolon(*path_end)) {
@@ -651,8 +651,8 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
*e = NUL; *e = NUL;
// Now we have one wildcard component between "s" and "e". // Now we have one wildcard component between "s" and "e".
/* Remove backslashes between "wildoff" and the start of the wildcard // Remove backslashes between "wildoff" and the start of the wildcard
* component. */ // component.
for (p = buf + wildoff; p < s; p++) { for (p = buf + wildoff; p < s; p++) {
if (rem_backslash((char *)p)) { if (rem_backslash((char *)p)) {
STRMOVE(p, p + 1); STRMOVE(p, p + 1);
@@ -698,8 +698,8 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
return 0; return 0;
} }
/* If "**" is by itself, this is the first time we encounter it and more // If "**" is by itself, this is the first time we encounter it and more
* is following then find matches without any directory. */ // is following then find matches without any directory.
if (!didstar && stardepth < 100 && starstar && e - s == 2 if (!didstar && stardepth < 100 && starstar && e - s == 2
&& *path_end == '/') { && *path_end == '/') {
STRCPY(s, path_end + 1); STRCPY(s, path_end + 1);
@@ -728,9 +728,9 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
len = STRLEN(buf); len = STRLEN(buf);
if (starstar && stardepth < 100) { if (starstar && stardepth < 100) {
/* For "**" in the pattern first go deeper in the tree to // For "**" in the pattern first go deeper in the tree to
* find matches. */ // find matches.
STRCPY(buf + len, "/**"); STRCPY(buf + len, "/**"); // NOLINT
STRCPY(buf + len + 3, path_end); STRCPY(buf + len + 3, path_end);
stardepth++; stardepth++;
(void)do_path_expand(gap, buf, len + 1, flags, true); (void)do_path_expand(gap, buf, len + 1, flags, true);
@@ -835,9 +835,9 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
copy_option_part((char **)&path_option, (char *)buf, MAXPATHL, " ,"); copy_option_part((char **)&path_option, (char *)buf, MAXPATHL, " ,");
if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) { if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) {
/* Relative to current buffer: // Relative to current buffer:
* "/path/file" + "." -> "/path/" // "/path/file" + "." -> "/path/"
* "/path/file" + "./subdir" -> "/path/subdir" */ // "/path/file" + "./subdir" -> "/path/subdir"
if (curbuf->b_ffname == NULL) { if (curbuf->b_ffname == NULL) {
continue; continue;
} }
@@ -1028,8 +1028,8 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
continue; continue;
} }
/* If the {filename} is not unique, change it to ./{filename}. // If the {filename} is not unique, change it to ./{filename}.
* Else reduce it to {filename} */ // Else reduce it to {filename}
short_name = path_shorten_fname(path, curdir); short_name = path_shorten_fname(path, curdir);
if (short_name == NULL) { if (short_name == NULL) {
short_name = path; short_name = path;
@@ -1278,8 +1278,8 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
&& (vim_ispathsep(p[1]) && (vim_ispathsep(p[1])
|| (p[1] == '.' || (p[1] == '.'
&& vim_ispathsep(p[2]))))) { && vim_ispathsep(p[2]))))) {
/* :find completion where 'path' is used. // :find completion where 'path' is used.
* Recursiveness is OK here. */ // Recursiveness is OK here.
recursive = false; recursive = false;
add_pat = expand_in_path(&ga, p, flags); add_pat = expand_in_path(&ga, p, flags);
recursive = true; recursive = true;
@@ -1295,8 +1295,8 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND))) { if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND))) {
char_u *t = (char_u *)backslash_halve_save((char *)p); char_u *t = (char_u *)backslash_halve_save((char *)p);
/* When EW_NOTFOUND is used, always add files and dirs. Makes // When EW_NOTFOUND is used, always add files and dirs. Makes
* "vim c:/" work. */ // "vim c:/" work.
if (flags & EW_NOTFOUND) { if (flags & EW_NOTFOUND) {
addfile(&ga, t, flags | EW_DIR | EW_FILE); addfile(&ga, t, flags | EW_DIR | EW_FILE);
} else { } else {
@@ -1505,8 +1505,8 @@ void simplify_filename(char_u *filename)
start = p; // remember start after "c:/" or "/" or "///" start = p; // remember start after "c:/" or "/" or "///"
do { do {
/* At this point "p" is pointing to the char following a single "/" // At this point "p" is pointing to the char following a single "/"
* or "p" is at the "start" of the (absolute or relative) path name. */ // or "p" is at the "start" of the (absolute or relative) path name.
if (vim_ispathsep(*p)) { if (vim_ispathsep(*p)) {
STRMOVE(p, p + 1); // remove duplicate "/" STRMOVE(p, p + 1); // remove duplicate "/"
} else if (p[0] == '.' } else if (p[0] == '.'
@@ -1514,10 +1514,10 @@ void simplify_filename(char_u *filename)
if (p == start && relative) { if (p == start && relative) {
p += 1 + (p[1] != NUL); // keep single "." or leading "./" p += 1 + (p[1] != NUL); // keep single "." or leading "./"
} else { } else {
/* Strip "./" or ".///". If we are at the end of the file name // Strip "./" or ".///". If we are at the end of the file name
* and there is no trailing path separator, either strip "/." if // and there is no trailing path separator, either strip "/." if
* we are after "start", or strip "." if we are at the beginning // we are after "start", or strip "." if we are at the beginning
* of an absolute path name . */ // of an absolute path name.
tail = p + 1; tail = p + 1;
if (p[1] != NUL) { if (p[1] != NUL) {
while (vim_ispathsep(*tail)) { while (vim_ispathsep(*tail)) {
@@ -1542,9 +1542,9 @@ void simplify_filename(char_u *filename)
// Don't strip for an erroneous file name. // Don't strip for an erroneous file name.
if (!stripping_disabled) { if (!stripping_disabled) {
/* If the preceding component does not exist in the file // If the preceding component does not exist in the file
* system, we strip it. On Unix, we don't accept a symbolic // system, we strip it. On Unix, we don't accept a symbolic
* link that refers to a non-existent file. */ // link that refers to a non-existent file.
saved_char = p[-1]; saved_char = p[-1];
p[-1] = NUL; p[-1] = NUL;
FileInfo file_info; FileInfo file_info;
@@ -1560,16 +1560,16 @@ void simplify_filename(char_u *filename)
} }
if (!do_strip) { if (!do_strip) {
/* If the component exists in the file system, check // If the component exists in the file system, check
* that stripping it won't change the meaning of the // that stripping it won't change the meaning of the
* file name. First get information about the // file name. First get information about the
* unstripped file name. This may fail if the component // unstripped file name. This may fail if the component
* to strip is not a searchable directory (but a regular // to strip is not a searchable directory (but a regular
* file, for instance), since the trailing "/.." cannot // file, for instance), since the trailing "/.." cannot
* be applied then. We don't strip it then since we // be applied then. We don't strip it then since we
* don't want to replace an erroneous file name by // don't want to replace an erroneous file name by
* a valid one, and we disable stripping of later // a valid one, and we disable stripping of later
* components. */ // components.
saved_char = *tail; saved_char = *tail;
*tail = NUL; *tail = NUL;
if (os_fileinfo((char *)filename, &file_info)) { if (os_fileinfo((char *)filename, &file_info)) {
@@ -1579,13 +1579,13 @@ void simplify_filename(char_u *filename)
} }
*tail = saved_char; *tail = saved_char;
if (do_strip) { if (do_strip) {
/* The check for the unstripped file name // The check for the unstripped file name
* above works also for a symbolic link pointing to // above works also for a symbolic link pointing to
* a searchable directory. But then the parent of // a searchable directory. But then the parent of
* the directory pointed to by the link must be the // the directory pointed to by the link must be the
* same as the stripped file name. (The latter // same as the stripped file name. (The latter
* exists in the file system since it is the // exists in the file system since it is the
* component's parent directory.) */ // component's parent directory.)
FileInfo new_file_info; FileInfo new_file_info;
if (p == start && relative) { if (p == start && relative) {
os_fileinfo(".", &new_file_info); os_fileinfo(".", &new_file_info);
@@ -1598,26 +1598,26 @@ void simplify_filename(char_u *filename)
if (!os_fileinfo_id_equal(&file_info, &new_file_info)) { if (!os_fileinfo_id_equal(&file_info, &new_file_info)) {
do_strip = false; do_strip = false;
/* We don't disable stripping of later // We don't disable stripping of later
* components since the unstripped path name is // components since the unstripped path name is
* still valid. */ // still valid.
} }
} }
} }
} }
if (!do_strip) { if (!do_strip) {
/* Skip the ".." or "../" and reset the counter for the // Skip the ".." or "../" and reset the counter for the
* components that might be stripped later on. */ // components that might be stripped later on.
p = tail; p = tail;
components = 0; components = 0;
} else { } else {
/* Strip previous component. If the result would get empty // Strip previous component. If the result would get empty
* and there is no trailing path separator, leave a single // and there is no trailing path separator, leave a single
* "." instead. If we are at the end of the file name and // "." instead. If we are at the end of the file name and
* there is no trailing path separator and a preceding // there is no trailing path separator and a preceding
* component is left after stripping, strip its trailing // component is left after stripping, strip its trailing
* path separator as well. */ // path separator as well.
if (p == start && relative && tail[-1] == '.') { if (p == start && relative && tail[-1] == '.') {
*p++ = '.'; *p++ = '.';
*p = NUL; *p = NUL;
@@ -1699,8 +1699,8 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
ptr[len] = c; ptr[len] = c;
} }
/* Repeat finding the file "count" times. This matters when it // Repeat finding the file "count" times. This matters when it
* appears several times in the path. */ // appears several times in the path.
while (file_name != NULL && --count > 0) { while (file_name != NULL && --count > 0) {
xfree(file_name); xfree(file_name);
file_name = file_name =

View File

@@ -180,10 +180,10 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
int csh_like; int csh_like;
bool fish_like; bool fish_like;
/* Only csh and similar shells expand '!' within single quotes. For sh and // Only csh and similar shells expand '!' within single quotes. For sh and
* the like we must not put a backslash before it, it will be taken // the like we must not put a backslash before it, it will be taken
* literally. If do_special is set the '!' will be escaped twice. // literally. If do_special is set the '!' will be escaped twice.
* Csh also needs to have "\n" escaped twice when do_special is set. */ // Csh also needs to have "\n" escaped twice when do_special is set.
csh_like = csh_like_shell(); csh_like = csh_like_shell();
// Fish shell uses '\' as an escape character within single quotes, so '\' // Fish shell uses '\' as an escape character within single quotes, so '\'