cmd: Inline some simple extern WCHAR strings.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-11-29 23:30:28 +01:00 committed by Alexandre Julliard
parent 77fc01d39d
commit 9fcb2b097c
5 changed files with 66 additions and 89 deletions

View File

@ -516,13 +516,13 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
doneModifier = TRUE; doneModifier = TRUE;
if (exists) { if (exists) {
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
/* Format the time */ /* Format the time */
FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime); FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime);
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime, GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime,
NULL, thisoutput, MAX_PATH); NULL, thisoutput, MAX_PATH);
lstrcatW(thisoutput, spaceW); lstrcatW(thisoutput, L" ");
datelen = lstrlenW(thisoutput); datelen = lstrlenW(thisoutput);
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime, GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime,
NULL, (thisoutput+datelen), MAX_PATH-datelen); NULL, (thisoutput+datelen), MAX_PATH-datelen);
@ -538,7 +538,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
doneModifier = TRUE; doneModifier = TRUE;
if (exists) { if (exists) {
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
wsprintfW(thisoutput, L"%u", fullsize); wsprintfW(thisoutput, L"%u", fullsize);
lstrcatW(finaloutput, thisoutput); 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) */ /* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (wmemchr(firstModifier, 's', modifierLen) != NULL) { 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 /* Convert fullfilename's path to a short path - Save filename away as
only path is valid, name may not exist which causes GetShortPathName 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 */ /* Note this overrides d,p,n,x */
if (wmemchr(firstModifier, 'f', modifierLen) != NULL) { if (wmemchr(firstModifier, 'f', modifierLen) != NULL) {
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
lstrcatW(finaloutput, fullfilename); lstrcatW(finaloutput, fullfilename);
} else { } else {
@ -580,7 +580,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 5. Handle 'd' : Drive Letter */ /* 5. Handle 'd' : Drive Letter */
if (wmemchr(firstModifier, 'd', modifierLen) != NULL) { if (wmemchr(firstModifier, 'd', modifierLen) != NULL) {
if (addSpace) { if (addSpace) {
lstrcatW(finaloutput, spaceW); lstrcatW(finaloutput, L" ");
addSpace = FALSE; addSpace = FALSE;
} }
@ -592,7 +592,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 6. Handle 'p' : Path */ /* 6. Handle 'p' : Path */
if (wmemchr(firstModifier, 'p', modifierLen) != NULL) { if (wmemchr(firstModifier, 'p', modifierLen) != NULL) {
if (addSpace) { if (addSpace) {
lstrcatW(finaloutput, spaceW); lstrcatW(finaloutput, L" ");
addSpace = FALSE; addSpace = FALSE;
} }
@ -604,7 +604,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 7. Handle 'n' : Name */ /* 7. Handle 'n' : Name */
if (wmemchr(firstModifier, 'n', modifierLen) != NULL) { if (wmemchr(firstModifier, 'n', modifierLen) != NULL) {
if (addSpace) { if (addSpace) {
lstrcatW(finaloutput, spaceW); lstrcatW(finaloutput, L" ");
addSpace = FALSE; addSpace = FALSE;
} }
@ -616,7 +616,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 8. Handle 'x' : Ext */ /* 8. Handle 'x' : Ext */
if (wmemchr(firstModifier, 'x', modifierLen) != NULL) { if (wmemchr(firstModifier, 'x', modifierLen) != NULL) {
if (addSpace) { if (addSpace) {
lstrcatW(finaloutput, spaceW); lstrcatW(finaloutput, L" ");
addSpace = FALSE; addSpace = FALSE;
} }
@ -629,7 +629,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
if (!doneFileModifier && if (!doneFileModifier &&
wmemchr(firstModifier, 's', modifierLen) != NULL) { wmemchr(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
lstrcatW(finaloutput, fullfilename); lstrcatW(finaloutput, fullfilename);
} }
} }

View File

@ -39,12 +39,6 @@ extern BOOL echo_mode;
extern BOOL interactive; extern BOOL interactive;
struct env_stack *pushd_directories; 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 wildcardsW[] = {'*','?','\0'};
const WCHAR slashstarW[] = {'\\','*','\0'}; const WCHAR slashstarW[] = {'\\','*','\0'};
const WCHAR deviceW[] = {'\\','\\','.','\\','\0'}; const WCHAR deviceW[] = {'\\','\\','.','\\','\0'};
@ -410,7 +404,7 @@ void WCMD_choice (const WCHAR * args) {
ptr = wcschr(opt_c, answer[0]); ptr = wcschr(opt_c, answer[0]);
if (ptr) { if (ptr) {
WCMD_output_asis(answer); WCMD_output_asis(answer);
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
if (have_console) if (have_console)
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldmode); SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldmode);
@ -807,8 +801,8 @@ void WCMD_copy(WCHAR * args) {
if (destination == NULL) { if (destination == NULL) {
WINE_TRACE("No destination supplied, so need to calculate it\n"); WINE_TRACE("No destination supplied, so need to calculate it\n");
lstrcpyW(destname, dotW); lstrcpyW(destname, L".");
lstrcatW(destname, slashW); lstrcatW(destname, L"\\");
destination = heap_xalloc(sizeof(COPY_FILES)); destination = heap_xalloc(sizeof(COPY_FILES));
if (destination == NULL) goto exitreturn; if (destination == NULL) goto exitreturn;
@ -835,7 +829,7 @@ void WCMD_copy(WCHAR * args) {
(attributes & FILE_ATTRIBUTE_DIRECTORY))) { (attributes & FILE_ATTRIBUTE_DIRECTORY))) {
destisdirectory = TRUE; 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)); 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 /* We need to know where the filename part starts, so append * and
recalculate the full resulting path */ recalculate the full resulting path */
lstrcatW(thiscopy->name, starW); lstrcatW(thiscopy->name, L"*");
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart); GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath)); 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'}; static const WCHAR parmQ[] = {'/','Q','\0'};
if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) { if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) {
static const WCHAR anyExt[]= {'.','*','\0'};
WCHAR drive[10]; WCHAR drive[10];
WCHAR dir[MAX_PATH]; WCHAR dir[MAX_PATH];
WCHAR fname[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); _wsplitpath(fpath, drive, dir, fname, ext);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */ /* Only prompt for * and *.*, not *a, a*, *.a* etc */
if ((lstrcmpW(fname, starW) == 0) && if ((lstrcmpW(fname, L"*") == 0) && (*ext == 0x00 || (lstrcmpW(ext, L".*") == 0))) {
(*ext == 0x00 || (lstrcmpW(ext, anyExt) == 0))) {
WCHAR question[MAXSTRING]; WCHAR question[MAXSTRING];
static const WCHAR fmt[] = {'%','s',' ','\0'}; static const WCHAR fmt[] = {'%','s',' ','\0'};
@ -1375,8 +1367,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
do { do {
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
(lstrcmpW(fd.cFileName, dotdotW) != 0) && (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0)) {
(lstrcmpW(fd.cFileName, dotW) != 0)) {
DIRECTORY_STACK *nextDir; DIRECTORY_STACK *nextDir;
WCHAR subParm[MAX_PATH]; WCHAR subParm[MAX_PATH];
@ -1384,7 +1375,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
/* Work out search parameter in sub dir */ /* Work out search parameter in sub dir */
lstrcpyW (subParm, thisDir); lstrcpyW (subParm, thisDir);
lstrcatW (subParm, fd.cFileName); lstrcatW (subParm, fd.cFileName);
lstrcatW (subParm, slashW); lstrcatW (subParm, L"\\");
lstrcatW (subParm, fname); lstrcatW (subParm, fname);
lstrcatW (subParm, ext); lstrcatW (subParm, ext);
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm)); 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; echo_mode = FALSE;
else { else {
WCMD_output_asis (args); WCMD_output_asis (args);
WCMD_output_asis (newlineW); WCMD_output_asis(L"\r\n");
} }
heap_free(trimmed); heap_free(trimmed);
} }
@ -1783,8 +1774,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
do { do {
WINE_TRACE("Looking for subdirectories\n"); WINE_TRACE("Looking for subdirectories\n");
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
(lstrcmpW(fd.cFileName, dotdotW) != 0) && (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0))
(lstrcmpW(fd.cFileName, dotW) != 0))
{ {
/* Allocate memory, add to list */ /* Allocate memory, add to list */
DIRECTORY_STACK *toWalk = heap_xalloc(sizeof(DIRECTORY_STACK)); DIRECTORY_STACK *toWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
@ -1794,7 +1784,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
remainingDirs = toWalk; remainingDirs = toWalk;
toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(dirsToWalk->dirName) + 2 + lstrlenW(fd.cFileName))); toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(dirsToWalk->dirName) + 2 + lstrlenW(fd.cFileName)));
lstrcpyW(toWalk->dirName, dirsToWalk->dirName); lstrcpyW(toWalk->dirName, dirsToWalk->dirName);
lstrcatW(toWalk->dirName, slashW); lstrcatW(toWalk->dirName, L"\\");
lstrcatW(toWalk->dirName, fd.cFileName); lstrcatW(toWalk->dirName, fd.cFileName);
WINE_TRACE("Added to stack %s (%p->%p)\n", wine_dbgstr_w(toWalk->dirName), WINE_TRACE("Added to stack %s (%p->%p)\n", wine_dbgstr_w(toWalk->dirName),
toWalk, toWalk->next); toWalk, toWalk->next);
@ -2329,7 +2319,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
as it is fully qualified in the /R case */ as it is fully qualified in the /R case */
if (dirsToWalk) { if (dirsToWalk) {
lstrcpyW(fullitem, dirsToWalk->dirName); lstrcpyW(fullitem, dirsToWalk->dirName);
lstrcatW(fullitem, slashW); lstrcatW(fullitem, L"\\");
lstrcatW(fullitem, item); lstrcatW(fullitem, item);
} else { } else {
WCHAR *prefix = wcsrchr(item, '\\'); 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 .. */ /* Handle as files or dirs appropriately, but ignore . and .. */
if (isDirectory == expandDirs && if (isDirectory == expandDirs &&
(lstrcmpW(fd.cFileName, dotdotW) != 0) && (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0))
(lstrcmpW(fd.cFileName, dotW) != 0))
{ {
thisCmdStart = cmdStart; thisCmdStart = cmdStart;
WINE_TRACE("Processing FOR filename %s\n", wine_dbgstr_w(fd.cFileName)); WINE_TRACE("Processing FOR filename %s\n", wine_dbgstr_w(fd.cFileName));
if (doRecurse) { if (doRecurse) {
lstrcpyW(fullitem, dirsToWalk->dirName); lstrcpyW(fullitem, dirsToWalk->dirName);
lstrcatW(fullitem, slashW); lstrcatW(fullitem, L"\\");
lstrcatW(fullitem, fd.cFileName); lstrcatW(fullitem, fd.cFileName);
} else { } else {
if (prefixlen) lstrcpynW(fullitem, item, prefixlen + 1); 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); int len = lstrlenW(param);
/* FindFirstFile does not like a directory path ending in '\', append a '.' */ /* 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); hff = FindFirstFileW(param, &fd);
*test = (hff != INVALID_HANDLE_VALUE ); *test = (hff != INVALID_HANDLE_VALUE );
@ -2982,7 +2971,7 @@ void WCMD_move (void)
/* If no destination supplied, assume current directory */ /* If no destination supplied, assume current directory */
if (param2[0] == 0x00) { if (param2[0] == 0x00) {
lstrcpyW(param2, dotW); lstrcpyW(param2, L".");
} }
/* If 2nd parm is directory, then use original filename */ /* If 2nd parm is directory, then use original filename */
@ -3017,7 +3006,7 @@ void WCMD_move (void)
if (attribs != INVALID_FILE_ATTRIBUTES && if (attribs != INVALID_FILE_ATTRIBUTES &&
(attribs & FILE_ATTRIBUTE_DIRECTORY)) { (attribs & FILE_ATTRIBUTE_DIRECTORY)) {
lstrcpyW(dest, output); lstrcpyW(dest, output);
lstrcatW(dest, slashW); lstrcatW(dest, L"\\");
lstrcatW(dest, fd.cFileName); lstrcatW(dest, fd.cFileName);
} else { } else {
lstrcpyW(dest, output); lstrcpyW(dest, output);
@ -3477,7 +3466,7 @@ void WCMD_setshow_default (const WCHAR *args) {
GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd); GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);
if (!*args) { if (!*args) {
lstrcatW (cwd, newlineW); lstrcatW(cwd, L"\r\n");
WCMD_output_asis (cwd); WCMD_output_asis (cwd);
} }
else { else {
@ -3544,7 +3533,7 @@ void WCMD_setshow_default (const WCHAR *args) {
drive */ drive */
if ((string[1] == ':') && IsCharAlphaW(string[0])) { if ((string[1] == ':') && IsCharAlphaW(string[0])) {
WCHAR env[4]; WCHAR env[4];
lstrcpyW(env, equalW); lstrcpyW(env, L"=");
memcpy(env+1, string, 2 * sizeof(WCHAR)); memcpy(env+1, string, 2 * sizeof(WCHAR));
env[3] = 0x00; env[3] = 0x00;
WINE_TRACE("Setting '%s' to '%s'\n", wine_dbgstr_w(env), wine_dbgstr_w(string)); 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; int r;
const WCHAR * const *str_a = a, * const *str_b = b; const WCHAR * const *str_a = a, * const *str_b = b;
r = CompareStringW( LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, 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_LESS_THAN ) return -1;
if( r == CSTR_GREATER_THAN ) return 1; if( r == CSTR_GREATER_THAN ) return 1;
return 0; return 0;
@ -3641,7 +3630,7 @@ static int WCMD_setshow_sortenv(const WCHAR *s, const WCHAR *stub)
/* Don't display special internal variables */ /* Don't display special internal variables */
if (str[i][0] != '=') { if (str[i][0] != '=') {
WCMD_output_asis(str[i]); WCMD_output_asis(str[i]);
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
displayedcount++; displayedcount++;
} }
} }
@ -4314,7 +4303,7 @@ void WCMD_setshow_path (const WCHAR *args) {
if (status != 0) { if (status != 0) {
WCMD_output_asis ( pathEqW); WCMD_output_asis ( pathEqW);
WCMD_output_asis ( string); WCMD_output_asis ( string);
WCMD_output_asis ( newlineW); WCMD_output_asis(L"\r\n");
} }
else { else {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOPATH)); WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOPATH));
@ -4438,7 +4427,7 @@ void WCMD_start(WCHAR *args)
lstrcatW( file, exeW ); lstrcatW( file, exeW );
cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) ); cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) );
lstrcpyW( cmdline, file ); lstrcpyW( cmdline, file );
lstrcatW( cmdline, spaceW ); lstrcatW(cmdline, L" ");
cmdline_params = cmdline + lstrlenW(cmdline); cmdline_params = cmdline + lstrlenW(cmdline);
/* The start built-in has some special command-line parsing properties /* 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; if (newValue) accessOptions |= KEY_WRITE;
/* Open a key to HKEY_CLASSES_ROOT for enumerating */ /* Open a key to HKEY_CLASSES_ROOT for enumerating */
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, nullW, 0, if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"", 0, accessOptions, &key) != ERROR_SUCCESS) {
accessOptions, &key) != ERROR_SUCCESS) {
WINE_FIXME("Unexpected failure opening HKCR key: %d\n", GetLastError()); WINE_FIXME("Unexpected failure opening HKCR key: %d\n", GetLastError());
return; return;
} }
@ -4901,12 +4889,12 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
valueLen = ARRAY_SIZE(keyValue); valueLen = ARRAY_SIZE(keyValue);
rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen); rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen);
WCMD_output_asis(keyName); WCMD_output_asis(keyName);
WCMD_output_asis(equalW); WCMD_output_asis(L"=");
/* If no default value found, leave line empty after '=' */ /* If no default value found, leave line empty after '=' */
if (rc == ERROR_SUCCESS) { if (rc == ERROR_SUCCESS) {
WCMD_output_asis(keyValue); WCMD_output_asis(keyValue);
} }
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
RegCloseKey(readKey); RegCloseKey(readKey);
} }
} }
@ -4933,10 +4921,10 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen); rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen);
WCMD_output_asis(args); WCMD_output_asis(args);
WCMD_output_asis(equalW); WCMD_output_asis(L"=");
/* If no default value found, leave line empty after '=' */ /* If no default value found, leave line empty after '=' */
if (rc == ERROR_SUCCESS) WCMD_output_asis(keyValue); if (rc == ERROR_SUCCESS) WCMD_output_asis(keyValue);
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
RegCloseKey(readKey); RegCloseKey(readKey);
} else { } else {
@ -5005,9 +4993,9 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
errorlevel = 2; errorlevel = 2;
} else { } else {
WCMD_output_asis(args); WCMD_output_asis(args);
WCMD_output_asis(equalW); WCMD_output_asis(L"=");
WCMD_output_asis(newValue); WCMD_output_asis(newValue);
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
} }
} }
} }

View File

@ -310,7 +310,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Output the results */ /* Output the results */
if (!bare) { 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)) { if (!recurse || ((entry_count > 0) && done_header==FALSE)) {
WCMD_output (L"Directory of %1\n\n", real_path); WCMD_output (L"Directory of %1\n\n", real_path);
done_header = TRUE; done_header = TRUE;
@ -397,7 +397,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if ((cur_width + widest) > max_width) { if ((cur_width + widest) > max_width) {
cur_width = 0; cur_width = 0;
} else { } 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) { } 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); if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,fd[i].cFileName); WCMD_output(fmt4,fd[i].cFileName);
} else { } else {
if (!((lstrcmpW(fd[i].cFileName, dotW) == 0) || if (!((lstrcmpW(fd[i].cFileName, L".") == 0) ||
(lstrcmpW(fd[i].cFileName, dotdotW) == 0))) { (lstrcmpW(fd[i].cFileName, L"..") == 0))) {
WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName); WCMD_output(fmt5, recurse?inputparms->dirName:L"", fd[i].cFileName);
} else { } else {
addNewLine = FALSE; addNewLine = FALSE;
} }
@ -429,11 +429,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (usernames) WCMD_output (fmt3, username); if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,fd[i].cFileName); WCMD_output(fmt4,fd[i].cFileName);
} else { } 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; cur_width = 0;
} }
@ -467,15 +467,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Build path to search */ /* Build path to search */
lstrcpyW(string, inputparms->dirName); lstrcpyW(string, inputparms->dirName);
lstrcatW(string, starW); lstrcatW(string, L"*");
WINE_TRACE("Recursive, looking for '%s'\n", wine_dbgstr_w(string)); WINE_TRACE("Recursive, looking for '%s'\n", wine_dbgstr_w(string));
hff = FindFirstFileW(string, &finddata); hff = FindFirstFileW(string, &finddata);
if (hff != INVALID_HANDLE_VALUE) { if (hff != INVALID_HANDLE_VALUE) {
do { do {
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
(lstrcmpW(finddata.cFileName, dotdotW) != 0) && (lstrcmpW(finddata.cFileName, L"..") != 0) &&
(lstrcmpW(finddata.cFileName, dotW) != 0)) { (lstrcmpW(finddata.cFileName, L".") != 0)) {
DIRECTORY_STACK *thisDir; DIRECTORY_STACK *thisDir;
int dirsToCopy = concurrentDirs; 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 */ /* Work out search parameter in sub dir */
lstrcpyW (string, inputparms->dirName); lstrcpyW (string, inputparms->dirName);
lstrcatW (string, finddata.cFileName); lstrcatW (string, finddata.cFileName);
lstrcatW (string, slashW); lstrcatW(string, L"\\");
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string)); WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
/* Allocate memory, add to list */ /* Allocate memory, add to list */
@ -762,7 +762,7 @@ void WCMD_directory (WCHAR *args)
argno = 0; argno = 0;
argN = args; argN = args;
GetCurrentDirectoryW(MAX_PATH, cwd); GetCurrentDirectoryW(MAX_PATH, cwd);
lstrcatW(cwd, slashW); lstrcatW(cwd, L"\\");
/* Loop through all args, calculating full effective directory */ /* Loop through all args, calculating full effective directory */
fullParms = NULL; fullParms = NULL;
@ -781,7 +781,7 @@ void WCMD_directory (WCHAR *args)
if (!GetEnvironmentVariableW(envvar, fullname, MAX_PATH)) { if (!GetEnvironmentVariableW(envvar, fullname, MAX_PATH)) {
wsprintfW(fullname, L"%c:", thisArg[0]); wsprintfW(fullname, L"%c:", thisArg[0]);
} }
lstrcatW(fullname, slashW); lstrcatW(fullname, L"\\");
lstrcatW(fullname, &thisArg[2]); lstrcatW(fullname, &thisArg[2]);
} else if (thisArg[0] == '\\') { } else if (thisArg[0] == '\\') {
memcpy(fullname, cwd, 2 * sizeof(WCHAR)); memcpy(fullname, cwd, 2 * sizeof(WCHAR));
@ -802,13 +802,13 @@ void WCMD_directory (WCHAR *args)
if ((wcschr(path, '*') == NULL) && (wcschr(path, '%') == NULL)) { if ((wcschr(path, '*') == NULL) && (wcschr(path, '%') == NULL)) {
status = GetFileAttributesW(path); status = GetFileAttributesW(path);
if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) { if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
if (!ends_with_backslash( path )) lstrcatW( path, slashW ); if (!ends_with_backslash(path)) lstrcatW(path, L"\\");
lstrcatW (path, starW); lstrcatW(path, L"*");
} }
} else { } else {
/* Special case wildcard search with no extension (ie parameters ending in '.') as /* Special case wildcard search with no extension (ie parameters ending in '.') as
GetFullPathName strips off the additional '.' */ 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)); 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 = heap_xalloc(sizeof(DIRECTORY_STACK));
fullParms->next = NULL; fullParms->next = NULL;
fullParms->dirName = heap_strdupW(cwd); fullParms->dirName = heap_strdupW(cwd);
fullParms->fileName = heap_strdupW(starW); fullParms->fileName = heap_strdupW(L"*");
} }
lastDrive = '?'; lastDrive = '?';

View File

@ -271,14 +271,6 @@ extern BOOL delayedsubst;
#define WCMD_EXIT 46 #define WCMD_EXIT 46
/* Some standard messages */ /* 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 anykey[];
extern WCHAR version_string[]; extern WCHAR version_string[];

View File

@ -46,8 +46,6 @@ int defaultColor = 7;
BOOL echo_mode = TRUE; BOOL echo_mode = TRUE;
WCHAR anykey[100], version_string[100]; 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 envPathExt[] = {'P','A','T','H','E','X','T','\0'};
static const WCHAR dfltPathExt[] = {'.','b','a','t',';', static const WCHAR dfltPathExt[] = {'.','b','a','t',';',
'.','c','o','m',';', '.','c','o','m',';',
@ -319,8 +317,7 @@ void WCMD_print_error (void) {
WCMD_output_asis_len(lpMsgBuf, lstrlenW(lpMsgBuf), WCMD_output_asis_len(lpMsgBuf, lstrlenW(lpMsgBuf),
GetStdHandle(STD_ERROR_HANDLE)); GetStdHandle(STD_ERROR_HANDLE));
LocalFree (lpMsgBuf); LocalFree (lpMsgBuf);
WCMD_output_asis_len (newlineW, lstrlenW(newlineW), WCMD_output_asis_len(L"\r\n", lstrlenW(L"\r\n"), GetStdHandle(STD_ERROR_HANDLE));
GetStdHandle(STD_ERROR_HANDLE));
return; return;
} }
@ -731,7 +728,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* search and replace manipulation */ /* search and replace manipulation */
} else { } else {
WCHAR *equalspos = wcsstr(colonpos, equalW); WCHAR *equalspos = wcsstr(colonpos, L"=");
WCHAR *replacewith = equalspos+1; WCHAR *replacewith = equalspos+1;
WCHAR *found = NULL; WCHAR *found = NULL;
WCHAR *searchIn; WCHAR *searchIn;
@ -1151,7 +1148,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
} }
/* 1. If extension supplied, see if that file exists */ /* 1. If extension supplied, see if that file exists */
lstrcatW(thisDir, slashW); lstrcatW(thisDir, L"\\");
lstrcatW(thisDir, stemofsearch); lstrcatW(thisDir, stemofsearch);
pos = &thisDir[lstrlenW(thisDir)]; /* Pos = end of name */ 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 /* According to MSDN CreateProcess docs, special env vars record
the current directory on each drive, in the form =C: the current directory on each drive, in the form =C:
so see if one specified, and if so go back to it */ so see if one specified, and if so go back to it */
lstrcpyW(envvar, equalW); lstrcpyW(envvar, L"=");
lstrcatW(envvar, cmd); lstrcatW(envvar, cmd);
if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) { if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) {
static const WCHAR fmt[] = {'%','s','\\','\0'}; static const WCHAR fmt[] = {'%','s','\\','\0'};
@ -1607,7 +1604,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WCMD_type (parms_start); WCMD_type (parms_start);
break; break;
case WCMD_VER: case WCMD_VER:
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
WCMD_version (); WCMD_version ();
break; break;
case WCMD_VERIFY: case WCMD_VERIFY:
@ -1886,7 +1883,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
if (lstrlenW(extraSpace) == MAXSTRING -1) { if (lstrlenW(extraSpace) == MAXSTRING -1) {
WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_TRUNCATEDLINE)); WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_TRUNCATEDLINE));
WCMD_output_asis_stderr(extraSpace); 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 */ /* 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, && CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
curPos, min_len, echoSlash, len) != CSTR_EQUAL) 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 */ /* 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 */ /* Continue to echo commands IF echo is on and in batch program */
if (context && echo_mode && *curPos && *curPos != '@') { if (context && echo_mode && *curPos && *curPos != '@') {
WCMD_output_asis(extraSpace); WCMD_output_asis(extraSpace);
WCMD_output_asis(newlineW); WCMD_output_asis(L"\r\n");
} }
/* Skip repeated 'no echo' characters and whitespace */ /* Skip repeated 'no echo' characters and whitespace */