groff-commit
[Top][All Lists]
Advanced

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

[groff] 11/12: [troff]: Alter color, cp, linetabs, vpt requests.


From: G. Branden Robinson
Subject: [groff] 11/12: [troff]: Alter color, cp, linetabs, vpt requests.
Date: Sun, 11 Feb 2024 12:56:54 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit d592ab9e3d3f9efeacece25ed8b03676031bd02e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Feb 11 10:21:25 2024 -0600

    [troff]: Alter color, cp, linetabs, vpt requests.
    
    [troff]: The `color`, `cp`, `linetabs`, and `vpt` requests now interpret
    arguments with negative values as instructions to disable the
    corresponding feature, using the *roff integer-to-Boolean conversion
    idiom instead of the C/C++ one.  Thus, if you invoke these requests with
    a register interpolation, the outcome agrees with an `if` test of the
    register's value.
    
    * src/roff/troff/div.cpp (vertical_position_traps):
    * src/roff/troff/env.cpp (widow_control_request) [WIDOW_CONTROL]
      (line_tabs_request):
    * src/roff/troff/input.cpp (activate_color, compatible): Do it.
    
    * doc/groff.texi.in (Tabs and Fields, Colors, Vertical Position Traps)
      (Compatibility Mode):
    * man/groff.7.man (Syntax reference conventions)
      (Request short reference):
    * man/groff_diff.7.man (New requests): Document it.
---
 ChangeLog                | 23 +++++++++++++++++++++
 NEWS                     |  7 +++++++
 doc/groff.texi.in        | 37 +++++++++++++++++-----------------
 man/groff.7.man          | 39 ++++++++++++++++--------------------
 man/groff_diff.7.man     | 52 +++++++++++++++++++++++++-----------------------
 src/roff/troff/div.cpp   |  2 +-
 src/roff/troff/env.cpp   |  4 ++--
 src/roff/troff/input.cpp |  4 ++--
 8 files changed, 97 insertions(+), 71 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 39ca2ddae..bfcfa32b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2024-02-11  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: The `color`, `cp`, `linetabs`, and `vpt` requests now
+       interpret arguments with negative values as instructions to
+       disable the corresponding feature, using the *roff
+       integer-to-Boolean conversion idiom instead of the C/C++ one.
+       Thus, if you invoke these requests with a register
+       interpolation, the outcome agrees with an `if` test of the
+       register's value.
+
+       * src/roff/troff/div.cpp (vertical_position_traps):
+       * src/roff/troff/env.cpp (widow_control_request) [WIDOW_CONTROL]
+       (line_tabs_request):
+       * src/roff/troff/input.cpp (activate_color, compatible): Do it.
+
+       * doc/groff.texi.in (Tabs and Fields, Colors)
+       (Vertical Position Traps, Compatibility Mode):
+       * man/groff.7.man (Syntax reference conventions)
+       (Request short reference):
+       * man/groff_diff.7.man (New requests): Document it.
+
+       * NEWS: Add item.
+
 2024-02-08  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        Update default search path for URW fonts; Fedora 39 has come up
diff --git a/NEWS b/NEWS
index 77570e9b8..f66982810 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,13 @@ VERSION next
 troff
 -----
 
+o The `color`, `cp`, `linetabs`, and `vpt` requests now interpret
+  arguments with negative values as instructions to disable the
+  corresponding feature, using the *roff integer-to-Boolean conversion
+  idiom instead of the C/C++ one.  Thus, if you invoke these requests
+  with a register interpolation, the outcome agrees with an `if` test of
+  the register's value.
+
 o In nroff mode (in other words, when producing output for devices that
   claim to be terminals), the formatter now reports warning diagnostics
   regarding certain output problems using units of lines instead of
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 852d37102..a0d0520c8 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -9383,11 +9383,11 @@ Only a single character of @var{c} is recognized; any 
excess is ignored.
 @cindex tab, line-tabs mode
 @cindex line-tabs mode
 @cindex mode, line-tabs
-Activate line-tabs in the environment if the expression @var{b} is
-non-zero; deactivate them otherwise.  They are inactive by default, and
-activated if @var{b} is omitted.  When line-tabs are active, tab stops
-are computed relative to the start of the pending output line instead of
-the drawing position corresponding to the start of the input line.
+Activate or deactivate line-tabs in the environment per Boolean
+expression @var{b}.  They are inactive by default, and activated if
+@var{b} is omitted.  When line-tabs are active, tab stops are computed
+relative to the start of the pending output line instead of the drawing
+position corresponding to the start of the input line.
 
 @Example
 .ta 1i 3i
@@ -12324,11 +12324,10 @@ of a closed geometric figure.
 
 @DefreqList {color, [@Var{b}]}
 @DefregListEndx {.color}
-Enable output of color-related device-independent output commands if the
-expression @var{b} is non-zero; disable it otherwise.  It is enabled by
-default, and if @var{b} is omitted.  This request modifies the
-formatter's internal state; it does not produce a
-token (@pxref{Gtroff Internals}).
+Enable or disable output of color-related device-independent output
+commands per Boolean expression @var{b}.  It is enabled by default, and
+if @var{b} is omitted.  This request modifies the formatter's internal
+state; it does not produce a token (@pxref{Gtroff Internals}).
 
 The read-only register @code{.color} interpolates@tie{}1 if color
 support is enabled, 0@tie{}otherwise.
@@ -14668,11 +14667,11 @@ multiple columns, and footnotes.
 @cindex enabling vertical position traps (@code{vpt})
 @cindex vertical position traps, enabling (@code{vpt})
 @cindex vertical position trap enable register (@code{.vpt})
-Enable vertical position traps if the expression @var{b} is non-zero;
-disable them otherwise.  They are enabled by default, and if @var{b} is
-omitted.  Vertical position traps are those set by the @code{wh} request
-or by @code{dt} within a diversion.  Vertical position trap enablement
-is global.  Its status is stored in the @code{.vpt} read-only register.
+Enable or disable vertical position traps per Boolean expression
+@var{b}.  They are enabled by default, and if @var{b} is omitted.
+Vertical position traps are those set by the @code{wh} request or by
+@code{dt} within a diversion.  Vertical position trap enablement is
+global.  Its status is stored in the @code{.vpt} read-only register.
 
 @cindex page break, prevented by @code{vpt}
 @cindex break, page, prevented by @code{vpt}
@@ -17480,10 +17479,10 @@ way; they thus can be two characters long at most.
 
 @DefreqList {cp, [@Var{b}]}
 @DefregListEndx {.C}
-Enable AT&T @command{troff} compatibility mode if the expression
-@var{b} is non-zero; disable it otherwise.  It is disabled by default,
-and enabled if @var{b} is omitted.  In compatibility mode, long names
-are not recognized, and the incompatibilities they cause do not arise.
+Enable or disable AT&T @command{troff} compatibility mode per Boolean
+expression @var{b}.  It is disabled by default, and enabled if @var{b}
+is omitted.  In compatibility mode, long names are not recognized, and
+the incompatibilities they cause do not arise.
 
 The read-only register @code{.C} interpolates@tie{}1 if compatibility
 mode is enabled, 0@tie{}otherwise.
diff --git a/man/groff.7.man b/man/groff.7.man
index 0bdbaba76..4143d82a1 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -2261,6 +2261,12 @@ Comments are ignored;
 trailing whitespace generally is not.
 .
 .TPx
+.I b
+is a numerical expression evaluated as a Boolean;
+positive values are true,
+others false.
+.
+.TPx
 .I c
 denotes a single input character,
 ordinary or special.
@@ -2813,12 +2819,9 @@ It is enabled by default.
 .
 .TPx
 .REQ .color b
-If
-.I b
-is zero,
-disable output of color-related device-independent output commands;
-otherwise,
-enable them.
+Enable or disable output of color-related device-independent output
+commands per Boolean expression
+.IR b .
 .
 .TPx
 .REQ .composite "c1 c2"
@@ -2846,13 +2849,10 @@ It is disabled by default.
 .
 .TPx
 .REQ .cp b
-If
-.I b
-is zero,
-disable AT&T
+Enable or disable AT&T
 .I troff \" AT&T
-compatibility mode,
-otherwise enable it.
+compatibility mode per Boolean expression
+.IR b .
 .
 .TPx
 .REQ .cs "font n m"
@@ -3586,11 +3586,9 @@ It is disabled by default.
 .
 .TPx
 .REQ .linetabs b
-If
-.I b
-is zero,
-deactivate line-tabs in the environment,
-otherwise enable them.
+Activate or deactivate line-tabs in the environment per Boolean
+expression
+.IR b .
 .
 .TPx
 .REQ .lf n
@@ -4578,11 +4576,8 @@ They are enabled by default.
 .
 .TPx
 .REQ .vpt b
-If
-.I b
-is zero,
-disable vertical position traps,
-otherwise enable them.
+Enable or disable vertical position traps per Boolean expression
+.IR b .
 .
 .TPx
 .REQ .vs
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index 27e9e7eaf..97d8e662e 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -2123,27 +2123,28 @@ See
 .TP
 .BR .color\~ [\c
 .IR b ]
-If
-.I b
-is non-zero or missing,
-enable output of color-related device-independent output commands,
-otherwise disable them.
+Enable or disable output of color-related device-independent output
+commands per Boolean expression
+.IR b .
 .
-It is enabled by default.
+It is enabled by default,
+and if
+.I b
+is omitted.
 .
 .
 .TP
 .BR .cp\~ [\c
 .IR b ]
-If
-.I b
-is non-zero or missing,
-enable AT&T
+Enable or disable AT&T
 .I troff \" AT&T
-compatibility mode,
-otherwise disable it.
+compatibility mode per Boolean expression
+.IR b .
 .
-It is disabled by default.
+It is disabled by default,
+and enabled if
+.I b
+is omitted.
 .
 In compatibility mode,
 long names are not recognized,
@@ -2971,13 +2972,14 @@ is read in copy mode.
 .TP
 .BR .linetabs\~ [\c
 .IR b ]
-If
-.I b
-is non-zero or missing,
-activate line-tabs in the environment,
-otherwise disable it.
+Activate or deactivate line-tabs in the environment per Boolean
+expression
+.IR b .
 .
-They are inactive by default.
+They are inactive by default,
+and activated if
+.I b
+is omitted.
 .
 When line-tabs are active,
 tab stops are computed relative to the start of the pending output line
@@ -3696,13 +3698,13 @@ is retained.
 .TP
 .BR .vpt\~ [\c
 .IR b ]
-If
-.I b
-is non-zero or missing,
-enable vertical position traps,
-otherwise disable them.
+Enable or disable vertical position traps per Boolean expression
+.IR b .
 .
-They are enabled by default.
+They are enabled by default,
+and if
+.I b
+is omitted.
 .
 .
 .IP
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 29d6ebe20..cb508b322 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -985,7 +985,7 @@ void vertical_position_traps()
 {
   int n;
   if (has_arg() && get_integer(&n))
-    vertical_position_traps_flag = (n != 0);
+    vertical_position_traps_flag = (n > 0);
   else
     vertical_position_traps_flag = 1;
   skip_line();
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index b916ae37b..545765c8f 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -208,7 +208,7 @@ void widow_control_request()
 {
   int n;
   if (has_arg() && get_integer(&n))
-    curenv->widow_control = n != 0;
+    curenv->widow_control = (n > 0);
   else
     curenv->widow_control = 1;
   skip_line();
@@ -2891,7 +2891,7 @@ void line_tabs_request()
 {
   int n;
   if (has_arg() && get_integer(&n))
-    curenv->line_tabs = n != 0;
+    curenv->line_tabs = (n > 0);
   else
     curenv->line_tabs = 1;
   skip_line();
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 78a93b27d..b2d54a033 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1487,7 +1487,7 @@ static void activate_color()
 {
   int n;
   if (has_arg() && get_integer(&n))
-    color_flag = n != 0;
+    color_flag = (n > 0);
   else
     color_flag = 1;
   skip_line();
@@ -2616,7 +2616,7 @@ void compatible()
 {
   int n;
   if (has_arg() && get_integer(&n))
-    compatible_flag = n != 0;
+    compatible_flag = (n > 0);
   else
     compatible_flag = 1;
   skip_line();



reply via email to

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