gbranden pushed a commit to branch master
in repository groff.

commit 1cdfa2839744f8f1e7f9ceaf3e986fb117ee7af8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Sep 14 15:20:16 2023 -0500

    [troff]: Trivially refactor (`want_break`).
    
    Rename `break_flag` symbol to `want_break` and demote its type from
    `int` to `bool`.
    
    * src/roff/troff/env.h:
    * src/roff/troff/input.cpp: Do it (declarations).
    
    * src/roff/troff/div.cpp (begin_page, space_request, flush_output):
    * src/roff/troff/env.cpp (fill, no_fill, center, right_justify, indent)
      (temporary_indent, do_break_request):
    * src/roff/troff/input.cpp (process_input_stack)
      (macro_iterator::macro_iterator, copy_file, transparent_file): Do it.
---
 ChangeLog                | 16 ++++++++++++++++
 src/roff/troff/div.cpp   |  8 ++++----
 src/roff/troff/env.cpp   | 14 +++++++-------
 src/roff/troff/env.h     |  2 +-
 src/roff/troff/input.cpp | 12 ++++++------
 5 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b7382956..26f5fef0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2023-09-14  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.  Rename `break_flag` symbol to
+       `want_break` and demote its type from `int` to `bool`.
+
+       * src/roff/troff/env.h:
+       * src/roff/troff/input.cpp: Do it (declarations).
+
+       * src/roff/troff/div.cpp (begin_page, space_request)
+       (flush_output):
+       * src/roff/troff/env.cpp (fill, no_fill, center, right_justify)
+       (indent, temporary_indent, do_break_request):
+       * src/roff/troff/input.cpp (process_input_stack)
+       (macro_iterator::macro_iterator, copy_file, transparent_file):
+       Do it.
+
 2023-09-12  G. Branden Robinson <[email protected]>
 
        * tmac/doc.tmac (doc-str-Ar-default): Use unbreakable space
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index f1f1ebda5..0cbae5c8e 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -718,7 +718,7 @@ void begin_page()
     tok.next();
   if (curdiv == topdiv) {
     if (topdiv->before_first_page) {
-      if (!break_flag) {
+      if (!want_break) {
        if (got_arg)
          topdiv->set_next_page_number(n);
        if (got_arg || !topdiv->no_space_mode)
@@ -751,7 +751,7 @@ void begin_page()
     }
     else {
       push_page_ejector();
-      if (break_flag)
+      if (want_break)
        curenv->do_break();
       if (got_arg)
        topdiv->set_next_page_number(n);
@@ -788,7 +788,7 @@ sprung, then we don't actually do the space. */
 void space_request()
 {
   postpone_traps();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   vunits n;
   if (!has_arg() || !get_vunits(&n, 'v'))
@@ -870,7 +870,7 @@ void flush_output()
 {
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   if (the_output)
     the_output->flush();
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 2f2e60bb4..bed574b3c 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1364,7 +1364,7 @@ void fill()
 {
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   curenv->fill = 1;
   tok.next();
@@ -1374,7 +1374,7 @@ void no_fill()
 {
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   curenv->fill = 0;
   curenv->suppress_next_eol = 1;
@@ -1390,7 +1390,7 @@ void center()
     n = 0;
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   curenv->right_justify_lines = 0;
   curenv->center_lines = n;
@@ -1407,7 +1407,7 @@ void right_justify()
     n = 0;
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   curenv->center_lines = 0;
   curenv->right_justify_lines = n;
@@ -1514,7 +1514,7 @@ void indent()
     temp = curenv->prev_indent;
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   curenv->have_temporary_indent = 0;
   curenv->prev_indent = curenv->indent;
@@ -1531,7 +1531,7 @@ void temporary_indent()
     err = 1;
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   if (temp < H0) {
     warning(WARN_RANGE, "total indent cannot be negative");
@@ -2464,7 +2464,7 @@ void do_break_request(int spread)
 {
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break(spread);
   tok.next();
 }
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 8382d11ea..122f8d9ac 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -412,7 +412,7 @@ bool is_family_valid(const char *);
 
 extern double spread_limit;
 
-extern int break_flag;
+extern bool want_break;
 extern symbol default_family;
 extern int translate_space_to_dummy;
 
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 94ad67279..54322d604 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -78,7 +78,7 @@ void vjustify();
 void transparent_file();
 
 token tok;
-int break_flag = 0;
+bool want_break = false;
 int class_flag = 0;
 int color_flag = 1;            // colors are on by default
 static int backtrace_flag = 0;
@@ -2953,7 +2953,7 @@ void process_input_stack()
        if (bol && !have_input
            && (curenv->get_control_character() == ch
                || curenv->get_no_break_control_character() == ch)) {
-         break_flag = (curenv->get_control_character() == ch);
+         want_break = (curenv->get_control_character() == ch);
          // skip tabs as well as spaces here
          do {
            tok.next();
@@ -4071,7 +4071,7 @@ int macro::empty()
 
 macro_iterator::macro_iterator(symbol s, macro &m, const char *how_called,
                               int init_args)
-: string_iterator(m, how_called, s), args(0), argc(0), with_break(break_flag)
+: string_iterator(m, how_called, s), args(0), argc(0), with_break(want_break)
 {
   if (init_args) {
     arg_list *al = input_stack::get_arg_list();
@@ -4082,7 +4082,7 @@ macro_iterator::macro_iterator(symbol s, macro &m, const 
char *how_called,
   }
 }
 
-macro_iterator::macro_iterator() : args(0), argc(0), with_break(break_flag)
+macro_iterator::macro_iterator() : args(0), argc(0), with_break(want_break)
 {
 }
 
@@ -7784,7 +7784,7 @@ void copy_file()
   symbol filename = get_long_name(true /* required */);
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   if (!filename.is_null())
     curdiv->copy_file(filename.contents());
@@ -7816,7 +7816,7 @@ void transparent_file()
   symbol filename = get_long_name(true /* required */);
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
-  if (break_flag)
+  if (want_break)
     curenv->do_break();
   if (!filename.is_null()) {
     errno = 0;

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

Reply via email to