gbranden pushed a commit to branch master
in repository groff.
commit e361d6f2d65311433da7d04837f8d68683a18d8a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 29 19:32:21 2026 -0500
[libgroff]: Improve #include discipline (2/5).
* src/libs/libgroff/prime.cpp: Improve header file inclusion discipline.
Use preprocessor to include "lib.h" header, which declares the
`ceil_prime()` function defined here. Also unabbreviate data type of
argument and return value; I prefer `unsigned int` to `unsigned`.
It's surprising to me that Thompson and Ritchie overcame their
inclination to extreme abbreviation here; not only are "signed" and
"unsigned" intelligible English words, but it proved to be a bad idea to
make their syntax closely resemble what eventually became ANSI C89's
type qualifiers `const`--notably an abbreviation again--and `volatile`.
It took ISO C99 to bring us `uintN_t` and `intN_t` types, at which point
Ritchie, at least, appears to have given up on staying current with the
language, never preparing with Kernighan a third edition of their _The C
Programming Language_ before his death in 2011. I find it diverting
to consider how many problems of the C language can be sufficiently
explained by a tacit but intense resentment of strong typing.
---
ChangeLog | 20 ++++++++++++++++++++
src/include/lib.h | 3 ++-
src/libs/libgroff/prime.cpp | 6 ++++--
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 92db5f672..984d09b94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2026-03-29 G. Branden Robinson <[email protected]>
+
+ * src/libs/libgroff/prime.cpp: Improve header file inclusion
+ discipline. Use preprocessor to include "lib.h" header, which
+ declares the `ceil_prime()` function defined here. Also
+ unabbreviate data type of argument and return value; I prefer
+ `unsigned int` to `unsigned`. (It's surprising that Thompson
+ and Ritchie overcame their inclination to extreme abbreviation
+ here; not only are "signed" and "unsigned" intelligible English
+ words, but it proved to be a bad idea to make their syntax
+ closely resemble what eventually became ANSI C89's type
+ qualifiers `const`--notably an abbreviation again--and
+ `volatile`. It took ISO C99 to bring us `uintN_t` and `intN_t`
+ types, at which point Ritchie, at least, appears to have given
+ up on staying current with the language, never preparing with
+ Kernighan a third edition of their _The C Programming Language_
+ before his death in 2011. I find it a fun diversion to consider
+ how many problems of the C language can be sufficiently
+ explained by a tacit but intense resentment of strong typing.)
+
2026-03-29 G. Branden Robinson <[email protected]>
* src/libs/libgroff/mksdir.cpp: Improve header file
diff --git a/src/include/lib.h b/src/include/lib.h
index c1a630d5e..4c4b917ae 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -47,7 +47,8 @@ extern "C" {
#include <stdbool.h>
char *strsave(const char *s);
-unsigned ceil_prime(unsigned);
+// libgroff/prime.cpp
+unsigned int ceil_prime(unsigned int);
#include <stdio.h>
#include <string.h>
diff --git a/src/libs/libgroff/prime.cpp b/src/libs/libgroff/prime.cpp
index 0f3657a3a..89793bfac 100644
--- a/src/libs/libgroff/prime.cpp
+++ b/src/libs/libgroff/prime.cpp
@@ -23,9 +23,11 @@ internet at <http://www.gnu.org/licenses/gpl-2.0.txt>. */
#include <assert.h>
#include <math.h>
-static bool is_prime(unsigned);
+#include "lib.h" // ceil_prime()
-unsigned ceil_prime(unsigned n)
+static bool is_prime(unsigned int);
+
+unsigned int ceil_prime(unsigned int n)
{
if (n <= 2)
return 2;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit