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

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

[Octave-bug-tracker] [bug #49536] many functions that expect a "string"


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #49536] many functions that expect a "string" silently truncate char matrix arguments (octave_value::string_vector)
Date: Sat, 17 Dec 2016 20:34:25 -0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0

URL:
  <http://savannah.gnu.org/bugs/?49536>

                 Summary: many functions that expect a "string" silently
truncate char matrix arguments (octave_value::string_vector)
                 Project: GNU Octave
            Submitted by: mtmiller
            Submitted on: Fri 04 Nov 2016 05:53:07 PM PDT
                Category: Libraries
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Other
                  Status: Postponed
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

Octave has many functions that operate on a char array with the concept of a
"string", even though char arrays may be two- or higher-dimensional. Octave
currently _silently truncates_ char arrays when given to some functions that
are expecting a string. Other functions flatten the char array into a vector
(in column-major order). Some motivating examples:


>> s = ["this"; "is a"; "char"; "matrix"]
s =

this  
is a  
char  
matrix

>> sprintf (s)
ans = this  
>> sprintf ("%s", s)
ans = ticmhshai atsarr   i   x
>> error (s)
error: this  
>> help (s)
error: help: 'ticmhshai atsarr   i   x' not found
>> struct (s, 0)
ans =

  scalar structure containing the fields:

    this   = 0

>> system (s);
sh: 1: this: not found
>> strrep (s, 'a', 'b')
ans = ticmhshbi btsbrr   i   x


The guilty function is octave_value::string_value. The code is labeled with a
FIXME where it deliberately pulls out the first row of a 2-dimensional char
array, so that seems like a prime candidate for discussion and resolution.

The list of functions affected is probably very long, but maybe we can gather
together a short list and get a Matlab compatibility check as a starting
point.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49536>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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