gbranden pushed a commit to branch master
in repository groff.

commit 498a48843c0c0357199f44891e02aed2dbda3be2
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Fri Dec 8 14:47:19 2023 -0600

    [troff]: Warn when `if` or `ie` lacks arguments.
    
    * src/roff/troff/input.cpp (if_else_request, if_request): Throw warning
      in category `missing` if given no arguments.
---
 ChangeLog                |  5 +++++
 src/roff/troff/input.cpp | 11 +++++++++++
 2 files changed, 16 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4638fee8e..fd6f695f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-12-08  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/roff/troff/input.cpp (if_else_request, if_request): Throw
+       warning in category `missing` if given no arguments.
+
 2023-12-08  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        Manage config.h more consistently.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index a9abd1905..afdce9885 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6059,11 +6059,21 @@ int do_if_request()
 
 void if_else_request()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "if-else request expects arguments");
+    skip_line();
+    return;
+  }
   if_else_stack.push(do_if_request());
 }
 
 void if_request()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "if-then request expects arguments");
+    skip_line();
+    return;
+  }
   do_if_request();
 }
 
@@ -6086,6 +6096,7 @@ static int while_break_flag = 0;
 
 void while_request()
 {
+  // We can't use `has_arg()` here.  XXX: Figure out why.
   macro mac;
   int escaped = 0;
   int level = 0;

_______________________________________________
Groff-commit mailing list
Groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to