gbranden pushed a commit to branch master
in repository groff.
commit c5f9a838832f9f30984c237222f84e72d58c74a0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Aug 14 13:16:09 2024 -0500
[troff]: Slightly refactor (1/6).
* src/roff/troff/node.h (struct hyphen_list): Demote `hyphen` member
from `unsigned char` to `bool` and rename it to `is_hyphen'.
(hyphen_list::hyphen_list): Migrate struct initializer list to new
name and Boolean literal.
* src/roff/troff/env.cpp (hyphenate): Update assignments to use new name
and Boolean, not integer, literals.
* src/roff/troff/node.cpp (glyph_node::add_self)
(composite_node::add_self): Update comparisons to use new name.
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/env.cpp | 10 +++++-----
src/roff/troff/node.cpp | 4 ++--
src/roff/troff/node.h | 4 ++--
4 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 029b9a290..10fcec9b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-08-14 G. Branden Robinson <[email protected]>
+
+ [troff]: Slightly refactor: boolify.
+
+ * src/roff/troff/node.h (struct hyphen_list): Demote `hyphen`
+ member from `unsigned char` to `bool` and rename it to
+ `is_hyphen'.
+ (hyphen_list::hyphen_list): Migrate struct initializer list to
+ new name and Boolean literal.
+ * src/roff/troff/env.cpp (hyphenate): Update assignments to use
+ new name and Boolean, not integer, literals.
+ * src/roff/troff/node.cpp (glyph_node::add_self)
+ (composite_node::add_self): Update comparisons to use new name.
+
2024-08-14 G. Branden Robinson <[email protected]>
* src/roff/troff/token.h (token:ch()): Return character instead
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 3d2f01eb0..c67668502 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -4274,7 +4274,7 @@ void hyphenate(hyphen_list *h, unsigned flags)
int i = 1;
for (tem = h; tem != 0 /* nullptr */; tem = tem->next, i++)
if (pos[j] == i) {
- tem->hyphen = 1;
+ tem->is_hyphen = true;
j++;
}
}
@@ -4292,14 +4292,14 @@ void hyphenate(hyphen_list *h, unsigned flags)
tem = h;
if (pos[j] == i) {
if (flags & HYPHEN_FIRST_CHAR)
- tem->hyphen = 1;
+ tem->is_hyphen = true;
j++;
}
tem = tem->next;
i++;
if (pos[j] == i) {
if (!(flags & HYPHEN_NOT_FIRST_CHARS))
- tem->hyphen = 1;
+ tem->is_hyphen = true;
j++;
}
tem = tem->next;
@@ -4310,7 +4310,7 @@ void hyphenate(hyphen_list *h, unsigned flags)
--len;
for (; i < len && tem; tem = tem->next, i++)
if (pos[j] == i) {
- tem->hyphen = 1;
+ tem->is_hyphen = true;
j++;
}
}
@@ -4335,7 +4335,7 @@ void hyphenate(hyphen_list *h, unsigned flags)
int i;
for (i = 2, tem = h; i < len && tem; tem = tem->next, i++)
if (num[i] & 1)
- tem->hyphen = 1;
+ tem->is_hyphen = true;
}
}
}
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 2250f136b..93828cf92 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -2054,7 +2054,7 @@ node *glyph_node::add_self(node *n, hyphen_list **p)
next = n;
nn = this;
}
- if ((*p)->hyphen)
+ if ((*p)->is_hyphen)
nn = nn->add_discretionary_hyphen();
hyphen_list *pp = *p;
*p = (*p)->next;
@@ -4375,7 +4375,7 @@ node *composite_node::add_self(node *nn, hyphen_list **p)
assert(ci->get_hyphenation_code() == (*p)->hyphenation_code);
next = nn;
nn = this;
- if ((*p)->hyphen)
+ if ((*p)->is_hyphen)
nn = nn->add_discretionary_hyphen();
hyphen_list *pp = *p;
*p = (*p)->next;
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 28bbf31ba..c98ad0abd 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public
License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
struct hyphen_list {
- unsigned char hyphen;
+ bool is_hyphen;
unsigned char breakable;
unsigned char hyphenation_code;
hyphen_list *next;
@@ -638,7 +638,7 @@ node *copy_node_list(node *);
int get_bold_fontno(int);
inline hyphen_list::hyphen_list(unsigned char code, hyphen_list *p)
-: hyphen(0), breakable(0), hyphenation_code(code), next(p)
+: is_hyphen(false), breakable(0), hyphenation_code(code), next(p)
{
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit