Mmm. It took me a while to get that one, even with the hint! Still, more of a bug than a WTF I reckon. And yes, I do live in Great Britain.
Giles
@Giles
Best posts made by Giles
Latest posts made by Giles
-
RE: Spot the WTF
-
RE: Switch me harder
GeneWitch/tster: There's no bug. Putting aside efficiency concerns (I suspect DaveK is right here) and the fact the code looks a bit odd, it does do what it's supposed to.
How come?
The switch/case construct in C works like a bunch of conditional goto's. The original code (ignoring the case where clip is neither 0 nor 1) is equivalent to the following:
if (asys->clip_oversamples == 0) {
goto case0;
}
if (temp > 255) {
*buf++ = 255;
} else if (temp < 0) {
*buf++ = 0;
} else {
case0:
*buf++ = temp;
}So in the case that asys->clip_oversamples == 1, the entire if statement is run normally, *buf will be set to one of {255, 0, temp} and then buf will be incremented.
In the case that asys->clip_oversamples == 0, we jump into the final else clause, set *buf to temp, increment it, and are done.
In other words, the fall-through is deliberate.
-
RE: Visual Studio wtf
I've noticed that happen in Visual Studio 2003 too... the mind boggles as to why it might be doing that. I don't think it has anything to do with localisation or changing font settings.
I'll keep my eyes peeled to see if I can catch it doing it again.