This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Fix idiocy in previous patch
On Jun 8, 2005, Nick Clifton <nickc@redhat.com> wrote:
> Ah - I remember the glorious days of programming in BBC BASIC. It had
> a wonderful switch statement where the code on the same line as the
> label would only be executed for the condition that matched the label,
> but then unless you had a break statement it would drop through as
> normal. This meant that you could have conditional initialisation to a
> generic body of code, sort of like this:
> switch (foo)
> {
> case 0: prefix="hi";
> case 1: prefix="bye";
> case 2: prefix="ciao";
> strcpy (buffer, "%s Nick", prefix);
> break;
> }
You can do that in C. Just make the cases the `then' part of if(0)s:
switch (foo)
{
case 0: prefix="hi";
if (0) { case 1: prefix="bye"; }
if (0) { case 2: prefix="ciao"; }
strcpy (buffer, "%s Nick", prefix);
break;
}
then hope nobody ever has to look at this piece of code again :-)
Yuck :-)
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}