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

[Pkg-octave-devel] Bug#603046: Bug#603046: octave3.2: strchr triggers Octave:str-to-num



Hi Kim, 

On Wed, Nov 10, 2010 at 05:38:50PM +0100, Kim Hansen wrote:
> Package: octave3.2
> Version: 3.2.4-8
> Severity: normal
> Tags: patch
> 
> 
> strchr treats a string as a number implicitly:
> 
> kim@raph:~/orion/svn/raph1/octave$ octave
> GNU Octave, version 3.2.4
> ....
> octave:1> warning error Octave:str-to-num
> octave:2> strchr("Octave is the best software","best")
> error: implicit conversion from string to real N-d array
> error: type conversion failed for binary operator `+'
> error: evaluating argument list element number 1
> error: invalid empty index list
> error: called from:
> error:   /usr/share/octave/3.2.4/m/strings/strchr.m at line 37, column 16
> octave:2> 
> 
> 
> I think it can be fixed by changing the the strchr function to:
> 
> function varargout = strchr (str, chars, varargin)
>   if (nargin < 2 || ! ischar (str) || ! ischar (chars))
>     print_usage ();
>   endif
>   f = false (1, 256);
>   f(uint8(chars) + 1) = true;
>   varargout = cell (1, nargout);
>   varargout{1} = [];
>   [varargout{:}] = find (reshape (f(uint8(str) + 1), size (str)), varargin{:});
> endfunction
> 
> 
> I found this bug by doing this:
>   warning error Octave:str-to-num
>   oldpath = path;
>   path(oldpath);
> If the octave-octcdf package is installed this will fail.

Okay, this might be a bug. But does octcdf set this warning to an error?

	Thoma





Reply to: