gbranden pushed a commit to branch master
in repository groff.
commit e0c24414358d686f9662f1a0877fe5208744f1be
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat May 4 14:27:29 2024 -0500
src/roff/troff/input.cpp (do_if_request): Boolify.
* src/roff/troff/input.cpp (do_if_request): Boolify. Demote `result`
from `int` to `bool`. Assign Boolean literals to it.
Also annotate null pointers with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
Also wrap long input lines.
---
ChangeLog | 5 +++++
src/roff/troff/input.cpp | 31 ++++++++++++++++---------------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c71a8469a..9c229e5cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-05-04 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (do_if_request): Boolify. Demote
+ `result` from `int` to `bool`. Assign Boolean literals to it.
+
2024-05-04 G. Branden Robinson <[email protected]>
* tmac/an.tmac (TH): Reset `mE` and `mS` registers from
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 7631fee39..8d828a01e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5915,7 +5915,7 @@ static bool do_if_request()
tok.next();
want_test_sense_inverted = !want_test_sense_inverted;
}
- int result;
+ bool result;
unsigned char c = tok.ch();
if (compatible_flag)
switch (c) {
@@ -5942,7 +5942,7 @@ static bool do_if_request()
}
else if (c == 'v') {
tok.next();
- result = 0;
+ result = false;
}
else if (c == 'o') {
result = (topdiv->get_page_number() & 1);
@@ -5957,29 +5957,29 @@ static bool do_if_request()
symbol nm = get_name(true /* required */);
if (nm.is_null()) {
skip_branch();
- return 0;
+ return false;
}
result = (c == 'd'
- ? request_dictionary.lookup(nm) != 0
- : register_dictionary.lookup(nm) != 0);
+ ? request_dictionary.lookup(nm) != 0 /* nullptr */
+ : register_dictionary.lookup(nm) != 0 /* nullptr */);
}
else if (c == 'm') {
tok.next();
symbol nm = get_long_name(true /* required */);
if (nm.is_null()) {
skip_branch();
- return 0;
+ return false;
}
result = (nm == default_symbol
- || color_dictionary.lookup(nm) != 0);
+ || color_dictionary.lookup(nm) != 0 /* nullptr */);
}
else if (c == 'c') {
tok.next();
tok.skip();
charinfo *ci = tok.get_char(true /* required */);
- if (ci == 0) {
+ if (ci == 0 /* nullptr */) {
skip_branch();
- return 0;
+ return false;
}
result = character_exists(ci, curenv);
tok.next();
@@ -5989,7 +5989,7 @@ static bool do_if_request()
symbol nm = get_long_name(true /* required */);
if (nm.is_null()) {
skip_branch();
- return 0;
+ return false;
}
result = is_font_name(curenv->get_family()->nm, nm);
}
@@ -5998,12 +5998,12 @@ static bool do_if_request()
symbol nm = get_long_name(true /* required */);
if (nm.is_null()) {
skip_branch();
- return 0;
+ return false;
}
result = is_abstract_style(nm);
}
else if (tok.is_space())
- result = 0;
+ result = false;
else if (tok.is_usable_as_delimiter()) {
token delim = tok;
int delim_level = input_stack::get_level();
@@ -6020,10 +6020,11 @@ static bool do_if_request()
" comparison operator (got %1)", tok.description());
tok.next();
curenv = oldenv;
- return 0;
+ return false;
}
if (tok == delim
- && (compatible_flag || input_stack::get_level() == delim_level))
+ && (compatible_flag
+ || input_stack::get_level() == delim_level))
break;
tok.process();
}
@@ -6043,7 +6044,7 @@ static bool do_if_request()
units n;
if (!get_number(&n, 'u')) {
skip_branch();
- return 0;
+ return false;
}
else
result = n > 0;
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit