gbranden pushed a commit to branch master
in repository groff.
commit 86a68f0b4f05587436eb427e5ed51609b5948e60
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Mar 14 08:44:23 2026 -0500
src/roff/troff/input.cpp (read_request): Boolify.
* src/roff/troff/input.cpp (read_request): Boolify and rename some local
variables. `reading_from_terminal` becomes
`is_reading_from_terminal`. `nl` becomes `saw_newline`. Assign to
`is_reading_from_terminal`, `had_prompt`, and `saw_newline` with
Boolean, not integer, literals. Use idiomatic test expressions.
---
ChangeLog | 9 +++++++++
src/roff/troff/input.cpp | 20 ++++++++++----------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index df5583555..8c792c036 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-03-14 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (read_request): Boolify and rename
+ some local variables. `reading_from_terminal` becomes
+ `is_reading_from_terminal`. `nl` becomes `saw_newline`. Assign
+ to `is_reading_from_terminal`, `had_prompt`, and `saw_newline`
+ with Boolean, not integer, literals. Use idiomatic test
+ expressions.
+
2026-03-14 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (word_space_node::need_reread)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 4288731fe..8f42d7fcf 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4961,17 +4961,17 @@ bool unpostpone_traps()
void read_request()
{
macro_iterator *mi = new macro_iterator;
- int reading_from_terminal = isatty(fileno(stdin));
- int had_prompt = 0;
+ bool is_reading_from_terminal = bool(isatty(fileno(stdin)));
+ bool had_prompt = false;
if (has_arg(true /* peek */)) {
int c = read_char_in_copy_mode(0 /* nullptr */);
while (c == ' ')
c = read_char_in_copy_mode(0 /* nullptr */);
while (c != EOF && c != '\n' && c != ' ') {
if (!is_invalid_input_char(c)) {
- if (reading_from_terminal)
+ if (is_reading_from_terminal)
fputc(c, stderr);
- had_prompt = 1;
+ had_prompt = true;
}
c = read_char_in_copy_mode(0 /* nullptr */);
}
@@ -4980,30 +4980,30 @@ void read_request()
decode_macro_call_arguments(mi);
}
}
- if (reading_from_terminal) {
+ if (is_reading_from_terminal) {
fputc(had_prompt ? ':' : '\a', stderr);
fflush(stderr);
}
input_stack::push(mi);
macro mac;
- int nl = 0;
+ bool saw_newline = false;
int c;
while ((c = getchar()) != EOF) {
if (is_invalid_input_char(c))
warning(WARN_INPUT, "invalid input character code %1", int(c));
else {
if (c == '\n') {
- if (nl != 0 /* nullptr */)
+ if (!saw_newline)
break;
else
- nl = 1;
+ saw_newline = true;
}
else
- nl = 0;
+ saw_newline = false;
mac.append(c);
}
}
- if (reading_from_terminal)
+ if (is_reading_from_terminal)
clearerr(stdin);
input_stack::push(new string_iterator(mac));
tok.next();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit