gbranden pushed a commit to branch master
in repository groff.

commit c7f4885869b2db096f78bd30e685253cdc4b3891
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Sep 2 01:58:36 2024 -0500

    [troff]: `kern` req now works like `color` et al.
    
    The `kern` request now interprets 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 this request with a register interpolation, the outcome
    agrees with an `if` test of the register's value.
    
    * src/roff/troff/node.cpp: Demote type of global `global_kern_mode` from
      `int` to `bool`.
    
      (set_kerning_mode): Assign value to `global_kern_mode` using *roff
      integer-to-Boolean conversion idiom.  When no argument is present,
      assign using Boolean, not integer, literal.
    
      (init_node_requests): Back `.kern` register with an object of class
      `readonly_boolean_register` instead of `readonly_register`.
    
    * doc/groff.texi.in (Ligatures and Kerning):
    * man/groff.7.man (Request short reference):
    * man/groff_diff.7.man (New requests):
    * NEWS: Document it.
---
 ChangeLog                | 23 +++++++++++++++++++++++
 NEWS                     | 12 ++++++------
 doc/groff.texi.in        |  9 +++++----
 man/groff.7.man          | 10 ++++------
 man/groff_diff.7.man     | 17 ++++++++++-------
 src/roff/troff/input.cpp |  2 +-
 src/roff/troff/node.cpp  | 12 ++++++------
 src/roff/troff/node.h    |  2 +-
 8 files changed, 56 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 91cef8c25..eb6a0b9d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2024-09-02  G. Branden Robinson <[email protected]>
+
+       [troff]: The `kern` request now interprets 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 this request with
+       a register interpolation, the outcome agrees with an `if` test
+       of the register's value.
+
+       * src/roff/troff/node.cpp: Demote type of global
+       `global_kern_mode` from `int` to `bool`.
+       (set_kerning_mode): Assign value to `global_kern_mode` using
+       *roff integer-to-Boolean conversion idiom.  When no argument is
+       present, assign using Boolean, not integer, literal.
+       (init_node_requests): Back `.kern` register with an object of
+       class `readonly_boolean_register` instead of
+       `readonly_register`.
+
+       * doc/groff.texi.in (Ligatures and Kerning):
+       * man/groff.7.man (Request short reference):
+       * man/groff_diff.7.man (New requests):
+       * NEWS: Document it.
+
 2024-09-02  G. Branden Robinson <[email protected]>
 
        [troff]: Prevent nested use of `do` requests from causing an
diff --git a/NEWS b/NEWS
index 86e8761f1..2ec48998b 100644
--- a/NEWS
+++ b/NEWS
@@ -42,12 +42,12 @@ o GNU troff no longer accepts nonpositive page lengths.  
Attempting to
 o GNU troff no longer accepts a newline as a delimiter for the
   parameterized escape sequences `\A`, `\b`, `\o`, `\w`, `\X`, and `\Z`.
 
-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 as an argument, the outcome agrees with
-  an `if` test of the register's value.
+o The `color`, `cp`, `kern`, `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 as an argument, the outcome
+  agrees with an `if` test of the register's value.
 
 o GNU troff now implements saturating rather than wrapping integer
   arithmetic.  Where before overflow would cause an error diagnostic,
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 6f9d81dfc..d878358d6 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -11776,10 +11776,11 @@ Monospaced (typewriter-like) fonts and terminals 
don't use kerning.
 @cindex activating kerning (@code{kern})
 @cindex kerning, activating (@code{kern})
 @cindex kerning enabled register (@code{.kern})
-Switch kerning on or off.  If the parameter is non-zero or missing,
-enable pairwise kerning, otherwise disable it.  The read-only register
-@code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
-0@tie{}otherwise.
+Enable or disable pairwise kerning of glyphs in the environment per
+@var{b}.  It is enabled by default, and if @var{b} is omitted.
+
+The read-only register @code{.kern} interpolates@tie{}1 if pairwise
+kerning is enabled, 0@tie{}otherwise.
 
 @cindex dummy character (@code{\&}), effect on kerning
 @cindex character, dummy (@code{\&}), effect on kerning
diff --git a/man/groff.7.man b/man/groff.7.man
index eb003d9b4..bb562f56d 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -3581,12 +3581,10 @@ escape sequence are not counted.
 Enable pairwise kerning.
 .
 .TPx
-.REQ .kern n
-If
-.I n
-is zero,
-disable pairwise kerning,
-otherwise enable it.
+.REQ .kern b
+Enable or disable pairwise kerning
+per Boolean expression
+.IR b .
 .
 .TPx
 .REQ .lc
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index bed85b238..f92503781 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -3043,13 +3043,16 @@ escape sequence are not applied to the line count.
 .
 .
 .TP
-.BI .kern\~ n
-If
-.I n
-is non-zero or missing,
-enable pairwise kerning
-(the default),
-otherwise disable it.
+.BR .kern\~ [\c
+.IR b ]
+Enable or disable pairwise kerning of glyphs in the environment per
+Boolean expression
+.IR b .
+.
+It is enabled by default,
+and if
+.I b
+is omitted.
 .
 .
 .TP
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6ef735fa1..0b37a0863 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -340,7 +340,7 @@ private:
   virtual bool set_location(const char *, int) { return false; }
   virtual bool next_file(FILE *, const char *) { return false; }
   virtual void shift(int) {}
-  virtual int is_boundary() {return 0; } // XXX: tri-valued Boolean
+  virtual int is_boundary() {return 0; } // three-valued Boolean :-|
   virtual bool is_file() { return false; }
   virtual bool is_macro() { return false; }
   virtual void set_att_compat(bool) {}
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 96d7ad728..cc3ae211f 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -93,8 +93,8 @@ struct special_font_list {
 };
 
 special_font_list *global_special_fonts;
-static int global_ligature_mode = 1;
-static int global_kern_mode = 1;
+static int global_ligature_mode = 1; // three-valued Boolean :-|
+static bool global_kern_mode = true;
 
 class track_kerning_function {
   int non_zero;
@@ -6792,9 +6792,9 @@ static void set_kerning_mode()
 {
   int k;
   if (has_arg() && get_integer(&k))
-    global_kern_mode = k != 0;
+    global_kern_mode = (k > 0);
   else
-    global_kern_mode = 1;
+    global_kern_mode = true;
   skip_line();
 }
 
@@ -6859,9 +6859,9 @@ void init_node_requests()
   register_dictionary.define(".fp",
                             new next_available_font_position_reg);
   register_dictionary.define(".kern",
-                            new readonly_register(&global_kern_mode));
+      new readonly_boolean_register(&global_kern_mode));
   register_dictionary.define(".lg",
-                            new readonly_register(&global_ligature_mode));
+      new readonly_register(&global_ligature_mode));
   register_dictionary.define(".P", new printing_reg);
   soft_hyphen_char = get_charinfo(HYPHEN_SYMBOL);
 }
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 606362eda..f781ec537 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -600,7 +600,7 @@ public:
   const char *type();
   bool causes_tprint();
   bool is_tag();
-  int ends_sentence(); // tri-state
+  int ends_sentence(); // three-valued Boolean :-|
 };
 
 struct hvpair {

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

Reply via email to