Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: C Indentation Survey Results Message-ID: <5533@umcp-cs.UUCP> Date: Tue, 7-May-85 19:29:04 EDT Article-I.D.: umcp-cs.5533 Posted: Tue May 7 19:29:04 1985 Date-Received: Thu, 9-May-85 02:38:55 EDT References: <9930@brl-tgr.ARPA> <381@busch.UUCP> <5497@utzoo.UUCP> <5557@utzoo.UUCP> <1472@orca.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 59 > From: warner@orca.UUCP (Ken Warner) > Below is an actual example of real C code. It's in K&R orthodox bracing > style. > switch (key) { > case BACK: > fprintf(stoout,"BACK\n"); Why isn't this "fprintf" indented another tabstop? > if (device->s.stroke.current_editpos > 1) { > device->s.stroke.current_editpos--; > for (device->s.stroke.editptr = > &(device->s.stroke.header), > i = 1; > device->s.stroke.editptr->next->next, > i < device->s.stroke.current_editpos; > device->s.stroke.editptr = > device->s.stroke.editptr->next, > i++ ) { > ; > } > } else { I don't quite understand. Is the reference to device->s.stroke.editptr->next->next in the test part of the for loop supposed to cause a memory fault if there is no next? The value is tossed because of the comma operator. This code would probably be more readable and faster if you had back pointers. Even without them, how about using register struct /*whatever_device->s.stroke_is*/ *s; . . . switch (key) { case BACK: fprintf(stoout, "BACK\n"); s = &device->s.stroke; if (s->current_editpos > 1) { s->current_editpos--; /* s->editptr = s->editptr->prev; */ s->editptr = &s->header; for (i = 1; i < s->current_editpos; i++) s->editptr = s->editptr->next; } else { > Is it easier to read because of it? Yes. (By the way, why > 1 rather than >= 1? Can't you untype the first key? The code would appear to work for editpos==1...) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland