Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!lll-lcc!lll-crg!seismo!brl-adm!brl-smoke!smoke!cuuxb!rsb@LLL-CRG.ARPA From: rsb@LLL-CRG.ARPA Newsgroups: net.lang.c Subject: Re: Jumping into blocks Message-ID: <346@brl-smoke.ARPA> Date: Mon, 28-Apr-86 09:42:48 EDT Article-I.D.: brl-smok.346 Posted: Mon Apr 28 09:42:48 1986 Date-Received: Fri, 2-May-86 22:45:00 EDT Sender: news@brl-smoke.ARPA Lines: 28 >>So, assuming that goatooze are acceptable for error handling, but jumping >>into a block is forbidden, what's the best way to write this? Use two >>braches, and hide the common code at the bottom of main()? Set an error >>flag and test it outside the while? (Ugh, that requires an artificial >>boolean *and* a break statement.) Make usage() a non-returning function >>instead of a label? (My usual preference.) Duplicate the code? I've seen two variations that *I* prefer: 1) If you're in a condition that calls for bailing out, use a function that prints an error message (to the appropriate place) and call exit(). This is what I tend to use for usage/fatal error kinds of situations. 2) In some (kernel) routines, one may have several "error" conditions that have a common set of "cleanup procedures" (like setting an error code or some such thing) before returning. In this case, several "gohtoose" that wind up at the bottom of the routine seem the neatest (well, least sloppy) way of doing it. I've used the other variations that you mentioned, but wouldn't in anything that anyone else would have to see/support. Rich Brown Downers Grove, IL P.S. I take that back. I've never jumped into a block like that. I think I would put that under the heading of "tacky".