[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 07/07: [troff]: Trivially refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 07/07: [troff]: Trivially refactor. |
Date: |
Sun, 26 Jun 2022 09:24:00 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 4def9fdba37a257f14a39d3aeeaa328a61f0fd5c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Jun 22 16:45:51 2022 -0500
[troff]: Trivially refactor.
* src/roff/troff/input.cpp (token::next): Rename statement label to use
documentary terminology.
* src/roff/troff/node.cpp (make_composite_node, make_glyph_node): Make
functions static since nothing outside this translation unit calls
them.
* src/roff/troff/node.cpp (make_glyph_node): Refactor optional argument
and its usage. Put it down, flip it, and reverse it. That is, demote
its type from `int` to `bool`, invert its sense, and rename it since
it affects warning, not error, diagnostics.
(character_exists): Update only call site of `make_glyph_node()` that
uses non-default argument value.
---
ChangeLog | 16 ++++++++++++++++
src/roff/troff/input.cpp | 6 +++---
src/roff/troff/node.cpp | 11 ++++++-----
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3735f66e..3dc1e909 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2022-06-22 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor.
+
+ * src/roff/troff/input.cpp (token::next): Rename statement label
+ to use documentary terminology.
+ * src/roff/troff/node.cpp (make_composite_node,
+ make_glyph_node): Make functions static since nothing outside
+ this translation unit calls them.
+ * src/roff/troff/node.cpp (make_glyph_node): Refactor optional
+ argument and its usage. Put it down, flip it, and reverse it.
+ That is, demote its type from `int` to `bool`, invert its sense,
+ and rename it since it affects warning, not error, diagnostics.
+ (character_exists): Update only call site of `make_glyph_node()`
+ that uses non-default argument value.
+
2022-06-22 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: Adjust diagnostic message text to clarify and better
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ee6c0771..b226fd07 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1744,7 +1744,7 @@ void token::next()
node *n = 0;
int cc = input_stack::get(&n);
if (cc != escape_char || escape_char == 0) {
- handle_normal_char:
+ handle_ordinary_char:
switch(cc) {
case INPUT_NO_BREAK_SPACE:
type = TOKEN_STRETCHABLE_SPACE;
@@ -2300,12 +2300,12 @@ void token::next()
type = TOKEN_SPECIAL;
return;
}
- goto handle_normal_char;
+ goto handle_ordinary_char;
default:
if (cc != escape_char && cc != '.')
warning(WARN_ESCAPE, "escape character ignored before %1",
input_char_description(cc));
- goto handle_normal_char;
+ goto handle_ordinary_char;
}
}
}
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index b348c949..0ddcd684 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4889,7 +4889,7 @@ void composite_node::tprint(troff_output_file *out)
out->right(track_kern);
}
-node *make_composite_node(charinfo *s, environment *env)
+static node *make_composite_node(charinfo *s, environment *env)
{
int fontno = env_definite_font(env);
if (fontno < 0) {
@@ -4908,7 +4908,8 @@ node *make_composite_node(charinfo *s, environment *env)
return new composite_node(n, s, tf, 0, 0, 0);
}
-node *make_glyph_node(charinfo *s, environment *env, int no_error_message = 0)
+static node *make_glyph_node(charinfo *s, environment *env,
+ bool want_warnings = true)
{
int fontno = env_definite_font(env);
if (fontno < 0) {
@@ -4923,7 +4924,7 @@ node *make_glyph_node(charinfo *s, environment *env, int
no_error_message = 0)
if (mac && s->is_fallback())
return make_composite_node(s, env);
if (s->numbered()) {
- if (!no_error_message)
+ if (want_warnings)
warning(WARN_CHAR, "character code %1 not defined in current"
" font", s->get_number());
return 0;
@@ -4967,7 +4968,7 @@ node *make_glyph_node(charinfo *s, environment *env, int
no_error_message = 0)
}
}
if (!found) {
- if (!no_error_message && s->first_time_not_found()) {
+ if (want_warnings && s->first_time_not_found()) {
unsigned char input_code = s->get_ascii_code();
if (input_code != 0) {
if (csgraph(input_code))
@@ -5032,7 +5033,7 @@ int character_exists(charinfo *ci, environment *env)
ci = tem;
if (ci->get_macro())
return 1;
- node *nd = make_glyph_node(ci, env, 1);
+ node *nd = make_glyph_node(ci, env, false /* don't want warnings */);
if (nd) {
delete nd;
return 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 07/07: [troff]: Trivially refactor.,
G. Branden Robinson <=