Skip to content

Commit

Permalink
Replace some uses of 0 and 1 as boolean constants with TRUE/FALSE mac…
Browse files Browse the repository at this point in the history
…ros.
  • Loading branch information
gwsw committed Nov 14, 2023
1 parent b469710 commit 2f5faad
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 52 deletions.
14 changes: 7 additions & 7 deletions charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ static int is_in_table(LWCHAR ch, struct wchar_range_table *table)

/* Binary search in the table. */
if (table->table == NULL || table->count == 0 || ch < table->table[0].first)
return 0;
return FALSE;
lo = 0;
hi = table->count - 1;
while (lo <= hi)
Expand All @@ -861,9 +861,9 @@ static int is_in_table(LWCHAR ch, struct wchar_range_table *table)
else if (ch < table->table[mid].first)
hi = mid - 1;
else
return 1;
return TRUE;
}
return 0;
return FALSE;
}

/*
Expand All @@ -872,7 +872,7 @@ static int is_in_table(LWCHAR ch, struct wchar_range_table *table)
*/
public int is_composing_char(LWCHAR ch)
{
if (is_in_table(ch, &user_prt_table)) return 0;
if (is_in_table(ch, &user_prt_table)) return FALSE;
return is_in_table(ch, &user_compose_table) ||
is_in_table(ch, &compose_table) ||
(bs_mode != BS_CONTROL && is_in_table(ch, &fmt_table));
Expand All @@ -883,7 +883,7 @@ public int is_composing_char(LWCHAR ch)
*/
public int is_ubin_char(LWCHAR ch)
{
if (is_in_table(ch, &user_prt_table)) return 0;
if (is_in_table(ch, &user_prt_table)) return FALSE;
return is_in_table(ch, &user_ubin_table) ||
is_in_table(ch, &ubin_table) ||
(bs_mode == BS_CONTROL && is_in_table(ch, &fmt_table));
Expand Down Expand Up @@ -911,8 +911,8 @@ public int is_combining_char(LWCHAR ch1, LWCHAR ch2)
{
if (ch1 == comb_table[i].first &&
ch2 == comb_table[i].last)
return 1;
return TRUE;
}
return 0;
return FALSE;
}

44 changes: 22 additions & 22 deletions cmdbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int cmd_complete(int action);
/*
* These variables are statics used by cmd_complete.
*/
static int in_completion = 0;
static int in_completion = FALSE;
static char *tk_text;
static char *tk_original;
static constant char *tk_ipoint;
Expand Down Expand Up @@ -771,8 +771,8 @@ public void cmd_accept(void)
*/
if (curr_mlist == NULL || curr_mlist == ml_examine)
return;
cmd_addhist(curr_mlist, cmdbuf, 1);
curr_mlist->modified = 1;
cmd_addhist(curr_mlist, cmdbuf, TRUE);
curr_mlist->modified = TRUE;
#endif
}

Expand Down Expand Up @@ -927,8 +927,8 @@ static char * delimit_word(void)
char *word;
#if SPACES_IN_FILENAMES
char *p;
int delim_quoted = 0;
int meta_quoted = 0;
int delim_quoted = FALSE;
int meta_quoted = FALSE;
constant char *esc = get_meta_escape();
size_t esclen = strlen(esc);
#endif
Expand Down Expand Up @@ -981,20 +981,20 @@ static char * delimit_word(void)
{
if (meta_quoted)
{
meta_quoted = 0;
meta_quoted = FALSE;
} else if (esclen > 0 && p + esclen < cp &&
strncmp(p, esc, esclen) == 0)
{
meta_quoted = 1;
meta_quoted = TRUE;
p += esclen - 1;
} else if (delim_quoted)
{
if (*p == closequote)
delim_quoted = 0;
delim_quoted = FALSE;
} else /* (!delim_quoted) */
{
if (*p == openquote)
delim_quoted = 1;
delim_quoted = TRUE;
else if (*p == ' ')
word = p+1;
}
Expand Down Expand Up @@ -1117,7 +1117,7 @@ static int cmd_complete(int action)
/*
* Use the first filename in the list.
*/
in_completion = 1;
in_completion = TRUE;
init_textlist(&tk_tlist, tk_text);
tk_trial = next_compl(action, (char*)NULL);
}
Expand All @@ -1142,7 +1142,7 @@ static int cmd_complete(int action)
* There are no more trial completions.
* Insert the original (uncompleted) filename.
*/
in_completion = 0;
in_completion = FALSE;
if (cmd_istr(tk_original) != CC_OK)
goto fail;
} else
Expand Down Expand Up @@ -1170,7 +1170,7 @@ static int cmd_complete(int action)
return (CC_OK);

fail:
in_completion = 0;
in_completion = FALSE;
bell();
return (CC_OK);
}
Expand Down Expand Up @@ -1390,7 +1390,7 @@ static char * histfile_name(int must_exist)
if (!must_exist)
{
/* If we're writing the file and the file already exists, use it. */
wname = histfile_find(1);
wname = histfile_find(TRUE);
}
if (wname == NULL)
wname = histfile_find(must_exist);
Expand All @@ -1408,7 +1408,7 @@ static void read_cmdhist2(void (*action)(void*,struct mlist*,constant char*), vo
FILE *f;
int *skip = NULL;

filename = histfile_name(1);
filename = histfile_name(TRUE);
if (filename == NULL)
return;
f = fopen(filename, "r");
Expand Down Expand Up @@ -1516,9 +1516,9 @@ static void write_mlist(struct mlist *ml, FILE *f)
if (!ml->modified)
continue;
fprintf(f, "\"%s\n", ml->string);
ml->modified = 0;
ml->modified = FALSE;
}
ml->modified = 0; /* entire mlist is now unmodified */
ml->modified = FALSE; /* entire mlist is now unmodified */
}

/*
Expand Down Expand Up @@ -1589,13 +1589,13 @@ static void copy_hist(void *uparam, struct mlist *ml, constant char *string)
static void make_file_private(FILE *f)
{
#if HAVE_FCHMOD
int do_chmod = 1;
int do_chmod = TRUE;
#if HAVE_STAT
struct stat statbuf;
int r = fstat(fileno(f), &statbuf);
if (r < 0 || !S_ISREG(statbuf.st_mode))
/* Don't chmod if not a regular file. */
do_chmod = 0;
do_chmod = FALSE;
#endif
if (do_chmod)
fchmod(fileno(f), 0600);
Expand All @@ -1609,14 +1609,14 @@ static void make_file_private(FILE *f)
static int histfile_modified(void)
{
if (mlist_search.modified)
return 1;
return TRUE;
#if SHELL_ESCAPE || PIPEC
if (mlist_shell.modified)
return 1;
return TRUE;
#endif
if (marks_modified)
return 1;
return 0;
return TRUE;
return FALSE;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void init_textlist(struct textlist *tlist, mutable char *str)
{
char *s;
#if SPACES_IN_FILENAMES
int meta_quoted = 0;
int delim_quoted = 0;
int meta_quoted = FALSE;
int delim_quoted = FALSE;
constant char *esc = get_meta_escape();
size_t esclen = strlen(esc);
#endif
Expand Down
2 changes: 1 addition & 1 deletion evar.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct replace {
*/
static size_t skipsl(constant char *buf, size_t len, size_t e)
{
int esc = 0;
int esc = FALSE;
while (e < len && buf[e] != '\0' && (esc || (buf[e] != '/' && buf[e] != '}')))
{
esc = (!esc && buf[e] == '\\');
Expand Down
8 changes: 4 additions & 4 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public char * shell_quote(constant char *s)
size_t len;
constant char *esc = get_meta_escape();
size_t esclen = strlen(esc);
int use_quotes = 0;
int have_quotes = 0;
int use_quotes = FALSE;
int have_quotes = FALSE;

/*
* Determine how big a string we need to allocate.
Expand All @@ -154,7 +154,7 @@ public char * shell_quote(constant char *s)
{
len++;
if (*p == openquote || *p == closequote)
have_quotes = 1;
have_quotes = TRUE;
if (metachar(*p))
{
if (esclen == 0)
Expand All @@ -163,7 +163,7 @@ public char * shell_quote(constant char *s)
* We've got a metachar, but this shell
* doesn't support escape chars. Use quotes.
*/
use_quotes = 1;
use_quotes = TRUE;
} else
{
/*
Expand Down
8 changes: 4 additions & 4 deletions forwback.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public int eof_displayed(void)
POSITION pos;

if (ignore_eoi)
return (0);
return (FALSE);

if (ch_length() == NULL_POSITION)
/*
* If the file length is not known,
* we can't possibly be displaying EOF.
*/
return (0);
return (FALSE);

/*
* If the bottom line is empty, we are at EOF.
Expand All @@ -96,7 +96,7 @@ public int entire_file_displayed(void)

/* Make sure last line of file is displayed. */
if (!eof_displayed())
return (0);
return (FALSE);

/* Make sure first line of file is displayed. */
pos = position(0);
Expand All @@ -113,7 +113,7 @@ public void squish_check(void)
{
if (!squished)
return;
squished = 0;
squished = FALSE;
repaint();
}

Expand Down
4 changes: 2 additions & 2 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ extern int show_attn;
static void init_status_col(POSITION base_pos, POSITION disp_pos, POSITION edisp_pos, POSITION eol_pos)
{
int hl_before = (chop_line() && disp_pos != NULL_POSITION) ?
is_hilited_attr(base_pos, disp_pos, TRUE, NULL) : 0;
is_hilited_attr(base_pos, disp_pos, TRUE, NULL) : FALSE;
int hl_after = (chop_line()) ?
is_hilited_attr(edisp_pos, eol_pos, TRUE, NULL) : 0;
is_hilited_attr(edisp_pos, eol_pos, TRUE, NULL) : FALSE;
int attr;
char ch;

Expand Down
8 changes: 4 additions & 4 deletions opttbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,8 @@ public struct loption * findopt_name(constant char **p_optname, constant char **
struct loption *maxo = NULL;
struct optname *maxoname = NULL;
size_t maxlen = 0;
int ambig = 0;
int exact = 0;
int ambig = FALSE;
int exact = FALSE;

/*
* Check all options.
Expand Down Expand Up @@ -843,7 +843,7 @@ public struct loption * findopt_name(constant char **p_optname, constant char **
* and now there's another one that
* matches the same length.
*/
ambig = 1;
ambig = TRUE;
else if (len > maxlen)
{
/*
Expand All @@ -853,7 +853,7 @@ public struct loption * findopt_name(constant char **p_optname, constant char **
maxo = o;
maxoname = oname;
maxlen = len;
ambig = 0;
ambig = FALSE;
exact = (len == (int)strlen(oname->oname));
}
if (!(o->otype & TRIPLE))
Expand Down
12 changes: 6 additions & 6 deletions os.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public ssize_t iread(int fd, unsigned char *buf, size_t len)
/*
* We jumped here from intread.
*/
reading = 0;
reading = FALSE;
#if HAVE_SIGPROCMASK
{
sigset_t mask;
Expand All @@ -214,7 +214,7 @@ public ssize_t iread(int fd, unsigned char *buf, size_t len)
}

flush();
reading = 1;
reading = TRUE;
#if MSDOS_COMPILER==DJGPPC
if (isatty(fd))
{
Expand All @@ -231,7 +231,7 @@ public ssize_t iread(int fd, unsigned char *buf, size_t len)
FD_SET(fd, &readfds);
if (select(fd+1, &readfds, 0, 0, 0) == -1)
{
reading = 0;
reading = FALSE;
return (READ_ERR);
}
}
Expand All @@ -244,7 +244,7 @@ public ssize_t iread(int fd, unsigned char *buf, size_t len)
{
if (ret == READ_INTR)
sigs |= S_INTERRUPT;
reading = 0;
reading = FALSE;
return (ret);
}
}
Expand All @@ -258,15 +258,15 @@ public ssize_t iread(int fd, unsigned char *buf, size_t len)
if (c == intr_char)
{
sigs |= S_INTERRUPT;
reading = 0;
reading = FALSE;
return (READ_INTR);
}
WIN32ungetch(c);
}
#endif
#endif
n = read(fd, buf, len);
reading = 0;
reading = FALSE;
#if 1
/*
* This is a kludge to workaround a problem on some systems
Expand Down

0 comments on commit 2f5faad

Please sign in to comment.