gbranden pushed a commit to branch master
in repository groff.
commit 434ba362381a5602537cf70b0a3b6f4529dd782b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Aug 13 08:05:51 2024 -0500
src/include/symbol.h: Boolify.
* src/include/symbol.h (class symbol): Boolify `is_null()` and
`is_empty()` member functions.
Also annotate null pointers with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
Also comment out parameter names in prototypes, in a compromise with the
Stroustrup-style C++ used in most of groff.
---
ChangeLog | 5 +++++
src/include/symbol.h | 16 ++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 772285396..483918e64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-08-13 G. Branden Robinson <[email protected]>
+
+ * src/include/symbol.h (class symbol): Boolify `is_null()` and
+ `is_empty()` member functions.
+
2024-08-13 G. Branden Robinson <[email protected]>
[troff]: Rename `WARN_TOTAL` symbol to `WARN_MAX` for
diff --git a/src/include/symbol.h b/src/include/symbol.h
index bafee4c9a..8dd162a19 100644
--- a/src/include/symbol.h
+++ b/src/include/symbol.h
@@ -29,21 +29,21 @@ class symbol {
static size_t block_size;
const char *s;
public:
- symbol(const char *p, int how = 0);
+ symbol(const char *p, int /* how */ = 0);
symbol();
uintptr_t hash() const;
int operator ==(symbol) const;
int operator !=(symbol) const;
const char *contents() const;
- int is_null() const;
- int is_empty() const;
+ bool is_null() const;
+ bool is_empty() const;
};
extern const symbol NULL_SYMBOL;
extern const symbol EMPTY_SYMBOL;
-inline symbol::symbol() : s(0)
+inline symbol::symbol() : s(0 /* nullptr */)
{
}
@@ -67,14 +67,14 @@ inline const char *symbol::contents() const
return s;
}
-inline int symbol::is_null() const
+inline bool symbol::is_null() const
{
- return s == 0;
+ return (0 /* nullptr */ == s);
}
-inline int symbol::is_empty() const
+inline bool symbol::is_empty() const
{
- return s != 0 && *s == 0;
+ return ((s != 0 /* nullptr */) && (0 /* nullptr */ == *s));
}
symbol concat(symbol, symbol);
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit