gbranden pushed a commit to branch master
in repository groff.

commit bb027037d984ce01064e8d573b8bf9be412340a3
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Dec 19 13:22:50 2025 -0600

    [troff]: Trivially refactor.
    
    ...for conceptual clarity.  In *roff, spaces and horizontal motions are
    distinct kinds of thing.  Spaces are potentially breakable, discardable
    (at the distal ends of text lines), and adjustable.  Horizontal motions
    are none of these.
    
    * src/roff/troff/token.h (class token): Rename enumeration constant from
      `TOKEN_HORIZONTAL_SPACE` to `TOKEN_HORIZONTAL_MOTION`.  Rename member
      function declaration from `is_horizontal_space()` to
      `is_horizontal_motion()`.
    
      (token::is_horizontal_space): Rename this...
      (token::is_horizontal_motion): ...to this.
    
    * src/roff/troff/input.cpp (do_overstrike): Update lone call site of
      `is_horizontal_space()`.
    
    * src/roff/troff/token.h (token::is_horizontal_motion):
    * src/roff/troff/input.cpp (token::next): Update sites of comparisons to
      `TOKEN_HORIZONTAL_SPACE`.
---
 ChangeLog                | 20 ++++++++++++++++++++
 src/roff/troff/input.cpp | 26 +++++++++++++-------------
 src/roff/troff/token.h   |  8 ++++----
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 945bdd414..cc7f34568 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2025-12-19  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor for conceptual clarity.  In *roff,
+       spaces and horizontal motions are distinct kinds of thing.
+       Spaces are potentially breakable, discardable (at the distal
+       ends of text lines), and adjustable.  Horizontal motions are
+       none of these.
+
+       * src/roff/troff/token.h (class token): Rename enumeration
+       constant from `TOKEN_HORIZONTAL_SPACE` to
+       `TOKEN_HORIZONTAL_MOTION`.  Rename member function declaration
+       from `is_horizontal_space()` to `is_horizontal_motion()`.
+       (token::is_horizontal_space): Rename this...
+       (token::is_horizontal_motion): ...to this.
+       * src/roff/troff/input.cpp (do_overstrike): Update lone call
+       site of `is_horizontal_space()`.
+       * src/roff/troff/token.h (token::is_horizontal_motion):
+       * src/roff/troff/input.cpp (token::next): Update sites of
+       comparisons to `TOKEN_HORIZONTAL_SPACE`.
+
 2025-12-19  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/token.h (class token): Rename member function
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index dc6aa8fca..ee292b68e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1690,7 +1690,7 @@ node *do_overstrike() // \o
     if (tok == start_token
        && (want_att_compat || input_stack::get_level() == start_level))
       break;
-    if (tok.is_horizontal_space())
+    if (tok.is_horizontal_motion())
       osnode->overstrike(tok.nd->copy());
     else if (tok.is_unstretchable_space()) {
       node *n = new hmotion_node(curenv->get_space_width(),
@@ -2066,7 +2066,7 @@ void token::diagnose_non_character()
   //   is_space()
   //   is_stretchable_space()
   //   is_unstrechable_space()
-  //   is_horizontal_space()
+  //   is_horizontal_motion()
   //   is_horizontal_whitespace()
   //   is_leader()
   //   is_backspace()
@@ -2210,13 +2210,13 @@ void token::next()
        goto handle_escape_char;
       case ESCAPE_BAR:
       ESCAPE_BAR:
-       type = TOKEN_HORIZONTAL_SPACE;
+       type = TOKEN_HORIZONTAL_MOTION;
        nd = new hmotion_node(curenv->get_narrow_space_width(),
                              curenv->get_fill_color());
        return;
       case ESCAPE_CIRCUMFLEX:
       ESCAPE_CIRCUMFLEX:
-       type = TOKEN_HORIZONTAL_SPACE;
+       type = TOKEN_HORIZONTAL_MOTION;
        nd = new hmotion_node(curenv->get_half_narrow_space_width(),
                              curenv->get_fill_color());
        return;
@@ -2337,7 +2337,7 @@ void token::next()
       case '0':
        nd = new hmotion_node(curenv->get_digit_width(),
                              curenv->get_fill_color());
-       type = TOKEN_HORIZONTAL_SPACE;
+       type = TOKEN_HORIZONTAL_MOTION;
        return;
       case '|':
        goto ESCAPE_BAR;
@@ -2507,7 +2507,7 @@ void token::next()
       case 'h':
        if (!read_delimited_measurement(&x, 'm'))
          break;
-       type = TOKEN_HORIZONTAL_SPACE;
+       type = TOKEN_HORIZONTAL_MOTION;
        nd = new hmotion_node(x, curenv->get_fill_color());
        return;
       case 'H':
@@ -2690,7 +2690,7 @@ void token::next()
        }
       case 'z':
        next();
-       if ((TOKEN_NODE == type) || (TOKEN_HORIZONTAL_SPACE == type))
+       if ((TOKEN_NODE == type) || (TOKEN_HORIZONTAL_MOTION == type))
          nd = new zero_width_node(nd);
        else {
          // TODO: In theory, we could accept spaces and horizontal
@@ -2955,7 +2955,7 @@ bool token::is_usable_as_delimiter(bool report_error,
   case TOKEN_SPACE:
   case TOKEN_STRETCHABLE_SPACE:
   case TOKEN_UNSTRETCHABLE_SPACE:
-  case TOKEN_HORIZONTAL_SPACE:
+  case TOKEN_HORIZONTAL_MOTION:
   case TOKEN_NEWLINE:
   case TOKEN_EOF:
     if (report_error)
@@ -3070,7 +3070,7 @@ const char *token::description()
     return "an escaped '~'";
   case TOKEN_UNSTRETCHABLE_SPACE:
     return "an escaped ' '";
-  case TOKEN_HORIZONTAL_SPACE:
+  case TOKEN_HORIZONTAL_MOTION:
     return "a horizontal motion";
   case TOKEN_TAB:
     return "a tab character";
@@ -3634,12 +3634,12 @@ void process_input_stack()
     case token::TOKEN_EOF:
       return;
     case token::TOKEN_NODE:
-    case token::TOKEN_HORIZONTAL_SPACE:
+    case token::TOKEN_HORIZONTAL_MOTION:
       if (curenv->get_was_line_interrupted()) {
        // We don't want to warn about node types.  They might have been
        // interpolated into the input by the formatter itself, as with
        // the extra vertical space nodes appended to diversions.
-       if (token::TOKEN_HORIZONTAL_SPACE == tok.type)
+       if (token::TOKEN_HORIZONTAL_MOTION == tok.type)
          warning(WARN_SYNTAX, "ignoring %1 on input line after"
                  " output line continuation escape sequence",
                  tok.description());
@@ -8931,7 +8931,7 @@ bool token::add_to_zero_width_node_list(node **pp)
     set_register(nm, curenv->get_input_line_position().to_units());
     break;
   case TOKEN_NODE:
-  case TOKEN_HORIZONTAL_SPACE:
+  case TOKEN_HORIZONTAL_MOTION:
     n = nd;
     nd = 0 /* nullptr */;
     break;
@@ -9025,7 +9025,7 @@ void token::process()
     curenv->newline();
     break;
   case TOKEN_NODE:
-  case TOKEN_HORIZONTAL_SPACE:
+  case TOKEN_HORIZONTAL_MOTION:
     curenv->add_node(nd);
     nd = 0 /* nullptr */;
     break;
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 3c636f916..aedcc10cb 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -65,7 +65,7 @@ class token {
     TOKEN_SPREAD,              // \p -- break and spread output line
     TOKEN_STRETCHABLE_SPACE,   // \~
     TOKEN_UNSTRETCHABLE_SPACE, // '\ '
-    TOKEN_HORIZONTAL_SPACE,    // horizontal motion: \|, \^, \0, \h
+    TOKEN_HORIZONTAL_MOTION,   // horizontal motion: \|, \^, \0, \h
     TOKEN_TAB,                 // ^I
     TOKEN_TRANSPARENT,         // \!
     TOKEN_TRANSPARENT_DUMMY,   // \)
@@ -87,7 +87,7 @@ public:
   bool is_space();
   bool is_stretchable_space();
   bool is_unstretchable_space();
-  bool is_horizontal_space();
+  bool is_horizontal_motion();
   bool is_horizontal_whitespace();
   bool is_any_character();
   // XXX: Do we need a `is_ordinary_character()`?
@@ -178,9 +178,9 @@ inline bool token::is_unstretchable_space()
   return (TOKEN_UNSTRETCHABLE_SPACE == type);
 }
 
-inline bool token::is_horizontal_space()
+inline bool token::is_horizontal_motion()
 {
-  return (TOKEN_HORIZONTAL_SPACE == type);
+  return (TOKEN_HORIZONTAL_MOTION == type);
 }
 
 inline bool token::is_special_character()

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

Reply via email to