Update of bug #68871 (group groff):

                  Status:                    None => In Progress
             Assigned to:                    None => gbranden
         Planned Release:                    None => 1.25.0
                 Summary: [troff] `ne` and `sv` requests should throw "range"
warning if argument is negative => [PATCH] [troff] `ne` and `sv` requests
should throw "range" warning if argument is negative

    _______________________________________________________

Follow-up Comment #1:


commit 9cd89cf5c3b3f31a08b86bfaeceed7949b7c7234
Author: G. Branden Robinson <[email protected]>
Date:   Sun Nov 1 23:22:18 2026 -0600

    [troff]: Warn on negative `ne` and `sv` arguments.
    
    * src/roff/troff/div.cpp (need_vertical_space_request)
      (save_vertical_space_request): Throw warning in category "range" and
      ignore request if a negative argument is specified.

diff --git a/ChangeLog b/ChangeLog
index 26778f284..af38cacdb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-11-01  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/div.cpp (need_vertical_space_request)
+       (save_vertical_space_request): Throw warning in category "range"
+       and ignore request if a negative argument is specified.
+
 2026-10-31  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp (translate_font_request): Distinguish
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 9fafa7235..eb0b02e84 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -922,6 +922,12 @@ static void need_vertical_space_request() // .ne
   vunits n;
   if (!has_arg() || !read_vunits(&n, 'v'))
     n = curenv->get_vertical_spacing();
+  if (n < V0) {
+    warning(WARN_RANGE, "ignoring request to require negative amount"
+                       " of vertical space: %1u", n.to_units());
+    skip_line();
+    return;
+  }
   while (!tok.is_terminator())
     tok.next();
   curdiv->need(n);
@@ -949,6 +955,12 @@ static void save_vertical_space_request() // .sv
   vunits x;
   if (!has_arg() || !read_vunits(&x, 'v'))
     x = curenv->get_vertical_spacing();
+  if (x < V0) {
+    warning(WARN_RANGE, "ignoring request to save negative amount"
+                       " of vertical space: %1u", x.to_units());
+    skip_line();
+    return;
+  }
   if (curdiv->distance_to_next_trap() > x)
     curdiv->space(x, true /* forcing */);
   else




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68871>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to