From: Joel E. Denny <jdenny@clemson.edu>
Date: Fri, 16 Oct 2009 23:27:12 +0000 (-0400)
Subject: cleanup.
X-Git-Tag: v2.5_rc1~144
X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/aa01d1934c885be15a961700808c9a786ff23a40

cleanup.

* src/Sbitset.c (Sbitset__new_on_obstack): Use Sbitset instead
of char*.
(Sbitset__isEmpty): Use Sbitset instead of char*.
* src/Sbitset.h (Sbitset): Make it a pointer to unsigned char
instead of char.  This helps to avoid casting errors.
(Sbitset__or): Use Sbitset instead of char*.
(cherry picked from commit 5297ebb3bcdf4f957bdab9c5535c2c9c47f7dc07)
---

diff --git a/ChangeLog b/ChangeLog
index 00343fc8..79572826 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-16  Joel E. Denny  <jdenny@clemson.edu>
+
+	cleanup.
+	* src/Sbitset.c (Sbitset__new_on_obstack): Use Sbitset instead
+	of char*.
+	(Sbitset__isEmpty): Use Sbitset instead of char*.
+	* src/Sbitset.h (Sbitset): Make it a pointer to unsigned char
+	instead of char.  This helps to avoid casting errors.
+	(Sbitset__or): Use Sbitset instead of char*.
+
 2009-10-16  Joel E. Denny  <jdenny@clemson.edu>
 
 	portability: don't assume 8-bit bytes.
diff --git a/src/Sbitset.c b/src/Sbitset.c
index af8600bd..742b5659 100644
--- a/src/Sbitset.c
+++ b/src/Sbitset.c
@@ -33,9 +33,9 @@ Sbitset__new (Sbitset__Index nbits)
 Sbitset
 Sbitset__new_on_obstack (Sbitset__Index nbits, struct obstack *obstackp)
 {
-  char *result;
-  char *ptr;
-  char *end;
+  Sbitset result;
+  Sbitset ptr;
+  Sbitset end;
   aver (nbits);
   result = obstack_alloc (obstackp, Sbitset__nbytes (nbits));
   for (ptr = result, end = result + Sbitset__nbytes (nbits); ptr < end; ++ptr)
@@ -52,7 +52,7 @@ Sbitset__delete (Sbitset self)
 bool
 Sbitset__isEmpty (Sbitset self, Sbitset__Index nbits)
 {
-  char *last = self + Sbitset__nbytes (nbits) - 1;
+  Sbitset last = self + Sbitset__nbytes (nbits) - 1;
   for (; self < last; ++self)
     if (*self != 0)
       return false;
diff --git a/src/Sbitset.h b/src/Sbitset.h
index 0d0aabf8..e379398f 100644
--- a/src/Sbitset.h
+++ b/src/Sbitset.h
@@ -20,7 +20,7 @@
 #ifndef SBITSET_H_
 # define SBITSET_H_
 
-typedef char *Sbitset;
+typedef unsigned char *Sbitset;
 typedef size_t Sbitset__Index;
 #define SBITSET__INDEX__CONVERSION_SPEC "zu"
 
@@ -73,10 +73,10 @@ do {                                                                          \
 /* NBITS is the size of every bitset.  More than NBITS bits might be set.  */
 #define Sbitset__or(SELF, OTHER1, OTHER2, NBITS)                              \
 do {                                                                          \
-  char *ptr_self = (SELF);                                                    \
-  char *ptr_other1 = (OTHER1);                                                \
-  char *ptr_other2 = (OTHER2);                                                \
-  char *end_self = ptr_self + Sbitset__nbytes (NBITS);                        \
+  Sbitset ptr_self = (SELF);                                                  \
+  Sbitset ptr_other1 = (OTHER1);                                              \
+  Sbitset ptr_other2 = (OTHER2);                                              \
+  Sbitset end_self = ptr_self + Sbitset__nbytes (NBITS);                      \
   for (; ptr_self < end_self; ++ptr_self, ++ptr_other1, ++ptr_other2)         \
     *ptr_self = *ptr_other1 | *ptr_other2;                                    \
 } while(0)