gbranden pushed a commit to branch master
in repository groff.

commit ad3fbc080cd28bede63d8dd54d792c2b020a9b7a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Sep 8 05:37:01 2024 -0500

    [troff]: Trivially refactor.
    
    * src/roff/troff/token.h (class token): Rename enumeration constant from
      `TOKEN_SPECIAL` to `TOKEN_SPECIAL_CHAR`.  Rename member function
      declaration from `is_special()` to `is_special_character()`.  Tokens
      can represent multiple types of formatter objects (at least three of
      which, "special characters", "special fonts", and "special nodes",
      have member functions named `is_special()`, and which have little to
      do with each other).
    
      (token::is_special): Rename this...
      (token::is_special_character): ...to this.
    
    * src/roff/troff/input.cpp (token::next, token:operator==)
      (token::description, token::get_char)
      (token::add_to_zero_width_node_list, token::process): Use new
      enumeration constant.
    
      (encode_character_for_device_output): Update `is_special()` call site.
---
 ChangeLog                | 22 ++++++++++++++++++++++
 src/roff/troff/input.cpp | 26 +++++++++++++-------------
 src/roff/troff/token.h   |  8 ++++----
 3 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 59de709f5..51b071809 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-09-08  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.
+
+       * src/roff/troff/token.h (class token): Rename enumeration
+       constant from `TOKEN_SPECIAL` to `TOKEN_SPECIAL_CHAR`.  Rename
+       member function declaration from `is_special()` to
+       `is_special_character()`.  Tokens can represent multiple types
+       of formatter objects (at least three of which, "special
+       characters", "special fonts", and "special nodes", have member
+       functions named `is_special()`, and which have little to do with
+       each other).
+       (token::is_special): Rename this...
+       (token::is_special_character): ...to this.
+
+       * src/roff/troff/input.cpp (token::next, token:operator==)
+       (token::description, token::get_char)
+       (token::add_to_zero_width_node_list, token::process): Use new
+       enumeration constant.
+       (encode_character_for_device_output): Update `is_special()`
+       call site.
+
 2024-09-08  G. Branden Robinson <[email protected]>
 
        Migrate to "device extension [command]" terminology.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 4384b440f..4493d2854 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2037,22 +2037,22 @@ void token::next()
        return;
       case ESCAPE_LEFT_QUOTE:
       ESCAPE_LEFT_QUOTE:
-       type = TOKEN_SPECIAL;
+       type = TOKEN_SPECIAL_CHAR;
        nm = symbol("ga");
        return;
       case ESCAPE_RIGHT_QUOTE:
       ESCAPE_RIGHT_QUOTE:
-       type = TOKEN_SPECIAL;
+       type = TOKEN_SPECIAL_CHAR;
        nm = symbol("aa");
        return;
       case ESCAPE_HYPHEN:
       ESCAPE_HYPHEN:
-       type = TOKEN_SPECIAL;
+       type = TOKEN_SPECIAL_CHAR;
        nm = symbol("-");
        return;
       case ESCAPE_UNDERSCORE:
       ESCAPE_UNDERSCORE:
-       type = TOKEN_SPECIAL;
+       type = TOKEN_SPECIAL_CHAR;
        nm = symbol("ul");
        return;
       case ESCAPE_c:
@@ -2120,7 +2120,7 @@ void token::next()
       switch (cc) {
       case '(':
        nm = read_two_char_escape_parameter();
-       type = TOKEN_SPECIAL;
+       type = TOKEN_SPECIAL_CHAR;
        return;
       case EOF:
        type = TOKEN_EOF;
@@ -2235,7 +2235,7 @@ void token::next()
        nm = get_delimited_name();
        if (nm.is_null())
          break;
-       type = TOKEN_SPECIAL;
+       type = TOKEN_SPECIAL_CHAR;
        return;
       case 'd':
        type = TOKEN_NODE;
@@ -2526,7 +2526,7 @@ void token::next()
            else
              nm = symbol(sc);
          }
-         type = TOKEN_SPECIAL;
+         type = TOKEN_SPECIAL_CHAR;
          return;
        }
        goto handle_ordinary_char;
@@ -2547,7 +2547,7 @@ bool token::operator==(const token &t)
   switch (type) {
   case TOKEN_CHAR:
     return c == t.c;
-  case TOKEN_SPECIAL:
+  case TOKEN_SPECIAL_CHAR:
     return nm == t.nm;
   case TOKEN_NUMBERED_CHAR:
     return val == t.val;
@@ -2679,7 +2679,7 @@ const char *token::description()
     return "an escaped '}'";
   case TOKEN_SPACE:
     return "a space";
-  case TOKEN_SPECIAL:
+  case TOKEN_SPECIAL_CHAR:
     return "a special character";
   case TOKEN_SPREAD:
     return "an escaped 'p'";
@@ -5838,7 +5838,7 @@ static void encode_character_for_device_output(macro 
*mac, const char c)
             || tok.is_dummy()
             || tok.is_transparent_dummy())
       /* do nothing */;
-    else if (tok.is_special())
+    else if (tok.is_special_character())
       encode_special_character_for_device_output(mac);
     else
       warning(WARN_CHAR, "%1 is not encodable in device-independent"
@@ -7773,7 +7773,7 @@ charinfo *token::get_char(bool required)
 {
   if (type == TOKEN_CHAR)
     return charset_table[c];
-  if (type == TOKEN_SPECIAL)
+  if (type == TOKEN_SPECIAL_CHAR)
     return get_charinfo(nm);
   if (type == TOKEN_NUMBERED_CHAR)
     return get_charinfo_by_number(val);
@@ -7862,7 +7862,7 @@ bool token::add_to_zero_width_node_list(node **pp)
     n = new hmotion_node(curenv->get_space_width(),
                         curenv->get_fill_color());
     break;
-  case TOKEN_SPECIAL:
+  case TOKEN_SPECIAL_CHAR:
     *pp = (*pp)->add_char(get_charinfo(nm), curenv, &w, &s);
     break;
   case TOKEN_STRETCHABLE_SPACE:
@@ -7957,7 +7957,7 @@ void token::process()
   case TOKEN_SPACE:
     curenv->space();
     break;
-  case TOKEN_SPECIAL:
+  case TOKEN_SPECIAL_CHAR:
     curenv->add_char(get_charinfo(nm));
     break;
   case TOKEN_SPREAD:
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 7de3eebae..c057a0538 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -48,7 +48,7 @@ class token {
     TOKEN_REQUEST,
     TOKEN_RIGHT_BRACE,         // \}
     TOKEN_SPACE,               // ' ' -- ordinary space
-    TOKEN_SPECIAL,             // special character
+    TOKEN_SPECIAL_CHAR,        // \(, \[
     TOKEN_SPREAD,              // \p -- break and spread output line
     TOKEN_STRETCHABLE_SPACE,   // \~
     TOKEN_UNSTRETCHABLE_SPACE, // '\ '
@@ -74,7 +74,7 @@ public:
   bool is_unstretchable_space();
   bool is_horizontal_space();
   bool is_white_space();
-  bool is_special();
+  bool is_special_character();
   bool is_newline();
   bool is_tab();
   bool is_leader();
@@ -162,9 +162,9 @@ inline bool token::is_horizontal_space()
   return type == TOKEN_HORIZONTAL_SPACE;
 }
 
-inline bool token::is_special()
+inline bool token::is_special_character()
 {
-  return type == TOKEN_SPECIAL;
+  return type == TOKEN_SPECIAL_CHAR;
 }
 
 inline int token::nspaces()

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

Reply via email to