# Patch created by kt
# Date: So Nov 21 10:29:53 CET 2004
# Repository: pnet
# Comments:
# 
# 2004-11-21  Klaus Treichel  <ktreichel@web.de>
# 
# 	* include/il_utils.h, engine/lib_string.c, support/unicode.c: Fix case
# 	insensitive string comparision (upper case char > lower case char).
#### End of Preamble ####

#### Patch data follows ####
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3126
diff -c -r1.3126 ChangeLog
*** ChangeLog	2 Nov 2004 09:48:54 -0000	1.3126
--- ChangeLog	21 Nov 2004 10:01:35 -0000
***************
*** 1,4 ****
--- 1,9 ----
  
+ 2004-11-21  Klaus Treichel  <ktreichel@web.de>
+ 
+ 	* include/il_utils.h, engine/lib_string.c, support/unicode.c: Fix case
+ 	insensitive string comparision (upper case char > lower case char).
+ 
  2004-11-02  Gopal V  <gopalv82@yahoo.com>
  
  	* cscc/common/cc_compat.c: Allow /debug:full and /debug:pdbonly flags
Index: include/il_utils.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_utils.h,v
retrieving revision 1.26
diff -c -r1.26 il_utils.h
*** include/il_utils.h	14 Jun 2004 11:51:49 -0000	1.26
--- include/il_utils.h	21 Nov 2004 10:01:51 -0000
***************
*** 325,333 ****
  /*
   * Compare two unicode strings, while ignoring case.
   */
! int ILUnicodeStringCompare(const unsigned short *str1,
! 						   const unsigned short *str2,
! 						   unsigned long len);
  
  /*
   * Option descriptors for command-line parsing support.
--- 325,340 ----
  /*
   * Compare two unicode strings, while ignoring case.
   */
! int ILUnicodeStringCompareIgnoreCase(const unsigned short *str1,
! 									 const unsigned short *str2,
! 									 unsigned long len);
! 
! /*
!  * Compare two unicode strings, while not ignoring case.
!  */
! int ILUnicodeStringCompareNoIgnoreCase(const unsigned short *str1,
! 									   const unsigned short *str2,
! 									   unsigned long len);
  
  /*
   * Option descriptors for command-line parsing support.
Index: engine/lib_string.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_string.c,v
retrieving revision 1.35
diff -c -r1.35 lib_string.c
*** engine/lib_string.c	29 Aug 2003 04:58:47 -0000	1.35
--- engine/lib_string.c	21 Nov 2004 10:02:07 -0000
***************
*** 449,492 ****
  	}
  
  	/* Compare the two strings */
! 	if(ignoreCase)
  	{
! 		if(lengthA >= lengthB)
  		{
! 			cmp = ILUnicodeStringCompare
  					(StringToBuffer(strA) + indexA,
  					 StringToBuffer(strB) + indexB,
  					 (unsigned long)(long)lengthB);
- 			if(cmp != 0)
- 			{
- 				return cmp;
- 			}
- 			if(lengthA > lengthB)
- 			{
- 				return 1;
- 			}
- 			else
- 			{
- 				return 0;
- 			}
  		}
  		else
  		{
! 			cmp = ILUnicodeStringCompare
  					(StringToBuffer(strA) + indexA,
  					 StringToBuffer(strB) + indexB,
! 					 (unsigned long)(long)lengthA);
! 			if(cmp != 0)
! 			{
! 				return cmp;
! 			}
! 			return -1;
  		}
  	}
  	else
  	{
! 		return ILStrCmpUnicode(StringToBuffer(strA) + indexA, lengthA,
! 							   StringToBuffer(strB) + indexB, lengthB);
  	}
  }
  
--- 449,504 ----
  	}
  
  	/* Compare the two strings */
! 	if(lengthA >= lengthB)
  	{
! 		if(ignoreCase)
  		{
! 			cmp = ILUnicodeStringCompareIgnoreCase
  					(StringToBuffer(strA) + indexA,
  					 StringToBuffer(strB) + indexB,
  					 (unsigned long)(long)lengthB);
  		}
  		else
  		{
! 			cmp = ILUnicodeStringCompareNoIgnoreCase
  					(StringToBuffer(strA) + indexA,
  					 StringToBuffer(strB) + indexB,
! 					 (unsigned long)(long)lengthB);
! 		}
! 		if(cmp != 0)
! 		{
! 			return cmp;
! 		}
! 		if(lengthA > lengthB)
! 		{
! 			return 1;
! 		}
! 		else
! 		{
! 			return 0;
  		}
  	}
  	else
  	{
! 		if(ignoreCase)
! 		{
! 			cmp = ILUnicodeStringCompareIgnoreCase
! 					(StringToBuffer(strA) + indexA,
! 					 StringToBuffer(strB) + indexB,
! 					 (unsigned long)(long)lengthA);
! 		}
! 		else
! 		{
! 			cmp = ILUnicodeStringCompareNoIgnoreCase
! 					(StringToBuffer(strA) + indexA,
! 					 StringToBuffer(strB) + indexB,
! 					 (unsigned long)(long)lengthA);
! 		}
! 		if(cmp != 0)
! 		{
! 			return cmp;
! 		}
! 		return -1;
  	}
  }
  
