gbranden pushed a commit to branch master
in repository groff.
commit a4bc2693165ef30b86ac1fa5dfef8988f648abc7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Apr 11 13:37:40 2026 -0500
src/devices/grotty/tty.cpp: Fix code style nit.
* src/devices/grotty/tty.cpp: Favor C++ `static_cast<>` operator over
omnipotent C-style cast.
---
ChangeLog | 5 +++++
src/devices/grotty/tty.cpp | 27 ++++++++++++++++-----------
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ae63e49e3..c493aa71e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -95,6 +95,11 @@
(add_hyphenation_exception_words_request): Slightly refactor.
Revise loop style.
+2026-04-11 G. Branden Robinson <[email protected]>
+
+ * src/devices/grotty/tty.cpp: Fix code style nit. Favor C++
+ `static_cast<>` operator over omnipotent C-style cast.
+
2026-04-11 G. Branden Robinson <[email protected]>
* src/devices/grotty/tty.cpp: Fix code style nit. Arrange
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index b36c60320..be7140e4b 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -141,14 +141,17 @@ tty_font *tty_font::load_tty_font(const char *s)
long n;
if ((num != 0 /* nullptr */)
&& (n = strtol(num, 0 /* nullptr */, 0)) != 0L)
- f->mode = (unsigned char)(n & (BOLD_MODE|UNDERLINE_MODE));
+ f->mode = static_cast<unsigned char>(n
+ & (BOLD_MODE|UNDERLINE_MODE));
if (!do_underline)
f->mode &= ~UNDERLINE_MODE;
if (!do_bold)
f->mode &= ~BOLD_MODE;
- if ((f->mode & (BOLD_MODE|UNDERLINE_MODE)) == (BOLD_MODE|UNDERLINE_MODE))
- f->mode = (unsigned char)((f->mode & ~(BOLD_MODE|UNDERLINE_MODE))
- | bold_underline_mode);
+ if ((f->mode & (BOLD_MODE|UNDERLINE_MODE))
+ == (BOLD_MODE|UNDERLINE_MODE))
+ f->mode = static_cast<unsigned char>((f->mode
+ & ~(BOLD_MODE|UNDERLINE_MODE))
+ | bold_underline_mode);
return f;
}
@@ -367,7 +370,7 @@ void tty_printer::set_char(glyph *g, font *f, const
environment *env,
add_char(f->get_code(g), w,
env->hpos, env->vpos,
env->col, env->fill,
- ((tty_font *)f)->get_mode());
+ (static_cast<tty_font *>(f))->get_mode());
}
void tty_printer::add_char(output_character c, int w,
@@ -696,18 +699,20 @@ void tty_printer::put_char(output_character wc)
int count;
char *p = buf;
if (wc < 0x800)
- count = 1, *p = (unsigned char)((wc >> 6) | 0xc0);
+ count = 1, *p = static_cast<unsigned char>((wc >> 6) | 0xc0);
else if (wc < 0x10000)
- count = 2, *p = (unsigned char)((wc >> 12) | 0xe0);
+ count = 2, *p = static_cast<unsigned char>((wc >> 12) | 0xe0);
else if (wc < 0x200000)
- count = 3, *p = (unsigned char)((wc >> 18) | 0xf0);
+ count = 3, *p = static_cast<unsigned char>((wc >> 18) | 0xf0);
else if (wc < 0x4000000)
- count = 4, *p = (unsigned char)((wc >> 24) | 0xf8);
+ count = 4, *p = static_cast<unsigned char>((wc >> 24) | 0xf8);
else if (wc <= 0x7fffffff)
- count = 5, *p = (unsigned char)((wc >> 30) | 0xfC);
+ count = 5, *p = static_cast<unsigned char>((wc >> 30) | 0xfC);
else
return;
- do *++p = (unsigned char)(((wc >> (6 * --count)) & 0x3f) | 0x80);
+ do
+ *++p = static_cast<unsigned char>(((wc >> (6 * --count)) & 0x3f)
+ | 0x80);
while (count > 0);
*++p = '\0';
putstring(buf);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit