groff-commit
[Top][All Lists]
Advanced

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

[groff] 08/21: [troff]: Trivially refactor (hyph flags->mode).


From: G. Branden Robinson
Subject: [groff] 08/21: [troff]: Trivially refactor (hyph flags->mode).
Date: Sat, 2 Mar 2024 01:25:01 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit b196c1be0e070f16a3214090ea69371cad035d75
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Mar 1 18:59:58 2024 -0600

    [troff]: Trivially refactor (hyph flags->mode).
    
    * src/roff/troff/env.h (class environment):
    * src/roff/troff/env.cpp (class environment):
      - Rename `hyphenation_flags` to `hyphenation_mode`.
      - Rename `get_hyphenation_flags` to `get_hyphenation_mode`.
    
    * src/roff/troff/env.cpp (environment::get_hyphenation_flags): Rename
      this...
      (environment::get_hyphenation_mode): ...to this.
    
      (environment::get_hyphenation_mode):
      (environment::environment):
      (environment::copy):
      (no_hyphenate):
      (environment::hyphenate_line):
      (environment::print_env):
      (init_env_requests): Update member function and variable references.
---
 ChangeLog              | 22 ++++++++++++++++++++++
 src/roff/troff/env.cpp | 46 +++++++++++++++++++++++-----------------------
 src/roff/troff/env.h   |  4 ++--
 3 files changed, 47 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aded40439..df51f3bf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-03-01  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Trivially refactor (hyphenation flags->mode).
+
+       * src/roff/troff/env.h (class environment):
+       * src/roff/troff/env.cpp (class environment):
+       - Rename `hyphenation_flags` to `hyphenation_mode`.
+       - Rename `get_hyphenation_flags` to `get_hyphenation_mode`.
+
+       * src/roff/troff/env.cpp (environment::get_hyphenation_flags):
+       Rename this...
+       (environment::get_hyphenation_mode): ...to this.
+
+       (environment::get_hyphenation_mode):
+       (environment::environment):
+       (environment::copy):
+       (no_hyphenate):
+       (environment::hyphenate_line):
+       (environment::print_env):
+       (init_env_requests): Update member function and variable
+       references.
+
 2024-03-01  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [troff]: `mso` request no longer rewrites its argument to search
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 6d42f1f19..0d7d8de07 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -397,9 +397,9 @@ void environment::add_hyphen_indicator()
   line = line->add_discretionary_hyphen();
 }
 
-int environment::get_hyphenation_flags()
+int environment::get_hyphenation_mode()
 {
-  return hyphenation_flags;
+  return hyphenation_mode;
 }
 
 int environment::get_hyphen_line_max()
@@ -729,7 +729,7 @@ environment::environment(symbol nm)
   line_number_indent(0),
   line_number_multiple(1),
   no_number_count(0),
-  hyphenation_flags(1),
+  hyphenation_mode(1),
   hyphen_line_count(0),
   hyphen_line_max(-1),
   hyphenation_space(H0),
@@ -822,7 +822,7 @@ environment::environment(const environment *e)
   line_number_indent(e->line_number_indent),
   line_number_multiple(e->line_number_multiple),
   no_number_count(e->no_number_count),
-  hyphenation_flags(e->hyphenation_flags),
+  hyphenation_mode(e->hyphenation_mode),
   hyphen_line_count(0),
   hyphen_line_max(e->hyphen_line_max),
   hyphenation_space(e->hyphenation_space),
@@ -908,7 +908,7 @@ void environment::copy(const environment *e)
   no_number_count = e->no_number_count;
   tab_char = e->tab_char;
   leader_char = e->leader_char;
-  hyphenation_flags = e->hyphenation_flags;
+  hyphenation_mode = e->hyphenation_mode;
   fontno = e->fontno;
   prev_fontno = e->prev_fontno;
   dummy = e->dummy;
@@ -1709,7 +1709,7 @@ void no_number()
 
 void no_hyphenate()
 {
-  curenv->hyphenation_flags = 0;
+  curenv->hyphenation_mode = 0;
   skip_line();
 }
 
@@ -1728,10 +1728,10 @@ void hyphenate_request()
       warning(WARN_SYNTAX, "contradictory hyphenation flags ignored: "
        "%1", n);
     else
-      curenv->hyphenation_flags = n;
+      curenv->hyphenation_mode = n;
   }
   else
-    curenv->hyphenation_flags = 1;
+    curenv->hyphenation_mode = 1;
   skip_line();
 }
 
@@ -2094,18 +2094,18 @@ void environment::hyphenate_line(int start_here)
       prev_code = h->hyphenation_code;
     }
   }
-  if (hyphenation_flags != 0
+  if (hyphenation_mode != 0
       && !inhibit
       // this may not be right if we have extra space on this line
-      && !((hyphenation_flags & HYPHEN_NOT_LAST_LINE)
+      && !((hyphenation_mode & HYPHEN_NOT_LAST_LINE)
           && (curdiv->distance_to_next_trap()
               <= vertical_spacing + total_post_vertical_spacing()))
       && i >= (4
-              - (hyphenation_flags & HYPHEN_FIRST_CHAR ? 1 : 0)
-              - (hyphenation_flags & HYPHEN_LAST_CHAR ? 1 : 0)
-              + (hyphenation_flags & HYPHEN_NOT_FIRST_CHARS ? 1 : 0)
-              + (hyphenation_flags & HYPHEN_NOT_LAST_CHARS ? 1 : 0)))
-    hyphenate(sl, hyphenation_flags);
+              - (hyphenation_mode & HYPHEN_FIRST_CHAR ? 1 : 0)
+              - (hyphenation_mode & HYPHEN_LAST_CHAR ? 1 : 0)
+              + (hyphenation_mode & HYPHEN_NOT_FIRST_CHARS ? 1 : 0)
+              + (hyphenation_mode & HYPHEN_NOT_LAST_CHARS ? 1 : 0)))
+    hyphenate(sl, hyphenation_mode);
   while (forward != 0) {
     node *tem1 = forward;
     forward = forward->next;
@@ -3414,19 +3414,19 @@ void environment::print_env()
             line_number_multiple > 1 ? "s" : "");
     errprint("  lines not to enumerate: %1\n", no_number_count);
   }
-  string hf = hyphenation_flags ? "on" : "off";
-  if (hyphenation_flags & HYPHEN_NOT_LAST_LINE)
+  string hf = hyphenation_mode ? "on" : "off";
+  if (hyphenation_mode & HYPHEN_NOT_LAST_LINE)
     hf += ", not last line";
-  if (hyphenation_flags & HYPHEN_LAST_CHAR)
+  if (hyphenation_mode & HYPHEN_LAST_CHAR)
     hf += ", last char";
-  if (hyphenation_flags & HYPHEN_NOT_LAST_CHARS)
+  if (hyphenation_mode & HYPHEN_NOT_LAST_CHARS)
     hf += ", not last two chars";
-  if (hyphenation_flags & HYPHEN_FIRST_CHAR)
+  if (hyphenation_mode & HYPHEN_FIRST_CHAR)
     hf += ", first char";
-  if (hyphenation_flags & HYPHEN_NOT_FIRST_CHARS)
+  if (hyphenation_mode & HYPHEN_NOT_FIRST_CHARS)
     hf += ", not first two chars";
   hf += '\0';
-  errprint("  hyphenation_flags: %1\n", hf.contents());
+  errprint("  hyphenation_mode: %1\n", hf.contents());
   errprint("  number of consecutive hyphenated lines: %1\n",
           hyphen_line_count);
   errprint("  maximum number of consecutive hyphenated lines: %1\n",
@@ -3530,7 +3530,7 @@ void init_env_requests()
   init_int_env_reg(".height", get_char_height);
   init_int_env_reg(".hlc", get_hyphen_line_count);
   init_int_env_reg(".hlm", get_hyphen_line_max);
-  init_int_env_reg(".hy", get_hyphenation_flags);
+  init_int_env_reg(".hy", get_hyphenation_mode);
   init_hunits_env_reg(".hym", get_hyphenation_margin);
   init_hunits_env_reg(".hys", get_hyphenation_space);
   init_hunits_env_reg(".i", get_indent);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 0777a3c6b..b1ab88fc8 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -211,7 +211,7 @@ class environment {
   int line_number_indent;      // in digit spaces
   int line_number_multiple;
   int no_number_count;
-  unsigned hyphenation_flags;
+  unsigned hyphenation_mode;
   int hyphen_line_count;
   int hyphen_line_max;
   hunits hyphenation_space;
@@ -308,7 +308,7 @@ public:
   hunits get_input_line_position();
   const char *get_tabs();
   int get_line_tabs();
-  int get_hyphenation_flags();
+  int get_hyphenation_mode();
   int get_hyphen_line_max();
   int get_hyphen_line_count();
   hunits get_hyphenation_space();



reply via email to

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