Subject: Re: [PATCH 1/2] dfa: prefer bool at DFA interfaces

From: Paul Eggert <[email-masked]>
Date: Sun, 1 May 2016 23:02:00 -0700

I installed these patches, along with the attached further patch along the same
lines.
>From e5654c5e82a9d412ea3a43c18dd647dce7f96c4d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 1 May 2016 22:55:18 -0700
Subject: [PATCH] dfa: prefer bool for boolean

* src/dfa.c (syntax_bits_set, dfasyntax, using_utf8, FETCH_WC)
(POP_LEX_STATE, State_transition):
* src/dfa.h (using_utf_8):
Use bool for boolean.
---
 src/dfa.c | 13 +++++++------
 src/dfa.h |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index a2aee29..c57b33a 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -641,7 +641,8 @@ charclass_index (charclass const s)
 }
 
 /* Syntax bits controlling the behavior of the lexical analyzer.  */
-static reg_syntax_t syntax_bits, syntax_bits_set;
+static reg_syntax_t syntax_bits;
+static bool syntax_bits_set;
 
 /* Flag for case-folding letters into sets.  */
 static bool case_fold;
@@ -693,7 +694,7 @@ void
 dfasyntax (reg_syntax_t bits, bool fold, unsigned char eol)
 {
   int i;
-  syntax_bits_set = 1;
+  syntax_bits_set = true;
   syntax_bits = bits;
   case_fold = fold;
   eolbyte = eol;
@@ -757,7 +758,7 @@ setbit_case_fold_c (int b, charclass c)
 
 /* UTF-8 encoding allows some optimizations that we can't otherwise
    assume in a multibyte encoding.  */
-int
+bool
 using_utf8 (void)
 {
   static int utf8 = -1;
@@ -858,7 +859,7 @@ static wint_t wctok;		/* Wide character representation of the current
         lexptr += nbytes;			\
         lexleft -= nbytes;			\
       }						\
-  } while (0)
+  } while (false)
 
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -1211,7 +1212,7 @@ parse_bracket_exp (void)
       lexptr = lexptr_saved;			\
       lexleft = lexleft_saved;			\
     }						\
-  while (0)
+  while (false)
 
 static token
 lex (void)
@@ -3327,7 +3328,7 @@ dfaexec_main (struct dfa *d, char const *begin, char *end, bool allow_nl,
                                                                         \
               mbp = p;                                                  \
               trans = d->trans;                                         \
-  } while (0)
+  } while (false)
 
               State_transition();
             }
diff --git a/src/dfa.h b/src/dfa.h
index ce267ec..60da0e4 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -100,4 +100,4 @@ extern void dfawarn (const char *);
    The user must supply a dfaerror.  */
 extern _Noreturn void dfaerror (const char *);
 
-extern int using_utf8 (void);
+extern bool using_utf8 (void);
-- 
2.5.5