octave-maintainers
[Top][All Lists]
Advanced

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

Re: operator< for caseless_str


From: Michael Goffioul
Subject: Re: operator< for caseless_str
Date: Sat, 14 May 2011 22:32:12 +0100

2011/5/14 Jordi Gutiérrez Hermoso <address@hidden>:
> Yes, looks like 68a59630798d broke something in stable. I just managed
> to successfully compile 2c54fde0f397. The following two lines appear
> to be what breaks in 68a59630798d:
>
>     set (0, "defaultfigurepapertype", "<custom>");
>     f = figure (1);
>
> After some printf debugging, I managed to conclude that the algorithm
> in op< implemented therein is buggy. Look:
>
>     http://codepad.org/aQsNx53a
>
> Clearly "queue" and "cancel" are not both greater than equal to each
> other lexicographically. Since this is happening, std::set concludes
> tha the two are the same so only inserts the first one of them into
> the set, which results in certain property values being taken as
> invalid, as the above error shows.
>
> Sadly, whatever state of mind David Bateman was in when he wrote this
> is the same one I'm in right now, because I can't see the bug.

I think the algorithm is not correct. It compares every characters
of t and s and returns false whenever one character of s is <
of the one in t. When comparing:
queue < cancel, this happens on the first char
cancel < queue, this happens on the third one

In proper lexicographic comparison, in the second case, the
algorithm should have stopped at the first char, as c < q.
There's no need to compare the rest.

Michael.


reply via email to

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