Mercurial > octave
changeset 29856:56b3e2af0298
Add 's'=sparse attribute for whos function (bug #60687)
* syminfo.cc (symbol_info::display_line): Increase width of attribute string by
one. Check m_is_sparse variable and display 's' if variable is sparse.
* syminfo.cc (symbol_info_list::parse_whos_line_format): Increase column width
for attribute field by one from 5 to 6.
* syminfo.h (symbol_info): Initialize member variable "m_is_sparse" by calling
octave_value method issparse(). Add method "is_sparse" which returns member
variable "m_is_sparse". Define boolean member variable "m_is_sparse".
* pt-eval.cc (Fwhos_line_format): Update documentation to discuss 's' = sparse
attribute and for new value of whos_line_format.
* pt-eval.h (tree_evaluator): Change initialization of member variable
"m_whos_line_format" to make attribute field left-justified and of width 6.
* NEWS: Add description of new attribute.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 06 Jul 2021 11:12:20 -0700 |
parents | 1e0530d86229 |
children | 0b01806bb663 |
files | NEWS libinterp/corefcn/syminfo.cc libinterp/corefcn/syminfo.h libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h |
diffstat | 5 files changed, 24 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue Jul 06 09:41:03 2021 -0700 +++ b/NEWS Tue Jul 06 11:12:20 2021 -0700 @@ -76,8 +76,8 @@ same number of digits for each value such as `[0x00_00_01; 0x00_01_00; 0x01_00_00]`. -- For Octave on Windows OS, the minimum required version of the Windows -API is now 6.1 (Windows 7 or newer). +- The `whos` function now displays an additional attribute 's' when +the variable is a sparse type. - As part of GSoC 2020, Abdallah K. Elshamy implemented the `jsondecode` and `jsonencode` functions to read and write JSON data. @@ -87,6 +87,9 @@ files (e.g., ${XDG_DATA_HOME} or, if that is not set, ~/.local/share on Unix-like operating systems or %APPDATA% on Windows). +- For Octave on Windows OS, the minimum required version of the Windows +API is now 6.1 (Windows 7 or newer). + - The non-re-entrant version of the QHull library "libqhull" was deprecated upstream. Octave now requires the re-entrant version of that library "libqhull_r" instead.
--- a/libinterp/corefcn/syminfo.cc Tue Jul 06 09:41:03 2021 -0700 +++ b/libinterp/corefcn/syminfo.cc Tue Jul 06 11:12:20 2021 -0700 @@ -109,13 +109,14 @@ { case 'a': { - char tmp[5]; + char tmp[6]; tmp[0] = (m_is_complex ? 'c' : ' '); - tmp[1] = (m_is_formal ? 'f' : ' '); - tmp[2] = (m_is_global ? 'g' : ' '); - tmp[3] = (m_is_persistent ? 'p' : ' '); - tmp[4] = 0; + tmp[1] = (m_is_sparse ? 's' : ' '); + tmp[2] = (m_is_formal ? 'f' : ' '); + tmp[3] = (m_is_global ? 'g' : ' '); + tmp[4] = (m_is_persistent ? 'p' : ' '); + tmp[5] = 0; os << tmp; } @@ -393,8 +394,8 @@ for (std::size_t i = 0; i < param_string.length (); i++) param_length(i) = param_names(i).length (); - // The attribute column needs size 5. - param_length(pos_a) = 5; + // The attribute column needs size 6. + param_length(pos_a) = 6; // Calculating necessary spacing for name column, // bytes column, elements column and class column
--- a/libinterp/corefcn/syminfo.h Tue Jul 06 09:41:03 2021 -0700 +++ b/libinterp/corefcn/syminfo.h Tue Jul 06 11:12:20 2021 -0700 @@ -59,8 +59,8 @@ symbol_info (const std::string& name, const octave_value& value, bool is_formal, bool is_global, bool is_persistent) : m_name (name), m_value (value), m_is_complex (value.iscomplex ()), - m_is_formal (is_formal), m_is_global (is_global), - m_is_persistent (is_persistent) + m_is_sparse (value.issparse ()), m_is_formal (is_formal), + m_is_global (is_global), m_is_persistent (is_persistent) { } std::string name (void) const { return m_name; } @@ -69,6 +69,8 @@ bool is_complex (void) const { return m_is_complex; } + bool is_sparse (void) const { return m_is_sparse; } + bool is_formal (void) const { return m_is_formal; } bool is_global (void) const { return m_is_global; } @@ -82,6 +84,7 @@ std::string m_name; octave_value m_value; bool m_is_complex; + bool m_is_sparse; bool m_is_formal; bool m_is_global; bool m_is_persistent;
--- a/libinterp/parse-tree/pt-eval.cc Tue Jul 06 09:41:03 2021 -0700 +++ b/libinterp/parse-tree/pt-eval.cc Tue Jul 06 11:12:20 2021 -0700 @@ -5173,7 +5173,8 @@ @table @code @item %a -Prints attributes of variables (g=global, p=persistent, f=formal parameter). +Prints attributes of variables (c=complex, s=sparse, f=formal parameter, +g=global, p=persistent). @item %b Prints number of bytes occupied by variables. @@ -5220,7 +5221,9 @@ The default format is: -@qcode{" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;@backslashchar{}n"} +@example +" %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;@backslashchar{}n" +@end example When called from inside a function with the @qcode{"local"} option, the variable is changed locally for the function and any subroutines it calls.
--- a/libinterp/parse-tree/pt-eval.h Tue Jul 06 09:41:03 2021 -0700 +++ b/libinterp/parse-tree/pt-eval.h Tue Jul 06 11:12:20 2021 -0700 @@ -133,7 +133,7 @@ m_call_stack (*this), m_profiler (), m_debug_frame (0), m_debug_mode (false), m_quiet_breakpoint_flag (false), m_debugger_stack (), m_exit_status (0), m_max_recursion_depth (256), - m_whos_line_format (" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"), + m_whos_line_format (" %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"), m_silent_functions (false), m_string_fill_char (' '), m_PS4 ("+ "), m_dbstep_flag (0), m_break_on_next_stmt (false), m_echo (ECHO_OFF), m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1),