octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #58617] cell2struct silently truncates char ma


From: Rik
Subject: [Octave-bug-tracker] [bug #58617] cell2struct silently truncates char matrices
Date: Fri, 19 Jun 2020 15:49:15 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Follow-up Comment #2, bug #58617 (project octave):

Taking a look at the code in ov-struct.cc for cell2struct I see


  if (! (args(1).iscellstr () || args(1).is_char_matrix ()))
    error ("cell2struct: FIELDS must be a cell array of strings or a character
matrix");

  int dim = 0;

  if (nargin == 3)
    {
      if (! args(2).is_real_scalar ())
        error ("cell2struct: DIM must be a real scalar");

      dim = args(2).int_value () - 1;
    }

  if (dim < 0)
    error ("cell2struct: DIM must be a valid dimension");

  const Cell vals = args(0).cell_value ();
  const Array<std::string> fields = args(1).cellstr_value ();

  octave_idx_type ext = (vals.ndims () > dim ? vals.dims ()(dim) : 1);

  if (ext != fields.numel ())
    error ("cell2struct: number of FIELDS does not match dimension");


So, the problem is a little deeper.  Have to look at cellstr_value() and see
how it operates.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58617>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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