gbranden pushed a commit to branch master
in repository groff.

commit dbe2b90dc6c6544896724f125c4210cd6a68a441
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Jun 6 09:15:20 2026 -0500

    [libgroff]: Boolify groff's `string` class.
    
    * src/include/stringclass.h:
    * src/libs/libgroff/string.cpp: Demote return values of `operator==()`,
      `operator!=()`, `empty()`, `operator<=()`, `operator<()`,
      `operator>=()`, and `operator>()` from `int` to `bool`.
---
 ChangeLog                    | 10 ++++++++++
 src/include/stringclass.h    | 24 ++++++++++++------------
 src/libs/libgroff/string.cpp |  8 ++++----
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a1cdc3af2..d683dfdfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-06-06  G. Branden Robinson <[email protected]>
+
+       [libgroff]: Boolify groff's `string` class.
+
+       * src/include/stringclass.h:
+       * src/libs/libgroff/string.cpp: Demote return values of
+       `operator==()`, `operator!=()`, `empty()`, `operator<=()`,
+       `operator<()`, `operator>=()`, and `operator>()` from `int` to
+       `bool`.
+
 2026-06-04  G. Branden Robinson <[email protected]>
 
        * src/libs/libgroff/string.cpp: Use ISO C++98 exceptions to
diff --git a/src/include/stringclass.h b/src/include/stringclass.h
index 9f8883f8d..93ecc2934 100644
--- a/src/include/stringclass.h
+++ b/src/include/stringclass.h
@@ -34,8 +34,8 @@ inline string operator+(const string &, const char *);
 inline string operator+(const char *, const string &);
 inline string operator+(const string &, char);
 inline string operator+(char, const string &);
-inline int operator==(const string &, const string &);
-inline int operator!=(const string &, const string &);
+inline bool operator==(const string &, const string &);
+inline bool operator!=(const string &, const string &);
 
 class string {
 public:
@@ -57,7 +57,7 @@ public:
   void append(const char *, int);
 
   int length() const;
-  int empty() const;
+  bool empty() const;
   int operator*() const;
 
   string substring(int i, int n) const;
@@ -84,12 +84,12 @@ public:
   friend string operator+(const string &, char);
   friend string operator+(char, const string &);
 
-  friend int operator==(const string &, const string &);
-  friend int operator!=(const string &, const string &);
-  friend int operator<=(const string &, const string &);
-  friend int operator<(const string &, const string &);
-  friend int operator>=(const string &, const string &);
-  friend int operator>(const string &, const string &);
+  friend bool operator==(const string &, const string &);
+  friend bool operator!=(const string &, const string &);
+  friend bool operator<=(const string &, const string &);
+  friend bool operator<(const string &, const string &);
+  friend bool operator>=(const string &, const string &);
+  friend bool operator>(const string &, const string &);
 
 private:
   char *ptr;
@@ -118,7 +118,7 @@ inline int string::length() const
   return len;
 }
 
-inline int string::empty() const
+inline bool string::empty() const
 {
   return (len == 0);
 }
@@ -160,13 +160,13 @@ inline string operator+(char c, const string &s)
   return string(&c, 1, s.ptr, s.len);
 }
 
-inline int operator==(const string &s1, const string &s2)
+inline bool operator==(const string &s1, const string &s2)
 {
   return (s1.len == s2.len
          && (s1.len == 0 || memcmp(s1.ptr, s2.ptr, s1.len) == 0));
 }
 
-inline int operator!=(const string &s1, const string &s2)
+inline bool operator!=(const string &s1, const string &s2)
 {
   return (s1.len != s2.len
          || (s1.len != 0 && memcmp(s1.ptr, s2.ptr, s1.len) != 0));
diff --git a/src/libs/libgroff/string.cpp b/src/libs/libgroff/string.cpp
index 3127aee6e..f5ea0464a 100644
--- a/src/libs/libgroff/string.cpp
+++ b/src/libs/libgroff/string.cpp
@@ -283,28 +283,28 @@ string::string(const char *s1, int n1, const char *s2, 
int n2)
   }
 }
 
-int operator<=(const string &s1, const string &s2)
+bool operator<=(const string &s1, const string &s2)
 {
   return ((s1.len <= s2.len)
          ? ((s1.len == 0) || (memcmp(s1.ptr, s2.ptr, s1.len) <= 0))
          : ((s2.len != 0) && (memcmp(s1.ptr, s2.ptr, s2.len) < 0)));
 }
 
-int operator<(const string &s1, const string &s2)
+bool operator<(const string &s1, const string &s2)
 {
   return ((s1.len < s2.len)
          ? ((s1.len == 0) || (memcmp(s1.ptr, s2.ptr, s1.len) <= 0))
          : ((s2.len != 0) && (memcmp(s1.ptr, s2.ptr, s2.len) < 0)));
 }
 
-int operator>=(const string &s1, const string &s2)
+bool operator>=(const string &s1, const string &s2)
 {
   return ((s1.len >= s2.len)
          ? ((s2.len == 0) || (memcmp(s1.ptr, s2.ptr, s2.len) >= 0))
          : ((s1.len != 0) && (memcmp(s1.ptr, s2.ptr, s1.len) > 0)));
 }
 
-int operator>(const string &s1, const string &s2)
+bool operator>(const string &s1, const string &s2)
 {
   return ((s1.len > s2.len)
          ? ((s2.len == 0) || (memcmp(s1.ptr, s2.ptr, s2.len) >= 0))

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to