gbranden pushed a commit to branch master
in repository groff.

commit db9150376b2f3fbc362a73144dcfb72e9f726b45
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Apr 10 02:42:26 2026 -0500

    [libgroff]: Implement `symbol::contains()`.
    
    * src/include/symbol.h: Preprocessor-include "<string.h>" header file to
      access strchr(3).
    
      (class symbol): Declare new member function `contains()` indicating
      whether the `char` argument appears the symbol.
    
      (symbol::contains): Implement it `inline`, wrapping strchr(3).
---
 ChangeLog            | 9 +++++++++
 src/include/symbol.h | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 921e2abfd..fa799425d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-04-10  G. Branden Robinson <[email protected]>
+
+       * src/include/symbol.h: Preprocessor-include "<string.h>" header
+       file to access strchr(3).
+       (class symbol): Declare new member function
+       `contains()` indicating whether the `char` argument appears the
+       symbol.
+       (symbol::contains): Implement it `inline`, wrapping strchr(3).
+
 2026-04-10  G. Branden Robinson <[email protected]>
 
        * src/include/symbol.h (class symbol): Comment formal argument
diff --git a/src/include/symbol.h b/src/include/symbol.h
index d526731ed..be19c58f7 100644
--- a/src/include/symbol.h
+++ b/src/include/symbol.h
@@ -19,6 +19,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include <stddef.h> // size_t
 #include <stdint.h> // uintptr_t
+#include <string.h> // strchr()
 
 #define DONT_STORE 1
 #define MUST_ALREADY_EXIST 2
@@ -37,6 +38,7 @@ public:
   int operator ==(symbol) const;
   int operator !=(symbol) const;
   const char *contents() const;
+  bool contains(char) const;
   bool is_null() const;
   bool is_empty() const;
   size_t json_length() const;
@@ -72,6 +74,11 @@ inline const char *symbol::contents() const
   return s;
 }
 
+inline bool symbol::contains(char c) const
+{
+  return strchr(s, c) != 0 /* nullptr */;
+}
+
 inline bool symbol::is_null() const
 {
   return (0 /* nullptr */ == s);

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

Reply via email to