]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StdLib: Fix strcmp so that comparisons are case sensitive. Simplified code for strca...
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Nov 2011 00:19:51 +0000 (00:19 +0000)
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Nov 2011 00:19:51 +0000 (00:19 +0000)
Signed-off-by: darylm503
Reviewed-by: jljusten
Reviewed-by: geekboy15a
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12620 6f19259b-4bc3-4df7-8a09-765794883524

StdLib/LibC/String/Comparison.c

index b4980c7c1e880273203c169f1f5fdc1ea54cc070..9452ceeb336108d19e3f3d368922925d22bba746 100644 (file)
@@ -40,7 +40,7 @@ int       memcmp(const void *s1, const void *s2, size_t n)
 **/\r
 int       strcmp(const char *s1, const char *s2)\r
 {\r
-  return (int)AsciiStriCmp( s1, s2);\r
+  return (int)AsciiStrCmp( s1, s2);\r
 }\r
 \r
 /** The strcoll function compares the string pointed to by s1 to the string\r
@@ -72,33 +72,33 @@ int       strncmp(const char *s1, const char *s2, size_t n)
   return (int)AsciiStrnCmp( s1, s2, n);\r
 }\r
 \r
-/** The strxfrm function transforms the string pointed to by s2 and places the\r
-    resulting string into the array pointed to by s1. The transformation is\r
+/** The strxfrm function transforms the string pointed to by Src and places the\r
+    resulting string into the array pointed to by Dest. The transformation is\r
     such that if the strcmp function is applied to two transformed strings, it\r
     returns a value greater than, equal to, or less than zero, corresponding to\r
     the result of the strcoll function applied to the same two original\r
-    strings. No more than n characters are placed into the resulting array\r
-    pointed to by s1, including the terminating null character. If n is zero,\r
-    s1 is permitted to be a null pointer. If copying takes place between\r
+    strings. No more than Len characters are placed into the resulting array\r
+    pointed to by Dest, including the terminating null character. If Len is zero,\r
+    Dest is permitted to be a null pointer. If copying takes place between\r
     objects that overlap, the behavior is undefined.\r
 \r
     @return   The strxfrm function returns the length of the transformed string\r
               (not including the terminating null character). If the value\r
-              returned is n or more, the contents of the array pointed to by s1\r
+              returned is Len or more, the contents of the array pointed to by Dest\r
               are indeterminate.\r
 **/\r
-size_t    strxfrm(char * __restrict s1, const char * __restrict s2, size_t n)\r
+size_t    strxfrm(char * __restrict Dest, const char * __restrict Src, size_t Len)\r
 {\r
   size_t srclen, copysize;\r
 \r
   /*\r
   * Since locales are unimplemented, this is just a copy.\r
   */\r
-  srclen = strlen(s2);\r
-  if (n != 0) {\r
-    copysize = srclen < n ? srclen : n - 1;\r
-    (void)memcpy(s1, s2, copysize);\r
-    s1[copysize] = 0;\r
+  srclen = strlen(Src);\r
+  if (Len != 0) {\r
+    copysize = srclen < Len ? srclen : Len - 1;\r
+    (void)memcpy(Dest, Src, copysize);\r
+    Dest[copysize] = 0;\r
   }\r
   return (srclen);\r
 }\r
@@ -107,17 +107,5 @@ size_t    strxfrm(char * __restrict s1, const char * __restrict s2, size_t n)
 int\r
 strcasecmp(const char *s1, const char *s2)\r
 {\r
-  const unsigned char *us1 = (const unsigned char *)s1,\r
-  *us2 = (const unsigned char *)s2;\r
-  int Difference;\r
-\r
-  while ( 0 == ( Difference = tolower(*us1) - tolower(*us2))) {\r
-    if (*us1 == 0) {\r
-    return (0);\r
-    }\r
-    us1 += 1;\r
-    us2 += 1;\r
-  }\r
-  return Difference;\r
+  return (int)AsciiStriCmp( s1, s2);\r
 }\r
-\r