gbranden pushed a commit to branch master
in repository groff.
commit 5787e9b8c092c0d1d1b800ac6204d6d4fe60f11f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jul 10 16:42:45 2025 -0500
[pre-grohtml]: Slightly refactor (1/2).
* src/preproc/html/pre-html.cpp (get_line): Use named variables more and
constant literals less.
---
ChangeLog | 5 +++++
src/preproc/html/pre-html.cpp | 7 ++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4e61f4daf..4a0c9e1f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-07-10 G. Branden Robinson <[email protected]>
+
+ * src/preproc/html/pre-html.cpp (get_line): Slightly refactor.
+ Use named variables more and constant literals less.
+
2025-07-10 G. Branden Robinson <[email protected]>
* src/preproc/html/pre-html.cpp (get_line): Fix code style nits.
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 535fb386f..9199a3c8d 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -267,8 +267,8 @@ static bool get_line(FILE *f)
if (0 /* nullptr */ == f)
return false;
if (0 /* nullptr */ == linebuf) {
- linebuf = new char[128];
linebufsize = 128;
+ linebuf = new char[linebufsize];
}
int i = 0;
// skip leading whitespace
@@ -286,11 +286,12 @@ static bool get_line(FILE *f)
if (EOF == c)
break;
if (i + 1 >= linebufsize) {
+ int newbufsize = linebufsize * 2;
char *old_linebuf = linebuf;
- linebuf = new char[linebufsize * 2];
+ linebuf = new char[newbufsize];
memcpy(linebuf, old_linebuf, linebufsize);
delete[] old_linebuf;
- linebufsize *= 2;
+ linebufsize = newbufsize;
}
linebuf[i++] = c;
if ('\n' == c) {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit