gbranden pushed a commit to branch master
in repository groff.
commit 75eedb7c63125be1322ebaf11aa206cfb8a13a49
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 00:25:13 2026 -0600
[grotty]: Refactor.
* src/devices/grotty/tty.cpp (tty_printer::add_char): Perform sanity
checks on vertical drawing position earlier. Also always initialize
`vpos` local variable.
---
ChangeLog | 6 ++++++
src/devices/grotty/tty.cpp | 19 +++++++++----------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a8d0bfdaa..df3a7d73d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-11-22 G. Branden Robinson <[email protected]>
+
+ * src/devices/grotty/tty.cpp (tty_printer::add_char): Refactor.
+ Perform sanity checks on vertical drawing position earlier.
+ Also always initialize `vpos` local variable.
+
2026-11-20 G. Branden Robinson <[email protected]>
* src/devices/grotty/tty.cpp (tty_printer::add_char): Add null
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index e00d16a54..7b1fb29bb 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -413,13 +413,18 @@ void tty_printer::add_char(output_character c, int w,
error("character with ridiculous horizontal position discarded");
return;
}
- int vpos;
+ // The first output line corresponds to drawing position `font::vert`.
+ int vpos = v / font::vert;
+ if (vpos <= 0) {
+ error("output above first line discarded");
+ return;
+ }
+ if ((v % font::vert) != 0)
+ fatal("vertical position not a multiple of vertical motion"
+ " quantum");
if ((v == cached_v) && (cached_v != 0))
vpos = cached_vpos;
else {
- if ((v % font::vert) != 0)
- fatal("vertical position not a multiple of vertical motion"
- " quantum");
vpos = v / font::vert;
if (vpos > nlines) {
tty_glyph **old_lines = lines;
@@ -444,12 +449,6 @@ void tty_printer::add_char(output_character c, int w,
delete[] old_lines;
nlines = new_nlines;
}
- // Note that the first output line corresponds to groff
- // position font::vert.
- if (vpos <= 0) {
- error("output above first line discarded");
- return;
- }
cached_v = v;
cached_vpos = vpos;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit