Style (was: C-DATABASE B-PLUS a quick look)

Peter da Silva peter at ficc.uu.net
Fri Dec 30 05:49:21 AEST 1988


In article <2537 at xyzzy.UUCP>, throopw at xyzzy.UUCP (Wayne A. Throop) writes:
>     #include <ctype.h>
>     char *p, *s;
>     ...
>     for( p = s; *p; ++p )
>         *p = toupper( *p );

> Nearly as I can tell, dpANS says that loop ought to have been

>     for( p = s; *p ++p )
>         if( *p >= 0 )
>             *p = toupper( *p );

Gee, I always do this:

	for(p = s; *p; p++)
		if(islower(*p))
			*p = toupper(*p);

While dpANS might have decided that toupper should bounds check, there
are too many V7-oid compilers out there that it's better to put the
bounds check in. Personally, I think that toupper should have been left
the way it was. Everything else in stdio forces you to do your own bounds
checking, so why should this be an exception?
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter at sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.



More information about the Comp.lang.c mailing list