U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » IsUpper bug?
IsUpper bug? [message #9543] Wed, 16 May 2007 09:00 Go to next message
unodgs is currently offline  unodgs
Messages: 1367
Registered: November 2005
Location: Poland
Ultimate Contributor

I discovered that IsUpper for '_' return false. Because of that my function:
bool IsUpperString(const char *q)
{
	while(*q)
		if(!IsUpper(*q++))
		   return false;
	return true;
}

did not work well for strings like NUMBER_10_AND_20 and I had to modify it to:
bool IsUpperString(const char *q)
{
	while(*q)
	{
		if(*q != '_' && !IsUpper(*q))
		   return false;
		q++;
	}
	return true;
}

Re: IsUpper bug? [message #9549 is a reply to message #9543] Wed, 16 May 2007 11:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
unodgs wrote on Wed, 16 May 2007 03:00

I discovered that IsUpper for '_' return false. Because of that my function:
bool IsUpperString(const char *q)
{
	while(*q)
		if(!IsUpper(*q++))
		   return false;
	return true;
}

did not work well for strings like NUMBER_10_AND_20 and I had to modify it to:
bool IsUpperString(const char *q)
{
	while(*q)
	{
		if(*q != '_' && !IsUpper(*q))
		   return false;
		q++;
	}
	return true;
}




Of what letter is '_' uppercase variant?

I think the check should look like this

if(IsLetter(*q) && IsUpper(*q))


Mirek
Re: IsUpper bug? [message #9550 is a reply to message #9549] Wed, 16 May 2007 12:30 Go to previous message
unodgs is currently offline  unodgs
Messages: 1367
Registered: November 2005
Location: Poland
Ultimate Contributor

I just thought that it would be better if IsUpper returned true for non-letter chars. That could simplify algorithms like this one for IsUpperString. On the other hand it is true that underscore or numebers have not upper case variants so IsUpper returns false in such case. Ok let's leave it as it is.
Previous Topic: Compile error "thread-local storage not supported ..."
Next Topic: Adding subclass objects to base class array using AppendPick()
Goto Forum:
  


Current Time: Fri Sep 11 22:25:36 GMT+2 2026

Total time taken to generate the page: 0.00573 seconds