gbranden pushed a commit to branch master
in repository groff.
commit f4b993b8968340913f44dc85689dd24fd5428649
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Mar 21 11:16:05 2026 -0500
src/roff/troff/input.cpp: Slightly refactor (1/3).
* src/roff/troff/input.cpp (substring_request): When iterating through a
`macro` object's contents, use its stored length to decide when to
stop instead of relying on the `string_iterator` accessing each
element to return an `EOF` character. This change prepares for a
future where GNU troff's internal character type does not encode
`EOF`. This change also weakens the resemblance of file and string
iterators, but that seems acceptable to me, because string and macro
contents have already undergone input processing. In the future, this
will mean decoding of UTF-8 sequences and possible NFD decomposition
to one or more `char32_t` (or similar) objects.
---
ChangeLog | 15 +++++++++++++++
src/roff/troff/input.cpp | 6 +++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 77c5bbb79..90e53deec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2026-03-21 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (substring_request): Slightly
+ refactor. When iterating through a `macro` object's contents,
+ use its stored length to decide when to stop instead of relying
+ on the `string_iterator` accessing each element to return an
+ `EOF` character. This change prepares for a future where GNU
+ troff's internal character type does not encode `EOF`. This
+ change also weakens the resemblance of file and string
+ iterators, but that seems acceptable to me, because string and
+ macro contents have already undergone input processing. In the
+ future, this will mean decoding of UTF-8 sequences and possible
+ NFD decomposition to one or more `char32_t` (or similar)
+ objects.
+
2026-03-21 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (substring_request): Recast warning
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index da60ef984..3e03e48d7 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5820,7 +5820,7 @@ void substring_request()
|| (PUSH_COMP_MODE == c)
|| (POP_GROFFCOMP_MODE == c))
continue;
- if (EOF == c)
+ if (l == m->len)
break;
operable_length++;
}
@@ -5865,7 +5865,7 @@ void substring_request()
|| (PUSH_COMP_MODE == c)
|| (POP_GROFFCOMP_MODE == c))
c = iter.get(0 /* nullptr */);
- if (EOF == c)
+ if (i == m->len)
break;
}
macro mac;
@@ -5876,7 +5876,7 @@ void substring_request()
|| (PUSH_COMP_MODE == c)
|| (POP_GROFFCOMP_MODE == c))
c = iter.get(0 /* nullptr */);
- if (EOF == c)
+ if (i == m->len)
break;
if (0U == c)
mac.append(nd);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit