gbranden pushed a commit to branch master
in repository groff.

commit 71ccefcf14694698ab8fbacf1219094eea24bdc9
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Dec 30 02:09:37 2025 -0600

    [troff]: Work on Savannah #67735.
    
    * src/roff/troff/node.h (struct node):
    * src/roff/troff/node.cpp (class break_char_node, node::get_break_code):
      Demote type of hyphenation codes from `int` to `unsigned char`, since
      the range of the latter is as much as has ever been stored in them
      anyway.  (This was discovered the hard way in Savannah #66919.)
      Retype `break_code` and `prev_break_code` private member variables and
      `get_break_code()` public member function accordingly.
---
 ChangeLog               | 13 +++++++++++++
 src/roff/troff/node.cpp | 18 ++++++++++++------
 src/roff/troff/node.h   |  5 ++++-
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 69de40c2e..fa42474d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-12-30  G. Branden Robinson <[email protected]>
+
+       [troff]: Work on Savannah #67735.
+
+       * src/roff/troff/node.h (struct node):
+       * src/roff/troff/node.cpp (class break_char_node)
+       (node::get_break_code): Demote type of hyphenation codes from
+       `int` to `unsigned char`, since the range of the latter is as
+       much as has ever been stored in them anyway.  (This was
+       discovered the hard way in Savannah #66919.)  Retype
+       `break_code` and `prev_break_code` private member variables and
+       `get_break_code()` public member function accordingly.
+
 2025-12-29  G. Branden Robinson <[email protected]>
 
        [troff]: Improve type-correctness (slightly).
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index bd06073b6..f3d96427b 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -2714,9 +2714,12 @@ bool node::is_tag()
   return false;
 }
 
-int node::get_break_code()
+// TODO: Figure out what a hyphenation code means in the UTF-8 future,
+// where a "grochar" is a vector of NFD decomposed code points.  Can it
+// be a scalar--a 32-bit int?
+unsigned char node::get_break_code()
 {
-  return 0;
+  return 0U;
 }
 
 hunits hmotion_node::width()
@@ -3022,8 +3025,11 @@ int italic_corrected_node::character_type()
 }
 
 class break_char_node : public container_node {
-  char break_code;
-  char prev_break_code;
+  // TODO: Figure out what a hyphenation code means in the UTF-8 future,
+  // where a "grochar" is a vector of NFD decomposed code points.  Can
+  // it be a scalar--a 32-bit int?
+  unsigned char break_code;
+  unsigned char prev_break_code;
   color *col;
 public:
   break_char_node(node *, int, int, color *, node * = 0 /* nullptr */);
@@ -3050,7 +3056,7 @@ public:
   const char *type();
   bool causes_tprint();
   bool is_tag();
-  int get_break_code();
+  unsigned char get_break_code();
   void dump_properties();
 };
 
@@ -6470,7 +6476,7 @@ bool break_char_node::is_tag()
   return false;
 }
 
-int break_char_node::get_break_code()
+unsigned char break_char_node::get_break_code()
 {
   return break_code;
 }
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index a8efd1911..08891c417 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -66,7 +66,10 @@ struct node {
   virtual bool set_unformat_flag();
   virtual bool causes_tprint() = 0;
   virtual bool is_tag() = 0;
-  virtual int get_break_code();
+  // TODO: Figure out what a hyphenation code means in the UTF-8 future,
+  // where a "grochar" is a vector of NFD decomposed code points.  Can
+  // it be a scalar--a 32-bit int?
+  virtual unsigned char get_break_code();
   virtual hunits width();
   virtual hunits subscript_correction();
   virtual hunits italic_correction();

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

Reply via email to