groff-commit
[Top][All Lists]
Advanced

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

[groff] 03/13: [troff]: Quieten `.ab` if given no arguments.


From: G. Branden Robinson
Subject: [groff] 03/13: [troff]: Quieten `.ab` if given no arguments.
Date: Sat, 11 Sep 2021 16:20:10 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit e266961202e32db22a94fa15ababddfc12771166
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Sep 7 07:16:20 2021 +1000

    [troff]: Quieten `.ab` if given no arguments.
    
    [troff]: Make `ab` request quiet if given no arguments.  The `tm`, and
    `tm1` and `tmc` requests provide ample flexibility for constructing
    diagnostic messages prior to an error exit, and it's convenient to make
    `ab` itself quiet instead of saying "User Abort." as Unix Version 7
    troff did.  Further, there is no standardization across troffs regarding
    what `ab` should emit if arguments are absent.
    
    * src/roff/troff/input.cpp (abort_request): Do it.
    
    * src/roff/groff/tests/ab_works.sh:
    * src/roff/groff/groff.am (groff_TESTS): Test it.
    
    * doc/groff.texi (Debugging, Implementation Differences):
    * man/groff.7.man (Requests/Request short reference):
    * man/groff_diff.7.man (Implementation differences): Document it.
    
    Fixes <https://savannah.gnu.org/bugs/?61070>.  Thanks to Dave Kemper for
    the discussion.
---
 ChangeLog                        | 23 +++++++++++++++++++++++
 doc/groff.texi                   |  9 +++++++--
 man/groff.7.man                  |  7 ++++---
 man/groff_diff.7.man             | 12 ++++++++++++
 src/roff/groff/groff.am          |  1 +
 src/roff/groff/tests/ab_works.sh | 33 +++++++++++++++++++++++++++++++++
 src/roff/troff/input.cpp         |  6 ++----
 7 files changed, 82 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7e5f831..361d9da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2021-09-07  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [troff]: Make `ab` request quiet if given no arguments.  The
+       `tm`, and `tm1` and `tmc` requests provide ample flexibility for
+       constructing diagnostic messages prior to an error exit, and
+       it's convenient to make `ab` itself quiet instead of saying
+       "User Abort." as Unix Version 7 troff did.  Further, there is no
+       standardization across troffs regarding what `ab` should emit if
+       arguments are absent.
+
+       * src/roff/troff/input.cpp (abort_request): Do it.
+
+       * src/roff/groff/tests/ab_works.sh:
+       * src/roff/groff/groff.am (groff_TESTS): Test it.
+
+       * doc/groff.texi (Debugging, Implementation Differences):
+       * man/groff.7.man (Requests/Request short reference):
+       * man/groff_diff.7.man (Implementation differences): Document
+       it.
+
+       Fixes <https://savannah.gnu.org/bugs/?61070>.  Thanks to Dave
+       Kemper for the discussion.
+
+2021-09-07  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        [troff]: Update exit status literals.
 
        * src/roff/troff/div.cpp (top_level_diversion::begin_page):
diff --git a/doc/groff.texi b/doc/groff.texi
index 0b9e719..67b5347 100644
--- a/doc/groff.texi
+++ b/doc/groff.texi
@@ -15298,8 +15298,7 @@ newline (as is done in @code{tm} and @code{tm1}).
 @cindex aborting (@code{ab})
 Write @var{string} to the standard error stream (like @code{tm}) and
 then abort GNU @code{troff}; that is, stop processing and terminate with
-a failure status.  With no argument, the message written is @samp{User
-Abort.}.
+a failure status.
 @endDefreq
 
 @Defreq {ex, }
@@ -15906,6 +15905,12 @@ indicators and thus @samp{.ps 10u} sets the point size 
to
 10@tie{}points, whereas in GNU @code{troff} it sets the point size to
 10@tie{}scaled points.  @xref{Fractional Type Sizes}.
 
+@cindex @code{ab} request, incompatibilities with @acronym{AT&T} @code{troff}
+The @code{ab} request differs from @acronym{AT&T} @code{troff}:
+GNU @code{troff} writes no message to the standard error stream if no
+arguments are given, and it exits with a failure status instead of a
+successful one.
+
 @cindex @code{bp} request, incompatibilities with @acronym{AT&T} @code{troff}
 The @code{bp} request differs from @acronym{AT&T} @code{troff}:
 GNU @code{troff} does not accept a scaling indicator on the argument, a
diff --git a/man/groff.7.man b/man/groff.7.man
index 750f44f..b1e5b43 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -1288,9 +1288,10 @@ Texinfo manual or
 .PD 0
 .
 .TPx
-.REQ .ab "string"
-Write
-.I string
+.REQ .ab "\f[R][\f[]message\f[R]]"
+Abort processing;
+write any
+.I message
 to the standard error stream and exit with failure status.
 .
 .
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index 6dd6c5f..3a08f4d 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -5056,6 +5056,18 @@ indicators\[rq] above.
 .
 .P
 The
+.B .ab
+request differs from AT&T
+.IR troff : \" AT&T
+GNU
+.I troff \" GNU
+writes no message to the standard error stream if no arguments are
+given,
+and it exits with a failure status instead of a successful one.
+.
+.
+.P
+The
 .B .bp
 request differs from AT&T
 .IR troff : \" AT&T
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 3b99c20..3140acd 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -36,6 +36,7 @@ man1_MANS += src/roff/groff/groff.1
 EXTRA_DIST += src/roff/groff/groff.1.man
 
 groff_TESTS = \
+  src/roff/groff/tests/ab_works.sh \
   src/roff/groff/tests/adjustment_works.sh \
   src/roff/groff/tests/break_zero-length_output_line_sanely.sh \
   src/roff/groff/tests/do_not_loop_infinitely_when_breaking_cjk.sh \
diff --git a/src/roff/groff/tests/ab_works.sh b/src/roff/groff/tests/ab_works.sh
new file mode 100755
index 0000000..73fbdbe
--- /dev/null
+++ b/src/roff/groff/tests/ab_works.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+echo "verifying exit status of .ab request" >&2
+printf '.ab\n' | "$groff" -Tascii
+test $? -eq 1 || exit 1
+
+echo "verifying empty output of .ab request with no arguments" >&2
+OUT=$(printf '.ab\n' | "$groff" -Tascii 2>&1)
+test "$OUT" = "" || exit 1
+
+echo "verifying that arguments to .ab request go to stderr" >&2
+OUT=$(printf '.ab foo\n' | "$groff" -Tascii 2>&1 > /dev/null)
+test "$OUT" = "foo" || exit 1
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index e4cad70..4b214ed 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7509,13 +7509,11 @@ void abort_request()
     while ((c = get_copy(0)) == ' ')
       ;
   }
-  if (c == EOF || c == '\n')
-    fputs("User Abort.", stderr);
-  else {
+  if (!(c == EOF || c == '\n')) {
     for (; c != '\n' && c != EOF; c = get_copy(0))
       fputs(asciify(c), stderr);
+    fputc('\n', stderr);
   }
-  fputc('\n', stderr);
   cleanup_and_exit(EXIT_FAILURE);
 }
 



reply via email to

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