groff-commit
[Top][All Lists]
Advanced

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

[groff] 09/16: [ms]: Fix `DS` code style nit and add diagnostic.


From: G. Branden Robinson
Subject: [groff] 09/16: [ms]: Fix `DS` code style nit and add diagnostic.
Date: Sat, 6 Nov 2021 01:38:19 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 1887bbe68cf3d8dfda99fe6f1d58e9bc9922fab0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Nov 5 20:02:57 2021 +1100

    [ms]: Fix `DS` code style nit and add diagnostic.
    
    * tmac/s.tmac (DS): Drop a redundant unconditional break; every display
      macro we call in the event of a valid call already breaks the line,
      and it's polite to not break if we're given an invalid argument.  Emit
      a diagnostic error if the argument we're given is invalid, and
      immediately end the diversion we just opened.
---
 ChangeLog   |  9 +++++++++
 tmac/s.tmac | 17 ++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9db080e..ef12705 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-11-05  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/s.tmac (DS): Drop a redundant unconditional break; every
+       display macro we call in the event of a valid call already
+       breaks the line, and it's polite to not break if we're given an
+       invalid argument.  Emit a diagnostic error if the argument we're
+       given is invalid, and immediately end the diversion we just
+       opened.
+
 2021-11-04  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/env.cpp (environment::set_font): Clarify
diff --git a/tmac/s.tmac b/tmac/s.tmac
index 907146e..d7bd116 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -1034,7 +1034,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 ..
 .de DS
 .if '\\n(.z'ds*div' .@error-recover cannot begin display within display
-.br
+.nr ds*badarg 0
 .di ds*div
 .ie '\\$1'B' \{\
 .      LD
@@ -1048,12 +1048,23 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .                      ie '\\$1'R' .RD
 .                      el \{\
 .                              ie '\\$1'I' .ID \\$2
-.                              el .ID \\$1
+.                              el \{\
+.                                      ie '\\$1'' .ID
+.                                      el .nr ds*badarg 1
+.                              \}
 .                      \}
 .              \}
 .      \}
-.      nr \\n[.ev]:ds-type 3
+.      ie \\n[ds*badarg] \{
+.              ds ds*msg unrecognized argument '\\$1' to .\\$0;\"
+.              as ds*msg " did you mean '.\\$0 I \\$1'?\"
+.              @error \\*[ds*msg]
+.              rm ds*msg
+.              di
+.      \}
+.      el .nr \\n[.ev]:ds-type 3
 .\}
+.rr ds*badarg
 ..
 .de ds@need
 .if '\\n(.z'' \{\



reply via email to

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