Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Mar 2001 20:18:31 +0100
From:      j mckitrick <jcm@FreeBSD-uk.eu.org>
To:        freebsd-questions@freebsd.org
Subject:   multiple C assignments in one statement
Message-ID:  <20010328201830.A76580@dogma.freebsd-uk.eu.org>

next in thread | raw e-mail | index | archive | help

--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii


In the source code for the shortest DVD decoder to date, I saw statements
with multiple assignments (not declarations) all separated by commas.  Does
this have any advantage, other than allowing a bunch of assignments to be
grouped in one statement without the need for braces?

jm
-- 
---------------------------------------------------------------
Jonathon McKitrick -- jcm@freebsd-uk.eu.org           
"It took the computing power of three C-64s to fly to the Moon.
It takes a 486 to run Windows 95. Something is wrong here."
---------------------------------------------------------------

--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="efdtt.c"

#define K(i) (x[i] ^ s[i + 84]) <<

unsigned char x[5], y, z, s[2048];

main(n)
{
	for(read(0, x, 5); read(0, s, n = 2048); write(1, s, n))
	if(s[y=s[13] % 8 + 20] / 16 % 4 == 1)
	{
		int i = K(1)17 ^ 256 + K(0)8,
		k = K(2)0,
		j = K(4)17 ^ K(3)9 ^ k * 2 -k % 8 ^ 8,
		a = 0,
		b = 0,
		c = 26;
		for(s[y] -= 16; --c; i /= 2,j /= 2)
			a = a * 2 ^ i & 1, 
			b = b * 2 ^ j & 1;
		for(j = 127; ++j < n; c = z + c > y)
			a ^= a >> 14,
			a = a >> 8 ^ (y = a ^ a * 8 ^ a << 6) <<9,
			b = b >> 8 ^ (z = b ^ b / 8 ^ b >> 4 ^ b >> 12) <<17,
			i = s[j],
			i = "7Wo~'G_\216"[i&7]+2^"cr3sfw6v;
				i*k+>/n."[i>>4]*2^i*257/8,
			s[j] = i ^ (i & i * 2 &34) * 6 ^ z + c + ~y;
	}
}

--Nq2Wo0NMKNjxTN9z--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010328201830.A76580>