refactor: convert TRUE/FALSE to true/false (#15660)

This commit is contained in:
dundargoc
2021-09-18 00:24:39 +02:00
committed by GitHub
parent ede5695eb1
commit 1f49268c46
8 changed files with 49 additions and 56 deletions

View File

@@ -846,13 +846,13 @@ int skip_expr(char_u **pp)
return eval1(pp, &rettv, FALSE); return eval1(pp, &rettv, FALSE);
} }
/* /// Top level evaluation function, returning a string.
* Top level evaluation function, returning a string. ///
* When "convert" is TRUE convert a List into a sequence of lines and convert /// @param convert when true convert a List into a sequence of lines and convert
* a Float to a String. /// a Float to a String.
* Return pointer to allocated memory, or NULL for failure. ///
*/ /// @return pointer to allocated memory, or NULL for failure.
char_u *eval_to_string(char_u *arg, char_u **nextcmd, int convert) char_u *eval_to_string(char_u *arg, char_u **nextcmd, bool convert)
{ {
typval_T tv; typval_T tv;
char *retval; char *retval;
@@ -8520,7 +8520,7 @@ static char_u *make_expanded_name(const char_u *in_start, char_u *expr_start,
c1 = *in_end; c1 = *in_end;
*in_end = NUL; *in_end = NUL;
temp_result = eval_to_string(expr_start + 1, &nextcmd, FALSE); temp_result = eval_to_string(expr_start + 1, &nextcmd, false);
if (temp_result != NULL && nextcmd == NULL) { if (temp_result != NULL && nextcmd == NULL) {
retval = xmalloc(STRLEN(temp_result) + (expr_start - in_start) retval = xmalloc(STRLEN(temp_result) + (expr_start - in_start)
+ (in_end - expr_end) + 1); + (in_end - expr_end) + 1);

View File

@@ -6431,9 +6431,9 @@ static void ex_colorscheme(exarg_T *eap)
char_u *expr = vim_strsave((char_u *)"g:colors_name"); char_u *expr = vim_strsave((char_u *)"g:colors_name");
char_u *p = NULL; char_u *p = NULL;
++emsg_off; emsg_off++;
p = eval_to_string(expr, NULL, FALSE); p = eval_to_string(expr, NULL, false);
--emsg_off; emsg_off--;
xfree(expr); xfree(expr);
if (p != NULL) { if (p != NULL) {

View File

@@ -5546,7 +5546,7 @@ char_u * file_pat_to_reg_pat(const char_u *pat, const char_u *pat_end, char *all
char_u *reg_pat; char_u *reg_pat;
const char_u *p; const char_u *p;
int nested = 0; int nested = 0;
int add_dollar = TRUE; bool add_dollar = true;
if (allow_dirs != NULL) { if (allow_dirs != NULL) {
*allow_dirs = FALSE; *allow_dirs = FALSE;

View File

@@ -143,12 +143,10 @@ int hasAnyFolding(win_T *win)
} }
// hasFolding() {{{2 // hasFolding() {{{2
/* /// When returning true, *firstp and *lastp are set to the first and last
* Return TRUE if line "lnum" in the current window is part of a closed /// lnum of the sequence of folded lines (skipped when NULL).
* fold. ///
* When returning TRUE, *firstp and *lastp are set to the first and last /// @return true if line "lnum" in the current window is part of a closed fold.
* lnum of the sequence of folded lines (skipped when NULL).
*/
bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp) bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
{ {
return hasFoldingWin(curwin, lnum, firstp, lastp, true, NULL); return hasFoldingWin(curwin, lnum, firstp, lastp, true, NULL);
@@ -545,11 +543,9 @@ static int checkCloseRec(garray_T *gap, linenr_T lnum, int level)
} }
// foldCreateAllowed() {{{2 // foldCreateAllowed() {{{2
/* /// Return TRUE if it's allowed to manually create or delete a fold.
* Return TRUE if it's allowed to manually create or delete a fold. /// Give an error message and return FALSE if not.
* Give an error message and return FALSE if not. int foldManualAllowed(bool create)
*/
int foldManualAllowed(int create)
{ {
if (foldmethodIsManual(curwin) || foldmethodIsMarker(curwin)) { if (foldmethodIsManual(curwin) || foldmethodIsMarker(curwin)) {
return TRUE; return TRUE;
@@ -1106,12 +1102,11 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
} }
// foldFind() {{{2 // foldFind() {{{2
/* /// Search for line "lnum" in folds of growarray "gap".
* Search for line "lnum" in folds of growarray "gap". /// Set *fpp to the fold struct for the fold that contains "lnum" or
* Set *fpp to the fold struct for the fold that contains "lnum" or /// the first fold below it (careful: it can be beyond the end of the array!).
* the first fold below it (careful: it can be beyond the end of the array!). ///
* Returns FALSE when there is no fold that contains "lnum". /// @return false when there is no fold that contains "lnum".
*/
static bool foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp) static bool foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp)
{ {
linenr_T low, high; linenr_T low, high;
@@ -1141,7 +1136,7 @@ static bool foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp)
} else { } else {
// lnum is inside this fold // lnum is inside this fold
*fpp = fp + i; *fpp = fp + i;
return TRUE; return true;
} }
} }
*fpp = fp + low; *fpp = fp + low;
@@ -1906,8 +1901,8 @@ void foldtext_cleanup(char_u *str)
{ {
char_u *s; char_u *s;
char_u *p; char_u *p;
int did1 = FALSE; bool did1 = false;
int did2 = FALSE; bool did2 = false;
// Ignore leading and trailing white space in 'commentstring'. // Ignore leading and trailing white space in 'commentstring'.
char_u *cms_start = skipwhite(curbuf->b_p_cms); char_u *cms_start = skipwhite(curbuf->b_p_cms);
@@ -1960,11 +1955,11 @@ void foldtext_cleanup(char_u *str)
} else if (cms_end != NULL) { } else if (cms_end != NULL) {
if (!did1 && cms_slen > 0 && STRNCMP(s, cms_start, cms_slen) == 0) { if (!did1 && cms_slen > 0 && STRNCMP(s, cms_start, cms_slen) == 0) {
len = cms_slen; len = cms_slen;
did1 = TRUE; did1 = true;
} else if (!did2 && cms_elen > 0 } else if (!did2 && cms_elen > 0
&& STRNCMP(s, cms_end, cms_elen) == 0) { && STRNCMP(s, cms_end, cms_elen) == 0) {
len = cms_elen; len = cms_elen;
did2 = TRUE; did2 = true;
} }
} }
if (len != 0) { if (len != 0) {

View File

@@ -3916,9 +3916,9 @@ eval_map_expr (
save_cursor = curwin->w_cursor; save_cursor = curwin->w_cursor;
save_msg_col = msg_col; save_msg_col = msg_col;
save_msg_row = msg_row; save_msg_row = msg_row;
p = eval_to_string(expr, NULL, FALSE); p = eval_to_string(expr, NULL, false);
--textlock; textlock--;
--ex_normal_lock; ex_normal_lock--;
curwin->w_cursor = save_cursor; curwin->w_cursor = save_cursor;
msg_col = save_msg_col; msg_col = save_msg_col;
msg_row = save_msg_row; msg_row = save_msg_row;

View File

@@ -765,9 +765,9 @@ char_u *get_expr_line(void)
return expr_copy; return expr_copy;
} }
++nested; nested++;
rv = eval_to_string(expr_copy, NULL, TRUE); rv = eval_to_string(expr_copy, NULL, true);
--nested; nested--;
xfree(expr_copy); xfree(expr_copy);
return rv; return rv;
} }
@@ -1237,16 +1237,14 @@ int insert_reg(int regname, bool literally_arg)
return retval; return retval;
} }
/* /// Stuff a string into the typeahead buffer, such that edit() will insert it
* Stuff a string into the typeahead buffer, such that edit() will insert it /// literally ("literally" true) or interpret is as typed characters.
* literally ("literally" TRUE) or interpret is as typed characters. static void stuffescaped(const char *arg, bool literally)
*/
static void stuffescaped(const char *arg, int literally)
{ {
while (*arg != NUL) { while (*arg != NUL) {
// Stuff a sequence of normal ASCII characters, that's fast. Also // Stuff a sequence of normal ASCII characters, that's fast. Also
// stuff K_SPECIAL to get the effect of a special key when "literally" // stuff K_SPECIAL to get the effect of a special key when "literally"
// is TRUE. // is true.
const char *const start = arg; const char *const start = arg;
while ((*arg >= ' ' && *arg < DEL) || ((uint8_t)(*arg) == K_SPECIAL while ((*arg >= ' ' && *arg < DEL) || ((uint8_t)(*arg) == K_SPECIAL
&& !literally)) { && !literally)) {
@@ -2890,7 +2888,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
int indent; int indent;
int orig_indent = 0; // init for gcc int orig_indent = 0; // init for gcc
int indent_diff = 0; // init for gcc int indent_diff = 0; // init for gcc
int first_indent = TRUE; bool first_indent = true;
int lendiff = 0; int lendiff = 0;
pos_T old_pos; pos_T old_pos;
char_u *insert_string = NULL; char_u *insert_string = NULL;
@@ -3487,7 +3485,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
} else if (first_indent) { } else if (first_indent) {
indent_diff = orig_indent - get_indent(); indent_diff = orig_indent - get_indent();
indent = orig_indent; indent = orig_indent;
first_indent = FALSE; first_indent = false;
} else if ((indent = get_indent() + indent_diff) < 0) { } else if ((indent = get_indent() + indent_diff) < 0) {
indent = 0; indent = 0;
} }

View File

@@ -1349,11 +1349,11 @@ static int expand_backtick(
// Create the command: lop off the backticks. // Create the command: lop off the backticks.
char_u *cmd = vim_strnsave(pat + 1, STRLEN(pat) - 2); char_u *cmd = vim_strnsave(pat + 1, STRLEN(pat) - 2);
if (*cmd == '=') /* `={expr}`: Expand expression */ if (*cmd == '=') { // `={expr}`: Expand expression
buffer = eval_to_string(cmd + 1, &p, TRUE); buffer = eval_to_string(cmd + 1, &p, true);
else } else {
buffer = get_cmd_output(cmd, NULL, buffer = get_cmd_output(cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0, NULL);
(flags & EW_SILENT) ? kShellOptSilent : 0, NULL); }
xfree(cmd); xfree(cmd);
if (buffer == NULL) { if (buffer == NULL) {
return -1; return -1;

View File

@@ -5335,9 +5335,9 @@ bool get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len)
curbuf = wp->w_buffer; curbuf = wp->w_buffer;
curwin = wp; curwin = wp;
STRCPY(buf, "b:keymap_name"); // must be writable STRCPY(buf, "b:keymap_name"); // must be writable
++emsg_skip; emsg_skip++;
s = p = eval_to_string(buf, NULL, FALSE); s = p = eval_to_string(buf, NULL, false);
--emsg_skip; emsg_skip--;
curbuf = old_curbuf; curbuf = old_curbuf;
curwin = old_curwin; curwin = old_curwin;
if (p == NULL || *p == NUL) { if (p == NULL || *p == NUL) {