Xref: utzoo comp.unix.questions:15908 comp.lang.c:21136 Path: utzoo!attcan!uunet!wuarchive!brutus.cs.uiuc.edu!tut.cis.ohio-state.edu!att!chinet!john From: john@chinet.chi.il.us (John Mundt) Newsgroups: comp.unix.questions,comp.lang.c Subject: Re: moving upper case names to lower case Message-ID: <9346@chinet.chi.il.us> Date: 24 Aug 89 16:58:40 GMT References: <20672@adm.BRL.MIL> <9326@chinet.chi.il.us> <2336@oakhill.UUCP> Reply-To: john@chinet.chi.il.us (John Mundt) Followup-To: comp.unix.questions Organization: Chinet - Public Access Unix Lines: 29 In article <2336@oakhill.UUCP> stevenw@oakhill.UUCP (Steven Weintraub) writes: >> while ((c = getchar()) != EOF) >> putchar(tolower(c)); >I should point out there is a risk in using tolower like this. Some >machines define tolower as ((c)-'A'+'a') (like some sun systems). >This works well if the character is an upper case letter but it will >translate 'FOO.c' to 'fooN^C'. Are you sure that tolower() and _tolower() aren't being confused? The latter is a macro that just takes a value and |= 040 to it to make it lower case, since it requires that an upper case letter be sent to it. tolower(), on the other hand, is a function that firsts checks to see if the value sent to it is uppercase, and only then does it do anything. Quoting from the man page, "..tolower has as a domain the rainge of getc(3S): the integers from -1 to 255. If the argument of tolower represents an upper-case letter, the result is the corresponding lower-case letter. All other arguments in the domain are returned unchanged." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- --------------------- John Mundt Teachers' Aide, Inc. P.O. Box 1666 Highland Park, IL john@chinet.chi.il.us (312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem