[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 13/24: [troff]: Slightly refactor (use `!has_arg()`).
From: |
G. Branden Robinson |
Subject: |
[groff] 13/24: [troff]: Slightly refactor (use `!has_arg()`). |
Date: |
Sun, 10 Nov 2024 14:56:21 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 713e10d79e301e1fada4486440f93536c1e5a2e3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 9 10:39:38 2024 -0600
[troff]: Slightly refactor (use `!has_arg()`).
* src/roff/troff/env.cpp (add_hyphenation_exceptions):
* src/roff/troff/input.cpp (read_title_parts, set_hyphenation_codes)
(report_hyphenation_codes, read_drawing_command_color_arguments)
(set_character_flags):
* src/roff/troff/reg.cpp (assign_register_format_request): Slightly
refactor. Replace `tok.is_newline() || tok.is_eof()` with
`!has_arg()`, for readability and consistency.
---
ChangeLog | 8 ++++++++
src/roff/troff/env.cpp | 2 +-
src/roff/troff/input.cpp | 12 ++++++------
src/roff/troff/reg.cpp | 2 +-
4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b3087567f..dbfbff457 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/env.cpp (add_hyphenation_exceptions):
+ * src/roff/troff/input.cpp (read_title_parts):
+ * src/roff/troff/reg.cpp (assign_register_format_request):
+ 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 (set_character_flags): Check for
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 1282d2283..2351e8d7e 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3785,7 +3785,7 @@ static void add_hyphenation_exceptions()
unsigned char pos[WORD_MAX + 2];
for (;;) {
tok.skip();
- if (tok.is_newline() || tok.is_eof())
+ if (!has_arg())
break;
int i = 0;
int npos = 0;
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index baf8996b0..541797756 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5703,7 +5703,7 @@ static const symbol percent_symbol("%");
void read_title_parts(node **part, hunits *part_width)
{
tok.skip();
- if (tok.is_newline() || tok.is_eof())
+ if (!has_arg())
return;
token start(tok);
int start_level = input_stack::get_level();
@@ -7764,7 +7764,7 @@ static void set_character_flags()
}
int flags;
if (get_integer(&flags)) {
- if (tok.is_newline() || tok.is_eof()) {
+ if (!has_arg()) {
warning(WARN_MISSING, "character flags configuration request"
" expects one or more characters to configure");
skip_line();
@@ -7787,7 +7787,7 @@ static void set_character_flags()
static void set_hyphenation_codes()
{
tok.skip();
- if (tok.is_newline() || tok.is_eof()) {
+ if (!has_arg()) {
warning(WARN_MISSING, "hyphenation code assignment request expects"
" arguments");
skip_line();
@@ -7809,7 +7809,7 @@ static void set_hyphenation_codes()
}
tok.next();
tok.skip();
- if (tok.is_newline() || tok.is_eof()) {
+ if (!has_arg()) {
error("hyphenation codes must be specified in pairs");
break;
}
@@ -7851,7 +7851,7 @@ static void set_hyphenation_codes()
static void report_hyphenation_codes()
{
tok.skip();
- if (tok.is_newline() || tok.is_eof()) {
+ if (!has_arg()) {
warning(WARN_MISSING, "hyphenation code report request expects"
" arguments");
skip_line();
@@ -9576,7 +9576,7 @@ static void read_drawing_command_color_arguments(token
&start)
if (col)
curenv->set_fill_color(col);
while (tok != start) {
- if (tok.is_newline() || tok.is_eof()) {
+ if (!has_arg()) {
// token::description() writes to static, class-wide storage, so
// we must allocate a copy of it before issuing the next
// diagnostic.
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 752b4e82e..dab110f0a 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -436,7 +436,7 @@ void assign_register_format_request()
}
else if (c == 'i' || c == 'I' || c == 'a' || c == 'A')
r->alter_format(c);
- else if (tok.is_newline() || tok.is_eof())
+ else if (!has_arg())
warning(WARN_MISSING, "register interpolation format assignment"
" request register format as second argument");
else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 13/24: [troff]: Slightly refactor (use `!has_arg()`).,
G. Branden Robinson <=