strncmp: bug comparing two character arrays

Ben Abbott bpabbott at mac.com
Thu Jan 1 07:41:58 CST 2009


On Jan 1, 2009, at 7:29 AM, Thorsten Meyer wrote:

> Hi,
>
> while patching the bug just reported I found another one in octave  
> mercurial:
>
> octave:56> strncmp(["ab";"cd"], ["ab";"ce"], 2)
> ans =  1
> octave:57> strncmp(["ab";"cd"], ["ab";"ce"], 3)
> ans =  1
> octave:58> strncmp(["ab";"cd"], ["ab";"ce"], 4)
> ans = 0
>

This appears to be compatible behavior.

 >> strncmp(['ab';'cd'], ['ab';'ce'], 2)

ans =     1

 >> strncmp(['ab';'cd'], ['ab';'ce'], 3)

ans =     1

 >> strncmp(['ab';'cd'], ['ab';'ce'], 4)

ans =     0

Ben


More information about the Bug-octave mailing list