[PATCH 2/4] cmd: Inline some simple extern WCHAR strings.
Michael Stefaniuc
mstefani at winehq.org
Sun Nov 29 16:30:28 CST 2020
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
programs/cmd/batch.c | 20 +++++------
programs/cmd/builtins.c | 72 +++++++++++++++++-----------------------
programs/cmd/directory.c | 34 +++++++++----------
programs/cmd/wcmd.h | 8 -----
programs/cmd/wcmdmain.c | 21 +++++-------
5 files changed, 66 insertions(+), 89 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index a08648d8c26..37cdff42188 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -516,13 +516,13 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
doneModifier = TRUE;
if (exists) {
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
/* Format the time */
FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime);
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime,
NULL, thisoutput, MAX_PATH);
- lstrcatW(thisoutput, spaceW);
+ lstrcatW(thisoutput, L" ");
datelen = lstrlenW(thisoutput);
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime,
NULL, (thisoutput+datelen), MAX_PATH-datelen);
@@ -538,7 +538,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
doneModifier = TRUE;
if (exists) {
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
wsprintfW(thisoutput, L"%u", fullsize);
lstrcatW(finaloutput, thisoutput);
}
@@ -546,7 +546,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (wmemchr(firstModifier, 's', modifierLen) != NULL) {
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
/* Convert fullfilename's path to a short path - Save filename away as
only path is valid, name may not exist which causes GetShortPathName
@@ -563,7 +563,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* Note this overrides d,p,n,x */
if (wmemchr(firstModifier, 'f', modifierLen) != NULL) {
doneModifier = TRUE;
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
lstrcatW(finaloutput, fullfilename);
} else {
@@ -580,7 +580,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 5. Handle 'd' : Drive Letter */
if (wmemchr(firstModifier, 'd', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -592,7 +592,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 6. Handle 'p' : Path */
if (wmemchr(firstModifier, 'p', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -604,7 +604,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 7. Handle 'n' : Name */
if (wmemchr(firstModifier, 'n', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -616,7 +616,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 8. Handle 'x' : Ext */
if (wmemchr(firstModifier, 'x', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -629,7 +629,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
if (!doneFileModifier &&
wmemchr(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE;
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
lstrcatW(finaloutput, fullfilename);
}
}
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index c6dce091c69..e4b1fed613f 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -39,12 +39,6 @@ extern BOOL echo_mode;
extern BOOL interactive;
struct env_stack *pushd_directories;
-const WCHAR dotW[] = {'.','\0'};
-const WCHAR dotdotW[] = {'.','.','\0'};
-const WCHAR nullW[] = {'\0'};
-const WCHAR starW[] = {'*','\0'};
-const WCHAR slashW[] = {'\\','\0'};
-const WCHAR equalW[] = {'=','\0'};
const WCHAR wildcardsW[] = {'*','?','\0'};
const WCHAR slashstarW[] = {'\\','*','\0'};
const WCHAR deviceW[] = {'\\','\\','.','\\','\0'};
@@ -410,7 +404,7 @@ void WCMD_choice (const WCHAR * args) {
ptr = wcschr(opt_c, answer[0]);
if (ptr) {
WCMD_output_asis(answer);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
if (have_console)
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldmode);
@@ -807,8 +801,8 @@ void WCMD_copy(WCHAR * args) {
if (destination == NULL) {
WINE_TRACE("No destination supplied, so need to calculate it\n");
- lstrcpyW(destname, dotW);
- lstrcatW(destname, slashW);
+ lstrcpyW(destname, L".");
+ lstrcatW(destname, L"\\");
destination = heap_xalloc(sizeof(COPY_FILES));
if (destination == NULL) goto exitreturn;
@@ -835,7 +829,7 @@ void WCMD_copy(WCHAR * args) {
(attributes & FILE_ATTRIBUTE_DIRECTORY))) {
destisdirectory = TRUE;
- if (!ends_with_backslash( destname )) lstrcatW(destname, slashW);
+ if (!ends_with_backslash(destname)) lstrcatW(destname, L"\\");
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(destname));
}
}
@@ -916,7 +910,7 @@ void WCMD_copy(WCHAR * args) {
/* We need to know where the filename part starts, so append * and
recalculate the full resulting path */
- lstrcatW(thiscopy->name, starW);
+ lstrcatW(thiscopy->name, L"*");
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
@@ -1208,7 +1202,6 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
static const WCHAR parmQ[] = {'/','Q','\0'};
if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) {
- static const WCHAR anyExt[]= {'.','*','\0'};
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
@@ -1220,8 +1213,7 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
_wsplitpath(fpath, drive, dir, fname, ext);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */
- if ((lstrcmpW(fname, starW) == 0) &&
- (*ext == 0x00 || (lstrcmpW(ext, anyExt) == 0))) {
+ if ((lstrcmpW(fname, L"*") == 0) && (*ext == 0x00 || (lstrcmpW(ext, L".*") == 0))) {
WCHAR question[MAXSTRING];
static const WCHAR fmt[] = {'%','s',' ','\0'};
@@ -1375,8 +1367,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
do {
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (lstrcmpW(fd.cFileName, dotdotW) != 0) &&
- (lstrcmpW(fd.cFileName, dotW) != 0)) {
+ (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0)) {
DIRECTORY_STACK *nextDir;
WCHAR subParm[MAX_PATH];
@@ -1384,7 +1375,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
/* Work out search parameter in sub dir */
lstrcpyW (subParm, thisDir);
lstrcatW (subParm, fd.cFileName);
- lstrcatW (subParm, slashW);
+ lstrcatW (subParm, L"\\");
lstrcatW (subParm, fname);
lstrcatW (subParm, ext);
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm));
@@ -1526,7 +1517,7 @@ void WCMD_echo (const WCHAR *args)
echo_mode = FALSE;
else {
WCMD_output_asis (args);
- WCMD_output_asis (newlineW);
+ WCMD_output_asis(L"\r\n");
}
heap_free(trimmed);
}
@@ -1783,8 +1774,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
do {
WINE_TRACE("Looking for subdirectories\n");
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (lstrcmpW(fd.cFileName, dotdotW) != 0) &&
- (lstrcmpW(fd.cFileName, dotW) != 0))
+ (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0))
{
/* Allocate memory, add to list */
DIRECTORY_STACK *toWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
@@ -1794,7 +1784,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
remainingDirs = toWalk;
toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(dirsToWalk->dirName) + 2 + lstrlenW(fd.cFileName)));
lstrcpyW(toWalk->dirName, dirsToWalk->dirName);
- lstrcatW(toWalk->dirName, slashW);
+ lstrcatW(toWalk->dirName, L"\\");
lstrcatW(toWalk->dirName, fd.cFileName);
WINE_TRACE("Added to stack %s (%p->%p)\n", wine_dbgstr_w(toWalk->dirName),
toWalk, toWalk->next);
@@ -2329,7 +2319,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
as it is fully qualified in the /R case */
if (dirsToWalk) {
lstrcpyW(fullitem, dirsToWalk->dirName);
- lstrcatW(fullitem, slashW);
+ lstrcatW(fullitem, L"\\");
lstrcatW(fullitem, item);
} else {
WCHAR *prefix = wcsrchr(item, '\\');
@@ -2347,15 +2337,14 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
/* Handle as files or dirs appropriately, but ignore . and .. */
if (isDirectory == expandDirs &&
- (lstrcmpW(fd.cFileName, dotdotW) != 0) &&
- (lstrcmpW(fd.cFileName, dotW) != 0))
+ (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0))
{
thisCmdStart = cmdStart;
WINE_TRACE("Processing FOR filename %s\n", wine_dbgstr_w(fd.cFileName));
if (doRecurse) {
lstrcpyW(fullitem, dirsToWalk->dirName);
- lstrcatW(fullitem, slashW);
+ lstrcatW(fullitem, L"\\");
lstrcatW(fullitem, fd.cFileName);
} else {
if (prefixlen) lstrcpynW(fullitem, item, prefixlen + 1);
@@ -2867,7 +2856,7 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
int len = lstrlenW(param);
/* FindFirstFile does not like a directory path ending in '\', append a '.' */
- if (len && param[len-1] == '\\') lstrcatW(param, dotW);
+ if (len && param[len-1] == '\\') lstrcatW(param, L".");
hff = FindFirstFileW(param, &fd);
*test = (hff != INVALID_HANDLE_VALUE );
@@ -2982,7 +2971,7 @@ void WCMD_move (void)
/* If no destination supplied, assume current directory */
if (param2[0] == 0x00) {
- lstrcpyW(param2, dotW);
+ lstrcpyW(param2, L".");
}
/* If 2nd parm is directory, then use original filename */
@@ -3017,7 +3006,7 @@ void WCMD_move (void)
if (attribs != INVALID_FILE_ATTRIBUTES &&
(attribs & FILE_ATTRIBUTE_DIRECTORY)) {
lstrcpyW(dest, output);
- lstrcatW(dest, slashW);
+ lstrcatW(dest, L"\\");
lstrcatW(dest, fd.cFileName);
} else {
lstrcpyW(dest, output);
@@ -3477,7 +3466,7 @@ void WCMD_setshow_default (const WCHAR *args) {
GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);
if (!*args) {
- lstrcatW (cwd, newlineW);
+ lstrcatW(cwd, L"\r\n");
WCMD_output_asis (cwd);
}
else {
@@ -3544,7 +3533,7 @@ void WCMD_setshow_default (const WCHAR *args) {
drive */
if ((string[1] == ':') && IsCharAlphaW(string[0])) {
WCHAR env[4];
- lstrcpyW(env, equalW);
+ lstrcpyW(env, L"=");
memcpy(env+1, string, 2 * sizeof(WCHAR));
env[3] = 0x00;
WINE_TRACE("Setting '%s' to '%s'\n", wine_dbgstr_w(env), wine_dbgstr_w(string));
@@ -3596,7 +3585,7 @@ static int __cdecl WCMD_compare( const void *a, const void *b )
int r;
const WCHAR * const *str_a = a, * const *str_b = b;
r = CompareStringW( LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- *str_a, wcscspn(*str_a, equalW), *str_b, wcscspn(*str_b, equalW) );
+ *str_a, wcscspn(*str_a, L"="), *str_b, wcscspn(*str_b, L"=") );
if( r == CSTR_LESS_THAN ) return -1;
if( r == CSTR_GREATER_THAN ) return 1;
return 0;
@@ -3641,7 +3630,7 @@ static int WCMD_setshow_sortenv(const WCHAR *s, const WCHAR *stub)
/* Don't display special internal variables */
if (str[i][0] != '=') {
WCMD_output_asis(str[i]);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
displayedcount++;
}
}
@@ -4314,7 +4303,7 @@ void WCMD_setshow_path (const WCHAR *args) {
if (status != 0) {
WCMD_output_asis ( pathEqW);
WCMD_output_asis ( string);
- WCMD_output_asis ( newlineW);
+ WCMD_output_asis(L"\r\n");
}
else {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOPATH));
@@ -4438,7 +4427,7 @@ void WCMD_start(WCHAR *args)
lstrcatW( file, exeW );
cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) );
lstrcpyW( cmdline, file );
- lstrcatW( cmdline, spaceW );
+ lstrcatW(cmdline, L" ");
cmdline_params = cmdline + lstrlenW(cmdline);
/* The start built-in has some special command-line parsing properties
@@ -4866,8 +4855,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
if (newValue) accessOptions |= KEY_WRITE;
/* Open a key to HKEY_CLASSES_ROOT for enumerating */
- if (RegOpenKeyExW(HKEY_CLASSES_ROOT, nullW, 0,
- accessOptions, &key) != ERROR_SUCCESS) {
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"", 0, accessOptions, &key) != ERROR_SUCCESS) {
WINE_FIXME("Unexpected failure opening HKCR key: %d\n", GetLastError());
return;
}
@@ -4901,12 +4889,12 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
valueLen = ARRAY_SIZE(keyValue);
rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen);
WCMD_output_asis(keyName);
- WCMD_output_asis(equalW);
+ WCMD_output_asis(L"=");
/* If no default value found, leave line empty after '=' */
if (rc == ERROR_SUCCESS) {
WCMD_output_asis(keyValue);
}
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
RegCloseKey(readKey);
}
}
@@ -4933,10 +4921,10 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen);
WCMD_output_asis(args);
- WCMD_output_asis(equalW);
+ WCMD_output_asis(L"=");
/* If no default value found, leave line empty after '=' */
if (rc == ERROR_SUCCESS) WCMD_output_asis(keyValue);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
RegCloseKey(readKey);
} else {
@@ -5005,9 +4993,9 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
errorlevel = 2;
} else {
WCMD_output_asis(args);
- WCMD_output_asis(equalW);
+ WCMD_output_asis(L"=");
WCMD_output_asis(newValue);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
}
}
}
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index 2d35f8eb1d1..df3ed4387ee 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -310,7 +310,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Output the results */
if (!bare) {
- if (level != 0 && (entry_count > 0)) WCMD_output_asis (newlineW);
+ if (level != 0 && (entry_count > 0)) WCMD_output_asis(L"\r\n");
if (!recurse || ((entry_count > 0) && done_header==FALSE)) {
WCMD_output (L"Directory of %1\n\n", real_path);
done_header = TRUE;
@@ -397,7 +397,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if ((cur_width + widest) > max_width) {
cur_width = 0;
} else {
- WCMD_output(L"%1!*s!", cur_width - tmp_width, nullW);
+ WCMD_output(L"%1!*s!", cur_width - tmp_width, L"");
}
} else if (fd[i].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
@@ -409,9 +409,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,fd[i].cFileName);
} else {
- if (!((lstrcmpW(fd[i].cFileName, dotW) == 0) ||
- (lstrcmpW(fd[i].cFileName, dotdotW) == 0))) {
- WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName);
+ if (!((lstrcmpW(fd[i].cFileName, L".") == 0) ||
+ (lstrcmpW(fd[i].cFileName, L"..") == 0))) {
+ WCMD_output(fmt5, recurse?inputparms->dirName:L"", fd[i].cFileName);
} else {
addNewLine = FALSE;
}
@@ -429,11 +429,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,fd[i].cFileName);
} else {
- WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName);
+ WCMD_output(fmt5, recurse ? inputparms->dirName : L"", fd[i].cFileName);
}
}
}
- if (addNewLine) WCMD_output_asis (newlineW);
+ if (addNewLine) WCMD_output_asis(L"\r\n");
cur_width = 0;
}
@@ -467,15 +467,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Build path to search */
lstrcpyW(string, inputparms->dirName);
- lstrcatW(string, starW);
+ lstrcatW(string, L"*");
WINE_TRACE("Recursive, looking for '%s'\n", wine_dbgstr_w(string));
hff = FindFirstFileW(string, &finddata);
if (hff != INVALID_HANDLE_VALUE) {
do {
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (lstrcmpW(finddata.cFileName, dotdotW) != 0) &&
- (lstrcmpW(finddata.cFileName, dotW) != 0)) {
+ (lstrcmpW(finddata.cFileName, L"..") != 0) &&
+ (lstrcmpW(finddata.cFileName, L".") != 0)) {
DIRECTORY_STACK *thisDir;
int dirsToCopy = concurrentDirs;
@@ -488,7 +488,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Work out search parameter in sub dir */
lstrcpyW (string, inputparms->dirName);
lstrcatW (string, finddata.cFileName);
- lstrcatW (string, slashW);
+ lstrcatW(string, L"\\");
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
/* Allocate memory, add to list */
@@ -762,7 +762,7 @@ void WCMD_directory (WCHAR *args)
argno = 0;
argN = args;
GetCurrentDirectoryW(MAX_PATH, cwd);
- lstrcatW(cwd, slashW);
+ lstrcatW(cwd, L"\\");
/* Loop through all args, calculating full effective directory */
fullParms = NULL;
@@ -781,7 +781,7 @@ void WCMD_directory (WCHAR *args)
if (!GetEnvironmentVariableW(envvar, fullname, MAX_PATH)) {
wsprintfW(fullname, L"%c:", thisArg[0]);
}
- lstrcatW(fullname, slashW);
+ lstrcatW(fullname, L"\\");
lstrcatW(fullname, &thisArg[2]);
} else if (thisArg[0] == '\\') {
memcpy(fullname, cwd, 2 * sizeof(WCHAR));
@@ -802,13 +802,13 @@ void WCMD_directory (WCHAR *args)
if ((wcschr(path, '*') == NULL) && (wcschr(path, '%') == NULL)) {
status = GetFileAttributesW(path);
if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
- if (!ends_with_backslash( path )) lstrcatW( path, slashW );
- lstrcatW (path, starW);
+ if (!ends_with_backslash(path)) lstrcatW(path, L"\\");
+ lstrcatW(path, L"*");
}
} else {
/* Special case wildcard search with no extension (ie parameters ending in '.') as
GetFullPathName strips off the additional '.' */
- if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, dotW);
+ if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, L".");
}
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
@@ -841,7 +841,7 @@ void WCMD_directory (WCHAR *args)
fullParms = heap_xalloc(sizeof(DIRECTORY_STACK));
fullParms->next = NULL;
fullParms->dirName = heap_strdupW(cwd);
- fullParms->fileName = heap_strdupW(starW);
+ fullParms->fileName = heap_strdupW(L"*");
}
lastDrive = '?';
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 9ae87ea7064..65a89ac26d7 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -271,14 +271,6 @@ extern BOOL delayedsubst;
#define WCMD_EXIT 46
/* Some standard messages */
-extern const WCHAR newlineW[];
-extern const WCHAR spaceW[];
-extern const WCHAR nullW[];
-extern const WCHAR dotW[];
-extern const WCHAR dotdotW[];
-extern const WCHAR starW[];
-extern const WCHAR slashW[];
-extern const WCHAR equalW[];
extern WCHAR anykey[];
extern WCHAR version_string[];
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 2b55a39dca3..3484f05ae73 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -46,8 +46,6 @@ int defaultColor = 7;
BOOL echo_mode = TRUE;
WCHAR anykey[100], version_string[100];
-const WCHAR newlineW[] = {'\r','\n','\0'};
-const WCHAR spaceW[] = {' ','\0'};
static const WCHAR envPathExt[] = {'P','A','T','H','E','X','T','\0'};
static const WCHAR dfltPathExt[] = {'.','b','a','t',';',
'.','c','o','m',';',
@@ -319,8 +317,7 @@ void WCMD_print_error (void) {
WCMD_output_asis_len(lpMsgBuf, lstrlenW(lpMsgBuf),
GetStdHandle(STD_ERROR_HANDLE));
LocalFree (lpMsgBuf);
- WCMD_output_asis_len (newlineW, lstrlenW(newlineW),
- GetStdHandle(STD_ERROR_HANDLE));
+ WCMD_output_asis_len(L"\r\n", lstrlenW(L"\r\n"), GetStdHandle(STD_ERROR_HANDLE));
return;
}
@@ -731,7 +728,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* search and replace manipulation */
} else {
- WCHAR *equalspos = wcsstr(colonpos, equalW);
+ WCHAR *equalspos = wcsstr(colonpos, L"=");
WCHAR *replacewith = equalspos+1;
WCHAR *found = NULL;
WCHAR *searchIn;
@@ -1151,7 +1148,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
}
/* 1. If extension supplied, see if that file exists */
- lstrcatW(thisDir, slashW);
+ lstrcatW(thisDir, L"\\");
lstrcatW(thisDir, stemofsearch);
pos = &thisDir[lstrlenW(thisDir)]; /* Pos = end of name */
@@ -1395,7 +1392,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
/* According to MSDN CreateProcess docs, special env vars record
the current directory on each drive, in the form =C:
so see if one specified, and if so go back to it */
- lstrcpyW(envvar, equalW);
+ lstrcpyW(envvar, L"=");
lstrcatW(envvar, cmd);
if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) {
static const WCHAR fmt[] = {'%','s','\\','\0'};
@@ -1607,7 +1604,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WCMD_type (parms_start);
break;
case WCMD_VER:
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
WCMD_version ();
break;
case WCMD_VERIFY:
@@ -1886,7 +1883,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
if (lstrlenW(extraSpace) == MAXSTRING -1) {
WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_TRUNCATEDLINE));
WCMD_output_asis_stderr(extraSpace);
- WCMD_output_asis_stderr(newlineW);
+ WCMD_output_asis_stderr(L"\r\n");
}
/* Replace env vars if in a batch context */
@@ -1914,9 +1911,9 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
curPos, min_len, echoSlash, len) != CSTR_EQUAL)
{
- WCMD_output_asis(spaceW);
+ WCMD_output_asis(L" ");
}
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
}
/* Skip repeated 'no echo' characters */
@@ -2354,7 +2351,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Continue to echo commands IF echo is on and in batch program */
if (context && echo_mode && *curPos && *curPos != '@') {
WCMD_output_asis(extraSpace);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
}
/* Skip repeated 'no echo' characters and whitespace */
--
2.26.2
More information about the wine-devel
mailing list