gbranden pushed a commit to branch master
in repository groff.
commit 42e50f184e2551cee36be1f7dd52d6c547f48fb6
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Dec 18 12:50:22 2025 -0600
Retire our hypot(3) replacement.
...in favor of gnulib's. Werner Lemberg borrowed ours from glibc in
2005 to work around a problem with its Interix implementation. Interix
has been dead a long time. We still want a replacement, though, as
gnulib documents hypot(3) as broken on mingw and MSVC 2014. We
certainly wish to keep working on the former.
* bootstrap.conf: Add "hypot" to "gnulib_modules".
* src/include/lib.h: Drop declaration of `groff_hypot()`.
* src/libs/libgroff/hypot.cpp: Delete.
* src/libs/libgroff/libgroff.am (libgroff_a_SOURCES): Drop foregoing
file.
* src/preproc/grn/hgraph.cpp (len, HGArc, picurve, Parameterize):
* src/preproc/pic/object.cpp (hypot): Migrate `groff_hypot()` calls to
`hypot()`.
Continues the long process of fixing Savannah #66518.
---
ChangeLog | 21 +++++++++++++++++++++
bootstrap.conf | 1 +
src/include/lib.h | 1 -
src/libs/libgroff/hypot.cpp | 40 ----------------------------------------
src/libs/libgroff/libgroff.am | 1 -
src/preproc/grn/hgraph.cpp | 14 +++++++-------
src/preproc/pic/object.cpp | 2 +-
7 files changed, 30 insertions(+), 50 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 68b5b2fcd..7fabe8f68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2025-12-18 G. Branden Robinson <[email protected]>
+
+ Retire our hypot(3) replacement in favor of gnulib's. Werner
+ Lemberg borrowed ours from glibc in 2005 to work around a
+ problem with its Interix implementation. Interix has been dead
+ a long time. We still want a replacement, though, as gnulib
+ documents hypot(3) as broken on mingw and MSVC 2014. We
+ certainly wish to keep working on the former.
+
+ * bootstrap.conf: Add "hypot" to "gnulib_modules".
+ * src/include/lib.h: Drop declaration of `groff_hypot()`.
+ * src/libs/libgroff/hypot.cpp: Delete.
+ * src/libs/libgroff/libgroff.am (libgroff_a_SOURCES): Drop
+ foregoing file.
+ * src/preproc/grn/hgraph.cpp (len, HGArc, picurve)
+ (Parameterize):
+ * src/preproc/pic/object.cpp (hypot): Migrate `groff_hypot()`
+ calls to `hypot()`.
+
+ Continues the long process of fixing Savannah #66518.
+
2025-12-17 G. Branden Robinson <[email protected]>
* tmac/ps.tmac: Delete internal macros after we're done using
diff --git a/bootstrap.conf b/bootstrap.conf
index 7cc44c82a..f16f9e7e0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -40,6 +40,7 @@ gnulib_modules="
getopt-gnu
git-version-gen
havelib
+ hypot
memmem
wcwidth
fmod
diff --git a/src/include/lib.h b/src/include/lib.h
index 3afb122af..27ccfdd69 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -47,7 +47,6 @@ extern "C" {
char *strsave(const char *s);
unsigned ceil_prime(unsigned);
-double groff_hypot(double, double);
#include <stdio.h>
#include <string.h>
diff --git a/src/libs/libgroff/hypot.cpp b/src/libs/libgroff/hypot.cpp
deleted file mode 100644
index 4b3db323c..000000000
--- a/src/libs/libgroff/hypot.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright 2005-2020 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-
-double groff_hypot(double x, double y)
-{
- double result = hypot(x, y);
-
-#ifdef __INTERIX
- /* hypot() on Interix is broken */
- if (isnan(result) && !isnan(x) && !isnan(y))
- return 0.0;
-#endif
-
- return result;
-}
-
-// Local Variables:
-// fill-column: 72
-// mode: C++
-// End:
-// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/libs/libgroff/libgroff.am b/src/libs/libgroff/libgroff.am
index 25b72bcf3..5994e5b6f 100644
--- a/src/libs/libgroff/libgroff.am
+++ b/src/libs/libgroff/libgroff.am
@@ -39,7 +39,6 @@ libgroff_a_SOURCES = \
src/libs/libgroff/geometry.cpp \
src/libs/libgroff/glyphuni.cpp \
src/libs/libgroff/htmlhint.cpp \
- src/libs/libgroff/hypot.cpp \
src/libs/libgroff/iftoa.c \
src/libs/libgroff/invalid.cpp \
src/libs/libgroff/itoa.c \
diff --git a/src/preproc/grn/hgraph.cpp b/src/preproc/grn/hgraph.cpp
index 2d785955a..9bf3d547a 100644
--- a/src/preproc/grn/hgraph.cpp
+++ b/src/preproc/grn/hgraph.cpp
@@ -24,8 +24,8 @@
#define PointsPerInterval 64
#define pi 3.14159265358979324
#define twopi (2.0 * pi)
-#define len(a, b) groff_hypot((double)(b.x-a.x), \
- (double)(b.y-a.y))
+#define len(a, b) hypot((double)(b.x-a.x), \
+ (double)(b.y-a.y))
extern int dotshifter; /* for the length of dotted curves */
@@ -610,7 +610,7 @@ HGArc(int cx,
length = 0;
- resolution = (1.0 + groff_hypot(xs, ys) / res) * PointsPerInterval;
+ resolution = (1.0 + hypot(xs, ys) / res) * PointsPerInterval;
/* mask = (1 << (int) log10(resolution + 1.0)) - 1; */
(void) frexp(resolution, &m); /* more elegant than log10 */
for (mask = 1; mask < m; mask = mask << 1);
@@ -681,14 +681,14 @@ picurve(int *x,
for (; npts--; x++, y++) { /* traverse the line segments */
xp = x[0] - x[1];
yp = y[0] - y[1];
- nseg = (int) groff_hypot((double) xp, (double) yp);
+ nseg = (int) hypot((double) xp, (double) yp);
xp = x[1] - x[2];
yp = y[1] - y[2];
/* 'nseg' is the number of line */
/* segments that will be drawn for */
/* each curve segment. */
- nseg = (int) ((double) (nseg + (int) groff_hypot((double) xp,
- (double) yp)) /
+ nseg = (int) ((double) (nseg + (int) hypot((double) xp,
+ (double) yp)) /
res * PointsPerInterval);
for (i = 1; i < nseg; i++) {
@@ -806,7 +806,7 @@ Parameterize(int x[],
dy = y[j + 1] - y[j];
/* Here was overflowing, so I changed it. */
/* u[i] += sqrt ((double) (dx * dx + dy * dy)); */
- u[i] += groff_hypot((double) dx, (double) dy);
+ u[i] += hypot((double) dx, (double) dy);
}
}
for (i = 1; i < n; ++i)
diff --git a/src/preproc/pic/object.cpp b/src/preproc/pic/object.cpp
index e44819cac..d33951104 100644
--- a/src/preproc/pic/object.cpp
+++ b/src/preproc/pic/object.cpp
@@ -207,7 +207,7 @@ double operator*(const position &a, const position &b)
double hypot(const position &a)
{
- return groff_hypot(a.x, a.y);
+ return hypot(a.x, a.y);
}
struct arrow_head_type {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit