From 20d7583c4021cb2e44beabcb8b2926dd7d7bbbbf Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Nov 2012 15:34:48 -0500 Subject: [PATCH] Use C99 booleans. --- linebyline.c | 7 ++++--- main.c | 5 +++-- report.c | 3 ++- shredtree.c | 9 +++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/linebyline.c b/linebyline.c index 4bbbcfe..a4bc014 100644 --- a/linebyline.c +++ b/linebyline.c @@ -10,12 +10,13 @@ NAME: #include #include #include +#include #include "shred.h" /* control bits */ -static int remove_braces = 0; -static int remove_whitespace = 0; -static int remove_comments = 0; +static bool remove_braces = false; +static bool remove_whitespace = false; +static bool remove_comments = false; static char *c_patterns[] = { /* Idioms that don't convey any meaning in isolation */ diff --git a/main.c b/main.c index 80b0716..b0c7221 100644 --- a/main.c +++ b/main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "shred.h" int verbose, debug, minsize, nofilter; @@ -49,7 +50,7 @@ struct filehdr_t *register_file(const char *file, linenum_t length) return(new); } -static int is_scf_file(const char *file) +static bool is_scf_file(const char *file) /* is the specified file an SCF hash list? */ { char buf[BUFSIZ]; @@ -63,7 +64,7 @@ static int is_scf_file(const char *file) return(0); } fclose(fp); - return(!strncmp(buf, "#SCF-A ", 7)); + return(strncmp(buf, "#SCF-A ", 7) == 0); } /* diff --git a/report.c b/report.c index 03c9109..9dce37c 100644 --- a/report.c +++ b/report.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "shred.h" #define min(x, y) ((x < y) ? (x) : (y)) @@ -76,7 +77,7 @@ static int merge_ranges(struct sorthash_t *p, return(1); } -static int sametree(const char *s, const char *t) +static bool sametree(const char *s, const char *t) /* are two files from the same tree? */ { int sn = strchr(s, '/') - s; diff --git a/shredtree.c b/shredtree.c index bb3edd8..60fdb16 100644 --- a/shredtree.c +++ b/shredtree.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "shred.h" /* control bits, meant to be set at startup */ @@ -39,17 +40,17 @@ static int file_count; #define MIN_PRINTABLE 0.9 -static int eligible(const char *file) +static bool eligible(const char *file) /* is the specified file eligible to be compared? */ { #define endswith(suff) !strcmp(suff, file + strlen(file) - strlen(suff)) if (strstr(file, "CVS") || strstr(file,"RCS") || strstr(file,"SCCS") || strstr(file, "SVN") || endswith(".svn") || endswith(".git") || endswith(".hg") || endswith(".bzr")) - return(0); + return(false); /* fast check for the most common suffixes */ else if (endswith(".c") || endswith(".h") || endswith(".html")) - return(1); + return(true); else if (endswith(".o") || endswith("~") || endswith(".bdf")) - return(0); + return(false); #undef endswith else { -- 2.43.0