gbranden pushed a commit to branch master
in repository groff.

commit 052b90187e0f66b7156663d01ecbd54e0ac390f8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Oct 18 11:45:44 2026 -0500

    src/roff/troff/input.cpp: Improve `\D` errors.
    
    * src/roff/troff/input.cpp (read_drawing_command)
      (read_drawing_command_color_arguments): When diagnosing invalid
      drawing command parameters, make the interpretation context clear.
---
 ChangeLog                |  9 +++++++++
 src/roff/troff/input.cpp | 17 ++++++++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 99e65c61b..6292f8be9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-10-18  G. Branden Robinson <[email protected]>
+
+       src/roff/troff/input.cpp: Improve `\D` error diagnostics.
+
+       * src/roff/troff/input.cpp (read_drawing_command)
+       (read_drawing_command_color_arguments): When diagnosing invalid
+       drawing command parameters, make the interpretation context
+       clear.
+
 2026-10-17  G. Branden Robinson <[email protected]>
 
        [troff]: `pm` request advances past invalid args.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index b3430159d..a5fc311a2 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -10726,6 +10726,7 @@ static node *read_drawing_command() // \D
       int type = tok.ch(); // safely compares to char literals
       // TODO: grochar
       if (type == 'F') {
+       // XXX: undocumented
        read_drawing_command_color_arguments(start_token);
        return 0 /* nullptr */;
       }
@@ -10781,36 +10782,38 @@ static node *read_drawing_command() // \D
        switch (type) {
        case 'l':
          if (npoints != 1 || no_last_v) {
-           error("two arguments needed for line");
+           error("two arguments needed for line drawing command");
            npoints = 1;
          }
          break;
        case 'c':
          if (npoints != 1 || !no_last_v) {
-           error("one argument needed for circle");
+           error("one argument needed for circle drawing command");
            npoints = 1;
            point[0].v = V0;
          }
          break;
        case 'e':
          if (npoints != 1 || no_last_v) {
-           error("two arguments needed for ellipse");
+           error("two arguments needed for ellipse drawing command");
            npoints = 1;
          }
          break;
        case 'a':
          if (npoints != 2 || no_last_v) {
-           error("four arguments needed for arc");
+           error("four arguments needed for arc drawing command");
            npoints = 2;
          }
          break;
        case '~':
          if (no_last_v)
-           error("even number of arguments needed for spline");
+           error("even number of arguments needed for spline drawing"
+                 " command");
          break;
        case 'f':
+         // XXX: undocumented
          if (npoints != 1 || !no_last_v) {
-           error("one argument needed for gray shade");
+           error("one argument needed for gray shade drawing command");
            npoints = 1;
            point[0].v = V0;
          }
@@ -10837,7 +10840,7 @@ static void read_drawing_command_color_arguments(token 
&start)
 {
   tok.next();
   if (tok == start) {
-    error("missing color scheme");
+    error("missing color scheme in drawing command");
     return;
   }
   // safely compares to char literals; TODO: grochar

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

Reply via email to