[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 33/46: [troff]: Trivially refactor ("number_reg_dic...").
From: |
G. Branden Robinson |
Subject: |
[groff] 33/46: [troff]: Trivially refactor ("number_reg_dic..."). |
Date: |
Wed, 7 Dec 2022 04:32:36 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit ab2442e6386d93e1a9a3524b29b3ebed7e476c73
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Dec 5 09:46:09 2022 -0600
[troff]: Trivially refactor ("number_reg_dic...").
Rename `number_reg_dictionary` to `register_dictionary`. It's shorter
_and_ non-abbreviated _and_ matches our documentation.
* src/roff/troff/column.cpp (init_column_requests):
* src/roff/troff/div.cpp (page_number, init_div_requests):
* src/roff/troff/env.cpp (print_env, init_env_requests)
(init_hyphen_requests):
* src/roff/troff/input.cpp (length_request, interpolate_number_format)
(do_register, do_if_request, main, init_registers)
(init_input_requests):
* src/roff/troff/node.cpp (get_register, init_node_requests):
* src/roff/troff/reg.cpp (top level, define_number_reg
(inline_define_reg, alter_format, remove_reg, alias_reg, rename_reg)
(print_number_regs):
* src/roff/troff/reg.h: Do it.
---
ChangeLog | 19 +++++++++++++
src/roff/troff/column.cpp | 8 +++---
src/roff/troff/div.cpp | 36 ++++++++++++------------
src/roff/troff/env.cpp | 28 +++++++++---------
src/roff/troff/input.cpp | 72 +++++++++++++++++++++++------------------------
src/roff/troff/node.cpp | 12 ++++----
src/roff/troff/reg.cpp | 30 ++++++++++----------
src/roff/troff/reg.h | 2 +-
8 files changed, 113 insertions(+), 94 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f407b9a75..bae29b086 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2022-12-05 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor. Rename `number_reg_dictionary` to
+ `register_dictionary`. It's shorter _and_ non-abbreviated _and_
+ matches our documentation.
+
+ * src/roff/troff/column.cpp (init_column_requests):
+ * src/roff/troff/div.cpp (page_number, init_div_requests):
+ * src/roff/troff/env.cpp (print_env, init_env_requests)
+ (init_hyphen_requests):
+ * src/roff/troff/input.cpp (length_request)
+ (interpolate_number_format, do_register, do_if_request, main)
+ (init_registers, init_input_requests):
+ * src/roff/troff/node.cpp (get_register, init_node_requests):
+ * src/roff/troff/reg.cpp (top level, define_number_reg)
+ (inline_define_reg, alter_format, remove_reg, alias_reg)
+ (rename_reg, print_number_regs):
+ * src/roff/troff/reg.h: Do it.
+
2022-12-04 G. Branden Robinson <g.branden.robinson@gmail.com>
[man]: Add regression test.
diff --git a/src/roff/troff/column.cpp b/src/roff/troff/column.cpp
index 00094946c..43ae9aa38 100644
--- a/src/roff/troff/column.cpp
+++ b/src/roff/troff/column.cpp
@@ -721,10 +721,10 @@ void init_column_requests()
init_request("colt", column_trim);
init_request("nvj", no_vjustify);
init_request("rvj", restore_vjustify);
- number_reg_dictionary.define(".colb", new column_bottom_reg);
- number_reg_dictionary.define(".colx", new column_extra_space_reg);
- number_reg_dictionary.define(".cola", new column_active_reg);
- number_reg_dictionary.define(".nvj",
+ register_dictionary.define(".colb", new column_bottom_reg);
+ register_dictionary.define(".colx", new column_extra_space_reg);
+ register_dictionary.define(".cola", new column_active_reg);
+ register_dictionary.define(".nvj",
new constant_int_reg(&no_vjustify_mode));
}
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 94db00062..f9dd8b350 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -814,7 +814,7 @@ void page_number()
// the ps4html register is set if we are using -Tps
// to generate images for html
- reg *r = (reg *)number_reg_dictionary.lookup("ps4html");
+ reg *r = (reg *)register_dictionary.lookup("ps4html");
if (r == NULL)
if (has_arg() && get_integer(&n, topdiv->get_page_number()))
topdiv->set_next_page_number(n);
@@ -1180,27 +1180,27 @@ void init_div_requests()
init_request("sv", save_vertical_space);
init_request("vpt", vertical_position_traps);
init_request("wh", when_request);
- number_reg_dictionary.define(".a",
+ register_dictionary.define(".a",
new constant_int_reg(&last_post_line_extra_space));
- number_reg_dictionary.define(".d", new vertical_position_reg);
- number_reg_dictionary.define(".h", new high_water_mark_reg);
- number_reg_dictionary.define(".ne",
+ register_dictionary.define(".d", new vertical_position_reg);
+ register_dictionary.define(".h", new high_water_mark_reg);
+ register_dictionary.define(".ne",
new constant_vunits_reg(&needed_space));
- number_reg_dictionary.define(".ns", new no_space_mode_reg);
- number_reg_dictionary.define(".o", new page_offset_reg);
- number_reg_dictionary.define(".p", new page_length_reg);
- number_reg_dictionary.define(".pe", new page_ejecting_reg);
- number_reg_dictionary.define(".pn", new next_page_number_reg);
- number_reg_dictionary.define(".t", new distance_to_next_trap_reg);
- number_reg_dictionary.define(".trunc",
+ register_dictionary.define(".ns", new no_space_mode_reg);
+ register_dictionary.define(".o", new page_offset_reg);
+ register_dictionary.define(".p", new page_length_reg);
+ register_dictionary.define(".pe", new page_ejecting_reg);
+ register_dictionary.define(".pn", new next_page_number_reg);
+ register_dictionary.define(".t", new distance_to_next_trap_reg);
+ register_dictionary.define(".trunc",
new constant_vunits_reg(&truncated_space));
- number_reg_dictionary.define(".vpt",
+ register_dictionary.define(".vpt",
new constant_int_reg(&vertical_position_traps_flag));
- number_reg_dictionary.define(".z", new diversion_name_reg);
- number_reg_dictionary.define("dl", new variable_reg(&dl_reg_contents));
- number_reg_dictionary.define("dn", new variable_reg(&dn_reg_contents));
- number_reg_dictionary.define("nl", new nl_reg);
- number_reg_dictionary.define("%", new page_number_reg);
+ register_dictionary.define(".z", new diversion_name_reg);
+ register_dictionary.define("dl", new variable_reg(&dl_reg_contents));
+ register_dictionary.define("dn", new variable_reg(&dn_reg_contents));
+ register_dictionary.define("nl", new nl_reg);
+ register_dictionary.define("%", new page_number_reg);
}
// Local Variables:
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 68aafaa0c..9f00284c6 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3407,16 +3407,16 @@ void print_env()
}
#define init_int_env_reg(name, func) \
- number_reg_dictionary.define(name, new int_env_reg(&environment::func))
+ register_dictionary.define(name, new int_env_reg(&environment::func))
#define init_vunits_env_reg(name, func) \
- number_reg_dictionary.define(name, new vunits_env_reg(&environment::func))
+ register_dictionary.define(name, new vunits_env_reg(&environment::func))
#define init_hunits_env_reg(name, func) \
- number_reg_dictionary.define(name, new hunits_env_reg(&environment::func))
+ register_dictionary.define(name, new hunits_env_reg(&environment::func))
#define init_string_env_reg(name, func) \
- number_reg_dictionary.define(name, new string_env_reg(&environment::func))
+ register_dictionary.define(name, new string_env_reg(&environment::func))
void init_env_requests()
{
@@ -3514,15 +3514,15 @@ void init_env_requests()
init_vunits_env_reg(".v", get_vertical_spacing);
init_hunits_env_reg(".w", get_prev_char_width);
init_int_env_reg(".zoom", get_zoom);
- number_reg_dictionary.define("ct", new variable_reg(&ct_reg_contents));
- number_reg_dictionary.define("hp", new horizontal_place_reg);
- number_reg_dictionary.define("ln", new variable_reg(&next_line_number));
- number_reg_dictionary.define("rsb", new variable_reg(&rsb_reg_contents));
- number_reg_dictionary.define("rst", new variable_reg(&rst_reg_contents));
- number_reg_dictionary.define("sb", new variable_reg(&sb_reg_contents));
- number_reg_dictionary.define("skw", new variable_reg(&skw_reg_contents));
- number_reg_dictionary.define("ssc", new variable_reg(&ssc_reg_contents));
- number_reg_dictionary.define("st", new variable_reg(&st_reg_contents));
+ register_dictionary.define("ct", new variable_reg(&ct_reg_contents));
+ register_dictionary.define("hp", new horizontal_place_reg);
+ register_dictionary.define("ln", new variable_reg(&next_line_number));
+ register_dictionary.define("rsb", new variable_reg(&rsb_reg_contents));
+ register_dictionary.define("rst", new variable_reg(&rst_reg_contents));
+ register_dictionary.define("sb", new variable_reg(&sb_reg_contents));
+ register_dictionary.define("skw", new variable_reg(&skw_reg_contents));
+ register_dictionary.define("ssc", new variable_reg(&ssc_reg_contents));
+ register_dictionary.define("st", new variable_reg(&st_reg_contents));
}
// Hyphenation - TeX's hyphenation algorithm with a less fancy implementation.
@@ -4128,7 +4128,7 @@ void init_hyphen_requests()
init_request("hla", set_hyphenation_language);
init_request("hpf", hyphenation_patterns_file);
init_request("hpfa", hyphenation_patterns_file_append);
- number_reg_dictionary.define(".hla", new hyphenation_language_reg);
+ register_dictionary.define(".hla", new hyphenation_language_reg);
}
// Local Variables:
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ade608563..a5bae4a4f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4921,7 +4921,7 @@ void length_request()
++len;
c = get_copy(&n);
}
- reg *r = (reg*)number_reg_dictionary.lookup(ret);
+ reg *r = (reg*)register_dictionary.lookup(ret);
if (r)
r->set_value(len);
else
@@ -5004,7 +5004,7 @@ void interpolate_number_reg(symbol nm, int inc)
static void interpolate_number_format(symbol nm)
{
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
if (r)
input_stack::push(make_temp_iterator(r->get_format()));
}
@@ -5256,7 +5256,7 @@ static void do_register()
return;
while (tok.is_space())
tok.next();
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
int prev_value;
if (!r || !r->get_value(&prev_value))
prev_value = 0;
@@ -5808,7 +5808,7 @@ int do_if_request()
}
result = (c == 'd'
? request_dictionary.lookup(nm) != 0
- : number_reg_dictionary.lookup(nm) != 0);
+ : register_dictionary.lookup(nm) != 0);
}
else if (c == 'm') {
tok.next();
@@ -8245,7 +8245,7 @@ int main(int argc, char **argv)
init_column_requests();
#endif /* COLUMN */
init_node_requests();
- number_reg_dictionary.define(".T", new constant_reg(tflag ? "1" : "0"));
+ register_dictionary.define(".T", new constant_reg(tflag ? "1" : "0"));
init_registers();
init_reg_requests();
init_hyphen_requests();
@@ -8313,7 +8313,7 @@ static void init_registers()
set_number_reg("year", int(1900 + tt->tm_year));
set_number_reg("yr", int(tt->tm_year));
set_number_reg("$$", getpid());
- number_reg_dictionary.define(".A",
+ register_dictionary.define(".A",
new constant_reg(ascii_output_flag
? "1"
: "0"));
@@ -8458,44 +8458,44 @@ void init_input_requests()
init_request("write", write_request);
init_request("writec", write_request_continue);
init_request("writem", write_macro_request);
- number_reg_dictionary.define(".$", new nargs_reg);
- number_reg_dictionary.define(".br", new break_flag_reg);
- number_reg_dictionary.define(".C", new constant_int_reg(&compatible_flag));
- number_reg_dictionary.define(".cp", new
constant_int_reg(&do_old_compatible_flag));
- number_reg_dictionary.define(".O", new variable_reg(&begin_level));
- number_reg_dictionary.define(".c", new lineno_reg);
- number_reg_dictionary.define(".color", new constant_int_reg(&color_flag));
- number_reg_dictionary.define(".F", new filename_reg);
- number_reg_dictionary.define(".g", new constant_reg("1"));
- number_reg_dictionary.define(".H", new constant_int_reg(&hresolution));
- number_reg_dictionary.define(".R", new constant_reg("10000"));
- number_reg_dictionary.define(".U", new constant_int_reg(&unsafe_flag));
- number_reg_dictionary.define(".V", new constant_int_reg(&vresolution));
- number_reg_dictionary.define(".warn", new constant_int_reg(&warning_mask));
+ register_dictionary.define(".$", new nargs_reg);
+ register_dictionary.define(".br", new break_flag_reg);
+ register_dictionary.define(".C", new constant_int_reg(&compatible_flag));
+ register_dictionary.define(".cp", new
constant_int_reg(&do_old_compatible_flag));
+ register_dictionary.define(".O", new variable_reg(&begin_level));
+ register_dictionary.define(".c", new lineno_reg);
+ register_dictionary.define(".color", new constant_int_reg(&color_flag));
+ register_dictionary.define(".F", new filename_reg);
+ register_dictionary.define(".g", new constant_reg("1"));
+ register_dictionary.define(".H", new constant_int_reg(&hresolution));
+ register_dictionary.define(".R", new constant_reg("10000"));
+ register_dictionary.define(".U", new constant_int_reg(&unsafe_flag));
+ register_dictionary.define(".V", new constant_int_reg(&vresolution));
+ register_dictionary.define(".warn", new constant_int_reg(&warning_mask));
extern const char *major_version;
- number_reg_dictionary.define(".x", new constant_reg(major_version));
+ register_dictionary.define(".x", new constant_reg(major_version));
extern const char *revision;
- number_reg_dictionary.define(".Y", new constant_reg(revision));
+ register_dictionary.define(".Y", new constant_reg(revision));
extern const char *minor_version;
- number_reg_dictionary.define(".y", new constant_reg(minor_version));
- number_reg_dictionary.define("c.", new writable_lineno_reg);
- number_reg_dictionary.define("llx", new variable_reg(&llx_reg_contents));
- number_reg_dictionary.define("lly", new variable_reg(&lly_reg_contents));
- number_reg_dictionary.define("lsn", new
variable_reg(&leading_spaces_number));
- number_reg_dictionary.define("lss", new variable_reg(&leading_spaces_space));
- number_reg_dictionary.define("opmaxx",
+ register_dictionary.define(".y", new constant_reg(minor_version));
+ register_dictionary.define("c.", new writable_lineno_reg);
+ register_dictionary.define("llx", new variable_reg(&llx_reg_contents));
+ register_dictionary.define("lly", new variable_reg(&lly_reg_contents));
+ register_dictionary.define("lsn", new variable_reg(&leading_spaces_number));
+ register_dictionary.define("lss", new variable_reg(&leading_spaces_space));
+ register_dictionary.define("opmaxx",
new variable_reg(&output_reg_maxx_contents));
- number_reg_dictionary.define("opmaxy",
+ register_dictionary.define("opmaxy",
new variable_reg(&output_reg_maxy_contents));
- number_reg_dictionary.define("opminx",
+ register_dictionary.define("opminx",
new variable_reg(&output_reg_minx_contents));
- number_reg_dictionary.define("opminy",
+ register_dictionary.define("opminy",
new variable_reg(&output_reg_miny_contents));
- number_reg_dictionary.define("slimit",
+ register_dictionary.define("slimit",
new variable_reg(&input_stack::limit));
- number_reg_dictionary.define("systat", new variable_reg(&system_status));
- number_reg_dictionary.define("urx", new variable_reg(&urx_reg_contents));
- number_reg_dictionary.define("ury", new variable_reg(&ury_reg_contents));
+ register_dictionary.define("systat", new variable_reg(&system_status));
+ register_dictionary.define("urx", new variable_reg(&urx_reg_contents));
+ register_dictionary.define("ury", new variable_reg(&ury_reg_contents));
}
object_dictionary request_dictionary(501);
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index bb61b257b..3d105f0ee 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4035,7 +4035,7 @@ int tag_node::ends_sentence()
static int get_register(const char *p)
{
assert(p != 0 /* nullptr */);
- reg *r = (reg *)number_reg_dictionary.lookup(p);
+ reg *r = (reg *)register_dictionary.lookup(p);
assert(r != 0 /* nullptr */);
units value;
assert(r->get_value(&value));
@@ -4047,7 +4047,7 @@ static int get_register(const char *p)
static const char *get_string(const char *p)
{
assert(p != 0 /* nullptr */);
- reg *r = (reg *)number_reg_dictionary.lookup(p);
+ reg *r = (reg *)register_dictionary.lookup(p);
assert(r != 0 /* nullptr */);
return r->get_string();
}
@@ -6640,12 +6640,12 @@ void init_node_requests()
init_request("sty", style);
init_request("tkf", track_kern);
init_request("uf", underline_font);
- number_reg_dictionary.define(".fp", new next_available_font_position_reg);
- number_reg_dictionary.define(".kern",
+ register_dictionary.define(".fp", new next_available_font_position_reg);
+ register_dictionary.define(".kern",
new constant_int_reg(&global_kern_mode));
- number_reg_dictionary.define(".lg",
+ register_dictionary.define(".lg",
new constant_int_reg(&global_ligature_mode));
- number_reg_dictionary.define(".P", new printing_reg);
+ register_dictionary.define(".P", new printing_reg);
soft_hyphen_char = get_charinfo(HYPHEN_SYMBOL);
}
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 27065db4e..6b7689d48 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -22,7 +22,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "request.h"
#include "reg.h"
-object_dictionary number_reg_dictionary(101);
+object_dictionary register_dictionary(101);
bool reg::get_value(units * /*d*/)
{
@@ -305,7 +305,7 @@ void define_number_reg()
skip_line();
return;
}
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
units v;
units prev_value;
if (!r || !r->get_value(&prev_value))
@@ -313,7 +313,7 @@ void define_number_reg()
if (get_number(&v, 'u', prev_value)) {
if (r == 0) {
r = new number_reg;
- number_reg_dictionary.define(nm, r);
+ register_dictionary.define(nm, r);
}
r->set_value(v);
if (tok.is_space() && has_arg() && get_number(&v, 'u'))
@@ -333,10 +333,10 @@ void inline_define_reg()
symbol nm = get_name(true /* required */);
if (nm.is_null())
return;
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
if (r == 0) {
r = new number_reg;
- number_reg_dictionary.define(nm, r);
+ register_dictionary.define(nm, r);
}
units v;
units prev_value;
@@ -357,21 +357,21 @@ void inline_define_reg()
void set_number_reg(symbol nm, units n)
{
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
if (r == 0) {
r = new number_reg;
- number_reg_dictionary.define(nm, r);
+ register_dictionary.define(nm, r);
}
r->set_value(n);
}
reg *lookup_number_reg(symbol nm)
{
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
if (r == 0) {
warning(WARN_REG, "register '%1' not defined", nm.contents());
r = new number_reg;
- number_reg_dictionary.define(nm, r);
+ register_dictionary.define(nm, r);
}
return r;
}
@@ -383,10 +383,10 @@ void alter_format()
skip_line();
return;
}
- reg *r = (reg *)number_reg_dictionary.lookup(nm);
+ reg *r = (reg *)register_dictionary.lookup(nm);
if (r == 0) {
r = new number_reg;
- number_reg_dictionary.define(nm, r);
+ register_dictionary.define(nm, r);
}
tok.skip();
char c = tok.ch();
@@ -416,7 +416,7 @@ void remove_reg()
symbol s = get_name();
if (s.is_null())
break;
- number_reg_dictionary.remove(s);
+ register_dictionary.remove(s);
}
skip_line();
}
@@ -427,7 +427,7 @@ void alias_reg()
if (!s1.is_null()) {
symbol s2 = get_name(true /* required */);
if (!s2.is_null()) {
- if (!number_reg_dictionary.alias(s1, s2))
+ if (!register_dictionary.alias(s1, s2))
warning(WARN_REG, "register '%1' not defined", s2.contents());
}
}
@@ -440,14 +440,14 @@ void rename_reg()
if (!s1.is_null()) {
symbol s2 = get_name(true /* required */);
if (!s2.is_null())
- number_reg_dictionary.rename(s1, s2);
+ register_dictionary.rename(s1, s2);
}
skip_line();
}
void print_number_regs()
{
- object_dictionary_iterator iter(number_reg_dictionary);
+ object_dictionary_iterator iter(register_dictionary);
reg *r;
symbol s;
while (iter.get(&s, (object **)&r)) {
diff --git a/src/roff/troff/reg.h b/src/roff/troff/reg.h
index 34ded8c98..8378649f1 100644
--- a/src/roff/troff/reg.h
+++ b/src/roff/troff/reg.h
@@ -63,7 +63,7 @@ public:
bool get_value(units *);
};
-extern object_dictionary number_reg_dictionary;
+extern object_dictionary register_dictionary;
extern void set_number_reg(symbol nm, units n);
extern void check_output_limits(int x, int y);
extern void reset_output_registers();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 33/46: [troff]: Trivially refactor ("number_reg_dic...").,
G. Branden Robinson <=