refactor: follow style guide

This commit is contained in:
dundargoc
2023-12-28 13:42:24 +01:00
committed by dundargoc
parent d634cd5b0b
commit c89292fcb7
90 changed files with 953 additions and 1121 deletions

View File

@@ -186,7 +186,7 @@ static int buf_write_convert_with_iconv(struct bw_info *ip, char **bufp, int *le
size_t save_len = tolen;
// output the initial shift state sequence
(void)iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen);
iconv(ip->bw_iconv_fd, NULL, NULL, &to, &tolen);
// There is a bug in iconv() on Linux (which appears to be
// wide-spread) which sets "to" to NULL and messes up "tolen".
@@ -378,7 +378,7 @@ static int make_bom(char *buf_in, char *name)
return 3;
}
char *p = (char *)buf;
(void)ucs2bytes(0xfeff, &p, flags);
ucs2bytes(0xfeff, &p, flags);
return (int)((uint8_t *)p - buf);
}
@@ -480,8 +480,7 @@ static int buf_write_do_autocmds(buf_T *buf, char **fnamep, char **sfnamep, char
semsg(_(e_no_matching_autocommands_for_buftype_str_buffer), curbuf->b_p_bt);
}
if (nofile_err
|| aborting()) {
if (nofile_err || aborting()) {
// An aborting error, interrupt or exception in the
// autocommands.
return FAIL;
@@ -720,7 +719,7 @@ static int get_fileinfo(buf_T *buf, char *fname, bool overwriting, bool forceit,
static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_old, vim_acl_T acl,
int perm, unsigned bkc, bool file_readonly, bool forceit,
int *backup_copyp, char **backupp, Error_T *err)
bool *backup_copyp, char **backupp, Error_T *err)
{
FileInfo file_info;
const bool no_prepend_dot = false;
@@ -897,7 +896,7 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
// set file protection same as original file, but
// strip s-bit.
(void)os_setperm(*backupp, perm & 0777);
os_setperm(*backupp, perm & 0777);
#ifdef UNIX
//
@@ -1134,8 +1133,8 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
fname = sfname;
#endif
// true if writing over original
int overwriting = buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0;
// true if writing over original
bool overwriting = buf->b_ffname != NULL && path_fnamecmp(ffname, buf->b_ffname) == 0;
no_wait_return++; // don't wait for return yet
@@ -1218,7 +1217,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
dobackup = false;
}
int backup_copy = false; // copy the original file?
bool backup_copy = false; // copy the original file?
// Save the value of got_int and reset it. We don't want a previous
// interruption cancel writing, only hitting CTRL-C while writing should
@@ -1251,7 +1250,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
&& file_info_old.stat.st_uid == getuid()
&& vim_strchr(p_cpo, CPO_FWRITE) == NULL) {
perm |= 0200;
(void)os_setperm(fname, perm);
os_setperm(fname, perm);
made_writable = true;
}
#endif
@@ -1278,8 +1277,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
// This makes all block numbers positive so that recovery does not need
// the original file.
// Don't do this if there is a backup file and we are exiting.
if (reset_changed && !newfile && overwriting
&& !(exiting && backup != NULL)) {
if (reset_changed && !newfile && overwriting && !(exiting && backup != NULL)) {
ml_preserve(buf, false, !!p_fs);
if (got_int) {
err = set_err(_(e_interr));
@@ -1303,7 +1301,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
}
// Check if the file needs to be converted.
int converted = need_conversion(fenc);
bool converted = need_conversion(fenc);
int wb_flags = 0;
// Check if UTF-8 to UCS-2/4 or Latin1 conversion needs to be done. Or
@@ -1367,7 +1365,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
int nchars;
linenr_T lnum;
int fileformat;
int checking_conversion;
bool checking_conversion;
int fd;
@@ -1605,7 +1603,7 @@ restore_backup:
if (!buf->b_p_fixeol && buf->b_p_eof) {
// write trailing CTRL-Z
(void)write_eintr(write_info.bw_fd, "\x1a", 1);
write_eintr(write_info.bw_fd, "\x1a", 1);
}
// Stop when writing done or an error was encountered.
@@ -1654,7 +1652,7 @@ restore_backup:
|| file_info.stat.st_gid != file_info_old.stat.st_gid) {
os_fchown(fd, (uv_uid_t)file_info_old.stat.st_uid, (uv_gid_t)file_info_old.stat.st_gid);
if (perm >= 0) { // Set permission again, may have changed.
(void)os_setperm(wfname, perm);
os_setperm(wfname, perm);
}
}
buf_set_file_id(buf);
@@ -1675,7 +1673,7 @@ restore_backup:
}
#endif
if (perm >= 0) { // Set perm. of new file same as old file.
(void)os_setperm(wfname, perm);
os_setperm(wfname, perm);
}
// Probably need to set the ACL before changing the user (can't set the
// ACL on a file the user doesn't own).