STRCAT is not compatible
Ben Abbott
bpabbott at mac.com
Thu Feb 21 13:12:04 CST 2008
On Thursday, February 21, 2008, at 01:06PM, "John W. Eaton" <jwe at bevo.che.wisc.edu> wrote:
>On 21-Feb-2008, Ben Abbott wrote:
>
>|
>| On Feb 20, 2008, at 11:30 PM, John W. Eaton wrote:
>|
>| > On 20-Feb-2008, Ben Abbott wrote:
>| >
>| > | I'll think this over. If no one else comes up with a solution, I'll
>| > | take a shot at it.
>| >
>| > OK. Another thing to look at is what hapens for trailing whitespace.
>| > For example, try
>| >
>| > strcat ('foo ', 'bar')
>| > strcat ('foo', ' ', 'bar')
>| >
>| > strcat ({'foo '}, {'bar '})
>| > strcat ({'foo'}, {' '}, {'bar'})
>| >
>| > in Matlab.
>| >
>| > Compatibility with this behavior will cause some trouble for existing
>| > Octave code.
>| >
>| > jwe
>|
>| hmmm ... It appears that the Matlab version converts string data to
>| cells of strings before doing its work.
>
>The problem I was referring to is that
>
> strcat ('foo ', 'bar')
>
>produces 'foobar', not 'foo bar'.
>
>| Where will this cause trouble?
>
>There are a number of places where Octave uses strcat with character
>strings with trailing blanks or all blanks and assumes they will be
>preserved in the output.
>
>jwe
>
ok.
Crazy question; Is there convenient method to determine where strcat() is used by Octave?
This feature can be repaired with some simple editing. For example,
octave:123> strcat({"foo "},{"bar"}){1}
ans = foo bar
The result above is from a version I coded over the last day (which is consistent with Matlab). At the moment is requires several do-loops. I'll look for ways to vectorize it.
Ben
More information about the Bug-octave
mailing list