Let me settle this. Here is my code in its totality...
/***************************************************************************
****
* MyStrToUpper
***************************************************************************
***/
static void MyStrToUpper(CharPtr string)
{
CharPtr s;
s = string;
while (*s)
{
if ( (*s >= 97) && (*s <= 122) )
*s-=32;
s++;
}
}
Regardless of my implementation, if there isn't a StrToUpper in the API,
why not? Why provide a StrToLower w/ no equivalent StrToUpper?
If my code above is worthy enough to be implemented within the API, then by
all means.
Thanks.
Lenny.
----------
> From: Chris Antos <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: StrToUpper() ?
> Date: Wednesday, March 24, 1999 7:10 PM
>
> i think Lenny probably meant he was checking first.
> but while we're on it, your code isn't much better because you're not
> checking if the character is a letter. maybe both you and Lenny are
> assuming a check first to make sure the character is appropriate to
modify;
> in which case it actually generates more code with less efficient
execution
> to do the masking on letters that are already uppercase as you suggest.
as
> long as Lenny checks to make sure he's only modifying lowercase
characters,
> his code is better.
>
>
> -----Original Message-----
> From: Kerry W. Podolsky <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Cc: Lenny Palozzi <[EMAIL PROTECTED]>
> Date: Wednesday, March 24, 1999 5:53 AM
> Subject: Re: StrToUpper() ?
>
>
> >The code you posted is Extremely bad.
> >
> >You are blindly subtracting 32 from every character.
> >What if the character is ALREADY upper case.
> >
> >i.e. Letter 'A' = 0x41 (65) - 0x20(32) = 0x21(33) or '!'
> >
> >What you want to do is "mask" the bit off.
> >
> >i.e. *c &= 0xdf
> >
> >this way if 'a'(0x61) ANDed with 0x20 = 'A'(0x41)
> >
> >Kerry
> >
> >
> >At 11:25 PM 3/23/99 -0500, Lenny wrote:
> >>Is there not a StrToUpper API function? I could only find a
StrToLower().
> >>
> >>I rolled my own, running through each character doing a "*c -= 32;" for
> the
> >>time being.
>
>