bugGNU Octave - Bugs: bug #37551, strcmp produces weird result

 
 

bug #37551: strcmp produces weird result

Submitter:  None
Submitted:  Thu 11 Oct 2012 09:57:35 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Works For Me Assigned to:  None
Originator Name:  CFB Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.1
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 12 Oct 2012 05:47:03 PM UTC, comment #3: 

I cannot reproduce either in 3.6.3, so I'm closing this bug.

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Fri 12 Oct 2012 05:46:16 PM UTC, comment #2: 

I reproduce below what the original reporter sent to me via email:

Example1

actual code:

strcmp('a','a')

expected value: ans=1
returned value: ans=0

strcmpi('a','a') produces the expected value: ans=1

Example2

actual code:
choice='l';
strcmp(choice,{'l' 's' 'z' 'b' 'p' 'i'})

expected value: ans=1 0 0 0 0 0
returned value: error: cell type invalid as index source

strcmp(choice,{'l' 's' 'z' 'b' 'p' 'i'}) produces the expected value: ans=1 0 0 0 0 0

Cheers,

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Thu 11 Oct 2012 10:11:59 PM UTC, comment #1: 

I cannot reproduce the first problem. I do not know what is the alleged second problem, because I don't know what the result is and I don't know what the expected result is. The last result is as expected.

Please post an actual working test case (something I can just paste into Octave) that demonstrates the unexpected behaviour and state what behaviour you expected instead.

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Thu 11 Oct 2012 09:57:35 PM UTC, original submission:  

Strcmp(choice,mainvalid) [where choice='l' and mainvalid={'l' 's' etc}] gives error: cell type invalid as index source.
Trying strcmp('a','a') gives ans=0.

strcmpi(choice,mainvalid) gives the expected vector
strcmpi('a','a') gives ans=1

Am I not understanding strcmp correctly?
-CFB

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-10-12 jordigh StatusNeed Info Works For Me
        Open/ClosedOpen Closed
    2012-10-11 jordigh StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code