[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 23/60: [troff]: Handle output line number better.
From: |
G. Branden Robinson |
Subject: |
[groff] 23/60: [troff]: Handle output line number better. |
Date: |
Wed, 11 Sep 2024 03:38:30 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit fe6b05ad8576c2f0a3cdec6290f5c1697a6ee5ce
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Sep 9 15:29:11 2024 -0500
[troff]: Handle output line number better.
* src/roff/troff/env.cpp (environment::output_line): Resize
stack-allocated character buffer to use constant defined by libgroff
for formatting unsigned `int`s as strings. Use sprintf(3)'s 'u'
conversion, not 'd', for output line number, which cannot be negative.
Explicitly discard return value of sprintf(3).
---
ChangeLog | 9 +++++++++
src/roff/troff/env.cpp | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b055eba34..0e2ffb88a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-09-08 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/env.cpp (environment::output_line): Resize
+ stack-allocated character buffer to use constant defined by
+ libgroff for formatting unsigned `int`s as strings. Use
+ sprintf(3)'s 'u' conversion, not 'd', for output line number,
+ which cannot be negative. Explicitly discard return value of
+ sprintf(3).
+
2024-09-08 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/node.cpp (class troff_output_file):
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 6e546d0ee..89f1dc417 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1950,8 +1950,8 @@ void environment::output_line(node *nd, hunits width,
bool was_centered)
* line_number_digit_width,
get_fill_color(), nn);
x -= number_text_separation*line_number_digit_width;
- char buf[30];
- sprintf(buf, "%3d", next_line_number);
+ char buf[UINT_DIGITS];
+ (void) sprintf(buf, "%3u", next_line_number);
for (char *p = strchr(buf, '\0') - 1; p >= buf && *p != ' '; --p)
{
node *gn = numbering_nodes;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 23/60: [troff]: Handle output line number better.,
G. Branden Robinson <=