[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 02/10: src/roff/troff/env.cpp: Refactor slightly.
From: |
G. Branden Robinson |
Subject: |
[groff] 02/10: src/roff/troff/env.cpp: Refactor slightly. |
Date: |
Mon, 6 Sep 2021 15:01:22 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 542c0adbe66949ddf4c444e866574b1faf3785a0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Sep 5 04:45:55 2021 +1000
src/roff/troff/env.cpp: Refactor slightly.
* src/roff/troff/env.cpp (do_underline_special): Refactor slightly.
- Rename `underline_spaces` -> `do_underline_spaces`.
- Demote it from an `int` to a `bool`. Update prototype.
- Use ternary operator and explicit character literals when writing
device control command instead of doing arithmetic on a character
literal.
- Update call sites to use Boolean literals.
---
ChangeLog | 11 +++++++++++
src/roff/troff/env.cpp | 16 ++++++++--------
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2734b80..f5a4d6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2021-09-05 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/env.cpp (do_underline_special): Refactor
+ slightly.
+ - Rename `underline_spaces` -> `do_underline_spaces`.
+ - Demote it from an `int` to a `bool`. Update prototype.
+ - Use ternary operator and explicit character literals when
+ writing device control command instead of doing arithmetic
+ on a character literal.
+ - Update call sites to use Boolean literals.
+
2021-09-04 Keith Marshall <keith.d.marshall@ntlworld.com>
Add "ms" footnote marker placement hook.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 3c6dea6..ae75323 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -488,7 +488,7 @@ void environment::space(hunits space_width, hunits
sentence_space_width)
spread_flag = 0;
}
-node *do_underline_special(int);
+node *do_underline_special(bool);
void environment::set_font(symbol nm)
{
@@ -515,9 +515,9 @@ void environment::set_font(symbol nm)
}
if (underline_spaces && fontno != prev_fontno) {
if (fontno == get_underline_fontno())
- add_node(do_underline_special(1));
+ add_node(do_underline_special(true));
if (prev_fontno == get_underline_fontno())
- add_node(do_underline_special(0));
+ add_node(do_underline_special(false));
}
}
@@ -1460,11 +1460,11 @@ void temporary_indent()
tok.next();
}
-node *do_underline_special(int underline_spaces)
+node *do_underline_special(bool do_underline_spaces)
{
macro m;
m.append_str("x u ");
- m.append(underline_spaces + '0');
+ m.append(do_underline_spaces ? '1' : '0');
return new special_node(m, 1);
}
@@ -1479,7 +1479,7 @@ void do_underline(int underline_spaces)
curenv->fontno = curenv->pre_underline_fontno;
if (underline_spaces) {
curenv->underline_spaces = 0;
- curenv->add_node(do_underline_special(0));
+ curenv->add_node(do_underline_special(false));
}
}
curenv->underline_lines = 0;
@@ -1490,7 +1490,7 @@ void do_underline(int underline_spaces)
curenv->fontno = get_underline_fontno();
if (underline_spaces) {
curenv->underline_spaces = 1;
- curenv->add_node(do_underline_special(1));
+ curenv->add_node(do_underline_special(true));
}
}
skip_line();
@@ -1691,7 +1691,7 @@ void environment::newline()
fontno = pre_underline_fontno;
if (underline_spaces) {
underline_spaces = 0;
- add_node(do_underline_special(0));
+ add_node(do_underline_special(false));
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 02/10: src/roff/troff/env.cpp: Refactor slightly.,
G. Branden Robinson <=