summaryrefslogtreecommitdiff
path: root/StdLib
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-01 00:19:51 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-01 00:19:51 +0000
commiteaa52ade0fa4ec5ccbd4b1f221719b602ea75564 (patch)
treea54db02bd2fff9f4d9f3db7d4c276c300089f3b0 /StdLib
parent52cb711dab08047f38529e087583c965058894e3 (diff)
downloadedk2-platforms-eaa52ade0fa4ec5ccbd4b1f221719b602ea75564.tar.xz
StdLib: Fix strcmp so that comparisons are case sensitive. Simplified code for strcasecmp.
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
Diffstat (limited to 'StdLib')
-rw-r--r--StdLib/LibC/String/Comparison.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/StdLib/LibC/String/Comparison.c b/StdLib/LibC/String/Comparison.c
index b4980c7c1e..9452ceeb33 100644
--- a/StdLib/LibC/String/Comparison.c
+++ b/StdLib/LibC/String/Comparison.c
@@ -40,7 +40,7 @@ int memcmp(const void *s1, const void *s2, size_t n)
**/
int strcmp(const char *s1, const char *s2)
{
- return (int)AsciiStriCmp( s1, s2);
+ return (int)AsciiStrCmp( s1, s2);
}
/** The strcoll function compares the string pointed to by s1 to the string
@@ -72,33 +72,33 @@ int strncmp(const char *s1, const char *s2, size_t n)
return (int)AsciiStrnCmp( s1, s2, n);
}
-/** The strxfrm function transforms the string pointed to by s2 and places the
- resulting string into the array pointed to by s1. The transformation is
+/** The strxfrm function transforms the string pointed to by Src and places the
+ resulting string into the array pointed to by Dest. The transformation is
such that if the strcmp function is applied to two transformed strings, it
returns a value greater than, equal to, or less than zero, corresponding to
the result of the strcoll function applied to the same two original
- strings. No more than n characters are placed into the resulting array
- pointed to by s1, including the terminating null character. If n is zero,
- s1 is permitted to be a null pointer. If copying takes place between
+ strings. No more than Len characters are placed into the resulting array
+ pointed to by Dest, including the terminating null character. If Len is zero,
+ Dest is permitted to be a null pointer. If copying takes place between
objects that overlap, the behavior is undefined.
@return The strxfrm function returns the length of the transformed string
(not including the terminating null character). If the value
- returned is n or more, the contents of the array pointed to by s1
+ returned is Len or more, the contents of the array pointed to by Dest
are indeterminate.
**/
-size_t strxfrm(char * __restrict s1, const char * __restrict s2, size_t n)
+size_t strxfrm(char * __restrict Dest, const char * __restrict Src, size_t Len)
{
size_t srclen, copysize;
/*
* Since locales are unimplemented, this is just a copy.
*/
- srclen = strlen(s2);
- if (n != 0) {
- copysize = srclen < n ? srclen : n - 1;
- (void)memcpy(s1, s2, copysize);
- s1[copysize] = 0;
+ srclen = strlen(Src);
+ if (Len != 0) {
+ copysize = srclen < Len ? srclen : Len - 1;
+ (void)memcpy(Dest, Src, copysize);
+ Dest[copysize] = 0;
}
return (srclen);
}
@@ -107,17 +107,5 @@ size_t strxfrm(char * __restrict s1, const char * __restrict s2, size_t n)
int
strcasecmp(const char *s1, const char *s2)
{
- const unsigned char *us1 = (const unsigned char *)s1,
- *us2 = (const unsigned char *)s2;
- int Difference;
-
- while ( 0 == ( Difference = tolower(*us1) - tolower(*us2))) {
- if (*us1 == 0) {
- return (0);
- }
- us1 += 1;
- us2 += 1;
- }
- return Difference;
+ return (int)AsciiStriCmp( s1, s2);
}
-