Index: support/unicode.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/unicode.c,v
retrieving revision 1.6
diff -c -r1.6 unicode.c
*** support/unicode.c	29 Aug 2003 04:58:47 -0000	1.6
--- support/unicode.c	21 Nov 2004 10:02:22 -0000
***************
*** 279,287 ****
  	}
  }
  
! int ILUnicodeStringCompare(const unsigned short *str1,
! 						   const unsigned short *str2,
! 						   unsigned long len)
  {
  	unsigned ch1;
  	unsigned ch2;
--- 279,287 ----
  	}
  }
  
! int ILUnicodeStringCompareIgnoreCase(const unsigned short *str1,
! 									 const unsigned short *str2,
! 									 unsigned long len)
  {
  	unsigned ch1;
  	unsigned ch2;
***************
*** 344,349 ****
--- 344,472 ----
  	return 0;
  }
  
+ int ILUnicodeStringCompareNoIgnoreCase(const unsigned short *str1,
+ 									   const unsigned short *str2,
+ 									   unsigned long len)
+ {
+ 	unsigned ch1;
+ 	unsigned ch2;
+ 	int uc1;
+ 	int uc2;
+ 	unsigned tc;
+ 	while(len > 0)
+ 	{
+ 		ch1 = *str1++;
+ 		uc1 = 0;
+ 		ch2 = *str2++;
+ 		uc2 = 0;
+ 		if(ch1 != ch2)
+ 		{
+ #ifdef SMALL_UNICODE_TABLE
+ 			if(ch1 < 0x0100)
+ 			{
+ 				if(ch1 != unicodeToLower[ch1])
+ 				{
+ 					ch1 = unicodeToLower[ch1];
+ 					uc1 = 1;
+ 				}
+ 			}
+ #else
+ 			if(ch1 <= UNICASE_RANGE1_UPPER)
+ 			{
+ 				unsigned tc = unicodeToLower[ch1];
+ 				if(tc != ch1)
+ 				{
+ 					ch1 = tc;
+ 					uc1 = 1;
+ 				}
+ 			}
+ 			else if(ch1 >= UNICASE_RANGE2_LOWER && ch1 <= UNICASE_RANGE2_UPPER)
+ 			{
+ 				unsigned tc = unicodeToLower
+ 					[ch1 - UNICASE_RANGE2_LOWER + UNICASE_RANGE2_OFFSET];
+ 				if(tc != ch1)
+ 				{
+ 					ch1 = tc;
+ 					uc1 = 1;
+ 				}
+ 			}
+ 			else if(ch1 >= UNICASE_RANGE3_LOWER && ch1 <= UNICASE_RANGE3_LOWER)
+ 			{
+ 				unsigned tc = unicodeToLower
+ 					[ch1 - UNICASE_RANGE3_LOWER + UNICASE_RANGE3_OFFSET];
+ 				if(tc != ch1)
+ 				{
+ 					ch1 = tc;
+ 					uc1 = 1;
+ 				}
+ 			}
+ #endif
+ #ifdef SMALL_UNICODE_TABLE
+ 			if(ch2 < 0x0100)
+ 			{
+ 				if(ch2 != unicodeToLower[ch2])
+ 				{
+ 					ch2 = unicodeToLower[ch2];
+ 					uc2 = 1;
+ 				}
+ 			}
+ #else
+ 			if(ch2 <= UNICASE_RANGE1_UPPER)
+ 			{
+ 				unsigned tc = unicodeToLower[ch2];
+ 				if(tc != ch2)
+ 				{
+ 					ch2 = tc;
+ 					uc2 = 1;
+ 				}
+ 			}
+ 			else if(ch2 >= UNICASE_RANGE2_LOWER && ch2 <= UNICASE_RANGE2_UPPER)
+ 			{
+ 				unsigned tc = unicodeToLower
+ 					[ch2 - UNICASE_RANGE2_LOWER + UNICASE_RANGE2_OFFSET];
+ 				if(tc != ch2)
+ 				{
+ 					ch2 = tc;
+ 					uc2 = 1;
+ 				}
+ 			}
+ 			else if(ch2 >= UNICASE_RANGE3_LOWER && ch2 <= UNICASE_RANGE3_LOWER)
+ 			{
+ 				unsigned tc = unicodeToLower
+ 					[ch2 - UNICASE_RANGE3_LOWER + UNICASE_RANGE3_OFFSET];
+ 				if(tc != ch2)
+ 				{
+ 					ch2 = tc;
+ 					uc2 = 1;
+ 				}
+ 			}
+ #endif
+ 			if(ch1 < ch2)
+ 			{
+ 				return -1;
+ 			}
+ 			else if(ch1 > ch2)
+ 			{
+ 				return 1;
+ 			}
+ 			else
+ 			{
+ 				if(uc1 < uc2)
+ 				{
+ 					return -1;
+ 				}
+ 				else if(uc1 > uc2)
+ 				{
+ 					return 1;
+ 				}
+ 			}
+ 		}
+ 		--len;
+ 	}
+ 	return 0;
+ }
+ 
+ 
  #ifdef	__cplusplus
  };
  #endif
#### End of Patch data ####
