moving upper case names to lower case
John Mundt
john at chinet.chi.il.us
Fri Aug 25 02:58:40 AEST 1989
In article <2336 at oakhill.UUCP> stevenw at 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 at chinet.chi.il.us
(312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem
More information about the Comp.unix.questions
mailing list