changeset 27071:4643682db06e

who: don't print summary line if variable list is empty (bug #56228) * syminfo-accumulator.h (symbol_info_accumulator::is_empty): New function. * call-stack.cc (octave_value call_stack::do_who_two): Don't print anything if variable list is empty.
author John W. Eaton <jwe@octave.org>
date Mon, 29 Apr 2019 12:56:41 -0500
parents 726d945f23de
children 1ccb40372115
files libinterp/corefcn/call-stack.cc libinterp/corefcn/syminfo-accumulator.h
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc	Thu Apr 25 08:51:25 2019 -0700
+++ b/libinterp/corefcn/call-stack.cc	Mon Apr 29 12:56:41 2019 -0500
@@ -935,8 +935,9 @@
         else
           return Cell (string_vector (sym_inf_accum.names ()));
       }
-    else
+    else if (! sym_inf_accum.is_empty ())
       {
+
         if (msg.empty ())
           octave_stdout << "Variables visible from the current scope:\n";
         else
--- a/libinterp/corefcn/syminfo-accumulator.h	Thu Apr 25 08:51:25 2019 -0700
+++ b/libinterp/corefcn/syminfo-accumulator.h	Mon Apr 29 12:56:41 2019 -0500
@@ -65,6 +65,19 @@
 
     ~symbol_info_accumulator (void) = default;
 
+    bool is_empty  (void) const
+    {
+      for (const auto& nm_sil : m_sym_inf_list)
+        {
+          const symbol_info_list& lst = nm_sil.second;
+
+          if (! lst.empty ())
+            return false;
+        }
+
+      return true;
+    }
+
     std::list<std::string> names (void) const
     {
       std::list<std::string> retval;