mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[CMD] Use kernel32!lstrcmp(i) when comparing strings with the IF command.
Use kernel32!lstrcmp(i) instead of CRT!_tcs(i)cmp, so as to use the correct current thread locale information when comparing user-specific strings. As a result, the following comparison: 'b LSS B' will return TRUE, instead of FALSE as it would be by using the CRT functions (and by naively considering the lexicographical order in ANSI). This behaviour has been introduced in Windows 2000 onwards.
This commit is contained in:
parent
5830ccb85e
commit
6e09a6a3ff
1 changed files with 13 additions and 7 deletions
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "precomp.h"
|
||||
|
||||
static INT GenericCmp(INT (*StringCmp)(LPCTSTR, LPCTSTR),
|
||||
static INT GenericCmp(INT (WINAPI *StringCmp)(LPCTSTR, LPCTSTR),
|
||||
LPCTSTR Left, LPCTSTR Right)
|
||||
{
|
||||
TCHAR *end;
|
||||
|
@ -152,14 +152,20 @@ INT ExecuteIf(PARSED_COMMAND *Cmd)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Do case-insensitive string comparisons if /I specified */
|
||||
INT (*StringCmp)(LPCTSTR, LPCTSTR) =
|
||||
(Cmd->If.Flags & IFFLAG_IGNORECASE) ? _tcsicmp : _tcscmp;
|
||||
/*
|
||||
* Do case-insensitive string comparisons if /I specified.
|
||||
*
|
||||
* Since both strings are user-specific, use kernel32!lstrcmp(i)
|
||||
* instead of CRT!_tcs(i)cmp, so as to use the correct
|
||||
* current thread locale information.
|
||||
*/
|
||||
INT (WINAPI *StringCmp)(LPCTSTR, LPCTSTR) =
|
||||
(Cmd->If.Flags & IFFLAG_IGNORECASE) ? lstrcmpi : lstrcmp;
|
||||
|
||||
if (Cmd->If.Operator == IF_STRINGEQ)
|
||||
{
|
||||
/* IF str1 == str2 */
|
||||
result = StringCmp(Left, Right) == 0;
|
||||
result = (StringCmp(Left, Right) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -168,9 +174,9 @@ INT ExecuteIf(PARSED_COMMAND *Cmd)
|
|||
{
|
||||
case IF_EQU: result = (result == 0); break;
|
||||
case IF_NEQ: result = (result != 0); break;
|
||||
case IF_LSS: result = (result < 0); break;
|
||||
case IF_LSS: result = (result < 0); break;
|
||||
case IF_LEQ: result = (result <= 0); break;
|
||||
case IF_GTR: result = (result > 0); break;
|
||||
case IF_GTR: result = (result > 0); break;
|
||||
case IF_GEQ: result = (result >= 0); break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue