Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxl.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!whuxl!mike From: mike@whuxl.UUCP (BALDWIN) Newsgroups: net.lang.c Subject: Re: Re: "handy.h" Message-ID: <702@whuxl.UUCP> Date: Mon, 9-Sep-85 16:48:27 EDT Article-I.D.: whuxl.702 Posted: Mon Sep 9 16:48:27 1985 Date-Received: Tue, 10-Sep-85 04:52:11 EDT References: <10200006@ada-uts.UUCP> <532@linus.UUCP> <699@whuxl.UUCP> <782@lsuc.UUCP> Organization: AT&T Bell Laboratories, Whippany Lines: 36 > > #define NELEM(arr) (sizeof (arr) / sizeof *(arr)) > > #define LAST(arr) ((arr) + NELEM(arr)) > > #define COPY(a,b) strncpy(a,b,sizeof a) > > These are dangerous. LAST is misnamed, because it points to the > space after the last element. If used, it should be called > something like AFTERLAST. Yeh, you're right. LAST is too generic sounding. Reminds me of curses(3C), with move() and erase(), which conflict with routines of the same name in plot(3X)! But I still say the functions they perform are easier to read (with suitable names) than the corresponding x+y/z... > And with COPY, there is a temptation to call it with arguments of the > wrong type. Can't you just see somebody writing > > fun(s) > char s[]; > { > char temp[PLENTY_BIG]; > ... > COPY (s, temp); /* WRONG */ > } I don't know what to call this one. But I still think it's useful. It's not a general-purpose string copy macro; it's just useful when you want to copy a string to a safe place without scrogging the safe place. Hmm, maybe STRBUFSAVE? Oh hell, mebbe I'll just use strncpy! > Mark Brader Hey! *My* initials are MSB! Wild. -- Michael Scott Baldwin AT&T Bell Labs {at&t}!whuxl!mike