forked from Mirrors/wine-wine
cmd: Build with msvcrt.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>stable
parent
71e7e73fc0
commit
43c430a6d8
|
@ -1,7 +1,8 @@
|
||||||
MODULE = cmd.exe
|
MODULE = cmd.exe
|
||||||
APPMODE = -mconsole -municode
|
|
||||||
IMPORTS = shell32 user32 advapi32
|
IMPORTS = shell32 user32 advapi32
|
||||||
|
|
||||||
|
EXTRADLLFLAGS = -mconsole -municode -mno-cygwin
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
batch.c \
|
batch.c \
|
||||||
builtins.c \
|
builtins.c \
|
||||||
|
|
|
@ -76,7 +76,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
|
||||||
|
|
||||||
/* If processing a call :label, 'goto' the label in question */
|
/* If processing a call :label, 'goto' the label in question */
|
||||||
if (startLabel) {
|
if (startLabel) {
|
||||||
strcpyW(param1, startLabel);
|
lstrcpyW(param1, startLabel);
|
||||||
WCMD_goto(NULL);
|
WCMD_goto(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start,
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
|
|
||||||
/* Absorb repeated word delimiters until we get to the next token (or the end!) */
|
/* Absorb repeated word delimiters until we get to the next token (or the end!) */
|
||||||
while (*p && (strchrW(delims, *p) != NULL))
|
while (*p && (wcschr(delims, *p) != NULL))
|
||||||
p++;
|
p++;
|
||||||
if (*p == '\0') return param;
|
if (*p == '\0') return param;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start,
|
||||||
/* Loop character by character, but just need to special case quotes */
|
/* Loop character by character, but just need to special case quotes */
|
||||||
while (*p) {
|
while (*p) {
|
||||||
/* Once we have found a delimiter, break */
|
/* Once we have found a delimiter, break */
|
||||||
if (strchrW(delims, *p) != NULL) break;
|
if (wcschr(delims, *p) != NULL) break;
|
||||||
|
|
||||||
/* Very odd special case - Seems as if a ( acts as a delimiter which is
|
/* Very odd special case - Seems as if a ( acts as a delimiter which is
|
||||||
not swallowed but is effective only when it comes between the program
|
not swallowed but is effective only when it comes between the program
|
||||||
|
@ -319,7 +319,7 @@ void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHA
|
||||||
} else if (drv)
|
} else if (drv)
|
||||||
*drv = '\0';
|
*drv = '\0';
|
||||||
|
|
||||||
end = path + strlenW(path);
|
end = path + lstrlenW(path);
|
||||||
|
|
||||||
/* search for begin of file extension */
|
/* search for begin of file extension */
|
||||||
for(p=end; p>path && *--p!='\\' && *p!='/'; )
|
for(p=end; p>path && *--p!='\\' && *p!='/'; )
|
||||||
|
@ -471,21 +471,21 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
whereas if you start applying other modifiers to it, you get the filename
|
whereas if you start applying other modifiers to it, you get the filename
|
||||||
the batch label is in */
|
the batch label is in */
|
||||||
if (*lastModifier == '0' && modifierLen > 1) {
|
if (*lastModifier == '0' && modifierLen > 1) {
|
||||||
strcpyW(outputparam, context->batchfileW);
|
lstrcpyW(outputparam, context->batchfileW);
|
||||||
} else if ((*lastModifier >= '0' && *lastModifier <= '9')) {
|
} else if ((*lastModifier >= '0' && *lastModifier <= '9')) {
|
||||||
strcpyW(outputparam,
|
lstrcpyW(outputparam,
|
||||||
WCMD_parameter (context -> command,
|
WCMD_parameter (context -> command,
|
||||||
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'],
|
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'],
|
||||||
NULL, FALSE, TRUE));
|
NULL, FALSE, TRUE));
|
||||||
} else {
|
} else {
|
||||||
int foridx = FOR_VAR_IDX(*lastModifier);
|
int foridx = FOR_VAR_IDX(*lastModifier);
|
||||||
strcpyW(outputparam, forloopcontext.variable[foridx]);
|
lstrcpyW(outputparam, forloopcontext.variable[foridx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. Handle '~' : Strip surrounding quotes */
|
/* 1. Handle '~' : Strip surrounding quotes */
|
||||||
if (outputparam[0]=='"' &&
|
if (outputparam[0]=='"' &&
|
||||||
memchrW(firstModifier, '~', modifierLen) != NULL) {
|
wmemchr(firstModifier, '~', modifierLen) != NULL) {
|
||||||
int len = strlenW(outputparam);
|
int len = lstrlenW(outputparam);
|
||||||
if (outputparam[len-1] == '"') {
|
if (outputparam[len-1] == '"') {
|
||||||
outputparam[len-1]=0x00;
|
outputparam[len-1]=0x00;
|
||||||
len = len - 1;
|
len = len - 1;
|
||||||
|
@ -494,11 +494,11 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2. Handle the special case of a $ */
|
/* 2. Handle the special case of a $ */
|
||||||
if (memchrW(firstModifier, '$', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, '$', modifierLen) != NULL) {
|
||||||
/* Special Case: Search envar specified in $[envvar] for outputparam
|
/* Special Case: Search envar specified in $[envvar] for outputparam
|
||||||
Note both $ and : are guaranteed otherwise check above would fail */
|
Note both $ and : are guaranteed otherwise check above would fail */
|
||||||
WCHAR *begin = strchrW(firstModifier, '$') + 1;
|
WCHAR *begin = wcschr(firstModifier, '$') + 1;
|
||||||
WCHAR *end = strchrW(firstModifier, ':');
|
WCHAR *end = wcschr(firstModifier, ':');
|
||||||
WCHAR env[MAX_PATH];
|
WCHAR env[MAX_PATH];
|
||||||
DWORD size;
|
DWORD size;
|
||||||
|
|
||||||
|
@ -535,13 +535,13 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2. Handle 'a' : Output attributes (File doesn't have to exist) */
|
/* 2. Handle 'a' : Output attributes (File doesn't have to exist) */
|
||||||
if (memchrW(firstModifier, 'a', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'a', modifierLen) != NULL) {
|
||||||
|
|
||||||
WCHAR defaults[] = {'-','-','-','-','-','-','-','-','-','\0'};
|
WCHAR defaults[] = {'-','-','-','-','-','-','-','-','-','\0'};
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
strcpyW(thisoutput, defaults);
|
lstrcpyW(thisoutput, defaults);
|
||||||
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
thisoutput[0]='d';
|
thisoutput[0]='d';
|
||||||
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
||||||
|
@ -557,12 +557,12 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
/* FIXME: What are 6 and 7? */
|
/* FIXME: What are 6 and 7? */
|
||||||
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||||
thisoutput[8]='l';
|
thisoutput[8]='l';
|
||||||
strcatW(finaloutput, thisoutput);
|
lstrcatW(finaloutput, thisoutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3. Handle 't' : Date+time (File doesn't have to exist) */
|
/* 3. Handle 't' : Date+time (File doesn't have to exist) */
|
||||||
if (memchrW(firstModifier, 't', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 't', modifierLen) != NULL) {
|
||||||
|
|
||||||
SYSTEMTIME systime;
|
SYSTEMTIME systime;
|
||||||
int datelen;
|
int datelen;
|
||||||
|
@ -570,22 +570,22 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
|
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
|
||||||
|
|
||||||
/* 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);
|
||||||
strcatW(thisoutput, spaceW);
|
lstrcatW(thisoutput, spaceW);
|
||||||
datelen = strlenW(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);
|
||||||
strcatW(finaloutput, thisoutput);
|
lstrcatW(finaloutput, thisoutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4. Handle 'z' : File length (File doesn't have to exist) */
|
/* 4. Handle 'z' : File length (File doesn't have to exist) */
|
||||||
if (memchrW(firstModifier, 'z', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'z', modifierLen) != NULL) {
|
||||||
/* FIXME: Output full 64 bit size (sprintf does not support I64 here) */
|
/* FIXME: Output full 64 bit size (sprintf does not support I64 here) */
|
||||||
ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/
|
ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/
|
||||||
fileInfo.nFileSizeLow;
|
fileInfo.nFileSizeLow;
|
||||||
|
@ -593,33 +593,33 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
|
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
if (exists) {
|
if (exists) {
|
||||||
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
|
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
|
||||||
wsprintfW(thisoutput, fmt, fullsize);
|
wsprintfW(thisoutput, fmt, fullsize);
|
||||||
strcatW(finaloutput, thisoutput);
|
lstrcatW(finaloutput, thisoutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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 (memchrW(firstModifier, 's', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 's', modifierLen) != NULL) {
|
||||||
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
|
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
|
||||||
|
|
||||||
/* 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
|
||||||
to fail if it is provided */
|
to fail if it is provided */
|
||||||
if (filepart) {
|
if (filepart) {
|
||||||
strcpyW(thisoutput, filepart);
|
lstrcpyW(thisoutput, filepart);
|
||||||
*filepart = 0x00;
|
*filepart = 0x00;
|
||||||
GetShortPathNameW(fullfilename, fullfilename, ARRAY_SIZE(fullfilename));
|
GetShortPathNameW(fullfilename, fullfilename, ARRAY_SIZE(fullfilename));
|
||||||
strcatW(fullfilename, thisoutput);
|
lstrcatW(fullfilename, thisoutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */
|
/* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */
|
||||||
/* Note this overrides d,p,n,x */
|
/* Note this overrides d,p,n,x */
|
||||||
if (memchrW(firstModifier, 'f', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'f', modifierLen) != NULL) {
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
|
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
|
||||||
strcatW(finaloutput, fullfilename);
|
lstrcatW(finaloutput, fullfilename);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
WCHAR drive[10];
|
WCHAR drive[10];
|
||||||
|
@ -633,65 +633,65 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
||||||
WCMD_splitpath(fullfilename, drive, dir, fname, ext);
|
WCMD_splitpath(fullfilename, drive, dir, fname, ext);
|
||||||
|
|
||||||
/* 5. Handle 'd' : Drive Letter */
|
/* 5. Handle 'd' : Drive Letter */
|
||||||
if (memchrW(firstModifier, 'd', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'd', modifierLen) != NULL) {
|
||||||
if (addSpace) {
|
if (addSpace) {
|
||||||
strcatW(finaloutput, spaceW);
|
lstrcatW(finaloutput, spaceW);
|
||||||
addSpace = FALSE;
|
addSpace = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcatW(finaloutput, drive);
|
lstrcatW(finaloutput, drive);
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
doneFileModifier = TRUE;
|
doneFileModifier = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 6. Handle 'p' : Path */
|
/* 6. Handle 'p' : Path */
|
||||||
if (memchrW(firstModifier, 'p', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'p', modifierLen) != NULL) {
|
||||||
if (addSpace) {
|
if (addSpace) {
|
||||||
strcatW(finaloutput, spaceW);
|
lstrcatW(finaloutput, spaceW);
|
||||||
addSpace = FALSE;
|
addSpace = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcatW(finaloutput, dir);
|
lstrcatW(finaloutput, dir);
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
doneFileModifier = TRUE;
|
doneFileModifier = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 7. Handle 'n' : Name */
|
/* 7. Handle 'n' : Name */
|
||||||
if (memchrW(firstModifier, 'n', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'n', modifierLen) != NULL) {
|
||||||
if (addSpace) {
|
if (addSpace) {
|
||||||
strcatW(finaloutput, spaceW);
|
lstrcatW(finaloutput, spaceW);
|
||||||
addSpace = FALSE;
|
addSpace = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcatW(finaloutput, fname);
|
lstrcatW(finaloutput, fname);
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
doneFileModifier = TRUE;
|
doneFileModifier = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 8. Handle 'x' : Ext */
|
/* 8. Handle 'x' : Ext */
|
||||||
if (memchrW(firstModifier, 'x', modifierLen) != NULL) {
|
if (wmemchr(firstModifier, 'x', modifierLen) != NULL) {
|
||||||
if (addSpace) {
|
if (addSpace) {
|
||||||
strcatW(finaloutput, spaceW);
|
lstrcatW(finaloutput, spaceW);
|
||||||
addSpace = FALSE;
|
addSpace = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcatW(finaloutput, ext);
|
lstrcatW(finaloutput, ext);
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
doneFileModifier = TRUE;
|
doneFileModifier = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If 's' but no other parameter, dump the whole thing */
|
/* If 's' but no other parameter, dump the whole thing */
|
||||||
if (!doneFileModifier &&
|
if (!doneFileModifier &&
|
||||||
memchrW(firstModifier, 's', modifierLen) != NULL) {
|
wmemchr(firstModifier, 's', modifierLen) != NULL) {
|
||||||
doneModifier = TRUE;
|
doneModifier = TRUE;
|
||||||
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
|
if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
|
||||||
strcatW(finaloutput, fullfilename);
|
lstrcatW(finaloutput, fullfilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If No other modifier processed, just add in parameter */
|
/* If No other modifier processed, just add in parameter */
|
||||||
if (!doneModifier) strcpyW(finaloutput, outputparam);
|
if (!doneModifier) lstrcpyW(finaloutput, outputparam);
|
||||||
|
|
||||||
/* Finish by inserting the replacement into the string */
|
/* Finish by inserting the replacement into the string */
|
||||||
WCMD_strsubstW(*start, lastModifier+1, finaloutput, -1);
|
WCMD_strsubstW(*start, lastModifier+1, finaloutput, -1);
|
||||||
|
@ -714,7 +714,7 @@ void WCMD_call (WCHAR *command) {
|
||||||
|
|
||||||
WCHAR gotoLabel[MAX_PATH];
|
WCHAR gotoLabel[MAX_PATH];
|
||||||
|
|
||||||
strcpyW(gotoLabel, param1);
|
lstrcpyW(gotoLabel, param1);
|
||||||
|
|
||||||
if (context) {
|
if (context) {
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -59,7 +59,7 @@ static WCHAR * WCMD_strrev (WCHAR *buff) {
|
||||||
int r, i;
|
int r, i;
|
||||||
WCHAR b;
|
WCHAR b;
|
||||||
|
|
||||||
r = strlenW (buff);
|
r = lstrlenW (buff);
|
||||||
for (i=0; i<r/2; i++) {
|
for (i=0; i<r/2; i++) {
|
||||||
b = buff[i];
|
b = buff[i];
|
||||||
buff[i] = buff[r-i-1];
|
buff[i] = buff[r-i-1];
|
||||||
|
@ -221,7 +221,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
|
||||||
/* Convert to a username */
|
/* Convert to a username */
|
||||||
if (LookupAccountSidW(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) {
|
if (LookupAccountSidW(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) {
|
||||||
static const WCHAR fmt[] = {'%','s','%','c','%','s','\0'};
|
static const WCHAR fmt[] = {'%','s','%','c','%','s','\0'};
|
||||||
snprintfW(owner, ownerlen, fmt, domain, '\\', name);
|
swprintf(owner, ownerlen, fmt, domain, '\\', name);
|
||||||
}
|
}
|
||||||
heap_free(secBuffer);
|
heap_free(secBuffer);
|
||||||
}
|
}
|
||||||
|
@ -274,12 +274,12 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
mirrors what windows does */
|
mirrors what windows does */
|
||||||
parms = inputparms;
|
parms = inputparms;
|
||||||
fd = heap_xalloc(sizeof(WIN32_FIND_DATAW));
|
fd = heap_xalloc(sizeof(WIN32_FIND_DATAW));
|
||||||
while (parms && strcmpW(inputparms->dirName, parms->dirName) == 0) {
|
while (parms && lstrcmpW(inputparms->dirName, parms->dirName) == 0) {
|
||||||
concurrentDirs++;
|
concurrentDirs++;
|
||||||
|
|
||||||
/* Work out the full path + filename */
|
/* Work out the full path + filename */
|
||||||
strcpyW(real_path, parms->dirName);
|
lstrcpyW(real_path, parms->dirName);
|
||||||
strcatW(real_path, parms->fileName);
|
lstrcatW(real_path, parms->fileName);
|
||||||
|
|
||||||
/* Load all files into an in memory structure */
|
/* Load all files into an in memory structure */
|
||||||
WINE_TRACE("Looking for matches to '%s'\n", wine_dbgstr_w(real_path));
|
WINE_TRACE("Looking for matches to '%s'\n", wine_dbgstr_w(real_path));
|
||||||
|
@ -293,7 +293,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
|
|
||||||
/* Keep running track of longest filename for wide output */
|
/* Keep running track of longest filename for wide output */
|
||||||
if (wide || orderByCol) {
|
if (wide || orderByCol) {
|
||||||
int tmpLen = strlenW(fd[entry_count-1].cFileName) + 3;
|
int tmpLen = lstrlenW(fd[entry_count-1].cFileName) + 3;
|
||||||
if (fd[entry_count-1].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) tmpLen = tmpLen + 2;
|
if (fd[entry_count-1].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) tmpLen = tmpLen + 2;
|
||||||
if (tmpLen > widest) widest = tmpLen;
|
if (tmpLen > widest) widest = tmpLen;
|
||||||
}
|
}
|
||||||
|
@ -310,8 +310,8 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Work out the actual current directory name without a trailing \ */
|
/* Work out the actual current directory name without a trailing \ */
|
||||||
strcpyW(real_path, parms->dirName);
|
lstrcpyW(real_path, parms->dirName);
|
||||||
real_path[strlenW(parms->dirName)-1] = 0x00;
|
real_path[lstrlenW(parms->dirName)-1] = 0x00;
|
||||||
|
|
||||||
/* Output the results */
|
/* Output the results */
|
||||||
if (!bare) {
|
if (!bare) {
|
||||||
|
@ -368,8 +368,8 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
|
|
||||||
/* /Q gets file ownership information */
|
/* /Q gets file ownership information */
|
||||||
if (usernames) {
|
if (usernames) {
|
||||||
strcpyW (string, inputparms->dirName);
|
lstrcpyW (string, inputparms->dirName);
|
||||||
strcatW (string, fd[i].cFileName);
|
lstrcatW (string, fd[i].cFileName);
|
||||||
WCMD_getfileowner(string, username, ARRAY_SIZE(username));
|
WCMD_getfileowner(string, username, ARRAY_SIZE(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,11 +391,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
static const WCHAR fmt[] = {'[','%','1',']','\0'};
|
static const WCHAR fmt[] = {'[','%','1',']','\0'};
|
||||||
WCMD_output (fmt, fd[i].cFileName);
|
WCMD_output (fmt, fd[i].cFileName);
|
||||||
dir_count++;
|
dir_count++;
|
||||||
tmp_width = tmp_width + strlenW(fd[i].cFileName) + 2;
|
tmp_width = tmp_width + lstrlenW(fd[i].cFileName) + 2;
|
||||||
} else {
|
} else {
|
||||||
static const WCHAR fmt[] = {'%','1','\0'};
|
static const WCHAR fmt[] = {'%','1','\0'};
|
||||||
WCMD_output (fmt, fd[i].cFileName);
|
WCMD_output (fmt, fd[i].cFileName);
|
||||||
tmp_width = tmp_width + strlenW(fd[i].cFileName) ;
|
tmp_width = tmp_width + lstrlenW(fd[i].cFileName) ;
|
||||||
file_count++;
|
file_count++;
|
||||||
file_size.u.LowPart = fd[i].nFileSizeLow;
|
file_size.u.LowPart = fd[i].nFileSizeLow;
|
||||||
file_size.u.HighPart = fd[i].nFileSizeHigh;
|
file_size.u.HighPart = fd[i].nFileSizeHigh;
|
||||||
|
@ -419,8 +419,8 @@ 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 (!((strcmpW(fd[i].cFileName, dotW) == 0) ||
|
if (!((lstrcmpW(fd[i].cFileName, dotW) == 0) ||
|
||||||
(strcmpW(fd[i].cFileName, dotdotW) == 0))) {
|
(lstrcmpW(fd[i].cFileName, dotdotW) == 0))) {
|
||||||
WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName);
|
WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName);
|
||||||
} else {
|
} else {
|
||||||
addNewLine = FALSE;
|
addNewLine = FALSE;
|
||||||
|
@ -484,16 +484,16 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
WIN32_FIND_DATAW finddata;
|
WIN32_FIND_DATAW finddata;
|
||||||
|
|
||||||
/* Build path to search */
|
/* Build path to search */
|
||||||
strcpyW(string, inputparms->dirName);
|
lstrcpyW(string, inputparms->dirName);
|
||||||
strcatW(string, starW);
|
lstrcatW(string, starW);
|
||||||
|
|
||||||
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) &&
|
||||||
(strcmpW(finddata.cFileName, dotdotW) != 0) &&
|
(lstrcmpW(finddata.cFileName, dotdotW) != 0) &&
|
||||||
(strcmpW(finddata.cFileName, dotW) != 0)) {
|
(lstrcmpW(finddata.cFileName, dotW) != 0)) {
|
||||||
|
|
||||||
DIRECTORY_STACK *thisDir;
|
DIRECTORY_STACK *thisDir;
|
||||||
int dirsToCopy = concurrentDirs;
|
int dirsToCopy = concurrentDirs;
|
||||||
|
@ -504,9 +504,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
dirsToCopy--;
|
dirsToCopy--;
|
||||||
|
|
||||||
/* Work out search parameter in sub dir */
|
/* Work out search parameter in sub dir */
|
||||||
strcpyW (string, inputparms->dirName);
|
lstrcpyW (string, inputparms->dirName);
|
||||||
strcatW (string, finddata.cFileName);
|
lstrcatW (string, finddata.cFileName);
|
||||||
strcatW (string, slashW);
|
lstrcatW (string, slashW);
|
||||||
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 */
|
||||||
|
@ -613,8 +613,8 @@ void WCMD_directory (WCHAR *args)
|
||||||
if (GetEnvironmentVariableW(dircmdW, string, ARRAY_SIZE(string))) {
|
if (GetEnvironmentVariableW(dircmdW, string, ARRAY_SIZE(string))) {
|
||||||
p = string;
|
p = string;
|
||||||
while ( (*p = toupper(*p)) ) ++p;
|
while ( (*p = toupper(*p)) ) ++p;
|
||||||
strcatW(string,quals);
|
lstrcatW(string,quals);
|
||||||
strcpyW(quals, string);
|
lstrcpyW(quals, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_total = 0;
|
byte_total = 0;
|
||||||
|
@ -789,7 +789,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
argno = 0;
|
argno = 0;
|
||||||
argN = args;
|
argN = args;
|
||||||
GetCurrentDirectoryW(MAX_PATH, cwd);
|
GetCurrentDirectoryW(MAX_PATH, cwd);
|
||||||
strcatW(cwd, slashW);
|
lstrcatW(cwd, slashW);
|
||||||
|
|
||||||
/* Loop through all args, calculating full effective directory */
|
/* Loop through all args, calculating full effective directory */
|
||||||
fullParms = NULL;
|
fullParms = NULL;
|
||||||
|
@ -801,7 +801,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
|
|
||||||
WINE_TRACE("Found parm '%s'\n", wine_dbgstr_w(thisArg));
|
WINE_TRACE("Found parm '%s'\n", wine_dbgstr_w(thisArg));
|
||||||
if (thisArg[1] == ':' && thisArg[2] == '\\') {
|
if (thisArg[1] == ':' && thisArg[2] == '\\') {
|
||||||
strcpyW(fullname, thisArg);
|
lstrcpyW(fullname, thisArg);
|
||||||
} else if (thisArg[1] == ':' && thisArg[2] != '\\') {
|
} else if (thisArg[1] == ':' && thisArg[2] != '\\') {
|
||||||
WCHAR envvar[4];
|
WCHAR envvar[4];
|
||||||
static const WCHAR envFmt[] = {'=','%','c',':','\0'};
|
static const WCHAR envFmt[] = {'=','%','c',':','\0'};
|
||||||
|
@ -810,14 +810,14 @@ void WCMD_directory (WCHAR *args)
|
||||||
static const WCHAR noEnvFmt[] = {'%','c',':','\0'};
|
static const WCHAR noEnvFmt[] = {'%','c',':','\0'};
|
||||||
wsprintfW(fullname, noEnvFmt, thisArg[0]);
|
wsprintfW(fullname, noEnvFmt, thisArg[0]);
|
||||||
}
|
}
|
||||||
strcatW(fullname, slashW);
|
lstrcatW(fullname, slashW);
|
||||||
strcatW(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));
|
||||||
strcpyW(fullname+2, thisArg);
|
lstrcpyW(fullname+2, thisArg);
|
||||||
} else {
|
} else {
|
||||||
strcpyW(fullname, cwd);
|
lstrcpyW(fullname, cwd);
|
||||||
strcatW(fullname, thisArg);
|
lstrcatW(fullname, thisArg);
|
||||||
}
|
}
|
||||||
WINE_TRACE("Using location '%s'\n", wine_dbgstr_w(fullname));
|
WINE_TRACE("Using location '%s'\n", wine_dbgstr_w(fullname));
|
||||||
|
|
||||||
|
@ -828,16 +828,16 @@ void WCMD_directory (WCHAR *args)
|
||||||
* path references a directory, we need to list the *contents* of that
|
* path references a directory, we need to list the *contents* of that
|
||||||
* directory not the directory file itself.
|
* directory not the directory file itself.
|
||||||
*/
|
*/
|
||||||
if ((strchrW(path, '*') == NULL) && (strchrW(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 )) strcatW( path, slashW );
|
if (!ends_with_backslash( path )) lstrcatW( path, slashW );
|
||||||
strcatW (path, starW);
|
lstrcatW (path, starW);
|
||||||
}
|
}
|
||||||
} 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[strlenW(fullname)-1] == '.') strcatW(path, dotW);
|
if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, dotW);
|
||||||
}
|
}
|
||||||
|
|
||||||
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
|
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
|
||||||
|
@ -853,13 +853,13 @@ void WCMD_directory (WCHAR *args)
|
||||||
wine_dbgstr_w(drive), wine_dbgstr_w(dir),
|
wine_dbgstr_w(drive), wine_dbgstr_w(dir),
|
||||||
wine_dbgstr_w(fname), wine_dbgstr_w(ext));
|
wine_dbgstr_w(fname), wine_dbgstr_w(ext));
|
||||||
|
|
||||||
thisEntry->dirName = heap_xalloc(sizeof(WCHAR) * (strlenW(drive)+strlenW(dir)+1));
|
thisEntry->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(drive)+lstrlenW(dir)+1));
|
||||||
strcpyW(thisEntry->dirName, drive);
|
lstrcpyW(thisEntry->dirName, drive);
|
||||||
strcatW(thisEntry->dirName, dir);
|
lstrcatW(thisEntry->dirName, dir);
|
||||||
|
|
||||||
thisEntry->fileName = heap_xalloc(sizeof(WCHAR) * (strlenW(fname)+strlenW(ext)+1));
|
thisEntry->fileName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(fname)+lstrlenW(ext)+1));
|
||||||
strcpyW(thisEntry->fileName, fname);
|
lstrcpyW(thisEntry->fileName, fname);
|
||||||
strcatW(thisEntry->fileName, ext);
|
lstrcatW(thisEntry->fileName, ext);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <wchar.h>
|
||||||
#include <wine/heap.h>
|
#include <wine/heap.h>
|
||||||
#include <wine/unicode.h>
|
|
||||||
|
|
||||||
/* msdn specified max for Win XP */
|
/* msdn specified max for Win XP */
|
||||||
#define MAXSTRING 8192
|
#define MAXSTRING 8192
|
||||||
|
@ -137,7 +137,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
|
||||||
if(str) {
|
if(str) {
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
size = (strlenW(str)+1)*sizeof(WCHAR);
|
size = (lstrlenW(str)+1)*sizeof(WCHAR);
|
||||||
ret = heap_xalloc(size);
|
ret = heap_xalloc(size);
|
||||||
memcpy(ret, str, size);
|
memcpy(ret, str, size);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
|
||||||
|
|
||||||
static inline BOOL ends_with_backslash( const WCHAR *path )
|
static inline BOOL ends_with_backslash( const WCHAR *path )
|
||||||
{
|
{
|
||||||
return path[0] && path[strlenW(path) - 1] == '\\';
|
return path[0] && path[lstrlenW(path) - 1] == '\\';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data structure to hold context when executing batch files */
|
/* Data structure to hold context when executing batch files */
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
* - Lots of functionality missing from builtins
|
* - Lots of functionality missing from builtins
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "wcmd.h"
|
#include "wcmd.h"
|
||||||
#include "shellapi.h"
|
#include "shellapi.h"
|
||||||
|
@ -271,7 +270,7 @@ static void WCMD_output_asis_handle (DWORD std_handle, const WCHAR *message) {
|
||||||
numChars = 0;
|
numChars = 0;
|
||||||
if (++line_count >= max_height - 1) {
|
if (++line_count >= max_height - 1) {
|
||||||
line_count = 0;
|
line_count = 0;
|
||||||
WCMD_output_asis_len(pagedMessage, strlenW(pagedMessage), handle);
|
WCMD_output_asis_len(pagedMessage, lstrlenW(pagedMessage), handle);
|
||||||
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count);
|
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count);
|
||||||
}
|
}
|
||||||
} while (((message = ptr) != NULL) && (*ptr));
|
} while (((message = ptr) != NULL) && (*ptr));
|
||||||
|
@ -346,7 +345,7 @@ static void WCMD_show_prompt (BOOL newLine) {
|
||||||
len = GetEnvironmentVariableW(envPrompt, prompt_string, ARRAY_SIZE(prompt_string));
|
len = GetEnvironmentVariableW(envPrompt, prompt_string, ARRAY_SIZE(prompt_string));
|
||||||
if ((len == 0) || (len >= ARRAY_SIZE(prompt_string))) {
|
if ((len == 0) || (len >= ARRAY_SIZE(prompt_string))) {
|
||||||
static const WCHAR dfltPrompt[] = {'$','P','$','G','\0'};
|
static const WCHAR dfltPrompt[] = {'$','P','$','G','\0'};
|
||||||
strcpyW (prompt_string, dfltPrompt);
|
lstrcpyW (prompt_string, dfltPrompt);
|
||||||
}
|
}
|
||||||
p = prompt_string;
|
p = prompt_string;
|
||||||
q = out_string;
|
q = out_string;
|
||||||
|
@ -403,7 +402,7 @@ static void WCMD_show_prompt (BOOL newLine) {
|
||||||
case 'P':
|
case 'P':
|
||||||
status = GetCurrentDirectoryW(ARRAY_SIZE(curdir), curdir);
|
status = GetCurrentDirectoryW(ARRAY_SIZE(curdir), curdir);
|
||||||
if (status) {
|
if (status) {
|
||||||
strcatW (q, curdir);
|
lstrcatW (q, curdir);
|
||||||
while (*q) q++;
|
while (*q) q++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -418,7 +417,7 @@ static void WCMD_show_prompt (BOOL newLine) {
|
||||||
while (*q) q++;
|
while (*q) q++;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
strcatW (q, version_string);
|
lstrcatW (q, version_string);
|
||||||
while (*q) q++;
|
while (*q) q++;
|
||||||
break;
|
break;
|
||||||
case '_':
|
case '_':
|
||||||
|
@ -462,7 +461,7 @@ void WCMD_strsubstW(WCHAR *start, const WCHAR *next, const WCHAR *insert, int le
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len=insert ? lstrlenW(insert) : 0;
|
len=insert ? lstrlenW(insert) : 0;
|
||||||
if (start+len != next)
|
if (start+len != next)
|
||||||
memmove(start+len, next, (strlenW(next) + 1) * sizeof(*next));
|
memmove(start+len, next, (lstrlenW(next) + 1) * sizeof(*next));
|
||||||
if (insert)
|
if (insert)
|
||||||
memcpy(start, insert, len * sizeof(*insert));
|
memcpy(start, insert, len * sizeof(*insert));
|
||||||
}
|
}
|
||||||
|
@ -529,7 +528,7 @@ static inline BOOL WCMD_is_magic_envvar(const WCHAR *s, const WCHAR *magicvar)
|
||||||
|
|
||||||
if (s[0] != '%')
|
if (s[0] != '%')
|
||||||
return FALSE; /* Didn't begin with % */
|
return FALSE; /* Didn't begin with % */
|
||||||
len = strlenW(s);
|
len = lstrlenW(s);
|
||||||
if (len < 2 || s[len-1] != '%')
|
if (len < 2 || s[len-1] != '%')
|
||||||
return FALSE; /* Didn't end with another % */
|
return FALSE; /* Didn't end with another % */
|
||||||
|
|
||||||
|
@ -573,7 +572,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
|
|
||||||
/* Find the end of the environment variable, and extract name */
|
/* Find the end of the environment variable, and extract name */
|
||||||
Delims[0] = startchar;
|
Delims[0] = startchar;
|
||||||
endOfVar = strpbrkW(start+1, Delims);
|
endOfVar = wcspbrk(start+1, Delims);
|
||||||
|
|
||||||
if (endOfVar == NULL || *endOfVar==' ') {
|
if (endOfVar == NULL || *endOfVar==' ') {
|
||||||
|
|
||||||
|
@ -593,13 +592,13 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
/* If ':' found, process remaining up until '%' (or stop at ':' if
|
/* If ':' found, process remaining up until '%' (or stop at ':' if
|
||||||
a missing '%' */
|
a missing '%' */
|
||||||
if (*endOfVar==':') {
|
if (*endOfVar==':') {
|
||||||
WCHAR *endOfVar2 = strchrW(endOfVar+1, startchar);
|
WCHAR *endOfVar2 = wcschr(endOfVar+1, startchar);
|
||||||
if (endOfVar2 != NULL) endOfVar = endOfVar2;
|
if (endOfVar2 != NULL) endOfVar = endOfVar2;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(thisVar, start, ((endOfVar - start) + 1) * sizeof(WCHAR));
|
memcpy(thisVar, start, ((endOfVar - start) + 1) * sizeof(WCHAR));
|
||||||
thisVar[(endOfVar - start)+1] = 0x00;
|
thisVar[(endOfVar - start)+1] = 0x00;
|
||||||
colonpos = strchrW(thisVar+1, ':');
|
colonpos = wcschr(thisVar+1, ':');
|
||||||
|
|
||||||
/* If there's complex substitution, just need %var% for now
|
/* If there's complex substitution, just need %var% for now
|
||||||
to get the expanded data to play with */
|
to get the expanded data to play with */
|
||||||
|
@ -624,22 +623,22 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
if (WCMD_is_magic_envvar(thisVar, ErrorLvl)) {
|
if (WCMD_is_magic_envvar(thisVar, ErrorLvl)) {
|
||||||
static const WCHAR fmt[] = {'%','d','\0'};
|
static const WCHAR fmt[] = {'%','d','\0'};
|
||||||
wsprintfW(thisVarContents, fmt, errorlevel);
|
wsprintfW(thisVarContents, fmt, errorlevel);
|
||||||
len = strlenW(thisVarContents);
|
len = lstrlenW(thisVarContents);
|
||||||
} else if (WCMD_is_magic_envvar(thisVar, Date)) {
|
} else if (WCMD_is_magic_envvar(thisVar, Date)) {
|
||||||
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL,
|
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL,
|
||||||
NULL, thisVarContents, MAXSTRING);
|
NULL, thisVarContents, MAXSTRING);
|
||||||
len = strlenW(thisVarContents);
|
len = lstrlenW(thisVarContents);
|
||||||
} else if (WCMD_is_magic_envvar(thisVar, Time)) {
|
} else if (WCMD_is_magic_envvar(thisVar, Time)) {
|
||||||
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL,
|
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL,
|
||||||
NULL, thisVarContents, MAXSTRING);
|
NULL, thisVarContents, MAXSTRING);
|
||||||
len = strlenW(thisVarContents);
|
len = lstrlenW(thisVarContents);
|
||||||
} else if (WCMD_is_magic_envvar(thisVar, Cd)) {
|
} else if (WCMD_is_magic_envvar(thisVar, Cd)) {
|
||||||
GetCurrentDirectoryW(MAXSTRING, thisVarContents);
|
GetCurrentDirectoryW(MAXSTRING, thisVarContents);
|
||||||
len = strlenW(thisVarContents);
|
len = lstrlenW(thisVarContents);
|
||||||
} else if (WCMD_is_magic_envvar(thisVar, Random)) {
|
} else if (WCMD_is_magic_envvar(thisVar, Random)) {
|
||||||
static const WCHAR fmt[] = {'%','d','\0'};
|
static const WCHAR fmt[] = {'%','d','\0'};
|
||||||
wsprintfW(thisVarContents, fmt, rand() % 32768);
|
wsprintfW(thisVarContents, fmt, rand() % 32768);
|
||||||
len = strlenW(thisVarContents);
|
len = lstrlenW(thisVarContents);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
len = ExpandEnvironmentStringsW(thisVar, thisVarContents, ARRAY_SIZE(thisVarContents));
|
len = ExpandEnvironmentStringsW(thisVar, thisVarContents, ARRAY_SIZE(thisVarContents));
|
||||||
|
@ -668,7 +667,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
if (colonpos == NULL) {
|
if (colonpos == NULL) {
|
||||||
WCMD_strsubstW(start, endOfVar + 1, NULL, 0);
|
WCMD_strsubstW(start, endOfVar + 1, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
len = strlenW(thisVar);
|
len = lstrlenW(thisVar);
|
||||||
thisVar[len-1] = 0x00;
|
thisVar[len-1] = 0x00;
|
||||||
/* If %:...% supplied, : is retained */
|
/* If %:...% supplied, : is retained */
|
||||||
if (colonpos == thisVar+1) {
|
if (colonpos == thisVar+1) {
|
||||||
|
@ -706,11 +705,11 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
if (savedchar == '~') {
|
if (savedchar == '~') {
|
||||||
|
|
||||||
int substrposition, substrlength = 0;
|
int substrposition, substrlength = 0;
|
||||||
WCHAR *commapos = strchrW(colonpos+2, ',');
|
WCHAR *commapos = wcschr(colonpos+2, ',');
|
||||||
WCHAR *startCopy;
|
WCHAR *startCopy;
|
||||||
|
|
||||||
substrposition = atolW(colonpos+2);
|
substrposition = wcstol(colonpos+2, NULL, 10);
|
||||||
if (commapos) substrlength = atolW(commapos+1);
|
if (commapos) substrlength = wcstol(commapos+1, NULL, 10);
|
||||||
|
|
||||||
/* Check bounds */
|
/* Check bounds */
|
||||||
if (substrposition >= 0) {
|
if (substrposition >= 0) {
|
||||||
|
@ -735,7 +734,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
|
|
||||||
/* search and replace manipulation */
|
/* search and replace manipulation */
|
||||||
} else {
|
} else {
|
||||||
WCHAR *equalspos = strstrW(colonpos, equalW);
|
WCHAR *equalspos = wcsstr(colonpos, equalW);
|
||||||
WCHAR *replacewith = equalspos+1;
|
WCHAR *replacewith = equalspos+1;
|
||||||
WCHAR *found = NULL;
|
WCHAR *found = NULL;
|
||||||
WCHAR *searchIn;
|
WCHAR *searchIn;
|
||||||
|
@ -745,29 +744,29 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
s = heap_strdupW(endOfVar + 1);
|
s = heap_strdupW(endOfVar + 1);
|
||||||
|
|
||||||
/* Null terminate both strings */
|
/* Null terminate both strings */
|
||||||
thisVar[strlenW(thisVar)-1] = 0x00;
|
thisVar[lstrlenW(thisVar)-1] = 0x00;
|
||||||
*equalspos = 0x00;
|
*equalspos = 0x00;
|
||||||
|
|
||||||
/* Since we need to be case insensitive, copy the 2 buffers */
|
/* Since we need to be case insensitive, copy the 2 buffers */
|
||||||
searchIn = heap_strdupW(thisVarContents);
|
searchIn = heap_strdupW(thisVarContents);
|
||||||
CharUpperBuffW(searchIn, strlenW(thisVarContents));
|
CharUpperBuffW(searchIn, lstrlenW(thisVarContents));
|
||||||
searchFor = heap_strdupW(colonpos+1);
|
searchFor = heap_strdupW(colonpos+1);
|
||||||
CharUpperBuffW(searchFor, strlenW(colonpos+1));
|
CharUpperBuffW(searchFor, lstrlenW(colonpos+1));
|
||||||
|
|
||||||
/* Handle wildcard case */
|
/* Handle wildcard case */
|
||||||
if (*(colonpos+1) == '*') {
|
if (*(colonpos+1) == '*') {
|
||||||
/* Search for string to replace */
|
/* Search for string to replace */
|
||||||
found = strstrW(searchIn, searchFor+1);
|
found = wcsstr(searchIn, searchFor+1);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
/* Do replacement */
|
/* Do replacement */
|
||||||
strcpyW(start, replacewith);
|
lstrcpyW(start, replacewith);
|
||||||
strcatW(start, thisVarContents + (found-searchIn) + strlenW(searchFor+1));
|
lstrcatW(start, thisVarContents + (found-searchIn) + lstrlenW(searchFor+1));
|
||||||
strcatW(start, s);
|
lstrcatW(start, s);
|
||||||
} else {
|
} else {
|
||||||
/* Copy as is */
|
/* Copy as is */
|
||||||
strcpyW(start, thisVarContents);
|
lstrcpyW(start, thisVarContents);
|
||||||
strcatW(start, s);
|
lstrcatW(start, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -776,18 +775,18 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
|
||||||
WCHAR *outputposn = start;
|
WCHAR *outputposn = start;
|
||||||
|
|
||||||
*start = 0x00;
|
*start = 0x00;
|
||||||
while ((found = strstrW(lastFound, searchFor))) {
|
while ((found = wcsstr(lastFound, searchFor))) {
|
||||||
lstrcpynW(outputposn,
|
lstrcpynW(outputposn,
|
||||||
thisVarContents + (lastFound-searchIn),
|
thisVarContents + (lastFound-searchIn),
|
||||||
(found - lastFound)+1);
|
(found - lastFound)+1);
|
||||||
outputposn = outputposn + (found - lastFound);
|
outputposn = outputposn + (found - lastFound);
|
||||||
strcatW(outputposn, replacewith);
|
lstrcatW(outputposn, replacewith);
|
||||||
outputposn = outputposn + strlenW(replacewith);
|
outputposn = outputposn + lstrlenW(replacewith);
|
||||||
lastFound = found + strlenW(searchFor);
|
lastFound = found + lstrlenW(searchFor);
|
||||||
}
|
}
|
||||||
strcatW(outputposn,
|
lstrcatW(outputposn,
|
||||||
thisVarContents + (lastFound-searchIn));
|
thisVarContents + (lastFound-searchIn));
|
||||||
strcatW(outputposn, s);
|
lstrcatW(outputposn, s);
|
||||||
}
|
}
|
||||||
heap_free(s);
|
heap_free(s);
|
||||||
heap_free(searchIn);
|
heap_free(searchIn);
|
||||||
|
@ -832,8 +831,8 @@ static void handleExpansion(WCHAR *cmd, BOOL atExecute, BOOL delayed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the next environment variable delimiter */
|
/* Find the next environment variable delimiter */
|
||||||
normalp = strchrW(p, '%');
|
normalp = wcschr(p, '%');
|
||||||
if (delayed) delayedp = strchrW(p, '!');
|
if (delayed) delayedp = wcschr(p, '!');
|
||||||
if (!normalp) p = delayedp;
|
if (!normalp) p = delayedp;
|
||||||
else if (!delayedp) p = normalp;
|
else if (!delayedp) p = normalp;
|
||||||
else p = min(p,delayedp);
|
else p = min(p,delayedp);
|
||||||
|
@ -868,7 +867,7 @@ static void handleExpansion(WCHAR *cmd, BOOL atExecute, BOOL delayed) {
|
||||||
WCHAR *startOfParms = NULL;
|
WCHAR *startOfParms = NULL;
|
||||||
WCHAR *thisParm = WCMD_parameter(context -> command, 0, &startOfParms, TRUE, TRUE);
|
WCHAR *thisParm = WCMD_parameter(context -> command, 0, &startOfParms, TRUE, TRUE);
|
||||||
if (startOfParms != NULL) {
|
if (startOfParms != NULL) {
|
||||||
startOfParms += strlenW(thisParm);
|
startOfParms += lstrlenW(thisParm);
|
||||||
while (*startOfParms==' ' || *startOfParms == '\t') startOfParms++;
|
while (*startOfParms==' ' || *startOfParms == '\t') startOfParms++;
|
||||||
WCMD_strsubstW(p, p+2, startOfParms, -1);
|
WCMD_strsubstW(p, p+2, startOfParms, -1);
|
||||||
} else
|
} else
|
||||||
|
@ -889,8 +888,8 @@ static void handleExpansion(WCHAR *cmd, BOOL atExecute, BOOL delayed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the next environment variable delimiter */
|
/* Find the next environment variable delimiter */
|
||||||
normalp = strchrW(p, '%');
|
normalp = wcschr(p, '%');
|
||||||
if (delayed) delayedp = strchrW(p, '!');
|
if (delayed) delayedp = wcschr(p, '!');
|
||||||
if (!normalp) p = delayedp;
|
if (!normalp) p = delayedp;
|
||||||
else if (!delayedp) p = normalp;
|
else if (!delayedp) p = normalp;
|
||||||
else p = min(p,delayedp);
|
else p = min(p,delayedp);
|
||||||
|
@ -919,7 +918,7 @@ static void WCMD_parse (const WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2)
|
||||||
case '/':
|
case '/':
|
||||||
*q++ = *s++;
|
*q++ = *s++;
|
||||||
while ((*s != '\0') && (*s != ' ') && *s != '/') {
|
while ((*s != '\0') && (*s != ' ') && *s != '/') {
|
||||||
*q++ = toupperW (*s++);
|
*q++ = towupper (*s++);
|
||||||
}
|
}
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
break;
|
break;
|
||||||
|
@ -1057,30 +1056,30 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
if (!firstParam) return;
|
if (!firstParam) return;
|
||||||
|
|
||||||
/* Calculate the search path and stem to search for */
|
/* Calculate the search path and stem to search for */
|
||||||
if (strpbrkW (firstParam, delims) == NULL) { /* No explicit path given, search path */
|
if (wcspbrk (firstParam, delims) == NULL) { /* No explicit path given, search path */
|
||||||
static const WCHAR curDir[] = {'.',';','\0'};
|
static const WCHAR curDir[] = {'.',';','\0'};
|
||||||
strcpyW(pathtosearch, curDir);
|
lstrcpyW(pathtosearch, curDir);
|
||||||
len = GetEnvironmentVariableW(envPath, &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2);
|
len = GetEnvironmentVariableW(envPath, &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2);
|
||||||
if ((len == 0) || (len >= ARRAY_SIZE(pathtosearch) - 2)) {
|
if ((len == 0) || (len >= ARRAY_SIZE(pathtosearch) - 2)) {
|
||||||
static const WCHAR curDir[] = {'.','\0'};
|
static const WCHAR curDir[] = {'.','\0'};
|
||||||
strcpyW (pathtosearch, curDir);
|
lstrcpyW (pathtosearch, curDir);
|
||||||
}
|
}
|
||||||
if (strchrW(firstParam, '.') != NULL) extensionsupplied = TRUE;
|
if (wcschr(firstParam, '.') != NULL) extensionsupplied = TRUE;
|
||||||
if (strlenW(firstParam) >= MAX_PATH)
|
if (lstrlenW(firstParam) >= MAX_PATH)
|
||||||
{
|
{
|
||||||
WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_LINETOOLONG));
|
WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_LINETOOLONG));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpyW(stemofsearch, firstParam);
|
lstrcpyW(stemofsearch, firstParam);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Convert eg. ..\fred to include a directory by removing file part */
|
/* Convert eg. ..\fred to include a directory by removing file part */
|
||||||
GetFullPathNameW(firstParam, ARRAY_SIZE(pathtosearch), pathtosearch, NULL);
|
GetFullPathNameW(firstParam, ARRAY_SIZE(pathtosearch), pathtosearch, NULL);
|
||||||
lastSlash = strrchrW(pathtosearch, '\\');
|
lastSlash = wcsrchr(pathtosearch, '\\');
|
||||||
if (lastSlash && strchrW(lastSlash, '.') != NULL) extensionsupplied = TRUE;
|
if (lastSlash && wcschr(lastSlash, '.') != NULL) extensionsupplied = TRUE;
|
||||||
strcpyW(stemofsearch, lastSlash+1);
|
lstrcpyW(stemofsearch, lastSlash+1);
|
||||||
|
|
||||||
/* Reduce pathtosearch to a path with trailing '\' to support c:\a.bat and
|
/* Reduce pathtosearch to a path with trailing '\' to support c:\a.bat and
|
||||||
c:\windows\a.bat syntax */
|
c:\windows\a.bat syntax */
|
||||||
|
@ -1090,7 +1089,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
/* Now extract PATHEXT */
|
/* Now extract PATHEXT */
|
||||||
len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
|
len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
|
||||||
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
|
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
|
||||||
strcpyW (pathext, dfltPathExt);
|
lstrcpyW (pathext, dfltPathExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop through the search path, dir by dir */
|
/* Loop through the search path, dir by dir */
|
||||||
|
@ -1118,28 +1117,28 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
thisDir[(pos-pathposn)] = 0x00;
|
thisDir[(pos-pathposn)] = 0x00;
|
||||||
pathposn = pos+1;
|
pathposn = pos+1;
|
||||||
} else { /* Reached string end */
|
} else { /* Reached string end */
|
||||||
strcpyW(thisDir, pathposn);
|
lstrcpyW(thisDir, pathposn);
|
||||||
pathposn = NULL;
|
pathposn = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove quotes */
|
/* Remove quotes */
|
||||||
length = strlenW(thisDir);
|
length = lstrlenW(thisDir);
|
||||||
if (thisDir[length - 1] == '"')
|
if (thisDir[length - 1] == '"')
|
||||||
thisDir[length - 1] = 0;
|
thisDir[length - 1] = 0;
|
||||||
|
|
||||||
if (*thisDir != '"')
|
if (*thisDir != '"')
|
||||||
strcpyW(temp, thisDir);
|
lstrcpyW(temp, thisDir);
|
||||||
else
|
else
|
||||||
strcpyW(temp, thisDir + 1);
|
lstrcpyW(temp, thisDir + 1);
|
||||||
|
|
||||||
/* Since you can have eg. ..\.. on the path, need to expand
|
/* Since you can have eg. ..\.. on the path, need to expand
|
||||||
to full information */
|
to full information */
|
||||||
GetFullPathNameW(temp, MAX_PATH, thisDir, NULL);
|
GetFullPathNameW(temp, MAX_PATH, thisDir, NULL);
|
||||||
|
|
||||||
/* 1. If extension supplied, see if that file exists */
|
/* 1. If extension supplied, see if that file exists */
|
||||||
strcatW(thisDir, slashW);
|
lstrcatW(thisDir, slashW);
|
||||||
strcatW(thisDir, stemofsearch);
|
lstrcatW(thisDir, stemofsearch);
|
||||||
pos = &thisDir[strlenW(thisDir)]; /* Pos = end of name */
|
pos = &thisDir[lstrlenW(thisDir)]; /* Pos = end of name */
|
||||||
|
|
||||||
/* 1. If extension supplied, see if that file exists */
|
/* 1. If extension supplied, see if that file exists */
|
||||||
if (extensionsupplied) {
|
if (extensionsupplied) {
|
||||||
|
@ -1154,7 +1153,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
WIN32_FIND_DATAW finddata;
|
WIN32_FIND_DATAW finddata;
|
||||||
static const WCHAR allFiles[] = {'.','*','\0'};
|
static const WCHAR allFiles[] = {'.','*','\0'};
|
||||||
|
|
||||||
strcatW(thisDir,allFiles);
|
lstrcatW(thisDir,allFiles);
|
||||||
h = FindFirstFileW(thisDir, &finddata);
|
h = FindFirstFileW(thisDir, &finddata);
|
||||||
FindClose(h);
|
FindClose(h);
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
if (h != INVALID_HANDLE_VALUE) {
|
||||||
|
@ -1163,14 +1162,14 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
|
|
||||||
/* 3. Yes - Try each path ext */
|
/* 3. Yes - Try each path ext */
|
||||||
while (thisExt) {
|
while (thisExt) {
|
||||||
WCHAR *nextExt = strchrW(thisExt, ';');
|
WCHAR *nextExt = wcschr(thisExt, ';');
|
||||||
|
|
||||||
if (nextExt) {
|
if (nextExt) {
|
||||||
memcpy(pos, thisExt, (nextExt-thisExt) * sizeof(WCHAR));
|
memcpy(pos, thisExt, (nextExt-thisExt) * sizeof(WCHAR));
|
||||||
pos[(nextExt-thisExt)] = 0x00;
|
pos[(nextExt-thisExt)] = 0x00;
|
||||||
thisExt = nextExt+1;
|
thisExt = nextExt+1;
|
||||||
} else {
|
} else {
|
||||||
strcpyW(pos, thisExt);
|
lstrcpyW(pos, thisExt);
|
||||||
thisExt = NULL;
|
thisExt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,14 +1188,14 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
SHFILEINFOW psfi;
|
SHFILEINFOW psfi;
|
||||||
DWORD console;
|
DWORD console;
|
||||||
HINSTANCE hinst;
|
HINSTANCE hinst;
|
||||||
WCHAR *ext = strrchrW( thisDir, '.' );
|
WCHAR *ext = wcsrchr( thisDir, '.' );
|
||||||
static const WCHAR batExt[] = {'.','b','a','t','\0'};
|
static const WCHAR batExt[] = {'.','b','a','t','\0'};
|
||||||
static const WCHAR cmdExt[] = {'.','c','m','d','\0'};
|
static const WCHAR cmdExt[] = {'.','c','m','d','\0'};
|
||||||
|
|
||||||
WINE_TRACE("Found as %s\n", wine_dbgstr_w(thisDir));
|
WINE_TRACE("Found as %s\n", wine_dbgstr_w(thisDir));
|
||||||
|
|
||||||
/* Special case BAT and CMD */
|
/* Special case BAT and CMD */
|
||||||
if (ext && (!strcmpiW(ext, batExt) || !strcmpiW(ext, cmdExt))) {
|
if (ext && (!wcsicmp(ext, batExt) || !wcsicmp(ext, cmdExt))) {
|
||||||
BOOL oldinteractive = interactive;
|
BOOL oldinteractive = interactive;
|
||||||
interactive = FALSE;
|
interactive = FALSE;
|
||||||
WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
|
WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
|
||||||
|
@ -1301,7 +1300,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
|
|
||||||
/* Move copy of the command onto the heap so it can be expanded */
|
/* Move copy of the command onto the heap so it can be expanded */
|
||||||
new_cmd = heap_xalloc(MAXSTRING * sizeof(WCHAR));
|
new_cmd = heap_xalloc(MAXSTRING * sizeof(WCHAR));
|
||||||
strcpyW(new_cmd, command);
|
lstrcpyW(new_cmd, command);
|
||||||
cmd = new_cmd;
|
cmd = new_cmd;
|
||||||
|
|
||||||
/* Move copy of the redirects onto the heap so it can be expanded */
|
/* Move copy of the redirects onto the heap so it can be expanded */
|
||||||
|
@ -1357,7 +1356,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
wsprintfW (new_redir, redirOut, redirects, (*cmdList)->nextcommand->pipeFile);
|
wsprintfW (new_redir, redirOut, redirects, (*cmdList)->nextcommand->pipeFile);
|
||||||
WINE_TRACE("Redirects now %s\n", wine_dbgstr_w(new_redir));
|
WINE_TRACE("Redirects now %s\n", wine_dbgstr_w(new_redir));
|
||||||
} else {
|
} else {
|
||||||
strcpyW(new_redir, redirects);
|
lstrcpyW(new_redir, redirects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand variables in command line mode only (batch mode will
|
/* Expand variables in command line mode only (batch mode will
|
||||||
|
@ -1381,8 +1380,8 @@ 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 */
|
||||||
strcpyW(envvar, equalW);
|
lstrcpyW(envvar, equalW);
|
||||||
strcatW(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'};
|
||||||
wsprintfW(cmd, fmt, cmd);
|
wsprintfW(cmd, fmt, cmd);
|
||||||
|
@ -1424,7 +1423,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
(*cmdList)->pipeFile[0] = 0x00;
|
(*cmdList)->pipeFile[0] = 0x00;
|
||||||
|
|
||||||
/* Otherwise STDIN could come from a '<' redirect */
|
/* Otherwise STDIN could come from a '<' redirect */
|
||||||
} else if ((pos = strchrW(new_redir,'<')) != NULL) {
|
} else if ((pos = wcschr(new_redir,'<')) != NULL) {
|
||||||
h = CreateFileW(WCMD_parameter(++pos, 0, NULL, FALSE, FALSE), GENERIC_READ, FILE_SHARE_READ,
|
h = CreateFileW(WCMD_parameter(++pos, 0, NULL, FALSE, FALSE), GENERIC_READ, FILE_SHARE_READ,
|
||||||
&sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
&sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
|
@ -1437,7 +1436,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan the whole command looking for > and 2> */
|
/* Scan the whole command looking for > and 2> */
|
||||||
while (redir != NULL && ((pos = strchrW(redir,'>')) != NULL)) {
|
while (redir != NULL && ((pos = wcschr(redir,'>')) != NULL)) {
|
||||||
int handle = 0;
|
int handle = 0;
|
||||||
|
|
||||||
if (pos > redir && (*(pos-1)=='2'))
|
if (pos > redir && (*(pos-1)=='2'))
|
||||||
|
@ -1586,7 +1585,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
WCMD_setshow_time ();
|
WCMD_setshow_time ();
|
||||||
break;
|
break;
|
||||||
case WCMD_TITLE:
|
case WCMD_TITLE:
|
||||||
if (strlenW(&whichcmd[count]) > 0)
|
if (lstrlenW(&whichcmd[count]) > 0)
|
||||||
WCMD_title(&whichcmd[count+1]);
|
WCMD_title(&whichcmd[count+1]);
|
||||||
break;
|
break;
|
||||||
case WCMD_TYPE:
|
case WCMD_TYPE:
|
||||||
|
@ -1668,7 +1667,7 @@ WCHAR *WCMD_LoadMessage(UINT id) {
|
||||||
|
|
||||||
if (!LoadStringW(GetModuleHandleW(NULL), id, msg, ARRAY_SIZE(msg))) {
|
if (!LoadStringW(GetModuleHandleW(NULL), id, msg, ARRAY_SIZE(msg))) {
|
||||||
WINE_FIXME("LoadString failed with %d\n", GetLastError());
|
WINE_FIXME("LoadString failed with %d\n", GetLastError());
|
||||||
strcpyW(msg, failedMsg);
|
lstrcpyW(msg, failedMsg);
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -1858,7 +1857,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
|
||||||
|
|
||||||
/* If initial command read in, use that, otherwise get input from handle */
|
/* If initial command read in, use that, otherwise get input from handle */
|
||||||
if (optionalcmd != NULL) {
|
if (optionalcmd != NULL) {
|
||||||
strcpyW(extraSpace, optionalcmd);
|
lstrcpyW(extraSpace, optionalcmd);
|
||||||
} else if (readFrom == INVALID_HANDLE_VALUE) {
|
} else if (readFrom == INVALID_HANDLE_VALUE) {
|
||||||
WINE_FIXME("No command nor handle supplied\n");
|
WINE_FIXME("No command nor handle supplied\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1868,7 +1867,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
|
||||||
curPos = extraSpace;
|
curPos = extraSpace;
|
||||||
|
|
||||||
/* Handle truncated input - issue warning */
|
/* Handle truncated input - issue warning */
|
||||||
if (strlenW(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(newlineW);
|
||||||
|
@ -1886,7 +1885,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
|
||||||
static const WCHAR echoCol[] = {'e','c','h','o',':'};
|
static const WCHAR echoCol[] = {'e','c','h','o',':'};
|
||||||
static const WCHAR echoSlash[] = {'e','c','h','o','/'};
|
static const WCHAR echoSlash[] = {'e','c','h','o','/'};
|
||||||
const DWORD len = ARRAY_SIZE(echoDot);
|
const DWORD len = ARRAY_SIZE(echoDot);
|
||||||
DWORD curr_size = strlenW(curPos);
|
DWORD curr_size = lstrlenW(curPos);
|
||||||
DWORD min_len = (curr_size < len ? curr_size : len);
|
DWORD min_len = (curr_size < len ? curr_size : len);
|
||||||
WCMD_show_prompt(TRUE);
|
WCMD_show_prompt(TRUE);
|
||||||
WCMD_output_asis(curPos);
|
WCMD_output_asis(curPos);
|
||||||
|
@ -2422,7 +2421,7 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
if (!GetEnvironmentVariableW(comspecW, comspec, ARRAY_SIZE(comspec)))
|
if (!GetEnvironmentVariableW(comspecW, comspec, ARRAY_SIZE(comspec)))
|
||||||
{
|
{
|
||||||
GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(cmdW));
|
GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(cmdW));
|
||||||
strcatW(comspec, cmdW);
|
lstrcatW(comspec, cmdW);
|
||||||
SetEnvironmentVariableW(comspecW, comspec);
|
SetEnvironmentVariableW(comspecW, comspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2433,11 +2432,10 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
GetVersionExW(&osv);
|
GetVersionExW(&osv);
|
||||||
|
|
||||||
/* Pre initialize some messages */
|
/* Pre initialize some messages */
|
||||||
strcpyW(anykey, WCMD_LoadMessage(WCMD_ANYKEY));
|
lstrcpyW(anykey, WCMD_LoadMessage(WCMD_ANYKEY));
|
||||||
sprintf(osver, "%d.%d.%d (%s)", osv.dwMajorVersion, osv.dwMinorVersion,
|
sprintf(osver, "%d.%d.%d", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber);
|
||||||
osv.dwBuildNumber, PACKAGE_VERSION);
|
|
||||||
cmd = WCMD_format_string(WCMD_LoadMessage(WCMD_VERSION), osver);
|
cmd = WCMD_format_string(WCMD_LoadMessage(WCMD_VERSION), osver);
|
||||||
strcpyW(version_string, cmd);
|
lstrcpyW(version_string, cmd);
|
||||||
LocalFree(cmd);
|
LocalFree(cmd);
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
|
|
||||||
|
@ -2461,29 +2459,29 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
}
|
}
|
||||||
|
|
||||||
c=argPos[1];
|
c=argPos[1];
|
||||||
if (tolowerW(c)=='c') {
|
if (towlower(c)=='c') {
|
||||||
opt_c = TRUE;
|
opt_c = TRUE;
|
||||||
} else if (tolowerW(c)=='q') {
|
} else if (towlower(c)=='q') {
|
||||||
opt_q = TRUE;
|
opt_q = TRUE;
|
||||||
} else if (tolowerW(c)=='k') {
|
} else if (towlower(c)=='k') {
|
||||||
opt_k = TRUE;
|
opt_k = TRUE;
|
||||||
} else if (tolowerW(c)=='s') {
|
} else if (towlower(c)=='s') {
|
||||||
opt_s = TRUE;
|
opt_s = TRUE;
|
||||||
} else if (tolowerW(c)=='a') {
|
} else if (towlower(c)=='a') {
|
||||||
unicodeOutput = FALSE;
|
unicodeOutput = FALSE;
|
||||||
} else if (tolowerW(c)=='u') {
|
} else if (towlower(c)=='u') {
|
||||||
unicodeOutput = TRUE;
|
unicodeOutput = TRUE;
|
||||||
} else if (tolowerW(c)=='v' && argPos[2]==':') {
|
} else if (towlower(c)=='v' && argPos[2]==':') {
|
||||||
delayedsubst = strncmpiW(&argPos[3], offW, 3);
|
delayedsubst = wcsnicmp(&argPos[3], offW, 3);
|
||||||
if (delayedsubst) WINE_TRACE("Delayed substitution is on\n");
|
if (delayedsubst) WINE_TRACE("Delayed substitution is on\n");
|
||||||
} else if (tolowerW(c)=='t' && argPos[2]==':') {
|
} else if (towlower(c)=='t' && argPos[2]==':') {
|
||||||
opt_t=strtoulW(&argPos[3], NULL, 16);
|
opt_t=wcstoul(&argPos[3], NULL, 16);
|
||||||
} else if (tolowerW(c)=='x' || tolowerW(c)=='y') {
|
} else if (towlower(c)=='x' || towlower(c)=='y') {
|
||||||
/* Ignored for compatibility with Windows */
|
/* Ignored for compatibility with Windows */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argPos[2]==0 || argPos[2]==' ' || argPos[2]=='\t' ||
|
if (argPos[2]==0 || argPos[2]==' ' || argPos[2]=='\t' ||
|
||||||
tolowerW(c)=='v') {
|
towlower(c)=='v') {
|
||||||
args++;
|
args++;
|
||||||
WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
|
WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
@ -2524,19 +2522,19 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
|
|
||||||
if (!opt_s) {
|
if (!opt_s) {
|
||||||
/* 1. Confirm there is at least one quote */
|
/* 1. Confirm there is at least one quote */
|
||||||
q1 = strchrW(argPos, '"');
|
q1 = wcschr(argPos, '"');
|
||||||
if (!q1) opt_s=1;
|
if (!q1) opt_s=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opt_s) {
|
if (!opt_s) {
|
||||||
/* 2. Confirm there is a second quote */
|
/* 2. Confirm there is a second quote */
|
||||||
q2 = strchrW(q1+1, '"');
|
q2 = wcschr(q1+1, '"');
|
||||||
if (!q2) opt_s=1;
|
if (!q2) opt_s=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opt_s) {
|
if (!opt_s) {
|
||||||
/* 3. Ensure there are no more quotes */
|
/* 3. Ensure there are no more quotes */
|
||||||
if (strchrW(q2+1, '"')) opt_s=1;
|
if (wcschr(q2+1, '"')) opt_s=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check first parameter for a space and invalid characters. There must not be any
|
/* check first parameter for a space and invalid characters. There must not be any
|
||||||
|
@ -2568,16 +2566,16 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
/* Now extract PATHEXT */
|
/* Now extract PATHEXT */
|
||||||
len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
|
len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
|
||||||
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
|
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
|
||||||
strcpyW (pathext, dfltPathExt);
|
lstrcpyW (pathext, dfltPathExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the supplied parameter has any directory information, look there */
|
/* If the supplied parameter has any directory information, look there */
|
||||||
WINE_TRACE("First parameter is '%s'\n", wine_dbgstr_w(thisArg));
|
WINE_TRACE("First parameter is '%s'\n", wine_dbgstr_w(thisArg));
|
||||||
if (strchrW(thisArg, '\\') != NULL) {
|
if (wcschr(thisArg, '\\') != NULL) {
|
||||||
|
|
||||||
GetFullPathNameW(thisArg, ARRAY_SIZE(string), string, NULL);
|
GetFullPathNameW(thisArg, ARRAY_SIZE(string), string, NULL);
|
||||||
WINE_TRACE("Full path name '%s'\n", wine_dbgstr_w(string));
|
WINE_TRACE("Full path name '%s'\n", wine_dbgstr_w(string));
|
||||||
p = string + strlenW(string);
|
p = string + lstrlenW(string);
|
||||||
|
|
||||||
/* Does file exist with this name? */
|
/* Does file exist with this name? */
|
||||||
if (GetFileAttributesW(string) != INVALID_FILE_ATTRIBUTES) {
|
if (GetFileAttributesW(string) != INVALID_FILE_ATTRIBUTES) {
|
||||||
|
@ -2588,14 +2586,14 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
|
|
||||||
/* No - try with each of the PATHEXT extensions */
|
/* No - try with each of the PATHEXT extensions */
|
||||||
while (!found && thisExt) {
|
while (!found && thisExt) {
|
||||||
WCHAR *nextExt = strchrW(thisExt, ';');
|
WCHAR *nextExt = wcschr(thisExt, ';');
|
||||||
|
|
||||||
if (nextExt) {
|
if (nextExt) {
|
||||||
memcpy(p, thisExt, (nextExt-thisExt) * sizeof(WCHAR));
|
memcpy(p, thisExt, (nextExt-thisExt) * sizeof(WCHAR));
|
||||||
p[(nextExt-thisExt)] = 0x00;
|
p[(nextExt-thisExt)] = 0x00;
|
||||||
thisExt = nextExt+1;
|
thisExt = nextExt+1;
|
||||||
} else {
|
} else {
|
||||||
strcpyW(p, thisExt);
|
lstrcpyW(p, thisExt);
|
||||||
thisExt = NULL;
|
thisExt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2618,7 +2616,7 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
|
|
||||||
/* No - try with each of the PATHEXT extensions */
|
/* No - try with each of the PATHEXT extensions */
|
||||||
while (!found && thisExt) {
|
while (!found && thisExt) {
|
||||||
WCHAR *nextExt = strchrW(thisExt, ';');
|
WCHAR *nextExt = wcschr(thisExt, ';');
|
||||||
|
|
||||||
if (nextExt) {
|
if (nextExt) {
|
||||||
*nextExt = 0;
|
*nextExt = 0;
|
||||||
|
@ -2716,7 +2714,7 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
size = ARRAY_SIZE(strvalue);
|
size = ARRAY_SIZE(strvalue);
|
||||||
RegQueryValueExW(key, dfltColorW, NULL, NULL,
|
RegQueryValueExW(key, dfltColorW, NULL, NULL,
|
||||||
(LPBYTE)strvalue, &size);
|
(LPBYTE)strvalue, &size);
|
||||||
value = strtoulW(strvalue, NULL, 10);
|
value = wcstoul(strvalue, NULL, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
|
@ -2737,7 +2735,7 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
size = ARRAY_SIZE(strvalue);
|
size = ARRAY_SIZE(strvalue);
|
||||||
RegQueryValueExW(key, dfltColorW, NULL, NULL,
|
RegQueryValueExW(key, dfltColorW, NULL, NULL,
|
||||||
(LPBYTE)strvalue, &size);
|
(LPBYTE)strvalue, &size);
|
||||||
value = strtoulW(strvalue, NULL, 10);
|
value = wcstoul(strvalue, NULL, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
|
|
Loading…
Reference in New Issue