gbranden pushed a commit to branch master
in repository groff.
commit 2632bcaa2b8e05d7001de2469b18624b81c9c6c9
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Sep 8 04:42:38 2024 -0500
[troff]: Trivially refactor.
[troff]: Rename `special_node` class to `device_extension_node`.
* src/roff/troff/node.h (class special_node): Rename this...
(class device_extension_node): ...to this. Rename constructors.
* src/roff/troff/node.cpp
(device_extension_node::device_extension_node): Rename constructors.
(special_node::is_same_as): Rename this...
(device_extension_node::is_same_as): ...to this.
(special_node::type): Rename this...
(device_extension_node::type): ...to this. Update return
string.
(special_node::ends_sentence): Rename this...
(device_extension_node::ends_sentence): ...to this.
(special_node::causes_tprint): Rename this...
(device_extension_node::causes_tprint): ...to this.
(special_node::is_tag): Rename this...
(device_extension_node::is_tag): ...to this.
(special_node::copy): Rename this...
(device_extension_node::copy): ...to this.
(special_node::tprint_start): Rename this...
(device_extension_node::tprint_start): ...to this.
(special_node::tprint_char): Rename this...
(device_extension_node::tprint_char): ...to this.
(special_node::tprint_end): Rename this...
(device_extension_node::tprint_end): ...to this.
(special_node::get_tfont): Rename this...
(device_extension_node::get_tfont): ...to this.
* src/roff/troff/env.cpp (configure_space_underlining)
(environment::make_tag):
* src/roff/troff/input.cpp (token::next, do_device_control)
(device_request, device_macro_request): Update constructor calls.
* src/roff/troff/input.cpp (special_node::tprint): Rename this...
(device_extension_node::tprint): ...to this.
---
ChangeLog | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
src/roff/troff/env.cpp | 4 ++--
src/roff/troff/input.cpp | 10 +++++-----
src/roff/troff/node.cpp | 43 ++++++++++++++++++++-------------------
src/roff/troff/node.h | 13 ++++++------
5 files changed, 89 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a3f8be846..3b35dfa8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,55 @@
+2024-09-08 G. Branden Robinson <[email protected]>
+
+ [troff]: Rename `special_node` class to `device_extension_node`.
+
+ * src/roff/troff/node.h (class special_node): Rename this...
+ (class device_extension_node): ...to this. Rename constructors.
+
+ * src/roff/troff/node.cpp
+ (device_extension_node::device_extension_node): Rename
+ constructors.
+
+ (special_node::is_same_as): Rename this...
+ (device_extension_node::is_same_as): ...to this.
+
+ (special_node::type): Rename this...
+ (device_extension_node::type): ...to this. Update return
+ string.
+
+ (special_node::ends_sentence): Rename this...
+ (device_extension_node::ends_sentence): ...to this.
+
+ (special_node::causes_tprint): Rename this...
+ (device_extension_node::causes_tprint): ...to this.
+
+ (special_node::is_tag): Rename this...
+ (device_extension_node::is_tag): ...to this.
+
+ (special_node::copy): Rename this...
+ (device_extension_node::copy): ...to this.
+
+ (special_node::tprint_start): Rename this...
+ (device_extension_node::tprint_start): ...to this.
+
+ (special_node::tprint_char): Rename this...
+ (device_extension_node::tprint_char): ...to this.
+
+ (special_node::tprint_end): Rename this...
+ (device_extension_node::tprint_end): ...to this.
+
+ (special_node::get_tfont): Rename this...
+ (device_extension_node::get_tfont): ...to this.
+
+ * src/roff/troff/env.cpp (configure_space_underlining)
+ (environment::make_tag):
+ * src/roff/troff/input.cpp (token::next, do_device_control)
+ (device_request, device_macro_request): Update constructor
+ calls.
+
+ * src/roff/troff/input.cpp (special_node::tprint): Rename
+ this...
+ (device_extension_node::tprint): ...to this.
+
2024-09-08 G. Branden Robinson <[email protected]>
* src/roff/troff/div.cpp (flush_output): Rename this...
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index bb4adfc1c..de09d554b 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -553,7 +553,7 @@ static node *configure_space_underlining(bool b)
macro m;
m.append_str("x u ");
m.append(b ? '1' : '0');
- return new special_node(m, 1);
+ return new device_extension_node(m, 1);
}
bool environment::set_font(symbol nm)
@@ -2404,7 +2404,7 @@ node *environment::make_tag(const char *nm, int i)
m.append(*p);
m.append(' ');
m.append_int(i);
- return new special_node(m);
+ return new device_extension_node(m);
}
return 0 /* nullptr */;
}
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index cb32f0e64..e9be6c04b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2450,7 +2450,7 @@ void token::next()
s.contents());
break;
}
- nd = new special_node(*m);
+ nd = new device_extension_node(*m);
type = TOKEN_NODE;
return;
}
@@ -5893,7 +5893,7 @@ static node *do_device_control() // \X
c = tok.ch();
encode_character_for_device_output(&mac, c);
}
- return new special_node(mac);
+ return new device_extension_node(mac);
}
static void device_request()
@@ -5922,7 +5922,7 @@ static void device_request()
for (; c != '\0' && c != '\n' && c != EOF;
c = get_copy(0 /* nullptr */))
mac.append(c);
- curenv->add_node(new special_node(mac));
+ curenv->add_node(new device_extension_node(mac));
tok.next();
}
@@ -5933,7 +5933,7 @@ static void device_macro_request()
request_or_macro *p = lookup_request(s);
macro *m = p->to_macro();
if (m)
- curenv->add_node(new special_node(*m));
+ curenv->add_node(new device_extension_node(*m));
else
error("cannot interpolate '%1' to device-independent output;"
" it is a request, not a macro", s.contents());
@@ -6033,7 +6033,7 @@ static node *do_suppress(symbol nm)
return 0;
}
-void special_node::tprint(troff_output_file *out)
+void device_extension_node::tprint(troff_output_file *out)
{
tprint_start(out);
string_iterator iter(mac);
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 343291aa7..0a7b8bffe 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3893,7 +3893,7 @@ int node::interpret(macro *)
return 0;
}
-special_node::special_node(const macro &m, bool b)
+device_extension_node::device_extension_node(const macro &m, bool b)
: mac(m), lacks_command_prefix(b)
{
font_size fs = curenv->get_font_size();
@@ -3908,7 +3908,7 @@ special_node::special_node(const macro &m, bool b)
is_special = 1;
}
-special_node::special_node(const macro &m, tfont *t,
+device_extension_node::device_extension_node(const macro &m, tfont *t,
color *gc, color *fc,
statem *s, int divlevel,
bool b)
@@ -3918,58 +3918,61 @@ special_node::special_node(const macro &m, tfont *t,
is_special = 1;
}
-bool special_node::is_same_as(node *n)
+bool device_extension_node::is_same_as(node *n)
{
- return ((mac == static_cast<special_node *>(n)->mac)
- && (tf == static_cast<special_node *>(n)->tf)
- && (gcol == static_cast<special_node *>(n)->gcol)
- && (fcol == static_cast<special_node *>(n)->fcol)
+ return ((mac == static_cast<device_extension_node *>(n)->mac)
+ && (tf == static_cast<device_extension_node *>(n)->tf)
+ && (gcol == static_cast<device_extension_node *>(n)->gcol)
+ && (fcol == static_cast<device_extension_node *>(n)->fcol)
&& (lacks_command_prefix
- == static_cast<special_node *>(n)->lacks_command_prefix));
+ == static_cast<device_extension_node *>(n)
+ ->lacks_command_prefix));
}
-const char *special_node::type()
+const char *device_extension_node::type()
{
- return "special_node";
+ return "device_extension_node";
}
-int special_node::ends_sentence()
+int device_extension_node::ends_sentence()
{
return 2;
}
-bool special_node::causes_tprint()
+bool device_extension_node::causes_tprint()
{
return false;
}
-bool special_node::is_tag()
+bool device_extension_node::is_tag()
{
return false;
}
-node *special_node::copy()
+node *device_extension_node::copy()
{
- return new special_node(mac, tf, gcol, fcol, state, div_nest_level,
- lacks_command_prefix);
+ return new device_extension_node(mac, tf, gcol, fcol, state,
+ div_nest_level,
+ lacks_command_prefix);
}
-void special_node::tprint_start(troff_output_file *out)
+void device_extension_node::tprint_start(troff_output_file *out)
{
out->start_device_extension(tf, gcol, fcol, lacks_command_prefix);
}
-void special_node::tprint_char(troff_output_file *out, unsigned char c)
+void device_extension_node::tprint_char(troff_output_file *out,
+ unsigned char c)
{
out->write_device_extension_char(c);
}
-void special_node::tprint_end(troff_output_file *out)
+void device_extension_node::tprint_end(troff_output_file *out)
{
out->end_device_extension();
}
-tfont *special_node::get_tfont()
+tfont *device_extension_node::get_tfont()
{
return tf;
}
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 2ae451142..078bf37bf 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -540,7 +540,7 @@ public:
bool is_tag();
};
-class special_node : public node {
+class device_extension_node : public node {
macro mac;
tfont *tf;
color *gcol;
@@ -550,11 +550,12 @@ class special_node : public node {
void tprint_char(troff_output_file *, unsigned char);
void tprint_end(troff_output_file *);
public:
- special_node(const macro & /* m */,
- bool /* lacks_command_prefix */ = false);
- special_node(const macro & /* m */, tfont * /* tf */,
- color * /* gcol */, color * /* fcol */, statem * /* s */,
- int divlevel, bool /* lacks_command_prefix */ = false);
+ device_extension_node(const macro & /* m */,
+ bool /* lacks_command_prefix */ = false);
+ device_extension_node(const macro & /* m */, tfont * /* tf */,
+ color * /* gcol */, color * /* fcol */,
+ statem * /* s */, int divlevel,
+ bool /* lacks_command_prefix */ = false);
node *copy();
void tprint(troff_output_file *);
bool is_same_as(node *);
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit