octave-maintainers
[Top][All Lists]
Advanced

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

String display


From: Rik
Subject: String display
Date: Wed, 23 Oct 2019 14:47:27 -0700

jwe,

It's trivial to get 90% of the way there, but the last 10% is going to be a
PITA.  See the attached diff.

The trouble is that disp() does not print surrounding characters around
strings, and disp() is used by all the print routines in the octave-value
directory.  This is required because disp() might be overloaded by a
user-defined class.  Here's a backtrace showing that display() is called to
print the name tag, which then calls disp(), which then calls the print
routines which are overloaded for a particular octave_value type

#0  octave_print_internal (os=..., chm=..., pr_as_read_syntax=false,
pr_as_string=true)
    at libinterp/corefcn/pr-output.cc:2628
#1  0x00007f097b2a9976 in octave_print_internal (os=..., nda=...,
pr_as_read_syntax=false,
    extra_indent=0, pr_as_string=true) at libinterp/corefcn/pr-output.cc:2678
#2  0x00007f097ad15ef3 in octave_char_matrix_str::print_raw
(this=0x7f0944456fc0, os=...,
    pr_as_read_syntax=false) at libinterp/octave-value/ov-str-mat.cc:260
#3  0x00007f097ac6f3fc in octave_base_matrix<charNDArray>::print
(this=0x7f0944456fc0, os=...,
    pr_as_read_syntax=false) at libinterp/octave-value/ov-base-mat.cc:454
#4  0x00007f097acf7000 in octave_value::print (this=0x7f0951317500, os=...,
pr_as_read_syntax=false)
    at ./libinterp/octave-value/ov.h:1233
#5  0x00007f097b2ae343 in Fdisp (args=..., nargout=0) at
libinterp/corefcn/pr-output.cc:3350
#6  0x00007f097ac5bde5 in octave_builtin::call (this=0x7f094409a960,
tw=..., nargout=0, args=...)
    at libinterp/octave-value/ov-builtin.cc:62
#7  0x00007f097b1a7616 in octave::interpreter::feval (this=0x7f0944004a60,
name="disp", args=...,
    nargout=0) at libinterp/corefcn/interpreter.cc:1402
#8  0x00007f097b1a74a5 in octave::interpreter::feval (this=0x7f0944004a60,
    name=0x7f097b3b90c5 "disp", args=..., nargout=0) at
libinterp/corefcn/interpreter.cc:1388
#9  0x00007f097ade7402 in octave::feval (name=0x7f097b3b90c5 "disp",
args=..., nargout=0)
    at libinterp/parse-tree/oct-parse.yy:4950
#10 0x00007f097b2ae884 in Fdisplay (args=...) at
libinterp/corefcn/pr-output.cc:3517
#11 0x00007f097ac5bde5 in octave_builtin::call (this=0x7f094409afa0,
tw=..., nargout=0, args=...)
    at libinterp/octave-value/ov-builtin.cc:62
#12 0x00007f097b1a7616 in octave::interpreter::feval (this=0x7f0944004a60,
name="display",
    args=..., nargout=0) at libinterp/corefcn/interpreter.cc:1402
#13 0x00007f097b1a74a5 in octave::interpreter::feval (this=0x7f0944004a60,
    name=0x7f097b3953d0 "display", args=..., nargout=0) at
libinterp/corefcn/interpreter.cc:1388
#14 0x00007f097ade7402 in octave::feval (name=0x7f097b3953d0 "display",
args=..., nargout=0)
    at libinterp/parse-tree/oct-parse.yy:4950

The simplest solution would be to have some knowledge of whether this
particular call to print was being done on behalf of the interpreter or
not.  Then the code within the overload of octave_print_internal for
charMatrix becomes

if (for_interpreter)
  os << '\'' << row << '\'';
else
  os << row;

But I don't have a good idea of how to pass that information down.

--Rik

Attachment: 56973.diff
Description: Text Data


reply via email to

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