gbranden pushed a commit to branch master
in repository groff.
commit f5d4d710e6086bbab46e1b1987741c868bdfb522
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Apr 9 23:42:48 2026 -0500
[libgroff]: Trivially refactor.
* src/include/symbol.h (class symbol): Rename `table_used` member
variable, which could suggest a Boolean value, to `table_occupancy`.
* src/libs/libgroff/symbol.cpp: Update dereference sites.
---
ChangeLog | 9 +++++++++
src/include/symbol.h | 2 +-
src/libs/libgroff/symbol.cpp | 14 ++++++++------
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 04c76bfcb..4d5438c84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-04-09 G. Branden Robinson <[email protected]>
+
+ [libgroff]: Trivially refactor.
+
+ * src/include/symbol.h (class symbol): Rename `table_used`
+ member variable, which could suggest a Boolean value, to
+ `table_occupancy`.
+ * src/libs/libgroff/symbol.cpp: Update dereference sites.
+
2026-04-09 G. Branden Robinson <[email protected]>
* src/roff/troff/div.h (class diversion, class macro_diversion):
diff --git a/src/include/symbol.h b/src/include/symbol.h
index a76ad94f5..bc1f611d9 100644
--- a/src/include/symbol.h
+++ b/src/include/symbol.h
@@ -25,7 +25,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
class symbol {
static const char **table;
- static int table_used;
+ static int table_occupancy; // # of entries in use
static int table_size;
static char *block;
static size_t block_size;
diff --git a/src/libs/libgroff/symbol.cpp b/src/libs/libgroff/symbol.cpp
index d3d79fcda..154c04fe4 100644
--- a/src/libs/libgroff/symbol.cpp
+++ b/src/libs/libgroff/symbol.cpp
@@ -33,8 +33,10 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "error.h"
#include "symbol.h"
+// Create an anonymous global symbol table to house two constants.
+
const char **symbol::table = 0 /* nullptr */;
-int symbol::table_used = 0; // # of entries in use
+int symbol::table_occupancy = 0;
int symbol::table_size = 0;
char *symbol::block = 0 /* nullptr */;
size_t symbol::block_size = 0;
@@ -99,7 +101,7 @@ symbol::symbol(const char *p, int how)
table = (const char **)new char*[table_size];
for (int i = 0; i < table_size; i++)
table[i] = 0 /* nullptr */;
- table_used = 0;
+ table_occupancy = 0;
}
unsigned int hc = hash_string(p);
const char **pp;
@@ -114,8 +116,8 @@ symbol::symbol(const char *p, int how)
s = 0 /* nullptr */;
return;
}
- if ((table_used >= (table_size - 1))
- || (table_used >= (table_size * FULL_MAX))) {
+ if ((table_occupancy >= (table_size - 1))
+ || (table_occupancy >= (table_size * FULL_MAX))) {
const char **old_table = table;
unsigned int old_table_size = table_size;
int i;
@@ -123,7 +125,7 @@ symbol::symbol(const char *p, int how)
if (table_sizes[i] == 0)
fatal("too many symbols");
table_size = table_sizes[i];
- table_used = 0;
+ table_occupancy = 0;
table = (const char **)new char*[table_size];
for (i = 0; i < table_size; i++)
table[i] = 0 /* nullptr */;
@@ -139,7 +141,7 @@ symbol::symbol(const char *p, int how)
(pp == table ? pp = table + table_size - 1 : --pp))
;
}
- ++table_used;
+ ++table_occupancy;
if (how == DONT_STORE)
s = *pp = p;
else {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit