groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/15: [troff]: Trivially refactor (usable_as_delimiter).


From: G. Branden Robinson
Subject: [groff] 05/15: [troff]: Trivially refactor (usable_as_delimiter).
Date: Thu, 12 Oct 2023 21:55:06 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 57c58af5783e77d1a6415761bde419cb5f756502
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Oct 7 18:23:29 2023 -0500

    [troff]: Trivially refactor (usable_as_delimiter).
    
    Rename Boolean-valued member function to read like a logical predicate.
    
    * src/roff/troff/token.h (token::usable_as_delimiter): Rename this...
      (token::is_usable_as_delimiter): ...to this (declaration).
    * src/roff/troff/input.cpp (token::usable_as_delimiter): Rename this...
      (token::is_usable_as_delimiter): ...to this (definition).
    
    * src/roff/troff/env.cpp (number_lines):
    * src/roff/troff/input.cpp (do_expr_test, get_delim_number)
      (get_line_arg, read_size, do_register, do_if_request, read_draw_node):
    * src/roff/troff/node.cpp (has_font, embolden_font): Update call sites.
---
 ChangeLog                | 17 +++++++++++++++++
 src/roff/troff/env.cpp   |  9 +++++----
 src/roff/troff/input.cpp | 18 +++++++++---------
 src/roff/troff/node.cpp  |  4 ++--
 src/roff/troff/token.h   |  2 +-
 5 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b403e1324..f190358bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2023-10-07  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Trivially refactor.  Rename Boolean-valued member
+       function to read like a logical predicate.
+
+       * src/roff/troff/token.h (token::usable_as_delimiter): Rename...
+       (token::is_usable_as_delimiter): ...declaration to this.
+       * src/roff/troff/input.cpp (token::usable_as_delimiter):
+       (token::is_usable_as_delimiter): ...same for implementation.
+
+       * src/roff/troff/env.cpp (number_lines):
+       * src/roff/troff/input.cpp (do_expr_test, get_delim_number)
+       (get_line_arg, read_size, do_register, do_if_request)
+       (read_draw_node):
+       * src/roff/troff/node.cpp (has_font, embolden_font): Update call
+       sites.
+
 2023-10-07  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (token::next, device_macro_request):
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 6ee1ff80c..93d90f059 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1635,7 +1635,7 @@ void number_lines()
     curenv->numbering_nodes = nd;
     curenv->line_number_digit_width = env_digit_width(curenv);
     int n;
-    if (!tok.usable_as_delimiter()) {
+    if (!tok.is_usable_as_delimiter()) {
       if (get_integer(&n, next_line_number)) {
        next_line_number = n;
        if (next_line_number < 0) {
@@ -1648,7 +1648,7 @@ void number_lines()
       while (!tok.is_space() && !tok.is_newline() && !tok.is_eof())
        tok.next();
     if (has_arg()) {
-      if (!tok.usable_as_delimiter()) {
+      if (!tok.is_usable_as_delimiter()) {
        if (get_integer(&n)) {
          if (n <= 0) {
            warning(WARN_RANGE, "negative or zero line number multiple");
@@ -1661,14 +1661,15 @@ void number_lines()
        while (!tok.is_space() && !tok.is_newline() && !tok.is_eof())
          tok.next();
       if (has_arg()) {
-       if (!tok.usable_as_delimiter()) {
+       if (!tok.is_usable_as_delimiter()) {
          if (get_integer(&n))
            curenv->number_text_separation = n;
        }
        else
          while (!tok.is_space() && !tok.is_newline() && !tok.is_eof())
            tok.next();
-       if (has_arg() && !tok.usable_as_delimiter() && get_integer(&n))
+       if (has_arg() && !tok.is_usable_as_delimiter()
+           && get_integer(&n))
          curenv->line_number_indent = n;
       }
     }
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 5a17bd480..72e877734 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1645,7 +1645,7 @@ static int do_expr_test()
   token start;
   start.next();
   int start_level = input_stack::get_level();
-  if (!start.usable_as_delimiter(true /* report error */))
+  if (!start.is_usable_as_delimiter(true /* report error */))
     return 0;
   tok.next();
   // disable all warning and error messages temporarily
@@ -2458,7 +2458,7 @@ int token::operator!=(const token &t)
 
 // is token a suitable delimiter (like ')?
 
-bool token::usable_as_delimiter(bool report_error)
+bool token::is_usable_as_delimiter(bool report_error)
 {
   switch(type) {
   case TOKEN_CHAR:
@@ -5131,7 +5131,7 @@ static int get_delim_number(units *n, unsigned char si, 
int prev_value)
 {
   token start;
   start.next();
-  if (start.usable_as_delimiter(true /* report error */)) {
+  if (start.is_usable_as_delimiter(true /* report error */)) {
     tok.next();
     if (get_number(n, si, prev_value)) {
       if (start != tok)
@@ -5146,7 +5146,7 @@ static int get_delim_number(units *n, unsigned char si)
 {
   token start;
   start.next();
-  if (start.usable_as_delimiter(true /* report error */)) {
+  if (start.is_usable_as_delimiter(true /* report error */)) {
     tok.next();
     if (get_number(n, si)) {
       if (start != tok)
@@ -5162,7 +5162,7 @@ static int get_line_arg(units *n, unsigned char si, 
charinfo **cp)
   token start;
   start.next();
   int start_level = input_stack::get_level();
-  if (!start.usable_as_delimiter(true /* report error */))
+  if (!start.is_usable_as_delimiter(true /* report error */))
     return 0;
   tok.next();
   if (get_number(n, si)) {
@@ -5243,7 +5243,7 @@ static bool read_size(int *x)
     }
     val *= sizescale;
   }
-  else if (!tok.usable_as_delimiter(true /* report error */))
+  else if (!tok.is_usable_as_delimiter(true /* report error */))
     return false;
   else {
     token start(tok);
@@ -5366,7 +5366,7 @@ static void do_register()
 {
   token start;
   start.next();
-  if (!start.usable_as_delimiter(true /* report error */))
+  if (!start.is_usable_as_delimiter(true /* report error */))
     return;
   tok.next();
   symbol nm = get_long_name(true /* required */);
@@ -5970,7 +5970,7 @@ int do_if_request()
   }
   else if (tok.is_space())
     result = 0;
-  else if (tok.usable_as_delimiter()) {
+  else if (tok.is_usable_as_delimiter()) {
     token delim = tok;
     int delim_level = input_stack::get_level();
     environment env1(curenv);
@@ -8684,7 +8684,7 @@ static node *read_draw_node()
 {
   token start;
   start.next();
-  if (!start.usable_as_delimiter(true /* report error */)){
+  if (!start.is_usable_as_delimiter(true /* report error */)){
     do {
       tok.next();
     } while (tok != start && !tok.is_newline() && !tok.is_eof());
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 8c0a0723e..6db9e9d15 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6204,7 +6204,7 @@ static bool has_font(font_lookup_info *finfo)
 {
   int n;
   tok.skip();
-  if (tok.usable_as_delimiter()) {
+  if (tok.is_usable_as_delimiter()) {
     symbol s = get_name(true /* required */);
     finfo->requested_name = (char *)s.contents();
     if (!s.is_null()) {
@@ -6490,7 +6490,7 @@ static void embolden_font()
   else {
     int n = finfo.position;
     if (has_arg()) {
-      if (tok.usable_as_delimiter()) {
+      if (tok.is_usable_as_delimiter()) {
        font_lookup_info finfo2;
        if (!has_font(&finfo2))
          font_lookup_error(finfo2, "for conditional emboldening");
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index aec3854d3..e54f55e8e 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -79,7 +79,7 @@ public:
   bool is_tab();
   bool is_leader();
   bool is_backspace();
-  bool usable_as_delimiter(bool = false);
+  bool is_usable_as_delimiter(bool = false);
   bool is_dummy();
   bool is_transparent_dummy();
   bool is_transparent();



reply via email to

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