groff-commit
[Top][All Lists]
Advanced

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

[groff] 02/08: [troff]: Slightly refactor (`nroff_mode`).


From: G. Branden Robinson
Subject: [groff] 02/08: [troff]: Slightly refactor (`nroff_mode`).
Date: Mon, 6 Nov 2023 13:25:49 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 334a20b3ec7ec76b6ab5646818e319dce0fda674
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Nov 6 09:38:05 2023 -0600

    [troff]: Slightly refactor (`nroff_mode`).
    
    [troff]: Make `in_nroff_mode` visible to other translation units, in
    preparation for Savannah #64866 fix.  Boolify it and rename it from
    `nroff_mode`.  Relocate definition alongside other externally visible
    symbols.
    
    * src/roff/troff/troff.h: Declare it.
    
    * src/roff/troff/input.cpp: Do it.
      (nroff_request, troff_request, do_if_request, do_error): Update
      references.
---
 ChangeLog                | 12 ++++++++++++
 src/roff/troff/input.cpp | 14 +++++++-------
 src/roff/troff/troff.h   |  1 +
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ad332f0ee..a6b3fdeb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-11-06  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Make `in_nroff_mode` visible to other translation
+       units, in preparation for Savannah #64866 fix.  Boolify it and
+       rename it from `nroff_mode`.  Relocate definition alongside
+       other externally visible symbols.
+
+       * src/roff/troff/troff.h: Declare it.
+       * src/roff/troff/input.cpp: Do it.
+       (nroff_request, troff_request, do_if_request, do_error): Update
+       references.
+
 2023-11-04  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/node.cpp (set_font_specific_special_fonts):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 746d456f2..73fae2c05 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -104,6 +104,8 @@ int suppress_output_flag = 0;
 int is_html = 0;
 int suppression_level = 0;     // depth of nested \O escapes
 
+bool in_nroff_mode = false;
+
 // Keep track of whether \f, \F, \D'F...', \H, \m, \M, \O[345], \R, \s,
 // or \S has been processed in token::next().
 bool have_formattable_input = false;
@@ -5807,17 +5809,15 @@ void line_file()
   skip_line();
 }
 
-static int nroff_mode = 0;
-
 static void nroff_request()
 {
-  nroff_mode = 1;
+  in_nroff_mode = true;
   skip_line();
 }
 
 static void troff_request()
 {
-  nroff_mode = 0;
+  in_nroff_mode = false;
   skip_line();
 }
 
@@ -5905,11 +5905,11 @@ int do_if_request()
     }
   if (c == 't') {
     tok.next();
-    result = !nroff_mode;
+    result = !in_nroff_mode;
   }
   else if (c == 'n') {
     tok.next();
-    result = nroff_mode;
+    result = in_nroff_mode;
   }
   else if (c == 'v') {
     tok.next();
@@ -8956,7 +8956,7 @@ static void do_error(error_type type,
     fputs("debug: ", stderr);
     break;
   case OUTPUT_WARNING:
-    if (nroff_mode) {
+    if (in_nroff_mode) {
       int fromtop = topdiv->get_vertical_position().to_units()
                    / vresolution;
       fprintf(stderr, "warning [page %d, line %d",
diff --git a/src/roff/troff/troff.h b/src/roff/troff/troff.h
index af5ca11bf..9355297c7 100644
--- a/src/roff/troff/troff.h
+++ b/src/roff/troff/troff.h
@@ -41,6 +41,7 @@ extern bool want_abstract_output;
 extern int suppress_output_flag;
 extern int color_flag;
 extern int is_html;
+extern bool in_nroff_mode;
 
 extern bool device_has_tcommand;
 extern int vresolution;



reply via email to

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