groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 11/12: [troff]: Warn on no-op device & output requests.


From: G. Branden Robinson
Subject: [groff] 11/12: [troff]: Warn on no-op device & output requests.
Date: Fri, 10 Nov 2023 17:36:14 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 429723c3ec773a36313001ba70862fa6a7408984
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Nov 10 15:16:50 2023 -0600

    [troff]: Warn on no-op device & output requests.
    
    * src/roff/troff/input.cpp (device_request, output_request): Throw
      warning diagnostic if no arguments given.
---
 ChangeLog                |  5 +++++
 man/groff_diff.7.man     |  1 -
 src/roff/troff/input.cpp | 10 ++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index dc2465fa0..05c0d528e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-11-10  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/input.cpp (device_request, output_request):
+       Throw warning diagnostic if no arguments given.
+
 2023-11-06  Pim <pimh@kth.se>
 
        * src/preproc/eqn/lex.cpp: Update internal macro definitions
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index b0a82b5c6..26b6b9639 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -3017,7 +3017,6 @@ used in the top-level diversion.
 An initial neutral double quote in
 .I contents
 is stripped to allow the embedding of leading spaces.
-.\" XXX: useless request warning if no argument?
 .
 .
 .TP
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 89812a84d..aa776abec 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5653,6 +5653,11 @@ static node *do_special()
 
 void device_request()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "device control request expects arguments");
+    skip_line();
+    return;
+  }
   if (!tok.is_newline() && !tok.is_eof()) {
     int c;
     macro mac;
@@ -5689,6 +5694,11 @@ void device_macro_request()
 
 void output_request()
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "output request expects arguments");
+    skip_line();
+    return;
+  }
   if (!tok.is_newline() && !tok.is_eof()) {
     int c;
     for (;;) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]