gbranden pushed a commit to branch master
in repository groff.

commit 4dc3be245e9c00a71bb2ce39d3e4b80b44bc1648
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Apr 11 05:14:51 2025 -0500

    [troff]: Fix build failure on GCC 5.5/Solaris 10.
    
    * src/roff/troff/env.cpp (environment::possibly_break_line): Fix build
      error with GCC 5.5 on Solaris 10.  Introduce a temporary variable
      `dsd` to store `space_deficit` as a `double`, and use it in divisions
      when computing the size of overset or underset reported in
      diagnostics.  Use `fabs()` instead of `abs()`.
---
 ChangeLog              |  8 ++++++++
 src/roff/troff/env.cpp | 23 +++++++++++------------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index db01e8285..8393bd255 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-04-11  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp (environment::possibly_break_line): Fix
+       build error with GCC 5.5 on Solaris 10.  Introduce a temporary
+       variable `dsd` to store `space_deficit` as a `double`, and use
+       it in divisions when computing the size of overset or underset
+       reported in diagnostics.  Use `fabs()` instead of `abs()`.
+
 2025-04-10  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/env.cpp (environment::possibly_break_line):
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index d29ad939a..ee3cf9df2 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -21,8 +21,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #endif
 
 #include <errno.h> // errno
-#include <math.h> // ceil()
-#include <stdlib.h> // abs()
+#include <math.h> // ceil(), fabs()
 
 #include <vector>
 #include <algorithm> // find()
@@ -2252,27 +2251,27 @@ void environment::possibly_break_line(bool 
must_break_here,
     // line length.
     hunits space_deficit = target_text_length - bp->width;
     // An overset line always gets a warning.
-    if (space_deficit < H0)
+    if (space_deficit < H0) {
+      double dsd = static_cast<double>(space_deficit.to_units());
       output_warning(WARN_BREAK, "cannot %1 line; overset by %2%3",
                     (ADJUST_BOTH == adjust_mode) ? "adjust" : "break",
                     in_nroff_mode
-                    ? static_cast<int>(ceil(abs(space_deficit
-                                                .to_units()
-                                       / hresolution)))
-                    : abs(space_deficit.to_units() / warn_scale),
+                    ? static_cast<int>(ceil(fabs(dsd / hresolution)))
+                    : fabs(dsd / warn_scale),
                     in_nroff_mode ? 'n' : warn_scaling_unit);
+    }
     // An underset line warns only if it requires adjustment but no
     // adjustable spaces exist on the line.
     else if ((ADJUST_BOTH == adjust_mode)
             && (space_deficit > H0)
-            && (0 == bp->nspaces))
+            && (0 == bp->nspaces)) {
+      double dsd = static_cast<double>(space_deficit.to_units());
       output_warning(WARN_BREAK, "cannot adjust line; underset by %1%2",
                     in_nroff_mode
-                    ? static_cast<int>(ceil(abs(space_deficit
-                                                .to_units()
-                                       / hresolution)))
-                    : abs(space_deficit.to_units() / warn_scale),
+                    ? static_cast<int>(ceil(fabs(dsd / hresolution)))
+                    : fabs(dsd / warn_scale),
                     in_nroff_mode ? 'n' : warn_scaling_unit);
+    }
     // The extra space is the amount of space to distribute among the
     // adjustable space nodes in an output line; this process occurs
     // only if adjustment is enabled.  We may however want to synthesize

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to