On Sat, Feb 14, 2009 at 03:16:56AM +0000, corvid wrote:
Jo?o wrote:
Sex, 2009-02-13 ?s 00:41 +0000, corvid escreveu:
Jo?o wrote:
Qui, 2009-02-12 ?s 23:43 +0000, corvid escreveu:
Jo?o wrote:
I've been trying to understand what's going on in CharIterator::prev() and have been running tests and I have a question regarding iterator.hh.
In the following code:
inline static bool charsEqual (char c1, char c2, bool caseSens) { return caseSens ? c1 == c2 : tolower (c1) == tolower (c2) || (isspace (c1) && isspace (c2)); }
Why are we checking if c1 and c2 are spaces? This is the code that, according to my tests, is wrecking the search-previous functionality.
We do want to regard whitespace chars as equivalent, don't we?
hm..Well, but doesn't c1 == c2 do the job? The tolower() call wouldn't 'change' the whitespace, as far as I know. Or do we want to consider ' ' a tab too (for example)? Maybe I missed the point. :S
I think we want to treat something like tab and space as the same.
Oh and one more thing. If our purpose is to treat all whitespace equaly (tabs=Spaces...), why do we _only_ do that when not doing a case-sensitive comparison?
A way to verify that (isspace (c1) && isspace (c2)) is causing the fail is to search for ' ' backwards with case-sens* on --- it finds it.
I don't really know that code in any detail whatsoever. I think Johannes implemented it.
Yes, I had added the (isspace (c1) && isspace (c2)) part to treat all whitespace equally. I didn't touch the caseSens==true case, because I wasn't sure whether we want to retain the possibility to search for e.g. \t or \n in plain text or not. Cheers, Johannes