cmd: Avoid duplication of commonly used strings.

oldstable
Frédéric Delanoy 2011-11-12 13:58:01 +01:00 committed by Alexandre Julliard
parent e8d8df3c54
commit 5fc25686a4
5 changed files with 22 additions and 25 deletions

View File

@ -317,7 +317,6 @@ void WCMD_HandleTildaModifiers(WCHAR **start, const WCHAR *forVariable,
static const WCHAR validmodifiers[NUMMODIFIERS] = {
'~', 'f', 'd', 'p', 'n', 'x', 's', 'a', 't', 'z', '$'
};
static const WCHAR space[] = {' ', '\0'};
WIN32_FILE_ATTRIBUTE_DATA fileInfo;
WCHAR outputparam[MAX_PATH];

View File

@ -58,17 +58,17 @@ extern DWORD errorlevel;
static BOOL verify_mode = FALSE;
static const WCHAR dotW[] = {'.','\0'};
static const WCHAR dotdotW[] = {'.','.','\0'};
static const WCHAR slashW[] = {'\\','\0'};
static const WCHAR starW[] = {'*','\0'};
static const WCHAR equalW[] = {'=','\0'};
const WCHAR dotW[] = {'.','\0'};
const WCHAR dotdotW[] = {'.','.','\0'};
const WCHAR nullW[] = {'\0'};
const WCHAR starW[] = {'*','\0'};
const WCHAR slashW[] = {'\\','\0'};
const WCHAR equalW[] = {'=','\0'};
static const WCHAR fslashW[] = {'/','\0'};
static const WCHAR onW[] = {'O','N','\0'};
static const WCHAR offW[] = {'O','F','F','\0'};
static const WCHAR parmY[] = {'/','Y','\0'};
static const WCHAR parmNoY[] = {'/','-','Y','\0'};
static const WCHAR nullW[] = {'\0'};
/**************************************************************************
* WCMD_ask_confirm

View File

@ -59,13 +59,6 @@ static BOOL orderReverse, orderGroupDirs, orderGroupDirsReverse, orderByCol;
static BOOL paged_mode, recurse, wide, bare, lower, shortname, usernames, separator;
static ULONG showattrs, attrsbits;
static const WCHAR dotW[] = {'.','\0'};
static const WCHAR dotdotW[] = {'.','.','\0'};
static const WCHAR starW[] = {'*','\0'};
static const WCHAR slashW[] = {'\\','\0'};
static const WCHAR emptyW[] = {'\0'};
static const WCHAR spaceW[] = {' ','\0'};
/*****************************************************************************
* WCMD_strrev
*
@ -432,14 +425,14 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Note: WCMD_output uses wvsprintf which does not allow %*
so manually pad with spaces to appropriate width */
strcpyW(temp, emptyW);
strcpyW(temp, nullW);
while (padding > 0) {
strcatW(&temp[toWrite], spaceW);
strcatW(&temp[toWrite], space);
toWrite++;
if (toWrite > 99) {
WCMD_output(temp);
toWrite = 0;
strcpyW(temp, emptyW);
strcpyW(temp, nullW);
}
padding--;
}
@ -457,7 +450,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
} else {
if (!((strcmpW((fd+i)->cFileName, dotW) == 0) ||
(strcmpW((fd+i)->cFileName, dotdotW) == 0))) {
WCMD_output (fmt5, recurse?inputparms->dirName:emptyW, (fd+i)->cFileName);
WCMD_output (fmt5, recurse?inputparms->dirName:nullW, (fd+i)->cFileName);
} else {
addNewLine = FALSE;
}
@ -475,7 +468,7 @@ 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:emptyW, (fd+i)->cFileName);
WCMD_output (fmt5, recurse?inputparms->dirName:nullW, (fd+i)->cFileName);
}
}
}

View File

@ -220,6 +220,13 @@ extern const WCHAR externals[NUM_EXTERNALS][10];
/* Some standard messages */
extern const WCHAR newline[];
extern const WCHAR space[];
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[];

View File

@ -90,7 +90,7 @@ int defaultColor = 7;
BOOL echo_mode = TRUE;
static int opt_c, opt_k, opt_s;
const WCHAR newline[] = {'\r','\n','\0'};
static const WCHAR equalsW[] = {'=','\0'};
const WCHAR space[] = {' ','\0'};
static const WCHAR closeBW[] = {')','\0'};
WCHAR anykey[100];
WCHAR version_string[100];
@ -747,7 +747,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start,
/* search and replace manipulation */
} else {
WCHAR *equalspos = strstrW(colonpos, equalsW);
WCHAR *equalspos = strstrW(colonpos, equalW);
WCHAR *replacewith = equalspos+1;
WCHAR *found = NULL;
WCHAR *searchIn;
@ -1084,7 +1084,6 @@ void WCMD_run_program (WCHAR *command, int called) {
WCHAR thisDir[MAX_PATH] = {'\0'};
WCHAR *pos = NULL;
BOOL found = FALSE;
static const WCHAR slashW[] = {'\\','\0'};
/* Work on the first directory on the search path */
pos = strchrW(pathposn, ';');
@ -1332,7 +1331,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 */
strcpyW(envvar, equalsW);
strcpyW(envvar, equalW);
strcatW(envvar, cmd);
if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) {
static const WCHAR fmt[] = {'%','s','\\','\0'};
@ -1835,7 +1834,6 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
if (context) handleExpansion(extraSpace, FALSE, NULL, NULL);
/* Show prompt before batch line IF echo is on and in batch program */
if (context && echo_mode && extraSpace[0] && (extraSpace[0] != '@')) {
static const WCHAR spc[]={' ','\0'};
static const WCHAR echoDot[] = {'e','c','h','o','.'};
static const WCHAR echoCol[] = {'e','c','h','o',':'};
const DWORD len = sizeof(echoDot)/sizeof(echoDot[0]);
@ -1850,7 +1848,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
extraSpace, min_len, echoCol, len) != CSTR_EQUAL)
{
WCMD_output_asis(spc);
WCMD_output_asis(space);
}
WCMD_output_asis(newline);
}