[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 94/127: [troff]: Trivially refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 94/127: [troff]: Trivially refactor. |
Date: |
Mon, 10 Jul 2023 04:31:01 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 9e1d1c3f683602f54cddb88ccc2f1ae36446f076
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue May 2 10:50:52 2023 -0500
[troff]: Trivially refactor.
* src/roff/troff/reg.cpp (set_number_reg): Rename to...
(set_register): ...this.
* src/roff/troff/reg.h: Update extern reference.
* src/roff/troff/div.cpp (mark):
* src/roff/troff/input.cpp (length_request, do_register)
(token::add_to_zero_width_node_list, do_register_assignment)
(init_registers): Update call sites.
* src/roff/troff/div.cpp (interpolate_number_reg): Rename to...
(interpolate_register): ...this.
(get_copy, token::next, length_request, read_title_parts): Update call
sites.
* src/roff/troff/token.h: Update extern reference. Explicitly declare
as `extern`.
* src/roff/troff/reg.cpp (define_number_reg): Rename to...
(define_register): ...this.
(init_reg_requests): Update call site.
(set_number_reg): Rename to...
(set_register): ...this.
(print_number_regs): Rename to...
(print_registers): ...this.
* src/roff/troff/reg.cpp (lookup_number_reg): Rename to...
(look_up_register): ...this.
* src/roff/troff/input.cpp (interpolate_register): Update call site.
* src/roff/troff/reg.h: Update extern reference. Explicitly declare as
`extern`.
---
ChangeLog | 34 ++++++++++++++++++++++++++++++++++
src/roff/troff/div.cpp | 12 ++++++------
src/roff/troff/input.cpp | 44 +++++++++++++++++++++-----------------------
src/roff/troff/reg.cpp | 14 +++++++-------
src/roff/troff/reg.h | 13 +++++++++----
src/roff/troff/token.h | 2 +-
6 files changed, 78 insertions(+), 41 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 332257f5a..6bd54a82b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2023-05-02 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor.
+
+ * src/roff/troff/reg.cpp (set_number_reg): Rename to...
+ (set_register): ...this.
+ * src/roff/troff/reg.h: Update extern reference.
+ * src/roff/troff/div.cpp (mark):
+ * src/roff/troff/input.cpp (length_request, do_register)
+ (token::add_to_zero_width_node_list, do_register_assignment)
+ (init_registers): Update call sites.
+
+ * src/roff/troff/div.cpp (interpolate_number_reg): Rename to...
+ (interpolate_register): ...this.
+ (get_copy, token::next, length_request, read_title_parts):
+ Update call sites.
+ * src/roff/troff/token.h: Update extern reference. Explicitly
+ declare as `extern`.
+
+ * src/roff/troff/reg.cpp (define_number_reg): Rename to...
+ (define_register): ...this.
+ (init_reg_requests): Update call site.
+ (set_number_reg): Rename to...
+ (set_register): ...this.
+ (print_number_regs): Rename to...
+ (print_registers): ...this.
+
+ * src/roff/troff/reg.cpp (lookup_number_reg): Rename to...
+ (look_up_register): ...this.
+ * src/roff/troff/input.cpp (interpolate_register): Update call
+ site.
+ * src/roff/troff/reg.h: Update extern reference. Explicitly
+ declare as `extern`.
+
2023-04-30 G. Branden Robinson <g.branden.robinson@gmail.com>
[eqn]: Improve tests of line number accuracy.
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index d195baf0e..f4dc06f33 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -919,9 +919,9 @@ void mark()
if (s.is_null())
curdiv->marked_place = curdiv->get_vertical_position();
else if (curdiv == topdiv)
- set_number_reg(s, nl_reg_contents);
+ set_register(s, nl_reg_contents);
else
- set_number_reg(s, curdiv->get_vertical_position().to_units());
+ set_register(s, curdiv->get_vertical_position().to_units());
skip_line();
}
@@ -1183,11 +1183,11 @@ void init_div_requests()
init_request("vpt", vertical_position_traps);
init_request("wh", when_request);
register_dictionary.define(".a",
- new readonly_register(&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",
- new constant_vunits_reg(&needed_space));
+ new constant_vunits_reg(&needed_space));
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);
@@ -1195,9 +1195,9 @@ void init_div_requests()
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));
+ new constant_vunits_reg(&truncated_space));
register_dictionary.define(".vpt",
- new readonly_register(&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 cd4638c81..a19935d20 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1048,7 +1048,7 @@ static int get_copy(node **nd, bool is_defining, bool
handle_escape_E)
int inc;
symbol s = read_increment_and_escape_parameter(&inc);
if (!(s.is_null() || s.is_empty()))
- interpolate_number_reg(s, inc);
+ interpolate_register(s, inc);
break;
}
case 'g':
@@ -2149,7 +2149,7 @@ void token::next()
int inc;
symbol s = read_increment_and_escape_parameter(&inc);
if (!(s.is_null() || s.is_empty()))
- interpolate_number_reg(s, inc);
+ interpolate_register(s, inc);
break;
}
case 'N':
@@ -4922,7 +4922,7 @@ void length_request()
if (r)
r->set_value(len);
else
- set_number_reg(ret, len);
+ set_register(ret, len);
tok.next();
}
@@ -4989,9 +4989,9 @@ static void interpolate_environment_variable(symbol nm)
input_stack::push(make_temp_iterator(s));
}
-void interpolate_number_reg(symbol nm, int inc)
+void interpolate_register(symbol nm, int inc)
{
- reg *r = lookup_number_reg(nm);
+ reg *r = look_up_register(nm);
if (inc < 0)
r->decrement();
else if (inc > 0)
@@ -5265,7 +5265,7 @@ static void do_register()
if (r)
r->set_value(val);
else
- set_number_reg(nm, val);
+ set_register(nm, val);
}
// this implements the \w escape sequence
@@ -5328,7 +5328,7 @@ void read_title_parts(node **part, hunits *part_width)
break;
}
if (page_character != 0 && tok.get_char() == page_character)
- interpolate_number_reg(percent_symbol, 0);
+ interpolate_register(percent_symbol, 0);
else
tok.process();
tok.next();
@@ -7314,7 +7314,7 @@ int token::add_to_zero_width_node_list(node **pp)
case TOKEN_LEFT_BRACE:
break;
case TOKEN_MARK_INPUT:
- set_number_reg(nm, curenv->get_input_line_position().to_units());
+ set_register(nm, curenv->get_input_line_position().to_units());
break;
case TOKEN_NODE:
case TOKEN_HORIZONTAL_SPACE:
@@ -7404,7 +7404,7 @@ void token::process()
case TOKEN_LEFT_BRACE:
break;
case TOKEN_MARK_INPUT:
- set_number_reg(nm, curenv->get_input_line_position().to_units());
+ set_register(nm, curenv->get_input_line_position().to_units());
break;
case TOKEN_NEWLINE:
curenv->newline();
@@ -7953,7 +7953,7 @@ static void do_register_assignment(const char *s)
buf[1] = 0;
units n;
if (evaluate_expression(s + 1, &n))
- set_number_reg(buf, n);
+ set_register(buf, n);
}
else {
char *buf = new char[p - s + 1];
@@ -7961,7 +7961,7 @@ static void do_register_assignment(const char *s)
buf[p - s] = 0;
units n;
if (evaluate_expression(p + 1, &n))
- set_number_reg(buf, n);
+ set_register(buf, n);
delete[] buf;
}
}
@@ -8291,19 +8291,17 @@ static void init_registers()
#endif /* not LONG_FOR_TIME_T */
t = current_time();
struct tm *tt = localtime(&t);
- set_number_reg("seconds", int(tt->tm_sec));
- set_number_reg("minutes", int(tt->tm_min));
- set_number_reg("hours", int(tt->tm_hour));
- set_number_reg("dw", int(tt->tm_wday + 1));
- set_number_reg("dy", int(tt->tm_mday));
- set_number_reg("mo", int(tt->tm_mon + 1));
- set_number_reg("year", int(1900 + tt->tm_year));
- set_number_reg("yr", int(tt->tm_year));
- set_number_reg("$$", getpid());
+ set_register("seconds", int(tt->tm_sec));
+ set_register("minutes", int(tt->tm_min));
+ set_register("hours", int(tt->tm_hour));
+ set_register("dw", int(tt->tm_wday + 1));
+ set_register("dy", int(tt->tm_mday));
+ set_register("mo", int(tt->tm_mon + 1));
+ set_register("year", int(1900 + tt->tm_year));
+ set_register("yr", int(tt->tm_year));
+ set_register("$$", getpid());
register_dictionary.define(".A",
- new readonly_text_register(ascii_output_flag
- ? "1"
- : "0"));
+ new readonly_text_register(ascii_output_flag ? "1" : "0"));
}
/*
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 3b8f020ae..680a3c6ae 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -298,7 +298,7 @@ bool variable_reg::get_value(units *res)
return true;
}
-void define_number_reg()
+void define_register()
{
symbol nm = get_name(true /* required */);
if (nm.is_null()) {
@@ -323,7 +323,7 @@ void define_number_reg()
}
#if 0
-void inline_define_reg()
+void inline_define_register()
{
token start;
start.next();
@@ -355,7 +355,7 @@ void inline_define_reg()
}
#endif
-void set_number_reg(symbol nm, units n)
+void set_register(symbol nm, units n)
{
reg *r = (reg *)register_dictionary.lookup(nm);
if (r == 0) {
@@ -365,7 +365,7 @@ void set_number_reg(symbol nm, units n)
r->set_value(n);
}
-reg *lookup_number_reg(symbol nm)
+reg *look_up_register(symbol nm)
{
reg *r = (reg *)register_dictionary.lookup(nm);
if (r == 0) {
@@ -445,7 +445,7 @@ void rename_reg()
skip_line();
}
-void print_number_regs()
+void print_registers()
{
object_dictionary_iterator iter(register_dictionary);
reg *r;
@@ -465,11 +465,11 @@ void print_number_regs()
void init_reg_requests()
{
init_request("rr", remove_reg);
- init_request("nr", define_number_reg);
+ init_request("nr", define_register);
init_request("af", alter_format);
init_request("aln", alias_reg);
init_request("rnn", rename_reg);
- init_request("pnr", print_number_regs);
+ init_request("pnr", print_registers);
}
// Local Variables:
diff --git a/src/roff/troff/reg.h b/src/roff/troff/reg.h
index 132bcf1f7..1ee3a4ee0 100644
--- a/src/roff/troff/reg.h
+++ b/src/roff/troff/reg.h
@@ -1,4 +1,3 @@
-// -*- C++ -*-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -64,11 +63,17 @@ public:
};
extern object_dictionary register_dictionary;
-extern void set_number_reg(symbol nm, units n);
+extern void set_register(symbol nm, units n);
extern void check_output_limits(int x, int y);
extern void reset_output_registers();
-reg *lookup_number_reg(symbol);
+extern reg *look_up_register(symbol);
#if 0
-void inline_define_reg();
+void inline_define_register();
#endif
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index bd7605576..aec3854d3 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -131,7 +131,7 @@ extern int get_integer(int *result);
extern int get_number(units *result, unsigned char si, units prev_value);
extern int get_integer(int *result, int prev_value);
-void interpolate_number_reg(symbol, int);
+extern void interpolate_register(symbol, int);
const char *asciify(int c);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 94/127: [troff]: Trivially refactor.,
G. Branden Robinson <=