[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 35/46: [troff]: Trivially refactor ("constant_int_reg").
From: |
G. Branden Robinson |
Subject: |
[groff] 35/46: [troff]: Trivially refactor ("constant_int_reg"). |
Date: |
Wed, 7 Dec 2022 04:32:37 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 9b1201303eccf7cb8136e90a6eb64f33bafe3ccc
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Dec 5 10:57:32 2022 -0600
[troff]: Trivially refactor ("constant_int_reg").
Rename class `constant_int_reg` to `readonly_register`. Say "readonly"
instead of "const" to try to avoid confusion with C++ constness. Drop
"int" because integer-valued registers are the norm, not the exception.
* src/roff/troff/column.cpp (init_column_requests):
* src/roff/troff/div.cpp (init_div_requests):
* src/roff/troff/input.cpp (top level, init_input_requests):
* src/roff/troff/node.cpp (init_node_requests):
* src/roff/troff/reg.h: Do it.
---
ChangeLog | 13 +++++++++++++
src/roff/troff/column.cpp | 2 +-
src/roff/troff/div.cpp | 4 ++--
src/roff/troff/input.cpp | 18 +++++++++---------
src/roff/troff/node.cpp | 4 ++--
src/roff/troff/reg.h | 4 ++--
6 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index eafa78c8d..31540aefa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-12-05 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor. Rename class `constant_int_reg` to
+ `readonly_register`. Say "readonly" instead of "const" to
+ try to avoid confusion with C++ constness. Drop "int" because
+ integer-valued registers are the norm, not the exception.
+
+ * src/roff/troff/column.cpp (init_column_requests):
+ * src/roff/troff/div.cpp (init_div_requests):
+ * src/roff/troff/input.cpp (top level, init_input_requests):
+ * src/roff/troff/node.cpp (init_node_requests):
+ * src/roff/troff/reg.h: Do it.
+
2022-12-05 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: Trivially refactor. Rename class `constant_reg` to
diff --git a/src/roff/troff/column.cpp b/src/roff/troff/column.cpp
index 43ae9aa38..55563ba46 100644
--- a/src/roff/troff/column.cpp
+++ b/src/roff/troff/column.cpp
@@ -725,7 +725,7 @@ void init_column_requests()
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));
+ new readonly_register(&no_vjustify_mode));
}
#endif /* COLUMN */
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index f9dd8b350..48565262e 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -1181,7 +1181,7 @@ void init_div_requests()
init_request("vpt", vertical_position_traps);
init_request("wh", when_request);
register_dictionary.define(".a",
- new constant_int_reg(&last_post_line_extra_space));
+ new readonly_register(&last_post_line_extra_space));
register_dictionary.define(".d", new vertical_position_reg);
register_dictionary.define(".h", new high_water_mark_reg);
register_dictionary.define(".ne",
@@ -1195,7 +1195,7 @@ void init_div_requests()
register_dictionary.define(".trunc",
new constant_vunits_reg(&truncated_space));
register_dictionary.define(".vpt",
- new constant_int_reg(&vertical_position_traps_flag));
+ new readonly_register(&vertical_position_traps_flag));
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));
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 5356f1092..cd786087b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7559,11 +7559,11 @@ const char *readonly_text_register::get_string()
return s;
}
-constant_int_reg::constant_int_reg(int *q) : p(q)
+readonly_register::readonly_register(int *q) : p(q)
{
}
-const char *constant_int_reg::get_string()
+const char *readonly_register::get_string()
{
return i_to_a(*p);
}
@@ -8460,18 +8460,18 @@ void init_input_requests()
init_request("writem", write_macro_request);
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(".C", new readonly_register(&compatible_flag));
+ register_dictionary.define(".cp", new
readonly_register(&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(".color", new readonly_register(&color_flag));
register_dictionary.define(".F", new filename_reg);
register_dictionary.define(".g", new readonly_text_register("1"));
- register_dictionary.define(".H", new constant_int_reg(&hresolution));
+ register_dictionary.define(".H", new readonly_register(&hresolution));
register_dictionary.define(".R", new readonly_text_register("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));
+ register_dictionary.define(".U", new readonly_register(&unsafe_flag));
+ register_dictionary.define(".V", new readonly_register(&vresolution));
+ register_dictionary.define(".warn", new readonly_register(&warning_mask));
extern const char *major_version;
register_dictionary.define(".x", new readonly_text_register(major_version));
extern const char *revision;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 3d105f0ee..d17198db8 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6642,9 +6642,9 @@ void init_node_requests()
init_request("uf", underline_font);
register_dictionary.define(".fp", new next_available_font_position_reg);
register_dictionary.define(".kern",
- new constant_int_reg(&global_kern_mode));
+ new readonly_register(&global_kern_mode));
register_dictionary.define(".lg",
- new constant_int_reg(&global_ligature_mode));
+ new readonly_register(&global_ligature_mode));
register_dictionary.define(".P", new printing_reg);
soft_hyphen_char = get_charinfo(HYPHEN_SYMBOL);
}
diff --git a/src/roff/troff/reg.h b/src/roff/troff/reg.h
index 8378649f1..132bcf1f7 100644
--- a/src/roff/troff/reg.h
+++ b/src/roff/troff/reg.h
@@ -30,10 +30,10 @@ public:
virtual void set_value(units);
};
-class constant_int_reg : public reg {
+class readonly_register : public reg {
int *p;
public:
- constant_int_reg(int *);
+ readonly_register(int *);
const char *get_string();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 35/46: [troff]: Trivially refactor ("constant_int_reg").,
G. Branden Robinson <=