diff --git a/Cryptlib/Include/CrtLibSupport.h b/Cryptlib/Include/CrtLibSupport.h index 42c056f..6312e5c 100644 --- a/Cryptlib/Include/CrtLibSupport.h +++ b/Cryptlib/Include/CrtLibSupport.h @@ -374,7 +374,6 @@ extern FILE *stdout; #define strncpy(strDest,strSource,count) AsciiStrnCpy(strDest,strSource,(UINTN)count) #define strcat(strDest,strSource) AsciiStrCat(strDest,strSource) #define strchr(str,ch) (char *)(ScanMem8((CHAR8 *)str,AsciiStrSize((CHAR8 *)str),ch)) -#define strcmp(string1,string2) strcmpa((CHAR8 *)string1,(CHAR8 *)string2) #define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count))) #define localtime(timer) NULL #define assert(expression) diff --git a/Cryptlib/SysCall/BaseStrings.c b/Cryptlib/SysCall/BaseStrings.c index 990037d..2267d86 100644 --- a/Cryptlib/SysCall/BaseStrings.c +++ b/Cryptlib/SysCall/BaseStrings.c @@ -93,3 +93,33 @@ AsciiStrDecimalToUintn(const char *String) return Result; } + +int +strcmp (const char *str1, const char *str2) +{ + return strcmpa((CHAR8 *)str1,(CHAR8 *)str2); +} + +inline static char +toupper (char c) +{ + return ((c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c); +} + +/* Based on AsciiStriCmp() in edk2 MdePkg/Library/BaseLib/String.c */ +int +strcasecmp (const char *str1, const char *str2) +{ + char c1, c2; + + c1 = toupper (*str1); + c2 = toupper (*str2); + while ((*str1 != '\0') && (c1 == c2)) { + str1++; + str2++; + c1 = toupper (*str1); + c2 = toupper (*str2); + } + + return c1 - c2; +}