This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix idiocy in previous patch


Alexandre Oliva dixit:

>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 :-)

evilwm does it like this.
>From event.c:

        if (c) {
                switch (key) {
                /* Sorry about all these if (0)s, but they actually
                 * *do* do something useful... */
[...]
                        break;
                case KEY_SLEFT:
                        c->width -= c->width_inc; if (0)
                case KEY_SDOWN:
                        c->height += c->height_inc; if (0)
                case KEY_SUP:
                        c->height -= c->height_inc; if (0)
                case KEY_SRIGHT:
                        c->width += c->width_inc;
                        if (c->width < 1)
                                c->width = 1;
                        if (c->height < 1)
                                c->height = 1;
                        moveresize(c);
                        break;
[...]

//mirabile
-- 
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy them.
If you don't believe in God, just consider God as Nature if you won't deny
existence.		-- Coywolf Qi Hunt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]