[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 17/24: [troff]: Slightly refactor (use `has_arg()`).
From: |
G. Branden Robinson |
Subject: |
[groff] 17/24: [troff]: Slightly refactor (use `has_arg()`). |
Date: |
Sun, 10 Nov 2024 14:56:22 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 9e32ae404b8e715547c6a4cdaf2badf7485ffc4d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 9 11:16:01 2024 -0600
[troff]: Slightly refactor (use `has_arg()`).
* src/roff/troff/input.cpp (read_request, do_terminal, do_write_request)
(set_hyphenation_codes, report_hyphenation_codes): Slightly refactor.
Replace `!(tok.is_newline() || tok.is_eof())` with `has_arg()`, for
readability and consistency.
---
ChangeLog | 8 ++++++++
src/roff/troff/input.cpp | 14 +++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6ff22ce5f..f08111d5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/input.cpp (read_request, do_terminal)
+ (do_write_request, set_hyphenation_codes)
+ (report_hyphenation_codes): Slightly refactor. Replace
+ `!(tok.is_newline() || tok.is_eof())` with `has_arg()`, for
+ readability and consistency.
+
2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (pipe_source_request): Align wording
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 89dd2d164..8218c5f8c 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4391,7 +4391,7 @@ void read_request()
macro_iterator *mi = new macro_iterator;
int reading_from_terminal = isatty(fileno(stdin));
int had_prompt = 0;
- if (!tok.is_newline() && !tok.is_eof()) {
+ if (has_arg(true /* peek */)) {
int c = get_copy(0);
while (c == ' ')
c = get_copy(0);
@@ -7263,7 +7263,7 @@ const char *input_char_description(int c)
void tag()
{
- if (!tok.is_newline() && !tok.is_eof()) {
+ if (has_arg(true /* peek */)) {
string s;
int c;
for (;;) {
@@ -7286,7 +7286,7 @@ void tag()
void taga()
{
- if (!tok.is_newline() && !tok.is_eof()) {
+ if (has_arg(true /* peek */)) {
string s;
int c;
for (;;) {
@@ -7311,7 +7311,7 @@ void taga()
void do_terminal(int newline, int string_like)
{
- if (!tok.is_newline() && !tok.is_eof()) {
+ if (has_arg(true /* peek */)) {
int c;
for (;;) {
c = get_copy(0);
@@ -7531,7 +7531,7 @@ void do_write_request(int newline)
skip_line();
return;
}
- if (!tok.is_newline() && !tok.is_eof()) {
+ if (has_arg(true /* peek */)) {
int c = get_copy(0 /* nullptr */);
while (' ' == c)
c = get_copy(0 /* nullptr */);
@@ -7801,7 +7801,7 @@ static void set_hyphenation_codes()
skip_line();
return;
}
- while (!tok.is_newline() && !tok.is_eof()) {
+ while (has_arg()) {
unsigned char cdst = tok.ch();
if (csdigit(cdst)) {
error("cannot apply a hyphenation code to a numeral");
@@ -7865,7 +7865,7 @@ static void report_hyphenation_codes()
skip_line();
return;
}
- while (!tok.is_newline() && !tok.is_eof()) {
+ while (has_arg()) {
unsigned char ch = tok.ch();
if (csdigit(ch)) {
error("a numeral cannot have a hyphenation code");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 17/24: [troff]: Slightly refactor (use `has_arg()`).,
G. Branden Robinson <=