Module: wine Branch: master Commit: 91de94ab9967749c8e7ece8123db947f996b092f URL: https://gitlab.winehq.org/wine/wine/-/commit/91de94ab9967749c8e7ece8123db947...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Fri Aug 18 12:51:54 2023 +0900
cmd: Use towlower()/towupper() for WCHARs.
Found with Coccinelle.
---
programs/cmd/builtins.c | 2 +- programs/cmd/directory.c | 12 ++++-------- programs/cmd/wcmdmain.c | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 397eb567277..419e812103a 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3496,7 +3496,7 @@ void WCMD_setshow_default (const WCHAR *args) { /* Restore old directory if drive letter would change, and CD x:\directory /D (or pushd c:\directory) not supplied */ if ((wcsstr(quals, L"/D") == NULL) && - (param1[1] == ':') && (toupper(param1[0]) != toupper(cwd[0]))) { + (param1[1] == ':') && (towupper(param1[0]) != towupper(cwd[0]))) { SetCurrentDirectoryW(cwd); } } diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index dfe7e925419..b9b8656fd70 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -328,10 +328,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le }
/* /L convers all names to lower case */ - if (lower) { - WCHAR *p = fd[i].cFileName; - while ( (*p = tolower(*p)) ) ++p; - } + if (lower) wcslwr( fd[i].cFileName );
/* /Q gets file ownership information */ if (usernames) { @@ -558,8 +555,7 @@ void WCMD_directory (WCHAR *args)
/* Prefill quals with (uppercased) DIRCMD env var */ if (GetEnvironmentVariableW(L"DIRCMD", string, ARRAY_SIZE(string))) { - p = string; - while ( (*p = toupper(*p)) ) ++p; + wcsupr( string ); lstrcatW(string,quals); lstrcpyW(quals, string); } @@ -827,7 +823,7 @@ void WCMD_directory (WCHAR *args)
/* Output disk free (trailer) and volume information (header) if the drive letter changes */ - if (lastDrive != toupper(thisEntry->dirName[0])) { + if (lastDrive != towupper(thisEntry->dirName[0])) {
/* Trailer Information */ if (lastDrive != '?') { @@ -835,7 +831,7 @@ void WCMD_directory (WCHAR *args) WCMD_dir_trailer(prevEntry->dirName[0]); }
- lastDrive = toupper(thisEntry->dirName[0]); + lastDrive = towupper(thisEntry->dirName[0]);
if (!bare) { WCHAR drive[3]; diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 298606f6caa..528e4a83800 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -347,7 +347,7 @@ static void WCMD_show_prompt (BOOL newLine) { } else { p++; - switch (toupper(*p)) { + switch (towupper(*p)) { case '$': *q++ = '$'; break;