gbranden pushed a commit to branch master
in repository groff.

commit 5310b2e8e4d1549efa2e2a312d16e4e88466e510
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Sep 14 15:30:51 2023 -0500

    [troff]: Trivially refactor (`want_html_debugging`).
    
    Rename `debug_state` symbol to `want_html_debugging` and demote its type
    from `int` to `bool`.
    
    * src/roff/troff/input.cpp:
    * src/roff/troff/mtsm.cpp: Do it (declarations).
    
    * src/roff/troff/input.cpp (input_stack::finish_get, input_stack::push)
      (process_input_stack, main, charinfo::get_flags, charinfo::contains):
      Do it.
    
    * src/roff/troff/node.cpp: Drop unused declaration.
---
 ChangeLog                | 14 ++++++++++++++
 src/roff/troff/input.cpp | 20 ++++++++++----------
 src/roff/troff/mtsm.cpp  | 16 ++++++++--------
 src/roff/troff/node.cpp  |  2 --
 4 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 26f5fef0d..380386419 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-09-14  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.  Rename `debug_state` symbol to
+       `want_html_debugging` and demote its type from `int` to `bool`.
+
+       * src/roff/troff/input.cpp:
+       * src/roff/troff/mtsm.cpp: Do it (declarations).
+
+       * src/roff/troff/input.cpp (input_stack::finish_get)
+       (input_stack::push, process_input_stack, main)
+       (charinfo::get_flags, charinfo::contains): Do it.
+
+       * src/roff/troff/node.cpp: Drop unused declaration.
+
 2023-09-14  G. Branden Robinson <[email protected]>
 
        [troff]: Trivially refactor.  Rename `break_flag` symbol to
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 54322d604..bdf3bd341 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -117,7 +117,7 @@ double spread_limit = -3.0 - 1.0;   // negative means 
deactivated
 
 double warn_scale;
 char warn_scaling_unit;
-int debug_state = 0;           // turns on debugging of the html troff state
+bool want_html_debugging = true;       // enable more diagnostics
 
 search_path *mac_path = &safer_macro_path;
 
@@ -603,7 +603,7 @@ int input_stack::finish_get(node **np)
     input_iterator *tem = top;
     check_end_diversion(tem);
 #if defined(DEBUGGING)
-    if (debug_state)
+    if (want_html_debugging)
       if (tem->is_diversion)
        fprintf(stderr,
                "in diversion level = %d\n", input_stack::get_div_level());
@@ -692,14 +692,14 @@ void input_stack::push(input_iterator *in)
     in->diversion_state = diversion_state;
     diversion_state = curenv->construct_state(0);
 #if defined(DEBUGGING)
-    if (debug_state) {
+    if (want_html_debugging) {
       curenv->dump_troff_state();
       fflush(stderr);
     }
 #endif
   }
 #if defined(DEBUGGING)
-  if (debug_state)
+  if (want_html_debugging)
     if (top->is_diversion) {
       fprintf(stderr,
              "in diversion level = %d\n", input_stack::get_div_level());
@@ -2960,7 +2960,7 @@ void process_input_stack()
          } while (tok.is_white_space());
          symbol nm = get_name();
 #if defined(DEBUGGING)
-         if (debug_state) {
+         if (want_html_debugging) {
            if (! nm.is_null()) {
              if (strcmp(nm.contents(), "test") == 0) {
                fprintf(stderr, "found it!\n");
@@ -2980,7 +2980,7 @@ void process_input_stack()
          else {
            interpolate_macro(nm);
 #if defined(DEBUGGING)
-           if (debug_state) {
+           if (want_html_debugging) {
              fprintf(stderr, "finished interpreting [%s] and environment state 
is\n", nm.contents());
              curenv->dump_troff_state();
            }
@@ -2994,7 +2994,7 @@ void process_input_stack()
          else {
            for (;;) {
 #if defined(DEBUGGING)
-             if (debug_state) {
+             if (want_html_debugging) {
                fprintf(stderr, "found [%c]\n", ch); fflush(stderr);
              }
 #endif
@@ -8287,7 +8287,7 @@ int main(int argc, char **argv)
       break;
 #if defined(DEBUGGING)
     case 'D':
-      debug_state = 1;
+      want_html_debugging = true;
       break;
 #endif
     case CHAR_MAX + 1: // --help
@@ -9147,7 +9147,7 @@ void charinfo::get_flags()
     assert(!s.is_null());
     if (ci->contains(get_unicode_code())) {
 #if defined(DEBUGGING)
-      if (debug_state)
+      if (want_html_debugging)
        fprintf(stderr, "charinfo::get_flags %p %s %d\n",
                        (void *)ci, ci->nm.contents(), ci->flags);
 #endif
@@ -9213,7 +9213,7 @@ bool charinfo::contains(int c, bool already_called)
   while (ranges_iter != ranges.end()) {
     if (c >= ranges_iter->first && c <= ranges_iter->second) {
 #if defined(DEBUGGING)
-      if (debug_state)
+      if (want_html_debugging)
        fprintf(stderr, "charinfo::contains(%d)\n", c);
 #endif
       return true;
diff --git a/src/roff/troff/mtsm.cpp b/src/roff/troff/mtsm.cpp
index 058b9b18f..37d9953d9 100644
--- a/src/roff/troff/mtsm.cpp
+++ b/src/roff/troff/mtsm.cpp
@@ -18,7 +18,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 // mtsm: minimum troff state machine
 
-extern int debug_state;
+extern bool want_html_debugging;
 
 #include "troff.h"
 #include "hvunits.h"
@@ -49,7 +49,7 @@ void int_value::diff(FILE *fp, const char *s, int_value 
compare)
     fputs("\n", fp);
     value = compare.value;
     is_known = 1;
-    if (debug_state)
+    if (want_html_debugging)
       fflush(fp);
   }
 }
@@ -93,7 +93,7 @@ void bool_value::diff(FILE *fp, const char *s, bool_value 
compare)
     fputs("\n", fp);
     value = compare.value;
     is_known = 1;
-    if (debug_state)
+    if (want_html_debugging)
       fflush(fp);
   }
 }
@@ -116,7 +116,7 @@ void units_value::diff(FILE *fp, const char *s, units_value 
compare)
     fputs("\n", fp);
     value = compare.value;
     is_known = 1;
-    if (debug_state)
+    if (want_html_debugging)
       fflush(fp);
   }
 }
@@ -225,7 +225,7 @@ void statem::flush(FILE *fp, statem *compare)
   bool_values[MTSM_BR].diff(fp, "devtag:.br",
                            compare->bool_values[MTSM_BR]);
 #if defined(DEBUGGING)
-  if (debug_state) {
+  if (want_html_debugging) {
     fprintf(stderr, "compared state %d\n", compare->issue_no);
     fflush(stderr);
   }
@@ -381,7 +381,7 @@ void mtsm::push_state(statem *n)
 {
   if (is_html) {
 #if defined(DEBUGGING)
-    if (debug_state) {
+    if (want_html_debugging) {
       fprintf(stderr, "--> state %d pushed\n", n->issue_no);
       fflush(stderr);
     }
@@ -394,7 +394,7 @@ void mtsm::pop_state()
 {
   if (is_html) {
 #if defined(DEBUGGING)
-    if (debug_state) {
+    if (want_html_debugging) {
       fprintf(stderr, "--> state popped\n");
       fflush(stderr);
     }
@@ -432,7 +432,7 @@ void mtsm::inherit(statem *s, int reset_bool)
        sp->state->bool_values[MTSM_BR].set(0);
       s->bool_values[MTSM_BR].set(1);
 #if defined(DEBUGGING)
-      if (debug_state)
+      if (want_html_debugging)
        fprintf(stderr, "inherited br from pushed state %d\n",
                sp->state->issue_no);
 #endif
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 1d3f2c196..1153174fb 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -16,8 +16,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-extern int debug_state;
-
 #include "troff.h"
 
 #ifdef HAVE_UNISTD_H

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

Reply via email to