On 2002-05-11 18:34, Dag-Erling Smorgrav wrote: > Hiten Pandya <[EMAIL PROTECTED]> writes: > > /* > > * A comment is probably needed here for those not > > * well versed in the "C" language. Yes, this is > > * supposed to be a "switch" with the body of the > > * "switch" being a "while" statement. The whole > > * purpose of the switch is to allow us to jump into > > * the middle of the while() loop, and then not have > > * to do any more switch()s. > > * > > * Some compilers will spit out a warning message > > * about the loop not being entered at the top. > > */ > > switch (n&03) > > while (n > 0) { > > case 0: > > ck ^= (int)*d++ << 24; > > --n; > > case 3: > > ck ^= (int)*d++ << 16; > > --n; > > case 2: > > ck ^= (int)*d++ << 8; > > --n; > > case 1: > > ck ^= (int)*d++; > > --n; > > } > > return(ck); > > Hmm, does this mean Duff's Device is not valid C?
It is ugly. I'm not sure if it's non-standard too. My impression until now was that jumping from an outter block 'inside' a contained block is not a Good Thing(TM). Note that the switch cases also lack a 'break' and are falling through. All of them! This makes me wonder that happens the second time the loop runs. Does the code start the second iteration at the beginning of the while body? Or does it start at where the loop was entered the first time (the proper 'case' of the switch statement)? - Giorgos To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message