groff-commit
[Top][All Lists]
Advanced

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

[groff] 02/26: src/preproc/refer/command.cpp: Refactor: simplify.


From: G. Branden Robinson
Subject: [groff] 02/26: src/preproc/refer/command.cpp: Refactor: simplify.
Date: Sun, 15 May 2022 05:07:52 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 737f57bff6dfc1b6619fee0a554f1c537efba2e7
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed May 4 18:28:53 2022 -0500

    src/preproc/refer/command.cpp: Refactor: simplify.
    
    * src/preproc/refer/command.cpp: Refactor to simplify.
    
      (get_location): Demote return type from `int` to `void`.  The function
      only ever returned a `1` literal.
    
      (input_stack::error): Update call site to stop uselessly testing
      return value of `get_location()`.
    
    Also update editor aid comments; drop old-style Emacs file-local
    variable setting.
---
 ChangeLog                     |  8 ++++++++
 src/preproc/refer/command.cpp | 23 ++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 67102794..0774d8b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-05-04  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/refer/command.cpp: Refactor to simplify.
+       (get_location): Demote return type from `int` to `void`.  The
+       function only ever returned a `1` literal.
+       (input_stack::error): Update call site to stop uselessly testing
+       return value of `get_location()`.
+
 2022-05-03  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * doc/doc.am (dist-info-bits, install_infodoc, dist-gnueps): Fix
diff --git a/src/preproc/refer/command.cpp b/src/preproc/refer/command.cpp
index d7832e8a..08e05a6b 100644
--- a/src/preproc/refer/command.cpp
+++ b/src/preproc/refer/command.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* Copyright (C) 1989-2020 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
@@ -37,7 +36,7 @@ public:
   int get_char();
   int peek_char();
   void skip_char();
-  int get_location(const char **, int *);
+  void get_location(const char **, int *);
 
   friend class input_stack;
 };
@@ -76,7 +75,7 @@ inline void input_item::skip_char()
   ptr++;
 }
 
-int input_item::get_location(const char **filenamep, int *linenop)
+void input_item::get_location(const char **filenamep, int *linenop)
 {
   *filenamep = filename;
   if (ptr == buffer.contents())
@@ -90,7 +89,7 @@ int input_item::get_location(const char **filenamep, int 
*linenop)
     ln--; // Back up to identify line number _before_ last seen newline.
     *linenop = ln;
   }
-  return 1;
+  return;
 }
 
 class input_stack {
@@ -227,11 +226,11 @@ void input_stack::error(const char *format, const errarg 
&arg1,
 {
   const char *filename;
   int lineno;
-  for (input_item *it = top; it; it = it->next)
-    if (it->get_location(&filename, &lineno)) {
-      error_with_file_and_line(filename, lineno, format, arg1, arg2, arg3);
-      return;
-    }
+  for (input_item *it = top; it; it = it->next) {
+    it->get_location(&filename, &lineno);
+    error_with_file_and_line(filename, lineno, format, arg1, arg2, arg3);
+    return;
+  }
   ::error(format, arg1, arg2, arg3);
 }
 
@@ -807,3 +806,9 @@ void process_commands(string &s, const char *file, int 
lineno)
   input_stack::push_string(s, file, lineno);
   command_loop();
 }
+
+// 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]