mirror of
https://https.git.savannah.gnu.org/git/groff.git
synced 2026-01-26 07:37:53 +00:00
Rename array_size to array_length.
* src/include/lib.h (array_size): Rename to... (array_length): ...this. * src/preproc/eqn/box.cpp (set_param, reset_param, get_param) (init_param_table, free_param_table): Migrate call sites. Thanks to Alex Colomar for the discussion. See <https://lists.gnu.org/archive/html/groff/2023-08/msg00140.html>. Acked-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
e5f6d91b6d
commit
e0cb0910cb
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2023-08-28 G. Branden Robinson <g.branden.robinson@gmail.com>
|
||||
|
||||
* src/include/lib.h (array_size): Rename to...
|
||||
(array_length): ...this.
|
||||
|
||||
* src/preproc/eqn/box.cpp (set_param, reset_param, get_param)
|
||||
(init_param_table, free_param_table): Migrate call sites.
|
||||
|
||||
Thanks to Alex Colomar for the discussion.
|
||||
|
||||
2023-08-28 G. Branden Robinson <g.branden.robinson@gmail.com>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Ship ancient groff ChangeLog files
|
||||
|
||||
6
HACKING
6
HACKING
@ -22,6 +22,12 @@ Standard Template Library is little used. A modest effort is underway
|
||||
to update the code to more idiomatic C++98. Where a C++11 feature
|
||||
promises to be advantageous, it may be annotated in a code comment.
|
||||
|
||||
Portability notes:
|
||||
|
||||
* `std::size` is not available in C++98. Use the `array_length`
|
||||
template function in src/include/lib.h instead of `sizeof` and
|
||||
dividing.
|
||||
|
||||
|
||||
Automake
|
||||
--------
|
||||
|
||||
@ -155,7 +155,7 @@ static const double PI = 3.14159265358979323846;
|
||||
#ifdef __cplusplus
|
||||
template <typename T, size_t N>
|
||||
// constexpr // C++11
|
||||
size_t array_size(T(&)[N]) {
|
||||
size_t array_length(T(&)[N]) {
|
||||
return N;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -135,7 +135,7 @@ struct param *param_table = 0 /* nullptr */;
|
||||
|
||||
void set_param(const char *name, int value)
|
||||
{
|
||||
for (size_t i = 0; i <= array_size(default_param_table); i++)
|
||||
for (size_t i = 0; i <= array_length(default_param_table); i++)
|
||||
if (strcmp(param_table[i].name, name) == 0) {
|
||||
*(param_table[i].ptr) = value;
|
||||
return;
|
||||
@ -145,7 +145,7 @@ void set_param(const char *name, int value)
|
||||
|
||||
void reset_param(const char *name)
|
||||
{
|
||||
for (size_t i = 0; i < array_size(default_param_table); i++)
|
||||
for (size_t i = 0; i < array_length(default_param_table); i++)
|
||||
if (strcmp(param_table[i].name, name) == 0) {
|
||||
*param_table[i].ptr = *(default_param_table[i].ptr);
|
||||
return;
|
||||
@ -156,7 +156,7 @@ void reset_param(const char *name)
|
||||
|
||||
int get_param(const char *name)
|
||||
{
|
||||
for (size_t i = 0; i < array_size(default_param_table); i++)
|
||||
for (size_t i = 0; i < array_length(default_param_table); i++)
|
||||
if (strcmp(param_table[i].name, name) == 0)
|
||||
return *(param_table[i].ptr);
|
||||
assert(0 == "attempted to access parameter not in table");
|
||||
@ -165,8 +165,8 @@ int get_param(const char *name)
|
||||
|
||||
void init_param_table()
|
||||
{
|
||||
param_table = new param[array_size(default_param_table)];
|
||||
for (size_t i = 0; i < array_size(default_param_table); i++) {
|
||||
param_table = new param[array_length(default_param_table)];
|
||||
for (size_t i = 0; i < array_length(default_param_table); i++) {
|
||||
param_table[i].name = default_param_table[i].name;
|
||||
param_table[i].ptr = new int(*(default_param_table[i].ptr));
|
||||
}
|
||||
@ -175,7 +175,7 @@ void init_param_table()
|
||||
void free_param_table()
|
||||
{
|
||||
if (param_table != 0 /* nullptr */) {
|
||||
for (size_t i = 0; i < array_size(default_param_table); i++)
|
||||
for (size_t i = 0; i < array_length(default_param_table); i++)
|
||||
delete param_table[i].ptr;
|
||||
delete[] param_table;
|
||||
param_table = 0 /* nullptr */;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user