]> thyrsus.com Git - comparator.git/commitdiff
Use C99 booleans.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 24 Nov 2012 20:34:48 +0000 (15:34 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 24 Nov 2012 20:34:48 +0000 (15:34 -0500)
linebyline.c
main.c
report.c
shredtree.c

index 4bbbcfee721a45c17ec8f2e1309f71ba30bbb476..a4bc0145afeb1d5803de46939514e0fa93913215 100644 (file)
@@ -10,12 +10,13 @@ NAME:
 #include <regex.h>
 #include <ctype.h>
 #include <string.h>
+#include <stdbool.h>
 #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 80b0716692f3f2dc83dc4a6926e6bb166bcfc7f6..b0c722114132d522d3eab966c3892e748b07156e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -12,6 +12,7 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <time.h>
+#include <stdbool.h>
 #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);
 }
 
 /* 
index 03c910979c64319507843da673d764bd7d3d1b52..9dce37ceb062de81955f61bdceb9196df7ac0514 100644 (file)
--- a/report.c
+++ b/report.c
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <stdbool.h>
 #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;
index bb3edd8c422648003c4cb7f479bf3e62e137c1fd..60fdb16c3479024b02c94104c4a9bd5bd521fb7e 100644 (file)
@@ -16,6 +16,7 @@
 #include <errno.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #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
     {