groff-commit
[Top][All Lists]
Advanced

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

[groff] 113/115: [eqn]: Trivially refactor (`check_tabs`).


From: G. Branden Robinson
Subject: [groff] 113/115: [eqn]: Trivially refactor (`check_tabs`).
Date: Thu, 1 Jun 2023 10:46:19 -0400 (EDT)

gbranden pushed a commit to branch branden-2022-06-01
in repository groff.

commit 0ab79b18b53cd4ac04269a881f58456c65098ccf
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue May 30 12:15:24 2023 -0500

    [eqn]: Trivially refactor (`check_tabs`).
    
    [eqn]: Rename `check_tabs` member functions to
    `diagnose_tab_stop_usage`, to be more expressive and to prepare for the
    diagnosis of leaders in the input as well.
    
    * src/preproc/eqn/box.cpp (box::check_tabs):
      (box_list::list_check_tabs):
      (pointer_box::check_tabs):
      (tab_box::check_tabs):
    * src/preproc/eqn/box.h (box::check_tabs):
      (box_list::list_check_tabs):
      (list_box::check_tabs):
      (pile_box::check_tabs):
      (matrix_box::check_tabs):
      (pointer_box::check_tabs):
      (tab_box::check_tabs):
    * src/preproc/eqn/delim.cpp (delim_box::check_tabs):
    * src/preproc/eqn/limit.cpp (limit_box::check_tabs):
    * src/preproc/eqn/list.cpp (list_box::check_tabs):
    * src/preproc/eqn/other.cpp (accent_box::check_tabs):
      (uaccent_box::check_tabs):
    * src/preproc/eqn/over.cpp (over_box::check_tabs):
    * src/preproc/eqn/pile.cpp (pile_box::check_tabs):
      (matrix_box::check_tabs):
    * src/preproc/eqn/script.cpp (script_box::check_tabs):
    * src/preproc/eqn/sqrt.cpp (sqrt_box::check_tabs): Rename these...
    
    * src/preproc/eqn/box.cpp (box::diagnose_tab_stop_usage):
      (box_list::list_diagnose_tab_stop_usage):
      (pointer_box::list_diagnose_tab_stop_usage):
      (tab_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/box.h (box::diagnose_tab_stop_usage):
      (box_list::list_diagnose_tab_stop_usage):
      (list_box::diagnose_tab_stop_usage):
      (pile_box::diagnose_tab_stop_usage):
      (matrix_box::diagnose_tab_stop_usage):
      (pointer_box::diagnose_tab_stop_usage):
      (tab_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/delim.cpp (delim_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/limit.cpp (limit_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/list.cpp (list_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/other.cpp (accent_box::diagnose_tab_stop_usage):
      (uaccent_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/over.cpp (over_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/pile.cpp (pile_box::diagnose_tab_stop_usage):
      (matrix_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/script.cpp (script_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/sqrt.cpp (sqrt_box::diagnose_tab_stop_usage):
      ...to these.
    
    * src/preproc/eqn/box.cpp (box::top_level)
      (box_list::list_diagnose_tab_stop_usage):
      (pointer_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/delim.cpp (delim_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/limit.cpp (limit_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/list.cpp (list_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/other.cpp (accent_box::diagnose_tab_stop_usage):
      (uaccent_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/over.cpp (over_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/pile.cpp (pile_box::diagnose_tab_stop_usage):
      (matrix_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/script.cpp
      (script_box::diagnose_tab_stop_usage):
    * src/preproc/eqn/sqrt.cpp (sqrt_box::diagnose_tab_stop_usage):
      Update call sites.
    
    Also update editor aid comments; drop old style Emacs file-local
    variable setting.
---
 ChangeLog                  | 75 ++++++++++++++++++++++++++++++++++++++++++++++
 src/preproc/eqn/box.cpp    | 14 ++++-----
 src/preproc/eqn/box.h      | 14 ++++-----
 src/preproc/eqn/delim.cpp  |  6 ++--
 src/preproc/eqn/limit.cpp  | 17 +++++++----
 src/preproc/eqn/list.cpp   | 11 +++++--
 src/preproc/eqn/other.cpp  | 22 ++++++++------
 src/preproc/eqn/over.cpp   | 15 ++++++----
 src/preproc/eqn/pile.cpp   |  8 ++---
 src/preproc/eqn/script.cpp | 10 +++----
 src/preproc/eqn/sqrt.cpp   | 13 +++++---
 11 files changed, 152 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b8e196a82..54852199e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,78 @@
+2023-05-30  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [eqn]: Trivially refactor.  Rename `check_tabs` member functions
+       to `diagnose_tab_stop_usage`, to be more expressive and to
+       prepare for the diagnosis of leaders in the input as well.
+
+       * src/preproc/eqn/box.cpp (box::check_tabs):
+       (box_list::list_check_tabs):
+       (pointer_box::check_tabs):
+       (tab_box::check_tabs):
+       * src/preproc/eqn/box.h (box::check_tabs):
+       (box_list::list_check_tabs):
+       (list_box::check_tabs):
+       (pile_box::check_tabs):
+       (matrix_box::check_tabs):
+       (pointer_box::check_tabs):
+       (tab_box::check_tabs):
+       * src/preproc/eqn/delim.cpp (delim_box::check_tabs):
+       * src/preproc/eqn/limit.cpp (limit_box::check_tabs):
+       * src/preproc/eqn/list.cpp (list_box::check_tabs):
+       * src/preproc/eqn/other.cpp (accent_box::check_tabs):
+       (uaccent_box::check_tabs):
+       * src/preproc/eqn/over.cpp (over_box::check_tabs):
+       * src/preproc/eqn/pile.cpp (pile_box::check_tabs):
+       (matrix_box::check_tabs):
+       * src/preproc/eqn/script.cpp (script_box::check_tabs):
+       * src/preproc/eqn/sqrt.cpp (sqrt_box::check_tabs):
+       Rename these...
+       * src/preproc/eqn/box.cpp (box::check_tabs):
+       (box::diagnose_tab_stop_usage):
+       (box_list::list_diagnose_tab_stop_usage):
+       (pointer_box::list_diagnose_tab_stop_usage):
+       (tab_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/box.h (box::diagnose_tab_stop_usage):
+       (box_list::list_diagnose_tab_stop_usage):
+       (list_box::diagnose_tab_stop_usage):
+       (pile_box::diagnose_tab_stop_usage):
+       (matrix_box::diagnose_tab_stop_usage):
+       (pointer_box::diagnose_tab_stop_usage):
+       (tab_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/delim.cpp
+       (delim_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/limit.cpp
+       (limit_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/list.cpp (list_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/other.cpp
+       (accent_box::diagnose_tab_stop_usage):
+       (uaccent_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/over.cpp (over_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/pile.cpp (pile_box::diagnose_tab_stop_usage):
+       (matrix_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/script.cpp
+       (script_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/sqrt.cpp (sqrt_box::diagnose_tab_stop_usage):
+       ...to these.
+
+       * src/preproc/eqn/box.cpp (box::top_level)
+       (box_list::list_diagnose_tab_stop_usage):
+       (pointer_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/delim.cpp
+       (delim_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/limit.cpp
+       (limit_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/list.cpp (list_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/other.cpp
+       (accent_box::diagnose_tab_stop_usage):
+       (uaccent_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/over.cpp (over_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/pile.cpp (pile_box::diagnose_tab_stop_usage):
+       (matrix_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/script.cpp
+       (script_box::diagnose_tab_stop_usage):
+       * src/preproc/eqn/sqrt.cpp (sqrt_box::diagnose_tab_stop_usage):
+       Update call sites.
+
 2023-05-25  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [eqn]: Trivially refactor.  Boolify `tab_box` member variable
diff --git a/src/preproc/eqn/box.cpp b/src/preproc/eqn/box.cpp
index 459e24ef6..a129982e9 100644
--- a/src/preproc/eqn/box.cpp
+++ b/src/preproc/eqn/box.cpp
@@ -307,7 +307,7 @@ void box::top_level()
     }
     current_roman_font = get_grfont();
     // This catches tabs used within \Z (which aren't allowed).
-    b->check_tabs(0);
+    b->diagnose_tab_stop_usage(0);
     int r = b->compute_metrics(DISPLAY_STYLE);
     printf(".ft \\n[" SAVED_PREV_FONT_REG "]\n");
     printf(".ft \\n[" SAVED_FONT_REG "]\n");
@@ -417,7 +417,7 @@ void box::output()
 {
 }
 
-void box::check_tabs(int)
+void box::diagnose_tab_stop_usage(int)
 {
 }
 
@@ -474,10 +474,10 @@ box_list::~box_list()
   delete[] p;
 }
 
-void box_list::list_check_tabs(int level)
+void box_list::list_diagnose_tab_stop_usage(int level)
 {
   for (int i = 0; i < len; i++)
-    p[i]->check_tabs(level);
+    p[i]->diagnose_tab_stop_usage(level);
 }
 
 
@@ -514,9 +514,9 @@ void pointer_box::compute_skew()
         uid, p->uid);
 }
 
-void pointer_box::check_tabs(int level)
+void pointer_box::diagnose_tab_stop_usage(int level)
 {
-  p->check_tabs(level);
+  p->diagnose_tab_stop_usage(level);
 }
 
 int simple_box::compute_metrics(int)
@@ -585,7 +585,7 @@ void tab_box::output()
     printf("\\t");
 }
 
-void tab_box::check_tabs(int level)
+void tab_box::diagnose_tab_stop_usage(int level)
 {
   if (level > 0) {
     error("tabs allowed only at outermost lexical level");
diff --git a/src/preproc/eqn/box.h b/src/preproc/eqn/box.h
index 079fd03cd..fc53e148b 100644
--- a/src/preproc/eqn/box.h
+++ b/src/preproc/eqn/box.h
@@ -42,7 +42,7 @@ public:
   enum { FOUND_NOTHING = 0, FOUND_MARK = 1, FOUND_LINEUP = 2 };
   void set_spacing_type(char *type);
   virtual void hint(unsigned);
-  virtual void check_tabs(int);
+  virtual void diagnose_tab_stop_usage(int);
 };
 
 class box_list {
@@ -55,7 +55,7 @@ public:
   box_list(box *);
   ~box_list();
   void append(box *);
-  void list_check_tabs(int);
+  void list_diagnose_tab_stop_usage(int);
   void list_debug_print(const char *sep);
   friend class list_box;
 };
@@ -75,7 +75,7 @@ public:
   int compute_metrics(int);
   void compute_subscript_kern();
   void output();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
   void append(box *);
   list_box *to_list_box();
   void handle_char_type(int, int);
@@ -107,7 +107,7 @@ public:
   int compute_metrics(int);
   void output();
   void debug_print();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
   void set_alignment(alignment a) { col.set_alignment(a); }
   void set_space(int n) { col.set_space(n); }
   void append(box *p) { col.append(p); }
@@ -124,7 +124,7 @@ public:
   void append(column *);
   int compute_metrics(int);
   void output();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
   void debug_print();
 };
 
@@ -138,7 +138,7 @@ public:
   void compute_subscript_kern();
   void compute_skew();
   void debug_print() = 0;
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 class vcenter_box : public pointer_box {
@@ -202,7 +202,7 @@ public:
   tab_box();
   void output();
   void debug_print();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 class size_box : public pointer_box {
diff --git a/src/preproc/eqn/delim.cpp b/src/preproc/eqn/delim.cpp
index 01557c52b..43cfe4996 100644
--- a/src/preproc/eqn/delim.cpp
+++ b/src/preproc/eqn/delim.cpp
@@ -170,7 +170,7 @@ public:
   ~delim_box();
   int compute_metrics(int);
   void output();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
   void debug_print();
 };
 
@@ -397,9 +397,9 @@ void delim_box::output()
   }
 }
 
-void delim_box::check_tabs(int level)
+void delim_box::diagnose_tab_stop_usage(int level)
 {
-  p->check_tabs(level);
+  p->diagnose_tab_stop_usage(level);
 }
 
 void delim_box::debug_print()
diff --git a/src/preproc/eqn/limit.cpp b/src/preproc/eqn/limit.cpp
index bf64a0417..c8b0eb943 100644
--- a/src/preproc/eqn/limit.cpp
+++ b/src/preproc/eqn/limit.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -31,7 +30,7 @@ public:
   int compute_metrics(int);
   void output();
   void debug_print();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 box *make_limit_box(box *pp, box *qq, box *rr)
@@ -207,11 +206,17 @@ void limit_box::debug_print()
   }
 }
 
-void limit_box::check_tabs(int level)
+void limit_box::diagnose_tab_stop_usage(int level)
 {
   if (to)
-    to->check_tabs(level + 1);
+    to->diagnose_tab_stop_usage(level + 1);
   if (from)
-    from->check_tabs(level + 1);
-  p->check_tabs(level + 1);
+    from->diagnose_tab_stop_usage(level + 1);
+  p->diagnose_tab_stop_usage(level + 1);
 }
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/preproc/eqn/list.cpp b/src/preproc/eqn/list.cpp
index 52644c50f..2e0cb104a 100644
--- a/src/preproc/eqn/list.cpp
+++ b/src/preproc/eqn/list.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -235,7 +234,13 @@ void list_box::debug_print()
   list.list_debug_print(" ");
 }
 
-void list_box::check_tabs(int level)
+void list_box::diagnose_tab_stop_usage(int level)
 {
-  list.list_check_tabs(level);
+  list.list_diagnose_tab_stop_usage(level);
 }
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/preproc/eqn/other.cpp b/src/preproc/eqn/other.cpp
index 1ddc8fbe5..c7e95cb5d 100644
--- a/src/preproc/eqn/other.cpp
+++ b/src/preproc/eqn/other.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -35,7 +34,7 @@ public:
   int compute_metrics(int);
   void output();
   void debug_print();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 box *make_accent_box(box *p, box *q)
@@ -146,10 +145,10 @@ void accent_box::output()
   }
 }
 
-void accent_box::check_tabs(int level)
+void accent_box::diagnose_tab_stop_usage(int level)
 {
-  ab->check_tabs(level + 1);
-  p->check_tabs(level + 1);
+  ab->diagnose_tab_stop_usage(level + 1);
+  p->diagnose_tab_stop_usage(level + 1);
 }
 
 void accent_box::debug_print()
@@ -256,7 +255,7 @@ public:
   int compute_metrics(int);
   void output();
   void compute_subscript_kern();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
   void debug_print();
 };
 
@@ -321,10 +320,10 @@ void uaccent_box::output()
   }
 }
 
-void uaccent_box::check_tabs(int level)
+void uaccent_box::diagnose_tab_stop_usage(int level)
 {
-  ab->check_tabs(level + 1);
-  p->check_tabs(level + 1);
+  ab->diagnose_tab_stop_usage(level + 1);
+  p->diagnose_tab_stop_usage(level + 1);
 }
 
 void uaccent_box::compute_subscript_kern()
@@ -704,3 +703,8 @@ void vcenter_box::debug_print()
   fprintf(stderr, " }");
 }
 
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/preproc/eqn/over.cpp b/src/preproc/eqn/over.cpp
index 6a9cd9b44..8a5729a3c 100644
--- a/src/preproc/eqn/over.cpp
+++ b/src/preproc/eqn/over.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -31,7 +30,7 @@ public:
   void debug_print();
   int compute_metrics(int);
   void output();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 box *make_over_box(box *pp, box *qq)
@@ -197,8 +196,14 @@ void over_box::debug_print()
   fprintf(stderr, " }");
 }
 
-void over_box::check_tabs(int level)
+void over_box::diagnose_tab_stop_usage(int level)
 {
-  num->check_tabs(level + 1);
-  den->check_tabs(level + 1);
+  num->diagnose_tab_stop_usage(level + 1);
+  den->diagnose_tab_stop_usage(level + 1);
 }
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/preproc/eqn/pile.cpp b/src/preproc/eqn/pile.cpp
index fcc2e925f..5ce8ee9eb 100644
--- a/src/preproc/eqn/pile.cpp
+++ b/src/preproc/eqn/pile.cpp
@@ -127,9 +127,9 @@ pile_box::pile_box(box *pp) : col(pp)
 {
 }
 
-void pile_box::check_tabs(int level)
+void pile_box::diagnose_tab_stop_usage(int level)
 {
-  col.list_check_tabs(level);
+  col.list_diagnose_tab_stop_usage(level);
 }
 
 void pile_box::debug_print()
@@ -295,10 +295,10 @@ void matrix_box::append(column *pp)
   p[len++] = pp;
 }
 
-void matrix_box::check_tabs(int level)
+void matrix_box::diagnose_tab_stop_usage(int level)
 {
   for (int i = 0; i < len; i++)
-    p[i]->list_check_tabs(level);
+    p[i]->list_diagnose_tab_stop_usage(level);
 }
 
 void matrix_box::debug_print()
diff --git a/src/preproc/eqn/script.cpp b/src/preproc/eqn/script.cpp
index f485eb93a..7bb16a5b9 100644
--- a/src/preproc/eqn/script.cpp
+++ b/src/preproc/eqn/script.cpp
@@ -33,7 +33,7 @@ public:
   void debug_print();
   int left_is_italic();
   void hint(unsigned);
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 /* The idea is that the script should attach to the rightmost box
@@ -234,13 +234,13 @@ void script_box::debug_print()
   }
 }
 
-void script_box::check_tabs(int level)
+void script_box::diagnose_tab_stop_usage(int level)
 {
   if (sup)
-    sup->check_tabs(level + 1);
+    sup->diagnose_tab_stop_usage(level + 1);
   if (sub)
-    sub->check_tabs(level + 1);
-  p->check_tabs(level);
+    sub->diagnose_tab_stop_usage(level + 1);
+  p->diagnose_tab_stop_usage(level);
 }
 
 // Local Variables:
diff --git a/src/preproc/eqn/sqrt.cpp b/src/preproc/eqn/sqrt.cpp
index e8d7c77ff..a4ae8d724 100644
--- a/src/preproc/eqn/sqrt.cpp
+++ b/src/preproc/eqn/sqrt.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -27,7 +26,7 @@ public:
   int compute_metrics(int style);
   void output();
   void debug_print();
-  void check_tabs(int);
+  void diagnose_tab_stop_usage(int);
 };
 
 box *make_sqrt_box(box *pp)
@@ -180,7 +179,13 @@ void sqrt_box::debug_print()
   fprintf(stderr, " }");
 }
 
-void sqrt_box::check_tabs(int level)
+void sqrt_box::diagnose_tab_stop_usage(int level)
 {
-  p->check_tabs(level + 1);
+  p->diagnose_tab_stop_usage(level + 1);
 }
+
+// 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]