gbranden pushed a commit to branch master
in repository groff.

commit 60b615223e90e0f290c76dd1648aad81f7f1f761
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Jul 27 22:38:39 2026 -0500

    src/roff/troff/input.cpp: Fix Savannah #68571.
    
    * src/roff/troff/input.cpp: Revise `shift` request behavior; perform no
      operation if the argument is invalid.
    
    Fixes <https://savannah.gnu.org/bugs/?68571>.
    
    NEWS: Add item.
---
 ChangeLog                |  7 +++++++
 NEWS                     |  3 +++
 src/roff/troff/input.cpp | 11 ++++++++---
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0abcaf9b0..f4845d31e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-07-27  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp: Revise `shift` request behavior;
+       perform no operation if the argument is invalid.
+
+       Fixes <https://savannah.gnu.org/bugs/?68571>.
+
 2026-07-23  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/div.cpp (write_any_trailer_and_exit): Add
diff --git a/NEWS b/NEWS
index ff0b9cf9b..0bc241507 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ VERSION next
 troff
 -----
 
+*  The `shift` request no longer performs an operation if it is given an
+   invalid argument.
+
 *  The formatter now emits a warning in category "style" if -crementing
    interpolation (such as `\n+[myreg]` or `\n-[count]`) is (uselessly)
    applied to a non-auto-crementing register.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8005e0287..32fbeeaa0 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1018,10 +1018,15 @@ static void next_file_request() // .nx
 
 static void shift_request() // .shift
 {
-  int n;
-  if (!has_arg() || !read_integer(&n))
+  int n = 0;
+  if (!has_arg())
     n = 1;
-  input_stack::shift(n);
+  else
+    (void) read_integer(&n);
+  if (n < 0)
+    warning(WARN_RANGE, "ignoring negative macro argument shift %1", n);
+  else if (n > 0)
+    input_stack::shift(n);
   skip_line();
 }
 

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

Reply via email to