From owner-freebsd-questions Wed Mar 28 11:18:38 2001 Delivered-To: freebsd-questions@freebsd.org Received: from serenity.mcc.ac.uk (serenity.mcc.ac.uk [130.88.200.93]) by hub.freebsd.org (Postfix) with ESMTP id 7198037B726 for ; Wed, 28 Mar 2001 11:18:33 -0800 (PST) (envelope-from jcm@freebsd-uk.eu.org) Received: from dogma.freebsd-uk.eu.org ([130.88.200.97] ident=root) by serenity.mcc.ac.uk with esmtp (Exim 2.05 #4) id 14iLSi-0005kk-00 for freebsd-questions@freebsd.org; Wed, 28 Mar 2001 20:18:32 +0100 Received: (from jcm@localhost) by dogma.freebsd-uk.eu.org (8.11.1/8.11.1) id f2SJIVn76604 for freebsd-questions@freebsd.org; Wed, 28 Mar 2001 20:18:31 +0100 (BST) (envelope-from jcm) Date: Wed, 28 Mar 2001 20:18:31 +0100 From: j mckitrick To: freebsd-questions@freebsd.org Subject: multiple C assignments in one statement Message-ID: <20010328201830.A76580@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" X-Mailer: Mutt 1.0.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --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