Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!ddl From: ddl@husc6.UUCP (Dan Lanciani) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: MS-DOS NRO (an 'NROFF'- 'RNO'-like Source in C) Message-ID: <2065@husc6.UUCP> Date: Sat, 23-May-87 19:44:30 EDT Article-I.D.: husc6.2065 Posted: Sat May 23 19:44:30 1987 Date-Received: Sun, 24-May-87 01:32:35 EDT References: <405@ritcv.UUCP> <725@thumper.UUCP> <345@polyslo.UUCP> Distribution: na Organization: Harvard University Computer Services Lines: 24 Keywords: NRO Xref: mnetor comp.lang.c:2230 comp.sys.ibm.pc:4320 In article <345@polyslo.UUCP>, mpatnode@polyslo.UUCP (Mike Patnode) writes: > But... there is one more small problem for all you MSC an BSD > 4.2 users. Look for two occurances of the following. > toupper(p++) > This is a BIG NO-NO since toupper is actually a macro which > evaluates it's arguments 3 times!!!!! In both cases simply add > another line with just p++; Not quite. This is a no-no, but for a different reason. The macros toupper and tolower do not evaluate their arguments more than once. (At least on BSD and MSC 4.0 and other "compatible" systems.) In order to avoid multiple eveluation, these macros do NOT check that their arguments are suitable. Therefore, toupper('A') will return garbage. The correct way to use toupper is something like: if(islower(x)) x = toupper(x); Note that Turbo C, some versions of Lattice, and whatever was originally used to compile NRO define toupper and tolower as functions which do the "right thing" while still eveluating only once (obviously). Dan Lanciani ddl@harvard.*