[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 14/24: [troff]: Slightly refactor `has_arg()`.
From: |
G. Branden Robinson |
Subject: |
[groff] 14/24: [troff]: Slightly refactor `has_arg()`. |
Date: |
Sun, 10 Nov 2024 14:56:22 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 497e7294ddfe7b020bb7262338a38231c2576bfa
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 9 10:55:20 2024 -0600
[troff]: Slightly refactor `has_arg()`.
* src/roff/troff/input.cpp (has_args): Slightly refactor; use the same
expression to compute the return value after having advaced the input
pointer through spaces as is used at the top of the function.
---
ChangeLog | 7 +++++++
src/roff/troff/input.cpp | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index dbfbff457..4f5f531fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/input.cpp (has_args): Slightly refactor; use
+ the same expression to compute the return value after having
+ advaced the input pointer through spaces as is used at the top
+ of the function.
+
2024-11-09 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/env.cpp (add_hyphenation_exceptions):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 541797756..d330ba91a 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1901,6 +1901,12 @@ void token::skip()
next();
}
+// Indicate whether an argument lies ahead on the current line in the
+// input stream, skipping over spaces. This function is therefore not
+// appropriate for use when handling requests or escape sequences that
+// don't use space to separate their arguments, as with `.tr aAbB` or
+// `\o'^e'`.
+//
// Specify `want_peek` if request reads the next argument in copy mode,
// or otherwise must interpret it specially, as when reading a
// conditional expression (`if`, `ie`, `while`), or expecting a
@@ -1923,7 +1929,7 @@ bool has_arg(bool want_peek)
else {
while (tok.is_space())
tok.next();
- return !tok.is_newline();
+ return !(tok.is_newline() || tok.is_eof());
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 14/24: [troff]: Slightly refactor `has_arg()`.,
G. Branden Robinson <=