gbranden pushed a commit to branch master
in repository groff.
commit 90a5dbd2070c5fda174790b9f89f915c810694e7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Dec 19 13:56:10 2025 -0600
[troff]: Fix code style nits.
* src/roff/troff/input.cpp (token::next, token::get_charinfo)
(is_conditional_expression_true):
* src/roff/troff/token.h (token::is_newline, token::is_space)
(token::is_stretchable_space, token::is_unstretchable_space)
(token::is_horizontal_space, token::is_special_character)
(token::nspaces, token::is_white_space, token::is_transparent)
(token::is_page_ejector, token::ch, token::is_any_character)
(token::is_indexed_character, token::is_node, token::is_eof)
(token::is_dummy, token::is_transparent_dummy)
(token::is_left_brace, token::is_right_brace, token::is_tab)
(token::is_leader, token::is_backspace)
(token::is_hyphen_indicator, token::is_zero_width_break): Parenthesize
formally complex expressions. Arrange equality comparisons to avoid
inadvertent lvalue assignment.
---
ChangeLog | 18 +++++++++++++++++
src/roff/troff/input.cpp | 14 +++++++-------
src/roff/troff/token.h | 50 ++++++++++++++++++++++++------------------------
3 files changed, 50 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 64b12a3b9..bde58d111 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2025-12-19 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (token::next, token::get_charinfo)
+ (is_conditional_expression_true):
+ * src/roff/troff/token.h (token::is_newline, token::is_space)
+ (token::is_stretchable_space, token::is_unstretchable_space)
+ (token::is_horizontal_space, token::is_special_character)
+ (token::nspaces, token::is_white_space, token::is_transparent)
+ (token::is_page_ejector, token::ch, token::is_any_character)
+ (token::is_indexed_character, token::is_node, token::is_eof)
+ (token::is_dummy, token::is_transparent_dummy)
+ (token::is_left_brace, token::is_right_brace, token::is_tab)
+ (token::is_leader, token::is_backspace)
+ (token::is_hyphen_indicator, token::is_zero_width_break): Fix
+ code style nits. Parenthesize formally complex expressions.
+ Arrange equality comparisons to avoid inadvertent lvalue
+ assignment.
+
2025-12-19 G. Branden Robinson <[email protected]>
[troff]: Refactor to use the C++ default argument force. Merge
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6ab580b61..bfd6c7e91 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2690,7 +2690,7 @@ void token::next()
}
case 'z':
next();
- if (type == TOKEN_NODE || type == TOKEN_HORIZONTAL_SPACE)
+ if ((TOKEN_NODE == type) || (TOKEN_HORIZONTAL_SPACE == type))
nd = new zero_width_node(nd);
else {
// TODO: In theory, we could accept spaces and horizontal
@@ -7225,7 +7225,7 @@ static bool is_conditional_expression_true()
return false;
}
else
- result = n > 0;
+ result = (n > 0);
}
if (perform_output_comparison)
result = are_comparands_equal();
@@ -8860,13 +8860,13 @@ static charinfo *get_charinfo_by_index(int n,
charinfo *token::get_charinfo(bool required, bool suppress_creation)
{
- if (type == TOKEN_CHAR)
+ if (TOKEN_CHAR == type)
return charset_table[c];
- if (type == TOKEN_SPECIAL_CHAR)
+ if (TOKEN_SPECIAL_CHAR == type)
return lookup_charinfo(nm, suppress_creation);
- if (type == TOKEN_INDEXED_CHAR)
+ if (TOKEN_INDEXED_CHAR == type)
return get_charinfo_by_index(val, suppress_creation);
- if (type == TOKEN_ESCAPE) {
+ if (TOKEN_ESCAPE == type) {
if (escape_char != 0U)
return charset_table[escape_char];
else {
@@ -8879,7 +8879,7 @@ charinfo *token::get_charinfo(bool required, bool
suppress_creation)
}
}
if (required) {
- if (type == TOKEN_EOF || type == TOKEN_NEWLINE)
+ if (TOKEN_EOF == type || TOKEN_NEWLINE == type)
warning(WARN_MISSING, "missing ordinary, special, or indexed"
" character");
else
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 3fc74ab08..09892fa55 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -161,68 +161,68 @@ const char *asciify(int c);
inline bool token::is_newline()
{
- return type == TOKEN_NEWLINE;
+ return (TOKEN_NEWLINE == type);
}
inline bool token::is_space()
{
- return type == TOKEN_SPACE;
+ return (TOKEN_SPACE == type);
}
inline bool token::is_stretchable_space()
{
- return type == TOKEN_STRETCHABLE_SPACE;
+ return (TOKEN_STRETCHABLE_SPACE == type);
}
inline bool token::is_unstretchable_space()
{
- return type == TOKEN_UNSTRETCHABLE_SPACE;
+ return (TOKEN_UNSTRETCHABLE_SPACE == type);
}
inline bool token::is_horizontal_space()
{
- return type == TOKEN_HORIZONTAL_SPACE;
+ return (TOKEN_HORIZONTAL_SPACE == type);
}
inline bool token::is_special_character()
{
- return type == TOKEN_SPECIAL_CHAR;
+ return (TOKEN_SPECIAL_CHAR == type);
}
inline int token::nspaces()
{
- return int(type == TOKEN_SPACE);
+ return int(TOKEN_SPACE == type);
}
inline bool token::is_white_space()
{
- return type == TOKEN_SPACE || type == TOKEN_TAB;
+ return (TOKEN_SPACE == type || TOKEN_TAB == type);
}
inline bool token::is_transparent()
{
- return type == TOKEN_TRANSPARENT;
+ return (TOKEN_TRANSPARENT == type);
}
inline bool token::is_page_ejector()
{
- return type == TOKEN_PAGE_EJECTOR;
+ return (TOKEN_PAGE_EJECTOR == type);
}
inline unsigned char token::ch()
{
- return type == TOKEN_CHAR ? c : '\0';
+ return ((TOKEN_CHAR == type) ? c : '\0');
}
inline bool token::is_any_character()
{
- return (TOKEN_CHAR == type) || (TOKEN_SPECIAL_CHAR == type)
- || (TOKEN_INDEXED_CHAR == type);
+ return ((TOKEN_CHAR == type) || (TOKEN_SPECIAL_CHAR == type)
+ || (TOKEN_INDEXED_CHAR == type));
}
inline bool token::is_indexed_character()
{
- return TOKEN_INDEXED_CHAR == type;
+ return (TOKEN_INDEXED_CHAR == type);
}
inline int token::character_index()
@@ -233,57 +233,57 @@ inline int token::character_index()
inline bool token::is_node()
{
- return type == TOKEN_NODE;
+ return (TOKEN_NODE == type);
}
inline bool token::is_eof()
{
- return type == TOKEN_EOF;
+ return (TOKEN_EOF == type);
}
inline bool token::is_dummy()
{
- return type == TOKEN_DUMMY;
+ return (TOKEN_DUMMY == type);
}
inline bool token::is_transparent_dummy()
{
- return type == TOKEN_TRANSPARENT_DUMMY;
+ return (TOKEN_TRANSPARENT_DUMMY == type);
}
inline bool token::is_left_brace()
{
- return type == TOKEN_LEFT_BRACE;
+ return (TOKEN_LEFT_BRACE == type);
}
inline bool token::is_right_brace()
{
- return type == TOKEN_RIGHT_BRACE;
+ return (TOKEN_RIGHT_BRACE == type);
}
inline bool token::is_tab()
{
- return type == TOKEN_TAB;
+ return (TOKEN_TAB == type);
}
inline bool token::is_leader()
{
- return type == TOKEN_LEADER;
+ return (TOKEN_LEADER == type);
}
inline bool token::is_backspace()
{
- return type == TOKEN_BACKSPACE;
+ return (TOKEN_BACKSPACE == type);
}
inline bool token::is_hyphen_indicator()
{
- return type == TOKEN_HYPHEN_INDICATOR;
+ return (TOKEN_HYPHEN_INDICATOR == type);
}
inline bool token::is_zero_width_break()
{
- return type == TOKEN_ZERO_WIDTH_BREAK;
+ return (TOKEN_ZERO_WIDTH_BREAK == type);
}
bool has_arg(bool /* want_peek */ = false);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit