groff-commit
[Top][All Lists]
Advanced

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

[groff] 19/38: [troff]: Trivially refactor.


From: G. Branden Robinson
Subject: [groff] 19/38: [troff]: Trivially refactor.
Date: Mon, 3 Oct 2022 01:42:57 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit a6ea51c1114ab0ee3f2f19c719cd543c515d18da
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Sep 28 19:04:43 2022 -0500

    [troff]: Trivially refactor.
    
    * src/roff/troff/input.cpp:
    * src/roff/troff/request.h: Trivially refactor.  Boolify
      `interpolate_macro` and `request::invoke`.  Also rename parameter
      `no_next` to `do_not_want_next_token`, exposing potentially confusing
      interface design.
    
    Also update editor aid comments and drop old style Emacs file-local
    variable setting.
---
 ChangeLog                |  8 ++++++++
 src/roff/troff/input.cpp | 14 +++++++-------
 src/roff/troff/request.h | 13 +++++++++----
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 113b065b2..9fd22d380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-09-28  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/input.cpp:
+       * src/roff/troff/request.h: Trivially refactor.  Boolify
+       `interpolate_macro` and `request::invoke`.  Also rename
+       parameter `no_next` to `do_not_want_next_token`, exposing
+       potentially confusing interface design.
+
 2022-09-28  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (spring_trap, interpolate_string)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index b2179919d..346b6a466 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -137,7 +137,7 @@ static symbol read_escape_parameter(read_mode = NO_ARGS);
 static symbol read_long_escape_parameters(read_mode = NO_ARGS);
 static void interpolate_string(symbol);
 static void interpolate_string_with_args(symbol);
-static void interpolate_macro(symbol, int = 0);
+static void interpolate_macro(symbol, bool = false);
 static void interpolate_number_format(symbol);
 static void interpolate_environment_variable(symbol);
 
@@ -2671,7 +2671,7 @@ void do_request()
   if (nm.is_null())
     skip_line();
   else
-    interpolate_macro(nm, 1);
+    interpolate_macro(nm, true /* don't want next token */);
   compatible_flag = do_old_compatible_flag;
   do_old_compatible_flag = -1;
   request_or_macro *p = lookup_request(nm);
@@ -3094,7 +3094,7 @@ request::request(REQUEST_FUNCP pp) : p(pp)
 {
 }
 
-void request::invoke(symbol, int)
+void request::invoke(symbol, bool)
 {
   (*p)();
 }
@@ -3793,7 +3793,7 @@ int operator==(const macro &m1, const macro &m2)
   return 1;
 }
 
-static void interpolate_macro(symbol nm, int no_next)
+static void interpolate_macro(symbol nm, bool do_not_want_next_token)
 {
   request_or_macro *p = (request_or_macro *)request_dictionary.lookup(nm);
   if (p == 0) {
@@ -3822,7 +3822,7 @@ static void interpolate_macro(symbol nm, int no_next)
     }
   }
   if (p)
-    p->invoke(nm, no_next);
+    p->invoke(nm, do_not_want_next_token);
   else {
     skip_line();
     return;
@@ -3931,14 +3931,14 @@ static void decode_string_args(macro_iterator *mi)
   }
 }
 
-void macro::invoke(symbol nm, int no_next)
+void macro::invoke(symbol nm, bool do_not_want_next_token)
 {
   macro_iterator *mi = new macro_iterator(nm, *this);
   decode_args(mi);
   input_stack::push(mi);
   // we must delay tok.next() in case the function has been called by
   // do_request to assure proper handling of compatible_flag
-  if (!no_next)
+  if (!do_not_want_next_token)
     tok.next();
 }
 
diff --git a/src/roff/troff/request.h b/src/roff/troff/request.h
index c706a5f74..0991e4912 100644
--- a/src/roff/troff/request.h
+++ b/src/roff/troff/request.h
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -24,14 +23,14 @@ class macro;
 class request_or_macro : public object {
 public:
   request_or_macro();
-  virtual void invoke(symbol, int) = 0;
+  virtual void invoke(symbol, bool) = 0;
   virtual macro *to_macro();
 };
 
 class request : public request_or_macro {
   REQUEST_FUNCP p;
 public:
-  void invoke(symbol, int);
+  void invoke(symbol, bool);
   request(REQUEST_FUNCP);
 };
 
@@ -64,7 +63,7 @@ public:
   void set(unsigned char, int);
   unsigned char get(int);
   int length();
-  void invoke(symbol, int);
+  void invoke(symbol, bool);
   macro *to_macro();
   void print_size();
   int empty();
@@ -90,3 +89,9 @@ class charinfo;
 class environment;
 
 node *charinfo_to_node_list(charinfo *, const environment *);
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:



reply via email to

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